id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,500 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/walk/TypesWalker.java
|
TypesWalker.isLowerBoundCompatible
|
private static boolean isLowerBoundCompatible(final WildcardType type, final Class... with) {
boolean res = true;
if (type.getLowerBounds().length > 0) {
// only one super could be used
// couldn't be an object here as ? super Object is always replaced to simply Object before comparison
final Class<?> lower = GenericsUtils.resolveClassIgnoringVariables(type.getLowerBounds()[0]);
// target may only be lower bound's super type (or same type)
for (Class<?> target : with) {
if (!target.isAssignableFrom(lower)) {
res = false;
break;
}
}
}
return res;
}
|
java
|
private static boolean isLowerBoundCompatible(final WildcardType type, final Class... with) {
boolean res = true;
if (type.getLowerBounds().length > 0) {
// only one super could be used
// couldn't be an object here as ? super Object is always replaced to simply Object before comparison
final Class<?> lower = GenericsUtils.resolveClassIgnoringVariables(type.getLowerBounds()[0]);
// target may only be lower bound's super type (or same type)
for (Class<?> target : with) {
if (!target.isAssignableFrom(lower)) {
res = false;
break;
}
}
}
return res;
}
|
[
"private",
"static",
"boolean",
"isLowerBoundCompatible",
"(",
"final",
"WildcardType",
"type",
",",
"final",
"Class",
"...",
"with",
")",
"{",
"boolean",
"res",
"=",
"true",
";",
"if",
"(",
"type",
".",
"getLowerBounds",
"(",
")",
".",
"length",
">",
"0",
")",
"{",
"// only one super could be used",
"// couldn't be an object here as ? super Object is always replaced to simply Object before comparison",
"final",
"Class",
"<",
"?",
">",
"lower",
"=",
"GenericsUtils",
".",
"resolveClassIgnoringVariables",
"(",
"type",
".",
"getLowerBounds",
"(",
")",
"[",
"0",
"]",
")",
";",
"// target may only be lower bound's super type (or same type)",
"for",
"(",
"Class",
"<",
"?",
">",
"target",
":",
"with",
")",
"{",
"if",
"(",
"!",
"target",
".",
"isAssignableFrom",
"(",
"lower",
")",
")",
"{",
"res",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] |
Check that wildcard's lower bound type is not less then any of provided types.
@param type wildcard with possible lower bound
@param with types to compare with lower bound
@return true if compatible or no lower bound set, false otherwise
|
[
"Check",
"that",
"wildcard",
"s",
"lower",
"bound",
"type",
"is",
"not",
"less",
"then",
"any",
"of",
"provided",
"types",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/walk/TypesWalker.java#L241-L257
|
4,501 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/error/UnknownGenericException.java
|
UnknownGenericException.rethrowWithType
|
public UnknownGenericException rethrowWithType(final Class<?> type) {
final boolean sameType = contextType != null && contextType.equals(type);
if (!sameType && contextType != null) {
// not allow changing type if it's already set
throw new IllegalStateException("Context type can't be changed");
}
return sameType ? this : new UnknownGenericException(type, genericName, genericSource, this);
}
|
java
|
public UnknownGenericException rethrowWithType(final Class<?> type) {
final boolean sameType = contextType != null && contextType.equals(type);
if (!sameType && contextType != null) {
// not allow changing type if it's already set
throw new IllegalStateException("Context type can't be changed");
}
return sameType ? this : new UnknownGenericException(type, genericName, genericSource, this);
}
|
[
"public",
"UnknownGenericException",
"rethrowWithType",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"final",
"boolean",
"sameType",
"=",
"contextType",
"!=",
"null",
"&&",
"contextType",
".",
"equals",
"(",
"type",
")",
";",
"if",
"(",
"!",
"sameType",
"&&",
"contextType",
"!=",
"null",
")",
"{",
"// not allow changing type if it's already set",
"throw",
"new",
"IllegalStateException",
"(",
"\"Context type can't be changed\"",
")",
";",
"}",
"return",
"sameType",
"?",
"this",
":",
"new",
"UnknownGenericException",
"(",
"type",
",",
"genericName",
",",
"genericSource",
",",
"this",
")",
";",
"}"
] |
Throw more specific exception.
@param type context type
@return new exception if type is different, same exception instance if type is the same
|
[
"Throw",
"more",
"specific",
"exception",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/error/UnknownGenericException.java#L75-L82
|
4,502 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/ValidateMojo.java
|
ValidateMojo.getSchema
|
private Schema getSchema( Resolver pResolver, ValidationSet pValidationSet )
throws MojoExecutionException
{
String schemaLanguage = pValidationSet.getSchemaLanguage();
if ( schemaLanguage == null || "".equals( schemaLanguage ) )
{
schemaLanguage = XMLConstants.W3C_XML_SCHEMA_NS_URI;
}
final String publicId = pValidationSet.getPublicId();
final String systemId = pValidationSet.getSystemId();
if ( ( publicId == null || "".equals( publicId ) ) && ( systemId == null || "".equals( systemId ) ) && !INTRINSIC_NS_URI.equals(schemaLanguage))
{
return null;
}
final SAXSource saxSource;
if (INTRINSIC_NS_URI.equals(schemaLanguage) && ( publicId == null || "".equals( publicId ) ) && ( systemId == null || "".equals( systemId ) ) ){
//publicId and systemID make no sense for the IntrinsicSchemaValidator.
saxSource=null;
}
else{
getLog().debug( "Loading schema with public Id " + publicId + ", system Id " + systemId );
InputSource inputSource = null;
if ( pResolver != null )
{
try
{
inputSource = pResolver.resolveEntity( publicId, systemId );
}
catch ( SAXException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
if ( inputSource == null )
{
inputSource = new InputSource();
inputSource.setPublicId( pResolver.filterPossibleURI( publicId ));
inputSource.setSystemId( pResolver.filterPossibleURI(systemId ));
}
saxSource = new SAXSource( inputSource );
}
try
{
SchemaFactory schemaFactory = SchemaFactory.newInstance( schemaLanguage );
if ( pResolver != null )
{
schemaFactory.setResourceResolver( pResolver );
}
return saxSource==null?schemaFactory.newSchema():schemaFactory.newSchema( saxSource );
}
catch ( SAXException e )
{
throw new MojoExecutionException( "Failed to load schema with public ID " + publicId + ", system ID "
+ systemId + ": " + e.getMessage(), e );
}
}
|
java
|
private Schema getSchema( Resolver pResolver, ValidationSet pValidationSet )
throws MojoExecutionException
{
String schemaLanguage = pValidationSet.getSchemaLanguage();
if ( schemaLanguage == null || "".equals( schemaLanguage ) )
{
schemaLanguage = XMLConstants.W3C_XML_SCHEMA_NS_URI;
}
final String publicId = pValidationSet.getPublicId();
final String systemId = pValidationSet.getSystemId();
if ( ( publicId == null || "".equals( publicId ) ) && ( systemId == null || "".equals( systemId ) ) && !INTRINSIC_NS_URI.equals(schemaLanguage))
{
return null;
}
final SAXSource saxSource;
if (INTRINSIC_NS_URI.equals(schemaLanguage) && ( publicId == null || "".equals( publicId ) ) && ( systemId == null || "".equals( systemId ) ) ){
//publicId and systemID make no sense for the IntrinsicSchemaValidator.
saxSource=null;
}
else{
getLog().debug( "Loading schema with public Id " + publicId + ", system Id " + systemId );
InputSource inputSource = null;
if ( pResolver != null )
{
try
{
inputSource = pResolver.resolveEntity( publicId, systemId );
}
catch ( SAXException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
if ( inputSource == null )
{
inputSource = new InputSource();
inputSource.setPublicId( pResolver.filterPossibleURI( publicId ));
inputSource.setSystemId( pResolver.filterPossibleURI(systemId ));
}
saxSource = new SAXSource( inputSource );
}
try
{
SchemaFactory schemaFactory = SchemaFactory.newInstance( schemaLanguage );
if ( pResolver != null )
{
schemaFactory.setResourceResolver( pResolver );
}
return saxSource==null?schemaFactory.newSchema():schemaFactory.newSchema( saxSource );
}
catch ( SAXException e )
{
throw new MojoExecutionException( "Failed to load schema with public ID " + publicId + ", system ID "
+ systemId + ": " + e.getMessage(), e );
}
}
|
[
"private",
"Schema",
"getSchema",
"(",
"Resolver",
"pResolver",
",",
"ValidationSet",
"pValidationSet",
")",
"throws",
"MojoExecutionException",
"{",
"String",
"schemaLanguage",
"=",
"pValidationSet",
".",
"getSchemaLanguage",
"(",
")",
";",
"if",
"(",
"schemaLanguage",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"schemaLanguage",
")",
")",
"{",
"schemaLanguage",
"=",
"XMLConstants",
".",
"W3C_XML_SCHEMA_NS_URI",
";",
"}",
"final",
"String",
"publicId",
"=",
"pValidationSet",
".",
"getPublicId",
"(",
")",
";",
"final",
"String",
"systemId",
"=",
"pValidationSet",
".",
"getSystemId",
"(",
")",
";",
"if",
"(",
"(",
"publicId",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"publicId",
")",
")",
"&&",
"(",
"systemId",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"systemId",
")",
")",
"&&",
"!",
"INTRINSIC_NS_URI",
".",
"equals",
"(",
"schemaLanguage",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"SAXSource",
"saxSource",
";",
"if",
"(",
"INTRINSIC_NS_URI",
".",
"equals",
"(",
"schemaLanguage",
")",
"&&",
"(",
"publicId",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"publicId",
")",
")",
"&&",
"(",
"systemId",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"systemId",
")",
")",
")",
"{",
"//publicId and systemID make no sense for the IntrinsicSchemaValidator.",
"saxSource",
"=",
"null",
";",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Loading schema with public Id \"",
"+",
"publicId",
"+",
"\", system Id \"",
"+",
"systemId",
")",
";",
"InputSource",
"inputSource",
"=",
"null",
";",
"if",
"(",
"pResolver",
"!=",
"null",
")",
"{",
"try",
"{",
"inputSource",
"=",
"pResolver",
".",
"resolveEntity",
"(",
"publicId",
",",
"systemId",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"if",
"(",
"inputSource",
"==",
"null",
")",
"{",
"inputSource",
"=",
"new",
"InputSource",
"(",
")",
";",
"inputSource",
".",
"setPublicId",
"(",
"pResolver",
".",
"filterPossibleURI",
"(",
"publicId",
")",
")",
";",
"inputSource",
".",
"setSystemId",
"(",
"pResolver",
".",
"filterPossibleURI",
"(",
"systemId",
")",
")",
";",
"}",
"saxSource",
"=",
"new",
"SAXSource",
"(",
"inputSource",
")",
";",
"}",
"try",
"{",
"SchemaFactory",
"schemaFactory",
"=",
"SchemaFactory",
".",
"newInstance",
"(",
"schemaLanguage",
")",
";",
"if",
"(",
"pResolver",
"!=",
"null",
")",
"{",
"schemaFactory",
".",
"setResourceResolver",
"(",
"pResolver",
")",
";",
"}",
"return",
"saxSource",
"==",
"null",
"?",
"schemaFactory",
".",
"newSchema",
"(",
")",
":",
"schemaFactory",
".",
"newSchema",
"(",
"saxSource",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Failed to load schema with public ID \"",
"+",
"publicId",
"+",
"\", system ID \"",
"+",
"systemId",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Reads a validation sets schema.
@param pResolver The resolver to use for loading external entities.
@param pValidationSet The validation set to configure.
@return The validation sets schema, if any, or null.
@throws MojoExecutionException Loading the schema failed.
|
[
"Reads",
"a",
"validation",
"sets",
"schema",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/ValidateMojo.java#L72-L131
|
4,503 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/ValidateMojo.java
|
ValidateMojo.validate
|
private void validate( final Resolver pResolver, ValidationSet pValidationSet, Schema pSchema, File pFile, ValidationErrorHandler errorHandler )
throws MojoExecutionException
{
errorHandler.setContext(pFile);
try
{
if ( pSchema == null )
{
getLog().debug( "Parsing " + pFile.getPath() );
parse( pResolver, pValidationSet, pFile ,errorHandler);
}
else
{
getLog().debug( "Validating " + pFile.getPath() );
Validator validator = pSchema.newValidator();
validator.setErrorHandler(errorHandler);
if ( pResolver != null )
{
validator.setResourceResolver( pResolver );
}
if ( pValidationSet.isXincludeAware() )
{
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware( true );
spf.setXIncludeAware( pValidationSet.isXincludeAware() );
InputSource isource = new InputSource( pFile.toURI().toASCIIString() );
XMLReader xmlReader = spf.newSAXParser().getXMLReader();
xmlReader.setEntityResolver( pResolver );
validator.validate( new SAXSource( xmlReader, isource ) );
}
else
{
validator.validate( new StreamSource( pFile ) );
}
}
}
catch ( SAXParseException e )
{
try{
errorHandler.fatalError(e);
}
catch(SAXException se){
throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), se );
}
}
catch ( Exception e )
{
throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), e );
}
}
|
java
|
private void validate( final Resolver pResolver, ValidationSet pValidationSet, Schema pSchema, File pFile, ValidationErrorHandler errorHandler )
throws MojoExecutionException
{
errorHandler.setContext(pFile);
try
{
if ( pSchema == null )
{
getLog().debug( "Parsing " + pFile.getPath() );
parse( pResolver, pValidationSet, pFile ,errorHandler);
}
else
{
getLog().debug( "Validating " + pFile.getPath() );
Validator validator = pSchema.newValidator();
validator.setErrorHandler(errorHandler);
if ( pResolver != null )
{
validator.setResourceResolver( pResolver );
}
if ( pValidationSet.isXincludeAware() )
{
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware( true );
spf.setXIncludeAware( pValidationSet.isXincludeAware() );
InputSource isource = new InputSource( pFile.toURI().toASCIIString() );
XMLReader xmlReader = spf.newSAXParser().getXMLReader();
xmlReader.setEntityResolver( pResolver );
validator.validate( new SAXSource( xmlReader, isource ) );
}
else
{
validator.validate( new StreamSource( pFile ) );
}
}
}
catch ( SAXParseException e )
{
try{
errorHandler.fatalError(e);
}
catch(SAXException se){
throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), se );
}
}
catch ( Exception e )
{
throw new MojoExecutionException( "While parsing " + pFile + ": " + e.getMessage(), e );
}
}
|
[
"private",
"void",
"validate",
"(",
"final",
"Resolver",
"pResolver",
",",
"ValidationSet",
"pValidationSet",
",",
"Schema",
"pSchema",
",",
"File",
"pFile",
",",
"ValidationErrorHandler",
"errorHandler",
")",
"throws",
"MojoExecutionException",
"{",
"errorHandler",
".",
"setContext",
"(",
"pFile",
")",
";",
"try",
"{",
"if",
"(",
"pSchema",
"==",
"null",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Parsing \"",
"+",
"pFile",
".",
"getPath",
"(",
")",
")",
";",
"parse",
"(",
"pResolver",
",",
"pValidationSet",
",",
"pFile",
",",
"errorHandler",
")",
";",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Validating \"",
"+",
"pFile",
".",
"getPath",
"(",
")",
")",
";",
"Validator",
"validator",
"=",
"pSchema",
".",
"newValidator",
"(",
")",
";",
"validator",
".",
"setErrorHandler",
"(",
"errorHandler",
")",
";",
"if",
"(",
"pResolver",
"!=",
"null",
")",
"{",
"validator",
".",
"setResourceResolver",
"(",
"pResolver",
")",
";",
"}",
"if",
"(",
"pValidationSet",
".",
"isXincludeAware",
"(",
")",
")",
"{",
"SAXParserFactory",
"spf",
"=",
"SAXParserFactory",
".",
"newInstance",
"(",
")",
";",
"spf",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"spf",
".",
"setXIncludeAware",
"(",
"pValidationSet",
".",
"isXincludeAware",
"(",
")",
")",
";",
"InputSource",
"isource",
"=",
"new",
"InputSource",
"(",
"pFile",
".",
"toURI",
"(",
")",
".",
"toASCIIString",
"(",
")",
")",
";",
"XMLReader",
"xmlReader",
"=",
"spf",
".",
"newSAXParser",
"(",
")",
".",
"getXMLReader",
"(",
")",
";",
"xmlReader",
".",
"setEntityResolver",
"(",
"pResolver",
")",
";",
"validator",
".",
"validate",
"(",
"new",
"SAXSource",
"(",
"xmlReader",
",",
"isource",
")",
")",
";",
"}",
"else",
"{",
"validator",
".",
"validate",
"(",
"new",
"StreamSource",
"(",
"pFile",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"SAXParseException",
"e",
")",
"{",
"try",
"{",
"errorHandler",
".",
"fatalError",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"SAXException",
"se",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"While parsing \"",
"+",
"pFile",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"se",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"While parsing \"",
"+",
"pFile",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Called for parsing or validating a single file.
@param pResolver The resolver to use for loading external entities.
@param pValidationSet The parsers or validators configuration.
@param pSchema The schema to use.
@param pFile The file to parse or validate.
@throws MojoExecutionException Parsing or validating the file failed.
|
[
"Called",
"for",
"parsing",
"or",
"validating",
"a",
"single",
"file",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/ValidateMojo.java#L142-L194
|
4,504 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/ValidateMojo.java
|
ValidateMojo.parse
|
private void parse( Resolver pResolver, ValidationSet pValidationSet, File pFile , ErrorHandler errorHandler)
throws IOException, SAXException, ParserConfigurationException
{
XMLReader xr = newSAXParserFactory( pValidationSet ).newSAXParser().getXMLReader();
if ( pResolver != null )
{
xr.setEntityResolver( pResolver );
}
xr.setErrorHandler( errorHandler );
xr.parse( pFile.toURI().toURL().toExternalForm() );
}
|
java
|
private void parse( Resolver pResolver, ValidationSet pValidationSet, File pFile , ErrorHandler errorHandler)
throws IOException, SAXException, ParserConfigurationException
{
XMLReader xr = newSAXParserFactory( pValidationSet ).newSAXParser().getXMLReader();
if ( pResolver != null )
{
xr.setEntityResolver( pResolver );
}
xr.setErrorHandler( errorHandler );
xr.parse( pFile.toURI().toURL().toExternalForm() );
}
|
[
"private",
"void",
"parse",
"(",
"Resolver",
"pResolver",
",",
"ValidationSet",
"pValidationSet",
",",
"File",
"pFile",
",",
"ErrorHandler",
"errorHandler",
")",
"throws",
"IOException",
",",
"SAXException",
",",
"ParserConfigurationException",
"{",
"XMLReader",
"xr",
"=",
"newSAXParserFactory",
"(",
"pValidationSet",
")",
".",
"newSAXParser",
"(",
")",
".",
"getXMLReader",
"(",
")",
";",
"if",
"(",
"pResolver",
"!=",
"null",
")",
"{",
"xr",
".",
"setEntityResolver",
"(",
"pResolver",
")",
";",
"}",
"xr",
".",
"setErrorHandler",
"(",
"errorHandler",
")",
";",
"xr",
".",
"parse",
"(",
"pFile",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
".",
"toExternalForm",
"(",
")",
")",
";",
"}"
] |
Called for validating a single file.
@param pResolver The resolver to use for loading external entities.
@param pValidationSet The validators configuration.
@param pFile The file to validate.
@throws IOException An I/O error occurred.
@throws SAXException Parsing the file failed.
@throws ParserConfigurationException Creating an XML parser failed.
|
[
"Called",
"for",
"validating",
"a",
"single",
"file",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/ValidateMojo.java#L250-L260
|
4,505 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/ValidateMojo.java
|
ValidateMojo.validate
|
private void validate( Resolver pResolver, ValidationSet pValidationSet,ValidationErrorHandler errorHandler )
throws MojoExecutionException, MojoFailureException
{
final Schema schema = getSchema( pResolver, pValidationSet );
final File[] files =
getFiles( pValidationSet.getDir(), pValidationSet.getIncludes(),
getExcludes( pValidationSet.getExcludes(), pValidationSet.isSkipDefaultExcludes() ) );
if ( files.length == 0 )
{
getLog().info( "No matching files found for ValidationSet with public ID " + pValidationSet.getPublicId()
+ ", system ID " + pValidationSet.getSystemId() + "." );
}
for ( int i = 0; i < files.length; i++ )
{
validate( pResolver, pValidationSet, schema, files[i],errorHandler );
}
}
|
java
|
private void validate( Resolver pResolver, ValidationSet pValidationSet,ValidationErrorHandler errorHandler )
throws MojoExecutionException, MojoFailureException
{
final Schema schema = getSchema( pResolver, pValidationSet );
final File[] files =
getFiles( pValidationSet.getDir(), pValidationSet.getIncludes(),
getExcludes( pValidationSet.getExcludes(), pValidationSet.isSkipDefaultExcludes() ) );
if ( files.length == 0 )
{
getLog().info( "No matching files found for ValidationSet with public ID " + pValidationSet.getPublicId()
+ ", system ID " + pValidationSet.getSystemId() + "." );
}
for ( int i = 0; i < files.length; i++ )
{
validate( pResolver, pValidationSet, schema, files[i],errorHandler );
}
}
|
[
"private",
"void",
"validate",
"(",
"Resolver",
"pResolver",
",",
"ValidationSet",
"pValidationSet",
",",
"ValidationErrorHandler",
"errorHandler",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"final",
"Schema",
"schema",
"=",
"getSchema",
"(",
"pResolver",
",",
"pValidationSet",
")",
";",
"final",
"File",
"[",
"]",
"files",
"=",
"getFiles",
"(",
"pValidationSet",
".",
"getDir",
"(",
")",
",",
"pValidationSet",
".",
"getIncludes",
"(",
")",
",",
"getExcludes",
"(",
"pValidationSet",
".",
"getExcludes",
"(",
")",
",",
"pValidationSet",
".",
"isSkipDefaultExcludes",
"(",
")",
")",
")",
";",
"if",
"(",
"files",
".",
"length",
"==",
"0",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"No matching files found for ValidationSet with public ID \"",
"+",
"pValidationSet",
".",
"getPublicId",
"(",
")",
"+",
"\", system ID \"",
"+",
"pValidationSet",
".",
"getSystemId",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"validate",
"(",
"pResolver",
",",
"pValidationSet",
",",
"schema",
",",
"files",
"[",
"i",
"]",
",",
"errorHandler",
")",
";",
"}",
"}"
] |
Called for validating a set of XML files against a common schema.
@param pResolver The resolver to use for loading external entities.
@param pValidationSet The set of XML files to validate.
@throws MojoExecutionException Validating the set of files failed.
@throws MojoFailureException A configuration error was detected.
|
[
"Called",
"for",
"validating",
"a",
"set",
"of",
"XML",
"files",
"against",
"a",
"common",
"schema",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/ValidateMojo.java#L270-L286
|
4,506 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/TransformMojo.java
|
TransformMojo.newTransformerFactory
|
public static TransformerFactory newTransformerFactory( String factoryClassName, ClassLoader classLoader )
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
// use reflection to avoid JAXP 1.4 (and hence JDK6) requirement
Class<?>[] methodTypes = new Class[] { String.class, ClassLoader.class };
Method method = TransformerFactory.class.getDeclaredMethod( "newInstance", methodTypes );
Object[] methodArgs = new Object[] { factoryClassName, classLoader };
return (TransformerFactory) method.invoke( null, methodArgs );
}
|
java
|
public static TransformerFactory newTransformerFactory( String factoryClassName, ClassLoader classLoader )
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
// use reflection to avoid JAXP 1.4 (and hence JDK6) requirement
Class<?>[] methodTypes = new Class[] { String.class, ClassLoader.class };
Method method = TransformerFactory.class.getDeclaredMethod( "newInstance", methodTypes );
Object[] methodArgs = new Object[] { factoryClassName, classLoader };
return (TransformerFactory) method.invoke( null, methodArgs );
}
|
[
"public",
"static",
"TransformerFactory",
"newTransformerFactory",
"(",
"String",
"factoryClassName",
",",
"ClassLoader",
"classLoader",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"// use reflection to avoid JAXP 1.4 (and hence JDK6) requirement",
"Class",
"<",
"?",
">",
"[",
"]",
"methodTypes",
"=",
"new",
"Class",
"[",
"]",
"{",
"String",
".",
"class",
",",
"ClassLoader",
".",
"class",
"}",
";",
"Method",
"method",
"=",
"TransformerFactory",
".",
"class",
".",
"getDeclaredMethod",
"(",
"\"newInstance\"",
",",
"methodTypes",
")",
";",
"Object",
"[",
"]",
"methodArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"factoryClassName",
",",
"classLoader",
"}",
";",
"return",
"(",
"TransformerFactory",
")",
"method",
".",
"invoke",
"(",
"null",
",",
"methodArgs",
")",
";",
"}"
] |
public for use by unit test
|
[
"public",
"for",
"use",
"by",
"unit",
"test"
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/TransformMojo.java#L209-L221
|
4,507 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/TransformMojo.java
|
TransformMojo.execute
|
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( isSkipping() )
{
getLog().debug( "Skipping execution, as demanded by user." );
return;
}
if ( transformationSets == null || transformationSets.length == 0 )
{
throw new MojoFailureException( "No TransformationSets configured." );
}
checkCatalogHandling();
Object oldProxySettings = activateProxy();
try
{
Resolver resolver = getResolver();
for ( int i = 0; i < transformationSets.length; i++ )
{
TransformationSet transformationSet = transformationSets[i];
resolver.setXincludeAware( transformationSet.isXincludeAware() );
resolver.setValidating( transformationSet.isValidating() );
transform( resolver, transformationSet );
}
}
finally
{
passivateProxy( oldProxySettings );
}
}
|
java
|
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( isSkipping() )
{
getLog().debug( "Skipping execution, as demanded by user." );
return;
}
if ( transformationSets == null || transformationSets.length == 0 )
{
throw new MojoFailureException( "No TransformationSets configured." );
}
checkCatalogHandling();
Object oldProxySettings = activateProxy();
try
{
Resolver resolver = getResolver();
for ( int i = 0; i < transformationSets.length; i++ )
{
TransformationSet transformationSet = transformationSets[i];
resolver.setXincludeAware( transformationSet.isXincludeAware() );
resolver.setValidating( transformationSet.isValidating() );
transform( resolver, transformationSet );
}
}
finally
{
passivateProxy( oldProxySettings );
}
}
|
[
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"if",
"(",
"isSkipping",
"(",
")",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Skipping execution, as demanded by user.\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"transformationSets",
"==",
"null",
"||",
"transformationSets",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"MojoFailureException",
"(",
"\"No TransformationSets configured.\"",
")",
";",
"}",
"checkCatalogHandling",
"(",
")",
";",
"Object",
"oldProxySettings",
"=",
"activateProxy",
"(",
")",
";",
"try",
"{",
"Resolver",
"resolver",
"=",
"getResolver",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"transformationSets",
".",
"length",
";",
"i",
"++",
")",
"{",
"TransformationSet",
"transformationSet",
"=",
"transformationSets",
"[",
"i",
"]",
";",
"resolver",
".",
"setXincludeAware",
"(",
"transformationSet",
".",
"isXincludeAware",
"(",
")",
")",
";",
"resolver",
".",
"setValidating",
"(",
"transformationSet",
".",
"isValidating",
"(",
")",
")",
";",
"transform",
"(",
"resolver",
",",
"transformationSet",
")",
";",
"}",
"}",
"finally",
"{",
"passivateProxy",
"(",
"oldProxySettings",
")",
";",
"}",
"}"
] |
Called by Maven to run the plugin.
|
[
"Called",
"by",
"Maven",
"to",
"run",
"the",
"plugin",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/TransformMojo.java#L610-L640
|
4,508 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java
|
IndentCheckSaxHandler.characters
|
@Override
public void characters( char[] ch, int start, int length )
throws SAXException
{
charBuffer.append( ch, start, length );
charLineNumber = locator.getLineNumber();
}
|
java
|
@Override
public void characters( char[] ch, int start, int length )
throws SAXException
{
charBuffer.append( ch, start, length );
charLineNumber = locator.getLineNumber();
}
|
[
"@",
"Override",
"public",
"void",
"characters",
"(",
"char",
"[",
"]",
"ch",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"SAXException",
"{",
"charBuffer",
".",
"append",
"(",
"ch",
",",
"start",
",",
"length",
")",
";",
"charLineNumber",
"=",
"locator",
".",
"getLineNumber",
"(",
")",
";",
"}"
] |
Stores the passed characters into a character buffer.
@see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
|
[
"Stores",
"the",
"passed",
"characters",
"into",
"a",
"character",
"buffer",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java#L129-L135
|
4,509 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java
|
IndentCheckSaxHandler.endElement
|
@Override
public void endElement( String uri, String localName, String qName )
throws SAXException
{
flushCharacters();
if ( stack.isEmpty() )
{
throw new IllegalStateException( "Stack must not be empty when closing the element " + qName
+ " around line " + locator.getLineNumber() + " and column " + locator.getColumnNumber() );
}
IndentCheckSaxHandler.ElementEntry startEntry = stack.pop();
int indentDiff = lastIndent.size - startEntry.expectedIndent.size;
int expectedIndent = startEntry.expectedIndent.size;
if ( lastIndent.lineNumber != startEntry.foundIndent.lineNumber && indentDiff != 0 )
{
/*
* diff should be zero unless we are on the same line as start element
*/
int opValue = expectedIndent - lastIndent.size;
String op = opValue > 0 ? "Insert" : "Delete";
String units = opValue == 1 ? "space" : "spaces";
String message = op + " " + Math.abs( opValue ) + " " + units + ". Expected " + expectedIndent + " found "
+ lastIndent.size + " spaces before end element </" + qName + ">";
XmlFormatViolation violation =
new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
violationHandler.handle( violation );
}
}
|
java
|
@Override
public void endElement( String uri, String localName, String qName )
throws SAXException
{
flushCharacters();
if ( stack.isEmpty() )
{
throw new IllegalStateException( "Stack must not be empty when closing the element " + qName
+ " around line " + locator.getLineNumber() + " and column " + locator.getColumnNumber() );
}
IndentCheckSaxHandler.ElementEntry startEntry = stack.pop();
int indentDiff = lastIndent.size - startEntry.expectedIndent.size;
int expectedIndent = startEntry.expectedIndent.size;
if ( lastIndent.lineNumber != startEntry.foundIndent.lineNumber && indentDiff != 0 )
{
/*
* diff should be zero unless we are on the same line as start element
*/
int opValue = expectedIndent - lastIndent.size;
String op = opValue > 0 ? "Insert" : "Delete";
String units = opValue == 1 ? "space" : "spaces";
String message = op + " " + Math.abs( opValue ) + " " + units + ". Expected " + expectedIndent + " found "
+ lastIndent.size + " spaces before end element </" + qName + ">";
XmlFormatViolation violation =
new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
violationHandler.handle( violation );
}
}
|
[
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"flushCharacters",
"(",
")",
";",
"if",
"(",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Stack must not be empty when closing the element \"",
"+",
"qName",
"+",
"\" around line \"",
"+",
"locator",
".",
"getLineNumber",
"(",
")",
"+",
"\" and column \"",
"+",
"locator",
".",
"getColumnNumber",
"(",
")",
")",
";",
"}",
"IndentCheckSaxHandler",
".",
"ElementEntry",
"startEntry",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"int",
"indentDiff",
"=",
"lastIndent",
".",
"size",
"-",
"startEntry",
".",
"expectedIndent",
".",
"size",
";",
"int",
"expectedIndent",
"=",
"startEntry",
".",
"expectedIndent",
".",
"size",
";",
"if",
"(",
"lastIndent",
".",
"lineNumber",
"!=",
"startEntry",
".",
"foundIndent",
".",
"lineNumber",
"&&",
"indentDiff",
"!=",
"0",
")",
"{",
"/*\n * diff should be zero unless we are on the same line as start element\n */",
"int",
"opValue",
"=",
"expectedIndent",
"-",
"lastIndent",
".",
"size",
";",
"String",
"op",
"=",
"opValue",
">",
"0",
"?",
"\"Insert\"",
":",
"\"Delete\"",
";",
"String",
"units",
"=",
"opValue",
"==",
"1",
"?",
"\"space\"",
":",
"\"spaces\"",
";",
"String",
"message",
"=",
"op",
"+",
"\" \"",
"+",
"Math",
".",
"abs",
"(",
"opValue",
")",
"+",
"\" \"",
"+",
"units",
"+",
"\". Expected \"",
"+",
"expectedIndent",
"+",
"\" found \"",
"+",
"lastIndent",
".",
"size",
"+",
"\" spaces before end element </\"",
"+",
"qName",
"+",
"\">\"",
";",
"XmlFormatViolation",
"violation",
"=",
"new",
"XmlFormatViolation",
"(",
"file",
",",
"locator",
".",
"getLineNumber",
"(",
")",
",",
"locator",
".",
"getColumnNumber",
"(",
")",
",",
"message",
")",
";",
"violationHandler",
".",
"handle",
"(",
"violation",
")",
";",
"}",
"}"
] |
Checks indentation for an end element.
@see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
|
[
"Checks",
"indentation",
"for",
"an",
"end",
"element",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java#L143-L170
|
4,510 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java
|
IndentCheckSaxHandler.startElement
|
@Override
public void startElement( String uri, String localName, String qName, Attributes attributes )
throws SAXException
{
flushCharacters();
IndentCheckSaxHandler.ElementEntry currentEntry = new ElementEntry( qName, lastIndent );
if ( !stack.isEmpty() )
{
IndentCheckSaxHandler.ElementEntry parentEntry = stack.peek();
/*
* note that we use parentEntry.expectedIndent rather than parentEntry.foundIndent this is to make the
* messages more useful
*/
int indentDiff = currentEntry.foundIndent.size - parentEntry.expectedIndent.size;
int expectedIndent = parentEntry.expectedIndent.size + indentSize;
if ( indentDiff == 0 && currentEntry.foundIndent.lineNumber == parentEntry.foundIndent.lineNumber )
{
/*
* Zero foundIndent acceptable only if current is on the same line as parent This is OK, therefore do
* nothing
*/
}
else if ( indentDiff != indentSize )
{
/* generally unexpected foundIndent */
int opValue = expectedIndent - currentEntry.foundIndent.size;
String op = opValue > 0 ? "Insert" : "Delete";
String message = op + " " + Math.abs( opValue ) + " spaces. Expected " + expectedIndent + " found "
+ currentEntry.foundIndent.size + " spaces before start element <" + currentEntry.elementName + ">";
XmlFormatViolation violation =
new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
violationHandler.handle( violation );
/* reset the expected indent in the entry we'll push */
currentEntry =
new ElementEntry( qName, lastIndent, new Indent( lastIndent.lineNumber, expectedIndent ) );
}
}
stack.push( currentEntry );
}
|
java
|
@Override
public void startElement( String uri, String localName, String qName, Attributes attributes )
throws SAXException
{
flushCharacters();
IndentCheckSaxHandler.ElementEntry currentEntry = new ElementEntry( qName, lastIndent );
if ( !stack.isEmpty() )
{
IndentCheckSaxHandler.ElementEntry parentEntry = stack.peek();
/*
* note that we use parentEntry.expectedIndent rather than parentEntry.foundIndent this is to make the
* messages more useful
*/
int indentDiff = currentEntry.foundIndent.size - parentEntry.expectedIndent.size;
int expectedIndent = parentEntry.expectedIndent.size + indentSize;
if ( indentDiff == 0 && currentEntry.foundIndent.lineNumber == parentEntry.foundIndent.lineNumber )
{
/*
* Zero foundIndent acceptable only if current is on the same line as parent This is OK, therefore do
* nothing
*/
}
else if ( indentDiff != indentSize )
{
/* generally unexpected foundIndent */
int opValue = expectedIndent - currentEntry.foundIndent.size;
String op = opValue > 0 ? "Insert" : "Delete";
String message = op + " " + Math.abs( opValue ) + " spaces. Expected " + expectedIndent + " found "
+ currentEntry.foundIndent.size + " spaces before start element <" + currentEntry.elementName + ">";
XmlFormatViolation violation =
new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
violationHandler.handle( violation );
/* reset the expected indent in the entry we'll push */
currentEntry =
new ElementEntry( qName, lastIndent, new Indent( lastIndent.lineNumber, expectedIndent ) );
}
}
stack.push( currentEntry );
}
|
[
"@",
"Override",
"public",
"void",
"startElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
",",
"Attributes",
"attributes",
")",
"throws",
"SAXException",
"{",
"flushCharacters",
"(",
")",
";",
"IndentCheckSaxHandler",
".",
"ElementEntry",
"currentEntry",
"=",
"new",
"ElementEntry",
"(",
"qName",
",",
"lastIndent",
")",
";",
"if",
"(",
"!",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"IndentCheckSaxHandler",
".",
"ElementEntry",
"parentEntry",
"=",
"stack",
".",
"peek",
"(",
")",
";",
"/*\n * note that we use parentEntry.expectedIndent rather than parentEntry.foundIndent this is to make the\n * messages more useful\n */",
"int",
"indentDiff",
"=",
"currentEntry",
".",
"foundIndent",
".",
"size",
"-",
"parentEntry",
".",
"expectedIndent",
".",
"size",
";",
"int",
"expectedIndent",
"=",
"parentEntry",
".",
"expectedIndent",
".",
"size",
"+",
"indentSize",
";",
"if",
"(",
"indentDiff",
"==",
"0",
"&&",
"currentEntry",
".",
"foundIndent",
".",
"lineNumber",
"==",
"parentEntry",
".",
"foundIndent",
".",
"lineNumber",
")",
"{",
"/*\n * Zero foundIndent acceptable only if current is on the same line as parent This is OK, therefore do\n * nothing\n */",
"}",
"else",
"if",
"(",
"indentDiff",
"!=",
"indentSize",
")",
"{",
"/* generally unexpected foundIndent */",
"int",
"opValue",
"=",
"expectedIndent",
"-",
"currentEntry",
".",
"foundIndent",
".",
"size",
";",
"String",
"op",
"=",
"opValue",
">",
"0",
"?",
"\"Insert\"",
":",
"\"Delete\"",
";",
"String",
"message",
"=",
"op",
"+",
"\" \"",
"+",
"Math",
".",
"abs",
"(",
"opValue",
")",
"+",
"\" spaces. Expected \"",
"+",
"expectedIndent",
"+",
"\" found \"",
"+",
"currentEntry",
".",
"foundIndent",
".",
"size",
"+",
"\" spaces before start element <\"",
"+",
"currentEntry",
".",
"elementName",
"+",
"\">\"",
";",
"XmlFormatViolation",
"violation",
"=",
"new",
"XmlFormatViolation",
"(",
"file",
",",
"locator",
".",
"getLineNumber",
"(",
")",
",",
"locator",
".",
"getColumnNumber",
"(",
")",
",",
"message",
")",
";",
"violationHandler",
".",
"handle",
"(",
"violation",
")",
";",
"/* reset the expected indent in the entry we'll push */",
"currentEntry",
"=",
"new",
"ElementEntry",
"(",
"qName",
",",
"lastIndent",
",",
"new",
"Indent",
"(",
"lastIndent",
".",
"lineNumber",
",",
"expectedIndent",
")",
")",
";",
"}",
"}",
"stack",
".",
"push",
"(",
"currentEntry",
")",
";",
"}"
] |
Checks indentation for a start element.
@see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
|
[
"Checks",
"indentation",
"for",
"a",
"start",
"element",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/format/IndentCheckSaxHandler.java#L245-L285
|
4,511 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.asAbsoluteFile
|
protected File asAbsoluteFile( File f )
{
if ( f.isAbsolute() )
{
return f;
}
return new File( getBasedir(), f.getPath() );
}
|
java
|
protected File asAbsoluteFile( File f )
{
if ( f.isAbsolute() )
{
return f;
}
return new File( getBasedir(), f.getPath() );
}
|
[
"protected",
"File",
"asAbsoluteFile",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
".",
"isAbsolute",
"(",
")",
")",
"{",
"return",
"f",
";",
"}",
"return",
"new",
"File",
"(",
"getBasedir",
"(",
")",
",",
"f",
".",
"getPath",
"(",
")",
")",
";",
"}"
] |
Converts the given file into an file with an absolute path.
|
[
"Converts",
"the",
"given",
"file",
"into",
"an",
"file",
"with",
"an",
"absolute",
"path",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L135-L142
|
4,512 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.setCatalogs
|
protected void setCatalogs(List<File> pCatalogFiles, List<URL> pCatalogUrls ) throws MojoExecutionException
{
if ( catalogs == null || catalogs.length == 0 )
{
return;
}
for ( int i = 0; i < catalogs.length; i++ )
{
try
{
URL url = new URL( catalogs[i] );
pCatalogUrls.add( url );
}
catch ( MalformedURLException e )
{
File absoluteCatalog = asAbsoluteFile( new File( catalogs[i] ) );
if (!absoluteCatalog.exists() || !absoluteCatalog.isFile()){
throw new MojoExecutionException("That catalog does not exist:"+absoluteCatalog.getPath(), e);
}
pCatalogFiles.add(absoluteCatalog );
}
}
}
|
java
|
protected void setCatalogs(List<File> pCatalogFiles, List<URL> pCatalogUrls ) throws MojoExecutionException
{
if ( catalogs == null || catalogs.length == 0 )
{
return;
}
for ( int i = 0; i < catalogs.length; i++ )
{
try
{
URL url = new URL( catalogs[i] );
pCatalogUrls.add( url );
}
catch ( MalformedURLException e )
{
File absoluteCatalog = asAbsoluteFile( new File( catalogs[i] ) );
if (!absoluteCatalog.exists() || !absoluteCatalog.isFile()){
throw new MojoExecutionException("That catalog does not exist:"+absoluteCatalog.getPath(), e);
}
pCatalogFiles.add(absoluteCatalog );
}
}
}
|
[
"protected",
"void",
"setCatalogs",
"(",
"List",
"<",
"File",
">",
"pCatalogFiles",
",",
"List",
"<",
"URL",
">",
"pCatalogUrls",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"catalogs",
"==",
"null",
"||",
"catalogs",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"catalogs",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"catalogs",
"[",
"i",
"]",
")",
";",
"pCatalogUrls",
".",
"add",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"File",
"absoluteCatalog",
"=",
"asAbsoluteFile",
"(",
"new",
"File",
"(",
"catalogs",
"[",
"i",
"]",
")",
")",
";",
"if",
"(",
"!",
"absoluteCatalog",
".",
"exists",
"(",
")",
"||",
"!",
"absoluteCatalog",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"That catalog does not exist:\"",
"+",
"absoluteCatalog",
".",
"getPath",
"(",
")",
",",
"e",
")",
";",
"}",
"pCatalogFiles",
".",
"add",
"(",
"absoluteCatalog",
")",
";",
"}",
"}",
"}"
] |
Returns the plugins catalog files.
|
[
"Returns",
"the",
"plugins",
"catalog",
"files",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L147-L170
|
4,513 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.getResolver
|
protected Resolver getResolver()
throws MojoExecutionException
{
List<File> catalogFiles = new ArrayList<File>();
List<URL> catalogUrls = new ArrayList<URL>();
setCatalogs( catalogFiles, catalogUrls );
return new Resolver( getBasedir(), catalogFiles, catalogUrls, getLocator(), catalogHandling,getLog().isDebugEnabled() );
}
|
java
|
protected Resolver getResolver()
throws MojoExecutionException
{
List<File> catalogFiles = new ArrayList<File>();
List<URL> catalogUrls = new ArrayList<URL>();
setCatalogs( catalogFiles, catalogUrls );
return new Resolver( getBasedir(), catalogFiles, catalogUrls, getLocator(), catalogHandling,getLog().isDebugEnabled() );
}
|
[
"protected",
"Resolver",
"getResolver",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"List",
"<",
"File",
">",
"catalogFiles",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"List",
"<",
"URL",
">",
"catalogUrls",
"=",
"new",
"ArrayList",
"<",
"URL",
">",
"(",
")",
";",
"setCatalogs",
"(",
"catalogFiles",
",",
"catalogUrls",
")",
";",
"return",
"new",
"Resolver",
"(",
"getBasedir",
"(",
")",
",",
"catalogFiles",
",",
"catalogUrls",
",",
"getLocator",
"(",
")",
",",
"catalogHandling",
",",
"getLog",
"(",
")",
".",
"isDebugEnabled",
"(",
")",
")",
";",
"}"
] |
Creates a new resolver.
|
[
"Creates",
"a",
"new",
"resolver",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L175-L183
|
4,514 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.getFileNames
|
protected String[] getFileNames( File pDir, String[] pIncludes, String[] pExcludes )
throws MojoFailureException, MojoExecutionException
{
if ( pDir == null )
{
throw new MojoFailureException( "A ValidationSet or TransformationSet"
+ " requires a nonempty 'dir' child element." );
}
final File dir = asAbsoluteFile( pDir );
if ( !dir.isDirectory() )
{
throw new MojoExecutionException("The directory " + dir.getPath()
+ ", which is a base directory of a ValidationSet or TransformationSet, does not exist.");
}
final DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir( dir );
if ( pIncludes != null && pIncludes.length > 0 )
{
ds.setIncludes( pIncludes );
}
if ( pExcludes != null && pExcludes.length > 0 )
{
ds.setExcludes( pExcludes );
}
ds.scan();
return ds.getIncludedFiles();
}
|
java
|
protected String[] getFileNames( File pDir, String[] pIncludes, String[] pExcludes )
throws MojoFailureException, MojoExecutionException
{
if ( pDir == null )
{
throw new MojoFailureException( "A ValidationSet or TransformationSet"
+ " requires a nonempty 'dir' child element." );
}
final File dir = asAbsoluteFile( pDir );
if ( !dir.isDirectory() )
{
throw new MojoExecutionException("The directory " + dir.getPath()
+ ", which is a base directory of a ValidationSet or TransformationSet, does not exist.");
}
final DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir( dir );
if ( pIncludes != null && pIncludes.length > 0 )
{
ds.setIncludes( pIncludes );
}
if ( pExcludes != null && pExcludes.length > 0 )
{
ds.setExcludes( pExcludes );
}
ds.scan();
return ds.getIncludedFiles();
}
|
[
"protected",
"String",
"[",
"]",
"getFileNames",
"(",
"File",
"pDir",
",",
"String",
"[",
"]",
"pIncludes",
",",
"String",
"[",
"]",
"pExcludes",
")",
"throws",
"MojoFailureException",
",",
"MojoExecutionException",
"{",
"if",
"(",
"pDir",
"==",
"null",
")",
"{",
"throw",
"new",
"MojoFailureException",
"(",
"\"A ValidationSet or TransformationSet\"",
"+",
"\" requires a nonempty 'dir' child element.\"",
")",
";",
"}",
"final",
"File",
"dir",
"=",
"asAbsoluteFile",
"(",
"pDir",
")",
";",
"if",
"(",
"!",
"dir",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"The directory \"",
"+",
"dir",
".",
"getPath",
"(",
")",
"+",
"\", which is a base directory of a ValidationSet or TransformationSet, does not exist.\"",
")",
";",
"}",
"final",
"DirectoryScanner",
"ds",
"=",
"new",
"DirectoryScanner",
"(",
")",
";",
"ds",
".",
"setBasedir",
"(",
"dir",
")",
";",
"if",
"(",
"pIncludes",
"!=",
"null",
"&&",
"pIncludes",
".",
"length",
">",
"0",
")",
"{",
"ds",
".",
"setIncludes",
"(",
"pIncludes",
")",
";",
"}",
"if",
"(",
"pExcludes",
"!=",
"null",
"&&",
"pExcludes",
".",
"length",
">",
"0",
")",
"{",
"ds",
".",
"setExcludes",
"(",
"pExcludes",
")",
";",
"}",
"ds",
".",
"scan",
"(",
")",
";",
"return",
"ds",
".",
"getIncludedFiles",
"(",
")",
";",
"}"
] |
Scans a directory for files and returns a set of path names.
|
[
"Scans",
"a",
"directory",
"for",
"files",
"and",
"returns",
"a",
"set",
"of",
"path",
"names",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L188-L214
|
4,515 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.getExcludes
|
protected String[] getExcludes( String[] origExcludes, boolean skipDefaultExcludes )
{
if ( skipDefaultExcludes )
{
return origExcludes;
}
String[] defaultExcludes = FileUtils.getDefaultExcludes();
if ( origExcludes == null || origExcludes.length == 0 )
{
return defaultExcludes;
}
String[] result = new String[origExcludes.length + defaultExcludes.length];
System.arraycopy( origExcludes, 0, result, 0, origExcludes.length );
System.arraycopy( defaultExcludes, 0, result, origExcludes.length, defaultExcludes.length );
return result;
}
|
java
|
protected String[] getExcludes( String[] origExcludes, boolean skipDefaultExcludes )
{
if ( skipDefaultExcludes )
{
return origExcludes;
}
String[] defaultExcludes = FileUtils.getDefaultExcludes();
if ( origExcludes == null || origExcludes.length == 0 )
{
return defaultExcludes;
}
String[] result = new String[origExcludes.length + defaultExcludes.length];
System.arraycopy( origExcludes, 0, result, 0, origExcludes.length );
System.arraycopy( defaultExcludes, 0, result, origExcludes.length, defaultExcludes.length );
return result;
}
|
[
"protected",
"String",
"[",
"]",
"getExcludes",
"(",
"String",
"[",
"]",
"origExcludes",
",",
"boolean",
"skipDefaultExcludes",
")",
"{",
"if",
"(",
"skipDefaultExcludes",
")",
"{",
"return",
"origExcludes",
";",
"}",
"String",
"[",
"]",
"defaultExcludes",
"=",
"FileUtils",
".",
"getDefaultExcludes",
"(",
")",
";",
"if",
"(",
"origExcludes",
"==",
"null",
"||",
"origExcludes",
".",
"length",
"==",
"0",
")",
"{",
"return",
"defaultExcludes",
";",
"}",
"String",
"[",
"]",
"result",
"=",
"new",
"String",
"[",
"origExcludes",
".",
"length",
"+",
"defaultExcludes",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"origExcludes",
",",
"0",
",",
"result",
",",
"0",
",",
"origExcludes",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"defaultExcludes",
",",
"0",
",",
"result",
",",
"origExcludes",
".",
"length",
",",
"defaultExcludes",
".",
"length",
")",
";",
"return",
"result",
";",
"}"
] |
Calculates the exclusions to use when searching files.
|
[
"Calculates",
"the",
"exclusions",
"to",
"use",
"when",
"searching",
"files",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L248-L264
|
4,516 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.activateProxy
|
protected Object activateProxy()
{
if ( settings == null )
{
return null;
}
final Proxy proxy = settings.getActiveProxy();
if ( proxy == null )
{
return null;
}
final List<String> properties = new ArrayList<String>();
final String protocol = proxy.getProtocol();
final String prefix = isEmpty( protocol ) ? "" : ( protocol + "." );
final String host = proxy.getHost();
final String hostProperty = prefix + "proxyHost";
final String hostValue = isEmpty( host ) ? null : host;
setProperty( properties, hostProperty, hostValue );
final int port = proxy.getPort();
final String portProperty = prefix + "proxyPort";
final String portValue = ( port == 0 || port == -1 ) ? null : String.valueOf( port );
setProperty( properties, portProperty, portValue );
final String username = proxy.getUsername();
final String userProperty = prefix + "proxyUser";
final String userValue = isEmpty( username ) ? null : username;
setProperty( properties, userProperty, userValue );
final String password = proxy.getPassword();
final String passwordProperty = prefix + "proxyPassword";
final String passwordValue = isEmpty( password ) ? null : password;
setProperty( properties, passwordProperty, passwordValue );
final String nonProxyHosts = proxy.getNonProxyHosts();
final String nonProxyHostsProperty = prefix + "nonProxyHosts";
final String nonProxyHostsValue = isEmpty( nonProxyHosts ) ? null : nonProxyHosts.replace( ',', '|' );
setProperty( properties, nonProxyHostsProperty, nonProxyHostsValue );
getLog().debug( "Proxy settings: " + hostProperty + "=" + hostValue + ", " + portProperty + "=" + portValue
+ ", " + userProperty + "=" + userValue + ", " + passwordProperty + "="
+ ( passwordValue == null ? "null" : "<PasswordNotLogged>" ) + ", " + nonProxyHostsProperty + "="
+ nonProxyHostsValue );
return properties;
}
|
java
|
protected Object activateProxy()
{
if ( settings == null )
{
return null;
}
final Proxy proxy = settings.getActiveProxy();
if ( proxy == null )
{
return null;
}
final List<String> properties = new ArrayList<String>();
final String protocol = proxy.getProtocol();
final String prefix = isEmpty( protocol ) ? "" : ( protocol + "." );
final String host = proxy.getHost();
final String hostProperty = prefix + "proxyHost";
final String hostValue = isEmpty( host ) ? null : host;
setProperty( properties, hostProperty, hostValue );
final int port = proxy.getPort();
final String portProperty = prefix + "proxyPort";
final String portValue = ( port == 0 || port == -1 ) ? null : String.valueOf( port );
setProperty( properties, portProperty, portValue );
final String username = proxy.getUsername();
final String userProperty = prefix + "proxyUser";
final String userValue = isEmpty( username ) ? null : username;
setProperty( properties, userProperty, userValue );
final String password = proxy.getPassword();
final String passwordProperty = prefix + "proxyPassword";
final String passwordValue = isEmpty( password ) ? null : password;
setProperty( properties, passwordProperty, passwordValue );
final String nonProxyHosts = proxy.getNonProxyHosts();
final String nonProxyHostsProperty = prefix + "nonProxyHosts";
final String nonProxyHostsValue = isEmpty( nonProxyHosts ) ? null : nonProxyHosts.replace( ',', '|' );
setProperty( properties, nonProxyHostsProperty, nonProxyHostsValue );
getLog().debug( "Proxy settings: " + hostProperty + "=" + hostValue + ", " + portProperty + "=" + portValue
+ ", " + userProperty + "=" + userValue + ", " + passwordProperty + "="
+ ( passwordValue == null ? "null" : "<PasswordNotLogged>" ) + ", " + nonProxyHostsProperty + "="
+ nonProxyHostsValue );
return properties;
}
|
[
"protected",
"Object",
"activateProxy",
"(",
")",
"{",
"if",
"(",
"settings",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Proxy",
"proxy",
"=",
"settings",
".",
"getActiveProxy",
"(",
")",
";",
"if",
"(",
"proxy",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"List",
"<",
"String",
">",
"properties",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"final",
"String",
"protocol",
"=",
"proxy",
".",
"getProtocol",
"(",
")",
";",
"final",
"String",
"prefix",
"=",
"isEmpty",
"(",
"protocol",
")",
"?",
"\"\"",
":",
"(",
"protocol",
"+",
"\".\"",
")",
";",
"final",
"String",
"host",
"=",
"proxy",
".",
"getHost",
"(",
")",
";",
"final",
"String",
"hostProperty",
"=",
"prefix",
"+",
"\"proxyHost\"",
";",
"final",
"String",
"hostValue",
"=",
"isEmpty",
"(",
"host",
")",
"?",
"null",
":",
"host",
";",
"setProperty",
"(",
"properties",
",",
"hostProperty",
",",
"hostValue",
")",
";",
"final",
"int",
"port",
"=",
"proxy",
".",
"getPort",
"(",
")",
";",
"final",
"String",
"portProperty",
"=",
"prefix",
"+",
"\"proxyPort\"",
";",
"final",
"String",
"portValue",
"=",
"(",
"port",
"==",
"0",
"||",
"port",
"==",
"-",
"1",
")",
"?",
"null",
":",
"String",
".",
"valueOf",
"(",
"port",
")",
";",
"setProperty",
"(",
"properties",
",",
"portProperty",
",",
"portValue",
")",
";",
"final",
"String",
"username",
"=",
"proxy",
".",
"getUsername",
"(",
")",
";",
"final",
"String",
"userProperty",
"=",
"prefix",
"+",
"\"proxyUser\"",
";",
"final",
"String",
"userValue",
"=",
"isEmpty",
"(",
"username",
")",
"?",
"null",
":",
"username",
";",
"setProperty",
"(",
"properties",
",",
"userProperty",
",",
"userValue",
")",
";",
"final",
"String",
"password",
"=",
"proxy",
".",
"getPassword",
"(",
")",
";",
"final",
"String",
"passwordProperty",
"=",
"prefix",
"+",
"\"proxyPassword\"",
";",
"final",
"String",
"passwordValue",
"=",
"isEmpty",
"(",
"password",
")",
"?",
"null",
":",
"password",
";",
"setProperty",
"(",
"properties",
",",
"passwordProperty",
",",
"passwordValue",
")",
";",
"final",
"String",
"nonProxyHosts",
"=",
"proxy",
".",
"getNonProxyHosts",
"(",
")",
";",
"final",
"String",
"nonProxyHostsProperty",
"=",
"prefix",
"+",
"\"nonProxyHosts\"",
";",
"final",
"String",
"nonProxyHostsValue",
"=",
"isEmpty",
"(",
"nonProxyHosts",
")",
"?",
"null",
":",
"nonProxyHosts",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"setProperty",
"(",
"properties",
",",
"nonProxyHostsProperty",
",",
"nonProxyHostsValue",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Proxy settings: \"",
"+",
"hostProperty",
"+",
"\"=\"",
"+",
"hostValue",
"+",
"\", \"",
"+",
"portProperty",
"+",
"\"=\"",
"+",
"portValue",
"+",
"\", \"",
"+",
"userProperty",
"+",
"\"=\"",
"+",
"userValue",
"+",
"\", \"",
"+",
"passwordProperty",
"+",
"\"=\"",
"+",
"(",
"passwordValue",
"==",
"null",
"?",
"\"null\"",
":",
"\"<PasswordNotLogged>\"",
")",
"+",
"\", \"",
"+",
"nonProxyHostsProperty",
"+",
"\"=\"",
"+",
"nonProxyHostsValue",
")",
";",
"return",
"properties",
";",
"}"
] |
Called to install the plugins proxy settings.
|
[
"Called",
"to",
"install",
"the",
"plugins",
"proxy",
"settings",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L291-L332
|
4,517 |
mojohaus/xml-maven-plugin
|
src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java
|
AbstractXmlMojo.passivateProxy
|
protected void passivateProxy( Object pProperties )
{
if ( pProperties == null )
{
return;
}
@SuppressWarnings( "unchecked" )
final List<String> properties = (List<String>) pProperties;
for ( Iterator<String> iter = properties.iterator(); iter.hasNext(); )
{
final String key = iter.next();
final String value = iter.next();
setProperty( null, key, value );
}
}
|
java
|
protected void passivateProxy( Object pProperties )
{
if ( pProperties == null )
{
return;
}
@SuppressWarnings( "unchecked" )
final List<String> properties = (List<String>) pProperties;
for ( Iterator<String> iter = properties.iterator(); iter.hasNext(); )
{
final String key = iter.next();
final String value = iter.next();
setProperty( null, key, value );
}
}
|
[
"protected",
"void",
"passivateProxy",
"(",
"Object",
"pProperties",
")",
"{",
"if",
"(",
"pProperties",
"==",
"null",
")",
"{",
"return",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"List",
"<",
"String",
">",
"properties",
"=",
"(",
"List",
"<",
"String",
">",
")",
"pProperties",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"iter",
"=",
"properties",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"final",
"String",
"key",
"=",
"iter",
".",
"next",
"(",
")",
";",
"final",
"String",
"value",
"=",
"iter",
".",
"next",
"(",
")",
";",
"setProperty",
"(",
"null",
",",
"key",
",",
"value",
")",
";",
"}",
"}"
] |
Called to restore the proxy settings, which have been installed when the plugin was invoked.
|
[
"Called",
"to",
"restore",
"the",
"proxy",
"settings",
"which",
"have",
"been",
"installed",
"when",
"the",
"plugin",
"was",
"invoked",
"."
] |
161edde37bbfe7a472369a9675c44d91ec24561d
|
https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L337-L351
|
4,518 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/client/HttpClient.java
|
HttpClient.addQueryParameters
|
private void addQueryParameters(HttpRequestBase request, Map<String, String> params) {
if (params != null) {
URIBuilder builder = new URIBuilder(request.getURI());
for(Map.Entry<String, String> param : params.entrySet()) {
builder.addParameter(param.getKey(), param.getValue());
}
try {
request.setURI(builder.build());
} catch (URISyntaxException e) {
throw new RuntimeException("Unable to construct API URI", e);
}
}
}
|
java
|
private void addQueryParameters(HttpRequestBase request, Map<String, String> params) {
if (params != null) {
URIBuilder builder = new URIBuilder(request.getURI());
for(Map.Entry<String, String> param : params.entrySet()) {
builder.addParameter(param.getKey(), param.getValue());
}
try {
request.setURI(builder.build());
} catch (URISyntaxException e) {
throw new RuntimeException("Unable to construct API URI", e);
}
}
}
|
[
"private",
"void",
"addQueryParameters",
"(",
"HttpRequestBase",
"request",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"if",
"(",
"params",
"!=",
"null",
")",
"{",
"URIBuilder",
"builder",
"=",
"new",
"URIBuilder",
"(",
"request",
".",
"getURI",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"param",
":",
"params",
".",
"entrySet",
"(",
")",
")",
"{",
"builder",
".",
"addParameter",
"(",
"param",
".",
"getKey",
"(",
")",
",",
"param",
".",
"getValue",
"(",
")",
")",
";",
"}",
"try",
"{",
"request",
".",
"setURI",
"(",
"builder",
".",
"build",
"(",
")",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to construct API URI\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Modifies request in place to add on any query parameters
|
[
"Modifies",
"request",
"in",
"place",
"to",
"add",
"on",
"any",
"query",
"parameters"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/client/HttpClient.java#L97-L109
|
4,519 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/AlgorithmException.java
|
AlgorithmException.wrapException
|
private static AlgorithmException wrapException(Throwable throwable) {
if(throwable == null) {
return null;
} else if(throwable instanceof AlgorithmException) {
return (AlgorithmException) throwable;
} else {
return new AlgorithmException(throwable.getMessage(), wrapException(throwable.getCause()), wrapStackTrace(throwable));
}
}
|
java
|
private static AlgorithmException wrapException(Throwable throwable) {
if(throwable == null) {
return null;
} else if(throwable instanceof AlgorithmException) {
return (AlgorithmException) throwable;
} else {
return new AlgorithmException(throwable.getMessage(), wrapException(throwable.getCause()), wrapStackTrace(throwable));
}
}
|
[
"private",
"static",
"AlgorithmException",
"wrapException",
"(",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"throwable",
"instanceof",
"AlgorithmException",
")",
"{",
"return",
"(",
"AlgorithmException",
")",
"throwable",
";",
"}",
"else",
"{",
"return",
"new",
"AlgorithmException",
"(",
"throwable",
".",
"getMessage",
"(",
")",
",",
"wrapException",
"(",
"throwable",
".",
"getCause",
"(",
")",
")",
",",
"wrapStackTrace",
"(",
"throwable",
")",
")",
";",
"}",
"}"
] |
Constructs a new algorithm exception from an existing throwable.
This replaces all Exceptions in the cause hierarchy to be replaced with AlgorithmException, for inter-jvm communication safety.
|
[
"Constructs",
"a",
"new",
"algorithm",
"exception",
"from",
"an",
"existing",
"throwable",
".",
"This",
"replaces",
"all",
"Exceptions",
"in",
"the",
"cause",
"hierarchy",
"to",
"be",
"replaced",
"with",
"AlgorithmException",
"for",
"inter",
"-",
"jvm",
"communication",
"safety",
"."
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/AlgorithmException.java#L90-L98
|
4,520 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataDirectory.java
|
DataDirectory.putFile
|
public DataFile putFile(File file) throws APIException, FileNotFoundException {
DataFile dataFile = new DataFile(client, trimmedPath + "/" + file.getName());
dataFile.put(file);
return dataFile;
}
|
java
|
public DataFile putFile(File file) throws APIException, FileNotFoundException {
DataFile dataFile = new DataFile(client, trimmedPath + "/" + file.getName());
dataFile.put(file);
return dataFile;
}
|
[
"public",
"DataFile",
"putFile",
"(",
"File",
"file",
")",
"throws",
"APIException",
",",
"FileNotFoundException",
"{",
"DataFile",
"dataFile",
"=",
"new",
"DataFile",
"(",
"client",
",",
"trimmedPath",
"+",
"\"/\"",
"+",
"file",
".",
"getName",
"(",
")",
")",
";",
"dataFile",
".",
"put",
"(",
"file",
")",
";",
"return",
"dataFile",
";",
"}"
] |
Convenience wrapper for putting a File
@param file a file to put into this data directory
@return a handle to the requested file
@throws APIException if there were any problems communicating with the Algorithmia API
@throws FileNotFoundException if the specified file does not exist
|
[
"Convenience",
"wrapper",
"for",
"putting",
"a",
"File"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataDirectory.java#L88-L92
|
4,521 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataDirectory.java
|
DataDirectory.create
|
public void create() throws APIException {
CreateDirectoryRequest reqObj = new CreateDirectoryRequest(this.getName(), null);
Gson gson = new Gson();
JsonElement inputJson = gson.toJsonTree(reqObj);
String url = this.getParent().getUrl();
HttpResponse response = this.client.post(url, new StringEntity(inputJson.toString(), ContentType.APPLICATION_JSON));
HttpClientHelpers.throwIfNotOk(response);
}
|
java
|
public void create() throws APIException {
CreateDirectoryRequest reqObj = new CreateDirectoryRequest(this.getName(), null);
Gson gson = new Gson();
JsonElement inputJson = gson.toJsonTree(reqObj);
String url = this.getParent().getUrl();
HttpResponse response = this.client.post(url, new StringEntity(inputJson.toString(), ContentType.APPLICATION_JSON));
HttpClientHelpers.throwIfNotOk(response);
}
|
[
"public",
"void",
"create",
"(",
")",
"throws",
"APIException",
"{",
"CreateDirectoryRequest",
"reqObj",
"=",
"new",
"CreateDirectoryRequest",
"(",
"this",
".",
"getName",
"(",
")",
",",
"null",
")",
";",
"Gson",
"gson",
"=",
"new",
"Gson",
"(",
")",
";",
"JsonElement",
"inputJson",
"=",
"gson",
".",
"toJsonTree",
"(",
"reqObj",
")",
";",
"String",
"url",
"=",
"this",
".",
"getParent",
"(",
")",
".",
"getUrl",
"(",
")",
";",
"HttpResponse",
"response",
"=",
"this",
".",
"client",
".",
"post",
"(",
"url",
",",
"new",
"StringEntity",
"(",
"inputJson",
".",
"toString",
"(",
")",
",",
"ContentType",
".",
"APPLICATION_JSON",
")",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"}"
] |
Creates this directory via the Algorithmia Data API
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Creates",
"this",
"directory",
"via",
"the",
"Algorithmia",
"Data",
"API"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataDirectory.java#L116-L124
|
4,522 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataDirectory.java
|
DataDirectory.delete
|
public void delete(boolean forceDelete) throws APIException {
HttpResponse response = client.delete(getUrl() + "?force=" + forceDelete);
HttpClientHelpers.throwIfNotOk(response);
}
|
java
|
public void delete(boolean forceDelete) throws APIException {
HttpResponse response = client.delete(getUrl() + "?force=" + forceDelete);
HttpClientHelpers.throwIfNotOk(response);
}
|
[
"public",
"void",
"delete",
"(",
"boolean",
"forceDelete",
")",
"throws",
"APIException",
"{",
"HttpResponse",
"response",
"=",
"client",
".",
"delete",
"(",
"getUrl",
"(",
")",
"+",
"\"?force=\"",
"+",
"forceDelete",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"}"
] |
Creates this directory vi the Algorithmia Data API
@param forceDelete forces deletion of the directory even if it still has other files in it
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Creates",
"this",
"directory",
"vi",
"the",
"Algorithmia",
"Data",
"API"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataDirectory.java#L142-L145
|
4,523 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataDirectory.java
|
DataDirectory.getPage
|
protected DirectoryListResponse getPage(String marker, Boolean getAcl) throws APIException {
String url = getUrl();
Map<String, String> params = new HashMap<String, String>();
if (marker != null) {
params.put("marker", marker);
}
if (getAcl) {
params.put("acl", getAcl.toString());
}
return client.get(url, new TypeToken<DirectoryListResponse>(){}, params);
}
|
java
|
protected DirectoryListResponse getPage(String marker, Boolean getAcl) throws APIException {
String url = getUrl();
Map<String, String> params = new HashMap<String, String>();
if (marker != null) {
params.put("marker", marker);
}
if (getAcl) {
params.put("acl", getAcl.toString());
}
return client.get(url, new TypeToken<DirectoryListResponse>(){}, params);
}
|
[
"protected",
"DirectoryListResponse",
"getPage",
"(",
"String",
"marker",
",",
"Boolean",
"getAcl",
")",
"throws",
"APIException",
"{",
"String",
"url",
"=",
"getUrl",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"marker",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"marker\"",
",",
"marker",
")",
";",
"}",
"if",
"(",
"getAcl",
")",
"{",
"params",
".",
"put",
"(",
"\"acl\"",
",",
"getAcl",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"client",
".",
"get",
"(",
"url",
",",
"new",
"TypeToken",
"<",
"DirectoryListResponse",
">",
"(",
")",
"{",
"}",
",",
"params",
")",
";",
"}"
] |
Gets a single page of the directory listing. Subsquent pages are fetched with the returned marker value.
@param marker indicates the specific page to fetch; first page is fetched if null
@return a page of files and directories that exist within this directory
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Gets",
"a",
"single",
"page",
"of",
"the",
"directory",
"listing",
".",
"Subsquent",
"pages",
"are",
"fetched",
"with",
"the",
"returned",
"marker",
"value",
"."
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataDirectory.java#L201-L213
|
4,524 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataObject.java
|
DataObject.getTrimmedPath
|
private static String getTrimmedPath(String path) {
String result = path;
if (result.endsWith("/")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
|
java
|
private static String getTrimmedPath(String path) {
String result = path;
if (result.endsWith("/")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
|
[
"private",
"static",
"String",
"getTrimmedPath",
"(",
"String",
"path",
")",
"{",
"String",
"result",
"=",
"path",
";",
"if",
"(",
"result",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"result",
"=",
"result",
".",
"substring",
"(",
"0",
",",
"result",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
a slash and those that don't.
|
[
"a",
"slash",
"and",
"those",
"that",
"don",
"t",
"."
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataObject.java#L73-L79
|
4,525 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.exists
|
public boolean exists() throws APIException {
HttpResponse response = client.head(getUrl());
int status = response.getStatusLine().getStatusCode();
if(status != 200 && status != 404) {
throw APIException.fromHttpResponse(response);
}
return (200 == status);
}
|
java
|
public boolean exists() throws APIException {
HttpResponse response = client.head(getUrl());
int status = response.getStatusLine().getStatusCode();
if(status != 200 && status != 404) {
throw APIException.fromHttpResponse(response);
}
return (200 == status);
}
|
[
"public",
"boolean",
"exists",
"(",
")",
"throws",
"APIException",
"{",
"HttpResponse",
"response",
"=",
"client",
".",
"head",
"(",
"getUrl",
"(",
")",
")",
";",
"int",
"status",
"=",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"status",
"!=",
"200",
"&&",
"status",
"!=",
"404",
")",
"{",
"throw",
"APIException",
".",
"fromHttpResponse",
"(",
"response",
")",
";",
"}",
"return",
"(",
"200",
"==",
"status",
")",
";",
"}"
] |
Returns whether the file exists in the Data API
@return true iff the file exists
@throws APIException if there were any problems communicating with the DataAPI
|
[
"Returns",
"whether",
"the",
"file",
"exists",
"in",
"the",
"Data",
"API"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L36-L43
|
4,526 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.getFile
|
public File getFile() throws APIException, IOException {
String filename = getName();
int extensionIndex = filename.lastIndexOf('.');
String body;
String ext;
if(extensionIndex <= 0) {
// No extension
body = filename;
ext = "";
} else {
body = filename.substring(0, extensionIndex);
ext = filename.substring(extensionIndex);
}
if(body.length() < 3 || body.length() > 127) {
// prefix must be at least 3 characters
body = "algodata";
}
File tempFile = File.createTempFile(body, ext);
client.getFile(getUrl(), tempFile);
return tempFile;
}
|
java
|
public File getFile() throws APIException, IOException {
String filename = getName();
int extensionIndex = filename.lastIndexOf('.');
String body;
String ext;
if(extensionIndex <= 0) {
// No extension
body = filename;
ext = "";
} else {
body = filename.substring(0, extensionIndex);
ext = filename.substring(extensionIndex);
}
if(body.length() < 3 || body.length() > 127) {
// prefix must be at least 3 characters
body = "algodata";
}
File tempFile = File.createTempFile(body, ext);
client.getFile(getUrl(), tempFile);
return tempFile;
}
|
[
"public",
"File",
"getFile",
"(",
")",
"throws",
"APIException",
",",
"IOException",
"{",
"String",
"filename",
"=",
"getName",
"(",
")",
";",
"int",
"extensionIndex",
"=",
"filename",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"body",
";",
"String",
"ext",
";",
"if",
"(",
"extensionIndex",
"<=",
"0",
")",
"{",
"// No extension",
"body",
"=",
"filename",
";",
"ext",
"=",
"\"\"",
";",
"}",
"else",
"{",
"body",
"=",
"filename",
".",
"substring",
"(",
"0",
",",
"extensionIndex",
")",
";",
"ext",
"=",
"filename",
".",
"substring",
"(",
"extensionIndex",
")",
";",
"}",
"if",
"(",
"body",
".",
"length",
"(",
")",
"<",
"3",
"||",
"body",
".",
"length",
"(",
")",
">",
"127",
")",
"{",
"// prefix must be at least 3 characters",
"body",
"=",
"\"algodata\"",
";",
"}",
"File",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"body",
",",
"ext",
")",
";",
"client",
".",
"getFile",
"(",
"getUrl",
"(",
")",
",",
"tempFile",
")",
";",
"return",
"tempFile",
";",
"}"
] |
Gets the data for this file and saves it to a local temporary file
@return the data as a local temporary file
@throws APIException if there were any problems communicating with the DataAPI
@throws IOException if there were any problems consuming the response content
|
[
"Gets",
"the",
"data",
"for",
"this",
"file",
"and",
"saves",
"it",
"to",
"a",
"local",
"temporary",
"file"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L51-L73
|
4,527 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.getInputStream
|
public InputStream getInputStream() throws APIException, IOException {
final HttpResponse response = client.get(getUrl());
HttpClientHelpers.throwIfNotOk(response);
return response.getEntity().getContent();
}
|
java
|
public InputStream getInputStream() throws APIException, IOException {
final HttpResponse response = client.get(getUrl());
HttpClientHelpers.throwIfNotOk(response);
return response.getEntity().getContent();
}
|
[
"public",
"InputStream",
"getInputStream",
"(",
")",
"throws",
"APIException",
",",
"IOException",
"{",
"final",
"HttpResponse",
"response",
"=",
"client",
".",
"get",
"(",
"getUrl",
"(",
")",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"return",
"response",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
";",
"}"
] |
Gets the data for this file as an InputStream
@return the data as an InputStream
@throws APIException if there were any problems communicating with the Algorithmia API
@throws IOException if there were any problems consuming the response content
|
[
"Gets",
"the",
"data",
"for",
"this",
"file",
"as",
"an",
"InputStream"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L81-L85
|
4,528 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.put
|
public void put(String data,Charset charset) throws APIException {
HttpResponse response = client.put(getUrl(), new StringEntity(data, charset));
HttpClientHelpers.throwIfNotOk(response);
}
|
java
|
public void put(String data,Charset charset) throws APIException {
HttpResponse response = client.put(getUrl(), new StringEntity(data, charset));
HttpClientHelpers.throwIfNotOk(response);
}
|
[
"public",
"void",
"put",
"(",
"String",
"data",
",",
"Charset",
"charset",
")",
"throws",
"APIException",
"{",
"HttpResponse",
"response",
"=",
"client",
".",
"put",
"(",
"getUrl",
"(",
")",
",",
"new",
"StringEntity",
"(",
"data",
",",
"charset",
")",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"}"
] |
Upload string data to this file as text using a custom Charset
@param data the data to upload
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Upload",
"string",
"data",
"to",
"this",
"file",
"as",
"text",
"using",
"a",
"custom",
"Charset"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L133-L136
|
4,529 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.put
|
public void put(byte[] data) throws APIException {
HttpResponse response = client.put(getUrl(), new ByteArrayEntity(data, ContentType.APPLICATION_OCTET_STREAM));
HttpClientHelpers.throwIfNotOk(response);
}
|
java
|
public void put(byte[] data) throws APIException {
HttpResponse response = client.put(getUrl(), new ByteArrayEntity(data, ContentType.APPLICATION_OCTET_STREAM));
HttpClientHelpers.throwIfNotOk(response);
}
|
[
"public",
"void",
"put",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"APIException",
"{",
"HttpResponse",
"response",
"=",
"client",
".",
"put",
"(",
"getUrl",
"(",
")",
",",
"new",
"ByteArrayEntity",
"(",
"data",
",",
"ContentType",
".",
"APPLICATION_OCTET_STREAM",
")",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"}"
] |
Upload raw data to this file as binary
@param data the data to upload
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Upload",
"raw",
"data",
"to",
"this",
"file",
"as",
"binary"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L143-L146
|
4,530 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/data/DataFile.java
|
DataFile.put
|
public void put(InputStream is) throws APIException {
HttpResponse response = client.put(getUrl(), new InputStreamEntity(is, -1, ContentType.APPLICATION_OCTET_STREAM));
HttpClientHelpers.throwIfNotOk(response);
}
|
java
|
public void put(InputStream is) throws APIException {
HttpResponse response = client.put(getUrl(), new InputStreamEntity(is, -1, ContentType.APPLICATION_OCTET_STREAM));
HttpClientHelpers.throwIfNotOk(response);
}
|
[
"public",
"void",
"put",
"(",
"InputStream",
"is",
")",
"throws",
"APIException",
"{",
"HttpResponse",
"response",
"=",
"client",
".",
"put",
"(",
"getUrl",
"(",
")",
",",
"new",
"InputStreamEntity",
"(",
"is",
",",
"-",
"1",
",",
"ContentType",
".",
"APPLICATION_OCTET_STREAM",
")",
")",
";",
"HttpClientHelpers",
".",
"throwIfNotOk",
"(",
"response",
")",
";",
"}"
] |
Upload raw data to this file as an input stream
@param is the input stream of data to upload
@throws APIException if there were any problems communicating with the Algorithmia API
|
[
"Upload",
"raw",
"data",
"to",
"this",
"file",
"as",
"an",
"input",
"stream"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataFile.java#L153-L156
|
4,531 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/algo/Algorithm.java
|
Algorithm.pipe
|
public AlgoResponse pipe(Object input) throws APIException {
if (input instanceof String) {
return pipeRequest((String)input,ContentType.Text);
} else if (input instanceof byte[]) {
return pipeBinaryRequest((byte[])input);
} else {
return pipeRequest(gson.toJsonTree(input).toString(),ContentType.Json);
}
}
|
java
|
public AlgoResponse pipe(Object input) throws APIException {
if (input instanceof String) {
return pipeRequest((String)input,ContentType.Text);
} else if (input instanceof byte[]) {
return pipeBinaryRequest((byte[])input);
} else {
return pipeRequest(gson.toJsonTree(input).toString(),ContentType.Json);
}
}
|
[
"public",
"AlgoResponse",
"pipe",
"(",
"Object",
"input",
")",
"throws",
"APIException",
"{",
"if",
"(",
"input",
"instanceof",
"String",
")",
"{",
"return",
"pipeRequest",
"(",
"(",
"String",
")",
"input",
",",
"ContentType",
".",
"Text",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"return",
"pipeBinaryRequest",
"(",
"(",
"byte",
"[",
"]",
")",
"input",
")",
";",
"}",
"else",
"",
"{",
"return",
"pipeRequest",
"(",
"gson",
".",
"toJsonTree",
"(",
"input",
")",
".",
"toString",
"(",
")",
",",
"ContentType",
".",
"Json",
")",
";",
"}",
"}"
] |
Calls the Algorithmia API for a given input.
Attempts to automatically serialize the input to JSON.
@param input algorithm input, will automatically be converted into JSON
@return algorithm result (AlgoSuccess or AlgoFailure)
@throws APIException if there is a problem communication with the Algorithmia API.
|
[
"Calls",
"the",
"Algorithmia",
"API",
"for",
"a",
"given",
"input",
".",
"Attempts",
"to",
"automatically",
"serialize",
"the",
"input",
"to",
"JSON",
"."
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/algo/Algorithm.java#L94-L102
|
4,532 |
algorithmiaio/algorithmia-java
|
src/main/java/com/algorithmia/algo/Algorithm.java
|
Algorithm.pipeAsync
|
public FutureAlgoResponse pipeAsync(Object input) {
final Gson gson = new Gson();
final JsonElement inputJson = gson.toJsonTree(input);
return pipeJsonAsync(inputJson.toString());
}
|
java
|
public FutureAlgoResponse pipeAsync(Object input) {
final Gson gson = new Gson();
final JsonElement inputJson = gson.toJsonTree(input);
return pipeJsonAsync(inputJson.toString());
}
|
[
"public",
"FutureAlgoResponse",
"pipeAsync",
"(",
"Object",
"input",
")",
"{",
"final",
"Gson",
"gson",
"=",
"new",
"Gson",
"(",
")",
";",
"final",
"JsonElement",
"inputJson",
"=",
"gson",
".",
"toJsonTree",
"(",
"input",
")",
";",
"return",
"pipeJsonAsync",
"(",
"inputJson",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Calls the Algorithmia API asynchronously for a given input.
Attempts to automatically serialize the input to JSON.
The future response will complete when the algorithm has completed or errored
@param input algorithm input, will automatically be converted into JSON
@return future algorithm result (AlgoSuccess or AlgoFailure)
|
[
"Calls",
"the",
"Algorithmia",
"API",
"asynchronously",
"for",
"a",
"given",
"input",
".",
"Attempts",
"to",
"automatically",
"serialize",
"the",
"input",
"to",
"JSON",
".",
"The",
"future",
"response",
"will",
"complete",
"when",
"the",
"algorithm",
"has",
"completed",
"or",
"errored"
] |
64bfdbd426e2d7f659be06d230523253e642a730
|
https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/algo/Algorithm.java#L112-L116
|
4,533 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpClient.java
|
MailChimpClient.execute
|
public <R> R execute(MailChimpMethod<R> method) throws IOException, MailChimpException {
final Gson gson = MailChimpGsonFactory.createGson();
JsonElement result = execute(buildUrl(method), gson.toJsonTree(method), method.getMetaInfo().version());
if(result.isJsonObject()) {
JsonElement error = result.getAsJsonObject().get("error");
if(error != null) {
JsonElement code = result.getAsJsonObject().get("code");
throw new MailChimpException(code.getAsInt(), error.getAsString());
}
}
return gson.fromJson(result, method.getResultType());
}
|
java
|
public <R> R execute(MailChimpMethod<R> method) throws IOException, MailChimpException {
final Gson gson = MailChimpGsonFactory.createGson();
JsonElement result = execute(buildUrl(method), gson.toJsonTree(method), method.getMetaInfo().version());
if(result.isJsonObject()) {
JsonElement error = result.getAsJsonObject().get("error");
if(error != null) {
JsonElement code = result.getAsJsonObject().get("code");
throw new MailChimpException(code.getAsInt(), error.getAsString());
}
}
return gson.fromJson(result, method.getResultType());
}
|
[
"public",
"<",
"R",
">",
"R",
"execute",
"(",
"MailChimpMethod",
"<",
"R",
">",
"method",
")",
"throws",
"IOException",
",",
"MailChimpException",
"{",
"final",
"Gson",
"gson",
"=",
"MailChimpGsonFactory",
".",
"createGson",
"(",
")",
";",
"JsonElement",
"result",
"=",
"execute",
"(",
"buildUrl",
"(",
"method",
")",
",",
"gson",
".",
"toJsonTree",
"(",
"method",
")",
",",
"method",
".",
"getMetaInfo",
"(",
")",
".",
"version",
"(",
")",
")",
";",
"if",
"(",
"result",
".",
"isJsonObject",
"(",
")",
")",
"{",
"JsonElement",
"error",
"=",
"result",
".",
"getAsJsonObject",
"(",
")",
".",
"get",
"(",
"\"error\"",
")",
";",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"JsonElement",
"code",
"=",
"result",
".",
"getAsJsonObject",
"(",
")",
".",
"get",
"(",
"\"code\"",
")",
";",
"throw",
"new",
"MailChimpException",
"(",
"code",
".",
"getAsInt",
"(",
")",
",",
"error",
".",
"getAsString",
"(",
")",
")",
";",
"}",
"}",
"return",
"gson",
".",
"fromJson",
"(",
"result",
",",
"method",
".",
"getResultType",
"(",
")",
")",
";",
"}"
] |
Execute MailChimp API method.
@param method MailChimp API method to be executed
@return execution result
|
[
"Execute",
"MailChimp",
"API",
"method",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpClient.java#L92-L105
|
4,534 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpClient.java
|
MailChimpClient.close
|
@Override
public void close() {
try {
connection.close();
} catch(IOException e) {
log.log(Level.WARNING, "Could not close connection", e);
}
}
|
java
|
@Override
public void close() {
try {
connection.close();
} catch(IOException e) {
log.log(Level.WARNING, "Could not close connection", e);
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"connection",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Could not close connection\"",
",",
"e",
")",
";",
"}",
"}"
] |
Release resources associated with the connection to MailChimp API service point.
|
[
"Release",
"resources",
"associated",
"with",
"the",
"connection",
"to",
"MailChimp",
"API",
"service",
"point",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpClient.java#L142-L149
|
4,535 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpObject.java
|
MailChimpObject.remove
|
@Override
public Object remove(Object key) {
if(key instanceof String && reflective.containsKey((String) key)) {
throw new ReflectiveValueRemovalException((String) key);
} else {
return regular.remove(key);
}
}
|
java
|
@Override
public Object remove(Object key) {
if(key instanceof String && reflective.containsKey((String) key)) {
throw new ReflectiveValueRemovalException((String) key);
} else {
return regular.remove(key);
}
}
|
[
"@",
"Override",
"public",
"Object",
"remove",
"(",
"Object",
"key",
")",
"{",
"if",
"(",
"key",
"instanceof",
"String",
"&&",
"reflective",
".",
"containsKey",
"(",
"(",
"String",
")",
"key",
")",
")",
"{",
"throw",
"new",
"ReflectiveValueRemovalException",
"(",
"(",
"String",
")",
"key",
")",
";",
"}",
"else",
"{",
"return",
"regular",
".",
"remove",
"(",
"key",
")",
";",
"}",
"}"
] |
Removes a regular mapping for a key from this map if it is present.
@param key key for a regular mapping
@return the previous value associated with key, or null if there was no mapping for key
@throws IllegalArgumentException if key is associated with a reflective mapping
|
[
"Removes",
"a",
"regular",
"mapping",
"for",
"a",
"key",
"from",
"this",
"map",
"if",
"it",
"is",
"present",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpObject.java#L268-L275
|
4,536 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpObject.java
|
MailChimpObject.fromJson
|
public static <T extends MailChimpObject> T fromJson(String json, Class<T> clazz) {
try {
return MailChimpGsonFactory.createGson().fromJson(json, clazz);
} catch(JsonParseException e) {
throw new IllegalArgumentException(e);
}
}
|
java
|
public static <T extends MailChimpObject> T fromJson(String json, Class<T> clazz) {
try {
return MailChimpGsonFactory.createGson().fromJson(json, clazz);
} catch(JsonParseException e) {
throw new IllegalArgumentException(e);
}
}
|
[
"public",
"static",
"<",
"T",
"extends",
"MailChimpObject",
">",
"T",
"fromJson",
"(",
"String",
"json",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"try",
"{",
"return",
"MailChimpGsonFactory",
".",
"createGson",
"(",
")",
".",
"fromJson",
"(",
"json",
",",
"clazz",
")",
";",
"}",
"catch",
"(",
"JsonParseException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
")",
";",
"}",
"}"
] |
Deserializes an object from JSON.
@throws IllegalArgumentException if <code>json</code> cannot be deserialized to an object of class <code>clazz</code>.
|
[
"Deserializes",
"an",
"object",
"from",
"JSON",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpObject.java#L383-L389
|
4,537 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpMethod.java
|
MailChimpMethod.getMetaInfo
|
public final Method getMetaInfo() {
for(Class<?> c=getClass(); c != null; c=c.getSuperclass()) {
Method a = c.getAnnotation(Method.class);
if(a != null) {
return a;
}
}
throw new IllegalArgumentException("Neither "+getClass()+" nor its superclasses are annotated with "+Method.class);
}
|
java
|
public final Method getMetaInfo() {
for(Class<?> c=getClass(); c != null; c=c.getSuperclass()) {
Method a = c.getAnnotation(Method.class);
if(a != null) {
return a;
}
}
throw new IllegalArgumentException("Neither "+getClass()+" nor its superclasses are annotated with "+Method.class);
}
|
[
"public",
"final",
"Method",
"getMetaInfo",
"(",
")",
"{",
"for",
"(",
"Class",
"<",
"?",
">",
"c",
"=",
"getClass",
"(",
")",
";",
"c",
"!=",
"null",
";",
"c",
"=",
"c",
".",
"getSuperclass",
"(",
")",
")",
"{",
"Method",
"a",
"=",
"c",
".",
"getAnnotation",
"(",
"Method",
".",
"class",
")",
";",
"if",
"(",
"a",
"!=",
"null",
")",
"{",
"return",
"a",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Neither \"",
"+",
"getClass",
"(",
")",
"+",
"\" nor its superclasses are annotated with \"",
"+",
"Method",
".",
"class",
")",
";",
"}"
] |
Get the MailChimp API method meta-info.
@throws IllegalArgumentException if neither this class nor any of its superclasses
are annotated with {@link Method}.
|
[
"Get",
"the",
"MailChimp",
"API",
"method",
"meta",
"-",
"info",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpMethod.java#L76-L85
|
4,538 |
Ecwid/ecwid-mailchimp
|
src/main/java/com/ecwid/mailchimp/MailChimpMethod.java
|
MailChimpMethod.getResultType
|
public final Type getResultType() {
Type type = resultTypeToken.getType();
if (type instanceof Class || type instanceof ParameterizedType || type instanceof GenericArrayType) {
return type;
} else {
throw new IllegalArgumentException("Cannot resolve result type: "+resultTypeToken);
}
}
|
java
|
public final Type getResultType() {
Type type = resultTypeToken.getType();
if (type instanceof Class || type instanceof ParameterizedType || type instanceof GenericArrayType) {
return type;
} else {
throw new IllegalArgumentException("Cannot resolve result type: "+resultTypeToken);
}
}
|
[
"public",
"final",
"Type",
"getResultType",
"(",
")",
"{",
"Type",
"type",
"=",
"resultTypeToken",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"instanceof",
"Class",
"||",
"type",
"instanceof",
"ParameterizedType",
"||",
"type",
"instanceof",
"GenericArrayType",
")",
"{",
"return",
"type",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot resolve result type: \"",
"+",
"resultTypeToken",
")",
";",
"}",
"}"
] |
Get the method result type.
|
[
"Get",
"the",
"method",
"result",
"type",
"."
] |
8acb37d7677bd494879d4db11f3c42ba4c85eb36
|
https://github.com/Ecwid/ecwid-mailchimp/blob/8acb37d7677bd494879d4db11f3c42ba4c85eb36/src/main/java/com/ecwid/mailchimp/MailChimpMethod.java#L90-L97
|
4,539 |
pwheel/spring-security-oauth2-client
|
src/main/java/com/racquettrack/security/oauth/OAuth2UserDetailsService.java
|
OAuth2UserDetailsService.postCreatedOrEnabledUser
|
private void postCreatedOrEnabledUser(UserDetails userDetails, Map<String, Object> userInfo) {
if (oAuth2PostCreatedOrEnabledUserService != null) {
oAuth2PostCreatedOrEnabledUserService.postCreatedOrEnabledUser(userDetails, userInfo);
}
}
|
java
|
private void postCreatedOrEnabledUser(UserDetails userDetails, Map<String, Object> userInfo) {
if (oAuth2PostCreatedOrEnabledUserService != null) {
oAuth2PostCreatedOrEnabledUserService.postCreatedOrEnabledUser(userDetails, userInfo);
}
}
|
[
"private",
"void",
"postCreatedOrEnabledUser",
"(",
"UserDetails",
"userDetails",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"userInfo",
")",
"{",
"if",
"(",
"oAuth2PostCreatedOrEnabledUserService",
"!=",
"null",
")",
"{",
"oAuth2PostCreatedOrEnabledUserService",
".",
"postCreatedOrEnabledUser",
"(",
"userDetails",
",",
"userInfo",
")",
";",
"}",
"}"
] |
Extension point to allow sub classes to optionally do some processing after a user has been created or enabled.
For example they could set something in the session so that the authentication success handler can treat
the first log in differently.
@param userDetails The {@link UserDetails} object created by
{@link OAuth2UserDetailsLoader#createUser(Object, Map)}
@param userInfo A map representing the user information returned from the OAuth Provider.
|
[
"Extension",
"point",
"to",
"allow",
"sub",
"classes",
"to",
"optionally",
"do",
"some",
"processing",
"after",
"a",
"user",
"has",
"been",
"created",
"or",
"enabled",
".",
"For",
"example",
"they",
"could",
"set",
"something",
"in",
"the",
"session",
"so",
"that",
"the",
"authentication",
"success",
"handler",
"can",
"treat",
"the",
"first",
"log",
"in",
"differently",
"."
] |
c0258823493e268495c9752c5d752f74c6809c6b
|
https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2UserDetailsService.java#L99-L103
|
4,540 |
pwheel/spring-security-oauth2-client
|
src/main/java/com/racquettrack/security/oauth/OAuth2ServiceProperties.java
|
OAuth2ServiceProperties.afterPropertiesSet
|
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(userAuthorisationUri, "The userAuthorisationUri must be set");
Assert.notNull(redirectUri, "The redirectUri must be set");
Assert.notNull(accessTokenUri, "The accessTokenUri must be set");
Assert.notNull(clientId, "The clientId must be set");
Assert.notNull(clientSecret, "The clientSecret must be set");
Assert.notNull(userInfoUri, "The userInfoUri must be set");
}
|
java
|
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(userAuthorisationUri, "The userAuthorisationUri must be set");
Assert.notNull(redirectUri, "The redirectUri must be set");
Assert.notNull(accessTokenUri, "The accessTokenUri must be set");
Assert.notNull(clientId, "The clientId must be set");
Assert.notNull(clientSecret, "The clientSecret must be set");
Assert.notNull(userInfoUri, "The userInfoUri must be set");
}
|
[
"@",
"Override",
"public",
"void",
"afterPropertiesSet",
"(",
")",
"throws",
"Exception",
"{",
"Assert",
".",
"notNull",
"(",
"userAuthorisationUri",
",",
"\"The userAuthorisationUri must be set\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"redirectUri",
",",
"\"The redirectUri must be set\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"accessTokenUri",
",",
"\"The accessTokenUri must be set\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"clientId",
",",
"\"The clientId must be set\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"clientSecret",
",",
"\"The clientSecret must be set\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"userInfoUri",
",",
"\"The userInfoUri must be set\"",
")",
";",
"}"
] |
Check whether all required properties have been set
@throws Exception in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.
|
[
"Check",
"whether",
"all",
"required",
"properties",
"have",
"been",
"set"
] |
c0258823493e268495c9752c5d752f74c6809c6b
|
https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2ServiceProperties.java#L63-L71
|
4,541 |
pwheel/spring-security-oauth2-client
|
src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java
|
OAuth2AuthenticationFilter.checkStateParameter
|
protected void checkStateParameter(HttpSession session, Map<String, String[]> parameters)
throws AuthenticationException {
String originalState = (String)session.getAttribute(oAuth2ServiceProperties.getStateParamName());
String receivedStates[] = parameters.get(oAuth2ServiceProperties.getStateParamName());
// There should only be one entry in the array, if there are more they will be ignored.
if (receivedStates == null || receivedStates.length == 0 ||
!receivedStates[0].equals(originalState)) {
String errorMsg = String.format("Received states %s was not equal to original state %s",
receivedStates, originalState);
LOG.error(errorMsg);
throw new AuthenticationServiceException(errorMsg);
}
}
|
java
|
protected void checkStateParameter(HttpSession session, Map<String, String[]> parameters)
throws AuthenticationException {
String originalState = (String)session.getAttribute(oAuth2ServiceProperties.getStateParamName());
String receivedStates[] = parameters.get(oAuth2ServiceProperties.getStateParamName());
// There should only be one entry in the array, if there are more they will be ignored.
if (receivedStates == null || receivedStates.length == 0 ||
!receivedStates[0].equals(originalState)) {
String errorMsg = String.format("Received states %s was not equal to original state %s",
receivedStates, originalState);
LOG.error(errorMsg);
throw new AuthenticationServiceException(errorMsg);
}
}
|
[
"protected",
"void",
"checkStateParameter",
"(",
"HttpSession",
"session",
",",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
")",
"throws",
"AuthenticationException",
"{",
"String",
"originalState",
"=",
"(",
"String",
")",
"session",
".",
"getAttribute",
"(",
"oAuth2ServiceProperties",
".",
"getStateParamName",
"(",
")",
")",
";",
"String",
"receivedStates",
"[",
"]",
"=",
"parameters",
".",
"get",
"(",
"oAuth2ServiceProperties",
".",
"getStateParamName",
"(",
")",
")",
";",
"// There should only be one entry in the array, if there are more they will be ignored.",
"if",
"(",
"receivedStates",
"==",
"null",
"||",
"receivedStates",
".",
"length",
"==",
"0",
"||",
"!",
"receivedStates",
"[",
"0",
"]",
".",
"equals",
"(",
"originalState",
")",
")",
"{",
"String",
"errorMsg",
"=",
"String",
".",
"format",
"(",
"\"Received states %s was not equal to original state %s\"",
",",
"receivedStates",
",",
"originalState",
")",
";",
"LOG",
".",
"error",
"(",
"errorMsg",
")",
";",
"throw",
"new",
"AuthenticationServiceException",
"(",
"errorMsg",
")",
";",
"}",
"}"
] |
Check the state parameter to ensure it is the same as was originally sent. Subclasses can override this
behaviour if they so choose, but it is not recommended.
@param session The http session, which will contain the original scope as an attribute.
@param parameters The parameters received from the OAuth 2 Provider, which should contain the same state as
originally sent to it and stored in the http session.
@throws AuthenticationException If the state differs from the original.
|
[
"Check",
"the",
"state",
"parameter",
"to",
"ensure",
"it",
"is",
"the",
"same",
"as",
"was",
"originally",
"sent",
".",
"Subclasses",
"can",
"override",
"this",
"behaviour",
"if",
"they",
"so",
"choose",
"but",
"it",
"is",
"not",
"recommended",
"."
] |
c0258823493e268495c9752c5d752f74c6809c6b
|
https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java#L107-L121
|
4,542 |
pwheel/spring-security-oauth2-client
|
src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java
|
OAuth2AuthenticationFilter.afterPropertiesSet
|
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
Assert.notNull(oAuth2ServiceProperties);
Assert.isTrue(oAuth2ServiceProperties.getRedirectUri().toString().endsWith(super.getFilterProcessesUrl()),
"The filter must be configured to be listening on the redirect_uri in OAuth2ServiceProperties");
}
|
java
|
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
Assert.notNull(oAuth2ServiceProperties);
Assert.isTrue(oAuth2ServiceProperties.getRedirectUri().toString().endsWith(super.getFilterProcessesUrl()),
"The filter must be configured to be listening on the redirect_uri in OAuth2ServiceProperties");
}
|
[
"@",
"Override",
"public",
"void",
"afterPropertiesSet",
"(",
")",
"{",
"super",
".",
"afterPropertiesSet",
"(",
")",
";",
"Assert",
".",
"notNull",
"(",
"oAuth2ServiceProperties",
")",
";",
"Assert",
".",
"isTrue",
"(",
"oAuth2ServiceProperties",
".",
"getRedirectUri",
"(",
")",
".",
"toString",
"(",
")",
".",
"endsWith",
"(",
"super",
".",
"getFilterProcessesUrl",
"(",
")",
")",
",",
"\"The filter must be configured to be listening on the redirect_uri in OAuth2ServiceProperties\"",
")",
";",
"}"
] |
Check properties are set
|
[
"Check",
"properties",
"are",
"set"
] |
c0258823493e268495c9752c5d752f74c6809c6b
|
https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java#L165-L171
|
4,543 |
tikivn/NoAdapter
|
noadapter/src/main/java/vn/tiki/noadapter2/AbsViewHolder.java
|
AbsViewHolder.bind
|
public void bind(Object item) {
this.item = item;
if (onItemBindListener != null) {
onItemBindListener.onItemBind(itemView, item, getAdapterPosition());
}
}
|
java
|
public void bind(Object item) {
this.item = item;
if (onItemBindListener != null) {
onItemBindListener.onItemBind(itemView, item, getAdapterPosition());
}
}
|
[
"public",
"void",
"bind",
"(",
"Object",
"item",
")",
"{",
"this",
".",
"item",
"=",
"item",
";",
"if",
"(",
"onItemBindListener",
"!=",
"null",
")",
"{",
"onItemBindListener",
".",
"onItemBind",
"(",
"itemView",
",",
"item",
",",
"getAdapterPosition",
"(",
")",
")",
";",
"}",
"}"
] |
Called to update view
@param item data
|
[
"Called",
"to",
"update",
"view"
] |
eee9c86bddcb0ddc4ab473efe2d14252e813cca4
|
https://github.com/tikivn/NoAdapter/blob/eee9c86bddcb0ddc4ab473efe2d14252e813cca4/noadapter/src/main/java/vn/tiki/noadapter2/AbsViewHolder.java#L26-L31
|
4,544 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java
|
BigIntStringChecksum.startsWithPrefix
|
public static boolean startsWithPrefix(final String input)
{
boolean ret = false;
if (input != null)
{
ret = input.toLowerCase().startsWith(PREFIX_BIGINT_DASH_CHECKSUM);
}
else
{
ret = false;
}
return ret;
}
|
java
|
public static boolean startsWithPrefix(final String input)
{
boolean ret = false;
if (input != null)
{
ret = input.toLowerCase().startsWith(PREFIX_BIGINT_DASH_CHECKSUM);
}
else
{
ret = false;
}
return ret;
}
|
[
"public",
"static",
"boolean",
"startsWithPrefix",
"(",
"final",
"String",
"input",
")",
"{",
"boolean",
"ret",
"=",
"false",
";",
"if",
"(",
"input",
"!=",
"null",
")",
"{",
"ret",
"=",
"input",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"PREFIX_BIGINT_DASH_CHECKSUM",
")",
";",
"}",
"else",
"{",
"ret",
"=",
"false",
";",
"}",
"return",
"ret",
";",
"}"
] |
Utility to test if the input string can even -possibly- be a BigIntStringChecksum encoded.
This is check is "necessary, but not sufficient" for the input string
to parse correctly.
@param input the string to check
@return true if the string starts with (case-insensitive)
BigIntStringChecksum.PREFIX_BIGINT_DASH_CHECKSUM
false all other cases
|
[
"Utility",
"to",
"test",
"if",
"the",
"input",
"string",
"can",
"even",
"-",
"possibly",
"-",
"be",
"a",
"BigIntStringChecksum",
"encoded",
".",
"This",
"is",
"check",
"is",
"necessary",
"but",
"not",
"sufficient",
"for",
"the",
"input",
"string",
"to",
"parse",
"correctly",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java#L109-L121
|
4,545 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java
|
BigIntStringChecksum.fromString
|
public static BigIntStringChecksum fromString(String bics)
{
boolean returnIsNegative = false;
BigIntStringChecksum ret = null;
if (bics == null)
{
createThrow("Input cannot be null", bics);
}
if (startsWithPrefix(bics))
{
String noprefix = bics.substring(PREFIX_BIGINT_DASH_CHECKSUM.length());
String noprefixnosign = noprefix;
if (noprefixnosign.startsWith("-"))
{
returnIsNegative = true;
noprefixnosign = noprefixnosign.substring(1);
}
String[] split = noprefixnosign.split("-");
if (split.length <= 1)
{
createThrow("Missing checksum section", bics);
}
else
{
String asHex = "";
if (returnIsNegative)
{
asHex = "-";
}
for (int i = 0, n = split.length - 1; i < n; i++)
{
asHex += split[i];
}
String computedMd5sum = computeMd5ChecksumLimit6(asHex);
String givenMd5sum = split[split.length - 1];
if (computedMd5sum.equalsIgnoreCase(givenMd5sum))
{
ret = new BigIntStringChecksum(asHex, computedMd5sum);
}
else
{
createThrow("Mismatch checksum given='" + givenMd5sum +
"' computed='" + computedMd5sum + "'", bics);
}
}
}
else
{
createThrow("Input must start with '" +
PREFIX_BIGINT_DASH_CHECKSUM + "'",
bics);
}
// The call to .asBigInteger() should never throw an exception at this point.
// But, if it is going to throw an exception, it is better to do it now rather than later:
ret.asBigInteger();
return ret;
}
|
java
|
public static BigIntStringChecksum fromString(String bics)
{
boolean returnIsNegative = false;
BigIntStringChecksum ret = null;
if (bics == null)
{
createThrow("Input cannot be null", bics);
}
if (startsWithPrefix(bics))
{
String noprefix = bics.substring(PREFIX_BIGINT_DASH_CHECKSUM.length());
String noprefixnosign = noprefix;
if (noprefixnosign.startsWith("-"))
{
returnIsNegative = true;
noprefixnosign = noprefixnosign.substring(1);
}
String[] split = noprefixnosign.split("-");
if (split.length <= 1)
{
createThrow("Missing checksum section", bics);
}
else
{
String asHex = "";
if (returnIsNegative)
{
asHex = "-";
}
for (int i = 0, n = split.length - 1; i < n; i++)
{
asHex += split[i];
}
String computedMd5sum = computeMd5ChecksumLimit6(asHex);
String givenMd5sum = split[split.length - 1];
if (computedMd5sum.equalsIgnoreCase(givenMd5sum))
{
ret = new BigIntStringChecksum(asHex, computedMd5sum);
}
else
{
createThrow("Mismatch checksum given='" + givenMd5sum +
"' computed='" + computedMd5sum + "'", bics);
}
}
}
else
{
createThrow("Input must start with '" +
PREFIX_BIGINT_DASH_CHECKSUM + "'",
bics);
}
// The call to .asBigInteger() should never throw an exception at this point.
// But, if it is going to throw an exception, it is better to do it now rather than later:
ret.asBigInteger();
return ret;
}
|
[
"public",
"static",
"BigIntStringChecksum",
"fromString",
"(",
"String",
"bics",
")",
"{",
"boolean",
"returnIsNegative",
"=",
"false",
";",
"BigIntStringChecksum",
"ret",
"=",
"null",
";",
"if",
"(",
"bics",
"==",
"null",
")",
"{",
"createThrow",
"(",
"\"Input cannot be null\"",
",",
"bics",
")",
";",
"}",
"if",
"(",
"startsWithPrefix",
"(",
"bics",
")",
")",
"{",
"String",
"noprefix",
"=",
"bics",
".",
"substring",
"(",
"PREFIX_BIGINT_DASH_CHECKSUM",
".",
"length",
"(",
")",
")",
";",
"String",
"noprefixnosign",
"=",
"noprefix",
";",
"if",
"(",
"noprefixnosign",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
"{",
"returnIsNegative",
"=",
"true",
";",
"noprefixnosign",
"=",
"noprefixnosign",
".",
"substring",
"(",
"1",
")",
";",
"}",
"String",
"[",
"]",
"split",
"=",
"noprefixnosign",
".",
"split",
"(",
"\"-\"",
")",
";",
"if",
"(",
"split",
".",
"length",
"<=",
"1",
")",
"{",
"createThrow",
"(",
"\"Missing checksum section\"",
",",
"bics",
")",
";",
"}",
"else",
"{",
"String",
"asHex",
"=",
"\"\"",
";",
"if",
"(",
"returnIsNegative",
")",
"{",
"asHex",
"=",
"\"-\"",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"split",
".",
"length",
"-",
"1",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"asHex",
"+=",
"split",
"[",
"i",
"]",
";",
"}",
"String",
"computedMd5sum",
"=",
"computeMd5ChecksumLimit6",
"(",
"asHex",
")",
";",
"String",
"givenMd5sum",
"=",
"split",
"[",
"split",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"computedMd5sum",
".",
"equalsIgnoreCase",
"(",
"givenMd5sum",
")",
")",
"{",
"ret",
"=",
"new",
"BigIntStringChecksum",
"(",
"asHex",
",",
"computedMd5sum",
")",
";",
"}",
"else",
"{",
"createThrow",
"(",
"\"Mismatch checksum given='\"",
"+",
"givenMd5sum",
"+",
"\"' computed='\"",
"+",
"computedMd5sum",
"+",
"\"'\"",
",",
"bics",
")",
";",
"}",
"}",
"}",
"else",
"{",
"createThrow",
"(",
"\"Input must start with '\"",
"+",
"PREFIX_BIGINT_DASH_CHECKSUM",
"+",
"\"'\"",
",",
"bics",
")",
";",
"}",
"// The call to .asBigInteger() should never throw an exception at this point.",
"// But, if it is going to throw an exception, it is better to do it now rather than later:",
"ret",
".",
"asBigInteger",
"(",
")",
";",
"return",
"ret",
";",
"}"
] |
Take input string, and create the instance.
As of version 1.3.2 forward, the case of the INPUT is not relevant.
Note, however, that when the Checksum CCCCCC is computed, the hex hhhhhh- string
is LOWER CASE.
@param bics string in "bigintcs:hhhhhh-hhhhhh-CCCCCC" format
@return big integer string checksum object
@throws SecretShareException on error, such as null input, OR
input doesn't start with correct prefix OR
string does not have 0-9a-f digits OR
checksum doesn't match.
|
[
"Take",
"input",
"string",
"and",
"create",
"the",
"instance",
".",
"As",
"of",
"version",
"1",
".",
"3",
".",
"2",
"forward",
"the",
"case",
"of",
"the",
"INPUT",
"is",
"not",
"relevant",
".",
"Note",
"however",
"that",
"when",
"the",
"Checksum",
"CCCCCC",
"is",
"computed",
"the",
"hex",
"hhhhhh",
"-",
"string",
"is",
"LOWER",
"CASE",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java#L136-L193
|
4,546 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java
|
BigIntStringChecksum.fromStringOrNull
|
public static BigIntStringChecksum fromStringOrNull(String bics)
{
BigIntStringChecksum ret;
if (bics == null)
{
ret = null;
}
else if (! startsWithPrefix(bics))
{
ret = null;
}
else
{
try
{
ret = fromString(bics);
// completely test the input: make sure
// asBigInteger will throw a SecretShareException on error
if (ret.asBigInteger() == null)
{
// asBigInteger() is not allowed to return null.
// but just in case it does:
throw new SecretShareException("Programmer error converting '" +
bics + "' to BigInteger");
}
}
catch (SecretShareException e)
{
ret = null;
}
}
return ret;
}
|
java
|
public static BigIntStringChecksum fromStringOrNull(String bics)
{
BigIntStringChecksum ret;
if (bics == null)
{
ret = null;
}
else if (! startsWithPrefix(bics))
{
ret = null;
}
else
{
try
{
ret = fromString(bics);
// completely test the input: make sure
// asBigInteger will throw a SecretShareException on error
if (ret.asBigInteger() == null)
{
// asBigInteger() is not allowed to return null.
// but just in case it does:
throw new SecretShareException("Programmer error converting '" +
bics + "' to BigInteger");
}
}
catch (SecretShareException e)
{
ret = null;
}
}
return ret;
}
|
[
"public",
"static",
"BigIntStringChecksum",
"fromStringOrNull",
"(",
"String",
"bics",
")",
"{",
"BigIntStringChecksum",
"ret",
";",
"if",
"(",
"bics",
"==",
"null",
")",
"{",
"ret",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"!",
"startsWithPrefix",
"(",
"bics",
")",
")",
"{",
"ret",
"=",
"null",
";",
"}",
"else",
"{",
"try",
"{",
"ret",
"=",
"fromString",
"(",
"bics",
")",
";",
"// completely test the input: make sure",
"// asBigInteger will throw a SecretShareException on error",
"if",
"(",
"ret",
".",
"asBigInteger",
"(",
")",
"==",
"null",
")",
"{",
"// asBigInteger() is not allowed to return null.",
"// but just in case it does:",
"throw",
"new",
"SecretShareException",
"(",
"\"Programmer error converting '\"",
"+",
"bics",
"+",
"\"' to BigInteger\"",
")",
";",
"}",
"}",
"catch",
"(",
"SecretShareException",
"e",
")",
"{",
"ret",
"=",
"null",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Take string as input, and either return an instance or return null.
@param bics string in "bigintcs:hhhhhh-hhhhhh-CCCCCC" format
@return big integer string checksum object
OR null if incorrect format, error parsing, etc.
|
[
"Take",
"string",
"as",
"input",
"and",
"either",
"return",
"an",
"instance",
"or",
"return",
"null",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/BigIntStringChecksum.java#L202-L235
|
4,547 |
androidsx/rate-me
|
LibraryRateMe/src/com/androidsx/rateme/RateMeDialogTimer.java
|
RateMeDialogTimer.setOptOut
|
public static void setOptOut(final Context context, boolean optOut) {
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
Editor editor = pref.edit();
editor.putBoolean(KEY_OPT_OUT, optOut);
editor.apply();
}
|
java
|
public static void setOptOut(final Context context, boolean optOut) {
SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
Editor editor = pref.edit();
editor.putBoolean(KEY_OPT_OUT, optOut);
editor.apply();
}
|
[
"public",
"static",
"void",
"setOptOut",
"(",
"final",
"Context",
"context",
",",
"boolean",
"optOut",
")",
"{",
"SharedPreferences",
"pref",
"=",
"context",
".",
"getSharedPreferences",
"(",
"PREF_NAME",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"Editor",
"editor",
"=",
"pref",
".",
"edit",
"(",
")",
";",
"editor",
".",
"putBoolean",
"(",
"KEY_OPT_OUT",
",",
"optOut",
")",
";",
"editor",
".",
"apply",
"(",
")",
";",
"}"
] |
Set opt out flag. If it is true, the rate dialog will never shown unless app data is cleared.
|
[
"Set",
"opt",
"out",
"flag",
".",
"If",
"it",
"is",
"true",
"the",
"rate",
"dialog",
"will",
"never",
"shown",
"unless",
"app",
"data",
"is",
"cleared",
"."
] |
a779706454ba585a09110745ac3035f28920524a
|
https://github.com/androidsx/rate-me/blob/a779706454ba585a09110745ac3035f28920524a/LibraryRateMe/src/com/androidsx/rateme/RateMeDialogTimer.java#L97-L102
|
4,548 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/EasyLinearEquation.java
|
EasyLinearEquation.createForPolynomial
|
public static EasyLinearEquation createForPolynomial(final BigInteger[] xarray,
final BigInteger[] fofxarray)
{
if (xarray.length != fofxarray.length)
{
throw new SecretShareException("Unequal length arrays are not allowed");
}
final int numRows = xarray.length;
final int numCols = xarray.length + 1;
BigInteger[][] cvt = new BigInteger[numRows][];
for (int row = 0; row < numRows; row++)
{
cvt[row] = new BigInteger[numCols];
fillInPolynomial(cvt[row],
fofxarray[row],
xarray[row]);
}
return create(cvt);
}
|
java
|
public static EasyLinearEquation createForPolynomial(final BigInteger[] xarray,
final BigInteger[] fofxarray)
{
if (xarray.length != fofxarray.length)
{
throw new SecretShareException("Unequal length arrays are not allowed");
}
final int numRows = xarray.length;
final int numCols = xarray.length + 1;
BigInteger[][] cvt = new BigInteger[numRows][];
for (int row = 0; row < numRows; row++)
{
cvt[row] = new BigInteger[numCols];
fillInPolynomial(cvt[row],
fofxarray[row],
xarray[row]);
}
return create(cvt);
}
|
[
"public",
"static",
"EasyLinearEquation",
"createForPolynomial",
"(",
"final",
"BigInteger",
"[",
"]",
"xarray",
",",
"final",
"BigInteger",
"[",
"]",
"fofxarray",
")",
"{",
"if",
"(",
"xarray",
".",
"length",
"!=",
"fofxarray",
".",
"length",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"Unequal length arrays are not allowed\"",
")",
";",
"}",
"final",
"int",
"numRows",
"=",
"xarray",
".",
"length",
";",
"final",
"int",
"numCols",
"=",
"xarray",
".",
"length",
"+",
"1",
";",
"BigInteger",
"[",
"]",
"[",
"]",
"cvt",
"=",
"new",
"BigInteger",
"[",
"numRows",
"]",
"[",
"",
"]",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"numRows",
";",
"row",
"++",
")",
"{",
"cvt",
"[",
"row",
"]",
"=",
"new",
"BigInteger",
"[",
"numCols",
"]",
";",
"fillInPolynomial",
"(",
"cvt",
"[",
"row",
"]",
",",
"fofxarray",
"[",
"row",
"]",
",",
"xarray",
"[",
"row",
"]",
")",
";",
"}",
"return",
"create",
"(",
"cvt",
")",
";",
"}"
] |
Create solver for polynomial equations.
Polynomial linear equations are a special case, because the C,x,x^2,x^3 coefficients
can be turned into the rows we need by being given:
a) which "x" values were used
b) what "constant" values were computed
This information happens to be exactly what the holder of a "Secret" in
"Secret Sharing" has been given.
So this constructor can be used to recover the secret if
given enough of the secrets.
@param xarray the "X" values
@param fofxarray the "f(x)" values
@return instance for solving this special case
|
[
"Create",
"solver",
"for",
"polynomial",
"equations",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/EasyLinearEquation.java#L127-L148
|
4,549 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/EasyLinearEquation.java
|
EasyLinearEquation.create
|
public static EasyLinearEquation create(BigInteger[][] inMatrix)
{
EasyLinearEquation ret = null;
final int width = inMatrix[0].length;
for (BigInteger[] row : inMatrix)
{
if (width != row.length)
{
throw new SecretShareException("All rows must be " +
width + " wide");
}
}
List<Row> rows = new ArrayList<Row>();
for (BigInteger[] row : inMatrix)
{
Row add = Row.create(row);
rows.add(add);
}
ret = new EasyLinearEquation(rows);
return ret;
}
|
java
|
public static EasyLinearEquation create(BigInteger[][] inMatrix)
{
EasyLinearEquation ret = null;
final int width = inMatrix[0].length;
for (BigInteger[] row : inMatrix)
{
if (width != row.length)
{
throw new SecretShareException("All rows must be " +
width + " wide");
}
}
List<Row> rows = new ArrayList<Row>();
for (BigInteger[] row : inMatrix)
{
Row add = Row.create(row);
rows.add(add);
}
ret = new EasyLinearEquation(rows);
return ret;
}
|
[
"public",
"static",
"EasyLinearEquation",
"create",
"(",
"BigInteger",
"[",
"]",
"[",
"]",
"inMatrix",
")",
"{",
"EasyLinearEquation",
"ret",
"=",
"null",
";",
"final",
"int",
"width",
"=",
"inMatrix",
"[",
"0",
"]",
".",
"length",
";",
"for",
"(",
"BigInteger",
"[",
"]",
"row",
":",
"inMatrix",
")",
"{",
"if",
"(",
"width",
"!=",
"row",
".",
"length",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"All rows must be \"",
"+",
"width",
"+",
"\" wide\"",
")",
";",
"}",
"}",
"List",
"<",
"Row",
">",
"rows",
"=",
"new",
"ArrayList",
"<",
"Row",
">",
"(",
")",
";",
"for",
"(",
"BigInteger",
"[",
"]",
"row",
":",
"inMatrix",
")",
"{",
"Row",
"add",
"=",
"Row",
".",
"create",
"(",
"row",
")",
";",
"rows",
".",
"add",
"(",
"add",
")",
";",
"}",
"ret",
"=",
"new",
"EasyLinearEquation",
"(",
"rows",
")",
";",
"return",
"ret",
";",
"}"
] |
Most typical factory, for BigInteger arrays.
@param inMatrix given in BigIntegers, where the first column is the constant
and all the other columns are the variables
@return instance
|
[
"Most",
"typical",
"factory",
"for",
"BigInteger",
"arrays",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/EasyLinearEquation.java#L172-L192
|
4,550 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.getPrimeUsedFor8192bigSecretPayload
|
public static BigInteger getPrimeUsedFor8192bigSecretPayload()
{
// 2018: It took 6 seconds to check using alpertron.com.ar/ECM.HTM "WebAssembly version".
// (comparison: the 4096 prime, below, took 1 second)
//
// This number is 2470 digits long
BigInteger p8192one =
new BigInteger(
"279231522718570477942523966651848412786" +
"755625471035569262549193264568660953374" +
"539575363644038451708729333066699816198" +
"469916126929965359120284410819859854028" +
"564200012503601405321884115258380340520" +
"882394013079459378373602954907987087391" +
"050381798882893060582464649164778803202" +
"580377606793174221031756238305523801728" +
"417330041767401217359965327363800941065" +
"035149118936045803200708786247512086542" +
"238084017753586024109523236048614557723" +
"115585648257171971411582352854028094056" +
"289905359934753668545924906214201949630" +
"392942663006227207072738059572864458946" +
"995442098987135298017199066044684799206" +
"646046852007692829583685501822083927579" +
"071735457164040393298305467092078136746" +
"232403045411490624416360836139009389471" +
"599615055083953010222383976037199530343" +
"650749295317216621610856318814974339038" +
"401628152419869957586845887861406968283" +
"393603484693172919144488209043235143942" +
"917711597456617030850345093344845985897" +
"228637329601259767634683509551299437410" +
"250309746800132742906307824914615196564" +
"591280851829591037942122046141801113374" +
"061071502459843521616519068508840608866" +
"142367016446371333344905644939606218218" +
"417724015092650576657942326665080385451" +
"599873057465726933634139504551380207635" +
"732730508948201719784282311694063519119" +
"639243736364276253689069434848647101071" +
"362100254351086081223103674307034576258" +
"686423188956569254966171125838939239921" +
"106224566793694393912187263674266535325" +
"772507180754537736572272329042950336363" +
"370798851143956021690701705567437971039" +
"256378548127430749169994462670402156122" +
"918017938186142563187105245902896325033" +
"680839207188324653847844773975235005076" +
"945808128766572234433268495689937486958" +
"100390065467437864644075017104695336221" +
"543165982790695835615515631994231511431" +
"260924853427059238919995356824115989937" +
"622769832207704636596283910866202357492" +
"467506454291595823775435851401331614913" +
"666393860839942086098314120390709421306" +
"518971383380559076685994283375663380057" +
"764241494257799693167997775692501598019" +
"901080423655494004717753331078458159262" +
"055518170817180281440517060614547611105" +
"545747781301175793208826135138672277976" +
"088445981721562249959417511860209657110" +
"039278232822620356487671024234137135540" +
"726721167743323091920287701321960015105" +
"097732434284751017974443861383170363586" +
"137823503261214393288044057973810845631" +
"331034904805398832430192982926982354654" +
"090524982435531180945318487132920328174" +
"085989844087121548092990523399171888560" +
"553067218681856208752028326977093161880" +
"486624111065893663542842180250983316936" +
"056087246483576051350441471279745450361" +
"783242982069");
String bigintcs =
"bigintcs:010000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"0002b5-1E18FD";
// Compare the values of both strings before returning a value.
// This guards against accidental changes to the strings
return checkAndReturn("8192bit prime", p8192one, bigintcs);
}
|
java
|
public static BigInteger getPrimeUsedFor8192bigSecretPayload()
{
// 2018: It took 6 seconds to check using alpertron.com.ar/ECM.HTM "WebAssembly version".
// (comparison: the 4096 prime, below, took 1 second)
//
// This number is 2470 digits long
BigInteger p8192one =
new BigInteger(
"279231522718570477942523966651848412786" +
"755625471035569262549193264568660953374" +
"539575363644038451708729333066699816198" +
"469916126929965359120284410819859854028" +
"564200012503601405321884115258380340520" +
"882394013079459378373602954907987087391" +
"050381798882893060582464649164778803202" +
"580377606793174221031756238305523801728" +
"417330041767401217359965327363800941065" +
"035149118936045803200708786247512086542" +
"238084017753586024109523236048614557723" +
"115585648257171971411582352854028094056" +
"289905359934753668545924906214201949630" +
"392942663006227207072738059572864458946" +
"995442098987135298017199066044684799206" +
"646046852007692829583685501822083927579" +
"071735457164040393298305467092078136746" +
"232403045411490624416360836139009389471" +
"599615055083953010222383976037199530343" +
"650749295317216621610856318814974339038" +
"401628152419869957586845887861406968283" +
"393603484693172919144488209043235143942" +
"917711597456617030850345093344845985897" +
"228637329601259767634683509551299437410" +
"250309746800132742906307824914615196564" +
"591280851829591037942122046141801113374" +
"061071502459843521616519068508840608866" +
"142367016446371333344905644939606218218" +
"417724015092650576657942326665080385451" +
"599873057465726933634139504551380207635" +
"732730508948201719784282311694063519119" +
"639243736364276253689069434848647101071" +
"362100254351086081223103674307034576258" +
"686423188956569254966171125838939239921" +
"106224566793694393912187263674266535325" +
"772507180754537736572272329042950336363" +
"370798851143956021690701705567437971039" +
"256378548127430749169994462670402156122" +
"918017938186142563187105245902896325033" +
"680839207188324653847844773975235005076" +
"945808128766572234433268495689937486958" +
"100390065467437864644075017104695336221" +
"543165982790695835615515631994231511431" +
"260924853427059238919995356824115989937" +
"622769832207704636596283910866202357492" +
"467506454291595823775435851401331614913" +
"666393860839942086098314120390709421306" +
"518971383380559076685994283375663380057" +
"764241494257799693167997775692501598019" +
"901080423655494004717753331078458159262" +
"055518170817180281440517060614547611105" +
"545747781301175793208826135138672277976" +
"088445981721562249959417511860209657110" +
"039278232822620356487671024234137135540" +
"726721167743323091920287701321960015105" +
"097732434284751017974443861383170363586" +
"137823503261214393288044057973810845631" +
"331034904805398832430192982926982354654" +
"090524982435531180945318487132920328174" +
"085989844087121548092990523399171888560" +
"553067218681856208752028326977093161880" +
"486624111065893663542842180250983316936" +
"056087246483576051350441471279745450361" +
"783242982069");
String bigintcs =
"bigintcs:010000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"000000-000000-000000-000000-000000-000000-000000-" +
"0002b5-1E18FD";
// Compare the values of both strings before returning a value.
// This guards against accidental changes to the strings
return checkAndReturn("8192bit prime", p8192one, bigintcs);
}
|
[
"public",
"static",
"BigInteger",
"getPrimeUsedFor8192bigSecretPayload",
"(",
")",
"{",
"// 2018: It took 6 seconds to check using alpertron.com.ar/ECM.HTM \"WebAssembly version\".",
"// (comparison: the 4096 prime, below, took 1 second)",
"//",
"// This number is 2470 digits long",
"BigInteger",
"p8192one",
"=",
"new",
"BigInteger",
"(",
"\"279231522718570477942523966651848412786\"",
"+",
"\"755625471035569262549193264568660953374\"",
"+",
"\"539575363644038451708729333066699816198\"",
"+",
"\"469916126929965359120284410819859854028\"",
"+",
"\"564200012503601405321884115258380340520\"",
"+",
"\"882394013079459378373602954907987087391\"",
"+",
"\"050381798882893060582464649164778803202\"",
"+",
"\"580377606793174221031756238305523801728\"",
"+",
"\"417330041767401217359965327363800941065\"",
"+",
"\"035149118936045803200708786247512086542\"",
"+",
"\"238084017753586024109523236048614557723\"",
"+",
"\"115585648257171971411582352854028094056\"",
"+",
"\"289905359934753668545924906214201949630\"",
"+",
"\"392942663006227207072738059572864458946\"",
"+",
"\"995442098987135298017199066044684799206\"",
"+",
"\"646046852007692829583685501822083927579\"",
"+",
"\"071735457164040393298305467092078136746\"",
"+",
"\"232403045411490624416360836139009389471\"",
"+",
"\"599615055083953010222383976037199530343\"",
"+",
"\"650749295317216621610856318814974339038\"",
"+",
"\"401628152419869957586845887861406968283\"",
"+",
"\"393603484693172919144488209043235143942\"",
"+",
"\"917711597456617030850345093344845985897\"",
"+",
"\"228637329601259767634683509551299437410\"",
"+",
"\"250309746800132742906307824914615196564\"",
"+",
"\"591280851829591037942122046141801113374\"",
"+",
"\"061071502459843521616519068508840608866\"",
"+",
"\"142367016446371333344905644939606218218\"",
"+",
"\"417724015092650576657942326665080385451\"",
"+",
"\"599873057465726933634139504551380207635\"",
"+",
"\"732730508948201719784282311694063519119\"",
"+",
"\"639243736364276253689069434848647101071\"",
"+",
"\"362100254351086081223103674307034576258\"",
"+",
"\"686423188956569254966171125838939239921\"",
"+",
"\"106224566793694393912187263674266535325\"",
"+",
"\"772507180754537736572272329042950336363\"",
"+",
"\"370798851143956021690701705567437971039\"",
"+",
"\"256378548127430749169994462670402156122\"",
"+",
"\"918017938186142563187105245902896325033\"",
"+",
"\"680839207188324653847844773975235005076\"",
"+",
"\"945808128766572234433268495689937486958\"",
"+",
"\"100390065467437864644075017104695336221\"",
"+",
"\"543165982790695835615515631994231511431\"",
"+",
"\"260924853427059238919995356824115989937\"",
"+",
"\"622769832207704636596283910866202357492\"",
"+",
"\"467506454291595823775435851401331614913\"",
"+",
"\"666393860839942086098314120390709421306\"",
"+",
"\"518971383380559076685994283375663380057\"",
"+",
"\"764241494257799693167997775692501598019\"",
"+",
"\"901080423655494004717753331078458159262\"",
"+",
"\"055518170817180281440517060614547611105\"",
"+",
"\"545747781301175793208826135138672277976\"",
"+",
"\"088445981721562249959417511860209657110\"",
"+",
"\"039278232822620356487671024234137135540\"",
"+",
"\"726721167743323091920287701321960015105\"",
"+",
"\"097732434284751017974443861383170363586\"",
"+",
"\"137823503261214393288044057973810845631\"",
"+",
"\"331034904805398832430192982926982354654\"",
"+",
"\"090524982435531180945318487132920328174\"",
"+",
"\"085989844087121548092990523399171888560\"",
"+",
"\"553067218681856208752028326977093161880\"",
"+",
"\"486624111065893663542842180250983316936\"",
"+",
"\"056087246483576051350441471279745450361\"",
"+",
"\"783242982069\"",
")",
";",
"String",
"bigintcs",
"=",
"\"bigintcs:010000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"000000-000000-000000-000000-000000-000000-000000-\"",
"+",
"\"0002b5-1E18FD\"",
";",
"// Compare the values of both strings before returning a value.",
"// This guards against accidental changes to the strings",
"return",
"checkAndReturn",
"(",
"\"8192bit prime\"",
",",
"p8192one",
",",
"bigintcs",
")",
";",
"}"
] |
All primes were tested with 100,000 iterations of Miller-Rabin
|
[
"All",
"primes",
"were",
"tested",
"with",
"100",
"000",
"iterations",
"of",
"Miller",
"-",
"Rabin"
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L201-L330
|
4,551 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.checkAndReturn
|
private static BigInteger checkAndReturn(String which,
BigInteger expected,
String asbigintcs)
{
BigInteger other =
BigIntStringChecksum.fromString(asbigintcs).asBigInteger();
if (expected.equals(other))
{
return expected;
}
else
{
throw new SecretShareException(which + " failure");
}
}
|
java
|
private static BigInteger checkAndReturn(String which,
BigInteger expected,
String asbigintcs)
{
BigInteger other =
BigIntStringChecksum.fromString(asbigintcs).asBigInteger();
if (expected.equals(other))
{
return expected;
}
else
{
throw new SecretShareException(which + " failure");
}
}
|
[
"private",
"static",
"BigInteger",
"checkAndReturn",
"(",
"String",
"which",
",",
"BigInteger",
"expected",
",",
"String",
"asbigintcs",
")",
"{",
"BigInteger",
"other",
"=",
"BigIntStringChecksum",
".",
"fromString",
"(",
"asbigintcs",
")",
".",
"asBigInteger",
"(",
")",
";",
"if",
"(",
"expected",
".",
"equals",
"(",
"other",
")",
")",
"{",
"return",
"expected",
";",
"}",
"else",
"{",
"throw",
"new",
"SecretShareException",
"(",
"which",
"+",
"\" failure\"",
")",
";",
"}",
"}"
] |
Guard against accidental changes to the strings.
@param which caller
@param expected value as biginteger
@param asbigintcs value as big-integer-checksum string
@return expected or throw exception
@throws SecretShareException if expected does not match asbigintcs
|
[
"Guard",
"against",
"accidental",
"changes",
"to",
"the",
"strings",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L470-L485
|
4,552 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.split
|
public SplitSecretOutput split(final BigInteger secret,
final Random random)
{
if (secret == null)
{
throw new SecretShareException("Secret cannot be null");
}
if (secret.signum() <= 0)
{
throw new SecretShareException("Secret cannot be negative");
}
if (publicInfo.getPrimeModulus() != null)
{
checkThatModulusIsAppropriate(publicInfo.getPrimeModulus(),
secret);
}
BigInteger[] coeffs = new BigInteger[publicInfo.getK()];
// create the equation by setting the coefficients:
// [a] randomize the coefficients:
randomizeCoeffs(coeffs, random, publicInfo.getPrimeModulus(), secret);
// [b] set the constant coefficient to the secret:
coeffs[0] = secret;
final PolyEquationImpl equation = new PolyEquationImpl(coeffs);
SplitSecretOutput ret = new SplitSecretOutput(this.publicInfo,
equation);
for (int x = 1, n = publicInfo.getNforSplit() + 1; x < n; x++)
{
final BigInteger fofx = equation.calculateFofX(BigInteger.valueOf(x));
BigInteger data = fofx;
if (publicInfo.primeModulus != null)
{
data = data.mod(publicInfo.primeModulus);
}
final ShareInfo share = new ShareInfo(x, data, this.publicInfo);
if (publicInfo.primeModulus != null)
{
if (data.compareTo(publicInfo.getPrimeModulus()) > 0)
{
throw new RuntimeException("" + data + "\n" + publicInfo.getPrimeModulus() + "\n");
}
}
ret.sharesInfo.add(share);
}
return ret;
}
|
java
|
public SplitSecretOutput split(final BigInteger secret,
final Random random)
{
if (secret == null)
{
throw new SecretShareException("Secret cannot be null");
}
if (secret.signum() <= 0)
{
throw new SecretShareException("Secret cannot be negative");
}
if (publicInfo.getPrimeModulus() != null)
{
checkThatModulusIsAppropriate(publicInfo.getPrimeModulus(),
secret);
}
BigInteger[] coeffs = new BigInteger[publicInfo.getK()];
// create the equation by setting the coefficients:
// [a] randomize the coefficients:
randomizeCoeffs(coeffs, random, publicInfo.getPrimeModulus(), secret);
// [b] set the constant coefficient to the secret:
coeffs[0] = secret;
final PolyEquationImpl equation = new PolyEquationImpl(coeffs);
SplitSecretOutput ret = new SplitSecretOutput(this.publicInfo,
equation);
for (int x = 1, n = publicInfo.getNforSplit() + 1; x < n; x++)
{
final BigInteger fofx = equation.calculateFofX(BigInteger.valueOf(x));
BigInteger data = fofx;
if (publicInfo.primeModulus != null)
{
data = data.mod(publicInfo.primeModulus);
}
final ShareInfo share = new ShareInfo(x, data, this.publicInfo);
if (publicInfo.primeModulus != null)
{
if (data.compareTo(publicInfo.getPrimeModulus()) > 0)
{
throw new RuntimeException("" + data + "\n" + publicInfo.getPrimeModulus() + "\n");
}
}
ret.sharesInfo.add(share);
}
return ret;
}
|
[
"public",
"SplitSecretOutput",
"split",
"(",
"final",
"BigInteger",
"secret",
",",
"final",
"Random",
"random",
")",
"{",
"if",
"(",
"secret",
"==",
"null",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"Secret cannot be null\"",
")",
";",
"}",
"if",
"(",
"secret",
".",
"signum",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"Secret cannot be negative\"",
")",
";",
"}",
"if",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
"!=",
"null",
")",
"{",
"checkThatModulusIsAppropriate",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
",",
"secret",
")",
";",
"}",
"BigInteger",
"[",
"]",
"coeffs",
"=",
"new",
"BigInteger",
"[",
"publicInfo",
".",
"getK",
"(",
")",
"]",
";",
"// create the equation by setting the coefficients:",
"// [a] randomize the coefficients:",
"randomizeCoeffs",
"(",
"coeffs",
",",
"random",
",",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
",",
"secret",
")",
";",
"// [b] set the constant coefficient to the secret:",
"coeffs",
"[",
"0",
"]",
"=",
"secret",
";",
"final",
"PolyEquationImpl",
"equation",
"=",
"new",
"PolyEquationImpl",
"(",
"coeffs",
")",
";",
"SplitSecretOutput",
"ret",
"=",
"new",
"SplitSecretOutput",
"(",
"this",
".",
"publicInfo",
",",
"equation",
")",
";",
"for",
"(",
"int",
"x",
"=",
"1",
",",
"n",
"=",
"publicInfo",
".",
"getNforSplit",
"(",
")",
"+",
"1",
";",
"x",
"<",
"n",
";",
"x",
"++",
")",
"{",
"final",
"BigInteger",
"fofx",
"=",
"equation",
".",
"calculateFofX",
"(",
"BigInteger",
".",
"valueOf",
"(",
"x",
")",
")",
";",
"BigInteger",
"data",
"=",
"fofx",
";",
"if",
"(",
"publicInfo",
".",
"primeModulus",
"!=",
"null",
")",
"{",
"data",
"=",
"data",
".",
"mod",
"(",
"publicInfo",
".",
"primeModulus",
")",
";",
"}",
"final",
"ShareInfo",
"share",
"=",
"new",
"ShareInfo",
"(",
"x",
",",
"data",
",",
"this",
".",
"publicInfo",
")",
";",
"if",
"(",
"publicInfo",
".",
"primeModulus",
"!=",
"null",
")",
"{",
"if",
"(",
"data",
".",
"compareTo",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
")",
">",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
"+",
"data",
"+",
"\"\\n\"",
"+",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
"+",
"\"\\n\"",
")",
";",
"}",
"}",
"ret",
".",
"sharesInfo",
".",
"add",
"(",
"share",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Split the secret into pieces, where the caller controls the random instance.
@param secret to split
@param random to use for random number generation
@return split secret output instance
|
[
"Split",
"the",
"secret",
"into",
"pieces",
"where",
"the",
"caller",
"controls",
"the",
"random",
"instance",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L528-L579
|
4,553 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.combine
|
public CombineOutput combine(final List<ShareInfo> usetheseshares)
{
CombineOutput ret = null;
sanityCheckPublicInfos(publicInfo, usetheseshares);
if (true)
{
println(" SOLVING USING THESE SHARES, mod=" + publicInfo.getPrimeModulus());
for (ShareInfo si : usetheseshares)
{
println(" " + si.share);
}
println("end SOLVING USING THESE SHARES");
}
if (publicInfo.getK() > usetheseshares.size())
{
throw new SecretShareException("Must have " + publicInfo.getK() +
" shares to solve. Only provided " +
usetheseshares.size());
}
checkForDuplicatesOrThrow(usetheseshares);
final int size = publicInfo.getK();
BigInteger[] xarray = new BigInteger[size];
BigInteger[] fofxarray = new BigInteger[size];
for (int i = 0, n = size; i < n; i++)
{
xarray[i] = usetheseshares.get(i).getXasBigInteger();
fofxarray[i] = usetheseshares.get(i).getShare();
}
EasyLinearEquation ele =
EasyLinearEquation.createForPolynomial(xarray, fofxarray);
if (publicInfo.getPrimeModulus() != null)
{
ele = ele.createWithPrimeModulus(publicInfo.getPrimeModulus());
}
BigInteger solveSecret = null;
if (false)
{
EasyLinearEquation.EasySolve solve = ele.solve();
solveSecret = solve.getAnswer(1);
}
else
{
BigInteger[][] matrix = ele.getMatrix();
NumberMatrix.print("SS.java", matrix, out);
println("CVT matrix.height=" + matrix.length + " width=" + matrix[0].length);
BigRationalMatrix brm = BigRationalMatrix.create(matrix);
NumberMatrix.print("SS.java brm", brm.getArray(), out);
NumberSimplex<BigRational> simplex = new NumberSimplex<BigRational>(brm, 0);
simplex.initForSolve(out);
simplex.solve(out);
BigRational answer = simplex.getAnswer(0);
if (publicInfo.getPrimeModulus() != null)
{
solveSecret = answer.computeBigIntegerMod(publicInfo.getPrimeModulus());
}
else
{
solveSecret = answer.bigIntegerValue();
}
}
if (publicInfo.getPrimeModulus() != null)
{
solveSecret = solveSecret.mod(publicInfo.getPrimeModulus());
}
ret = new CombineOutput(solveSecret);
return ret;
}
|
java
|
public CombineOutput combine(final List<ShareInfo> usetheseshares)
{
CombineOutput ret = null;
sanityCheckPublicInfos(publicInfo, usetheseshares);
if (true)
{
println(" SOLVING USING THESE SHARES, mod=" + publicInfo.getPrimeModulus());
for (ShareInfo si : usetheseshares)
{
println(" " + si.share);
}
println("end SOLVING USING THESE SHARES");
}
if (publicInfo.getK() > usetheseshares.size())
{
throw new SecretShareException("Must have " + publicInfo.getK() +
" shares to solve. Only provided " +
usetheseshares.size());
}
checkForDuplicatesOrThrow(usetheseshares);
final int size = publicInfo.getK();
BigInteger[] xarray = new BigInteger[size];
BigInteger[] fofxarray = new BigInteger[size];
for (int i = 0, n = size; i < n; i++)
{
xarray[i] = usetheseshares.get(i).getXasBigInteger();
fofxarray[i] = usetheseshares.get(i).getShare();
}
EasyLinearEquation ele =
EasyLinearEquation.createForPolynomial(xarray, fofxarray);
if (publicInfo.getPrimeModulus() != null)
{
ele = ele.createWithPrimeModulus(publicInfo.getPrimeModulus());
}
BigInteger solveSecret = null;
if (false)
{
EasyLinearEquation.EasySolve solve = ele.solve();
solveSecret = solve.getAnswer(1);
}
else
{
BigInteger[][] matrix = ele.getMatrix();
NumberMatrix.print("SS.java", matrix, out);
println("CVT matrix.height=" + matrix.length + " width=" + matrix[0].length);
BigRationalMatrix brm = BigRationalMatrix.create(matrix);
NumberMatrix.print("SS.java brm", brm.getArray(), out);
NumberSimplex<BigRational> simplex = new NumberSimplex<BigRational>(brm, 0);
simplex.initForSolve(out);
simplex.solve(out);
BigRational answer = simplex.getAnswer(0);
if (publicInfo.getPrimeModulus() != null)
{
solveSecret = answer.computeBigIntegerMod(publicInfo.getPrimeModulus());
}
else
{
solveSecret = answer.bigIntegerValue();
}
}
if (publicInfo.getPrimeModulus() != null)
{
solveSecret = solveSecret.mod(publicInfo.getPrimeModulus());
}
ret = new CombineOutput(solveSecret);
return ret;
}
|
[
"public",
"CombineOutput",
"combine",
"(",
"final",
"List",
"<",
"ShareInfo",
">",
"usetheseshares",
")",
"{",
"CombineOutput",
"ret",
"=",
"null",
";",
"sanityCheckPublicInfos",
"(",
"publicInfo",
",",
"usetheseshares",
")",
";",
"if",
"(",
"true",
")",
"{",
"println",
"(",
"\" SOLVING USING THESE SHARES, mod=\"",
"+",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
")",
";",
"for",
"(",
"ShareInfo",
"si",
":",
"usetheseshares",
")",
"{",
"println",
"(",
"\" \"",
"+",
"si",
".",
"share",
")",
";",
"}",
"println",
"(",
"\"end SOLVING USING THESE SHARES\"",
")",
";",
"}",
"if",
"(",
"publicInfo",
".",
"getK",
"(",
")",
">",
"usetheseshares",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"Must have \"",
"+",
"publicInfo",
".",
"getK",
"(",
")",
"+",
"\" shares to solve. Only provided \"",
"+",
"usetheseshares",
".",
"size",
"(",
")",
")",
";",
"}",
"checkForDuplicatesOrThrow",
"(",
"usetheseshares",
")",
";",
"final",
"int",
"size",
"=",
"publicInfo",
".",
"getK",
"(",
")",
";",
"BigInteger",
"[",
"]",
"xarray",
"=",
"new",
"BigInteger",
"[",
"size",
"]",
";",
"BigInteger",
"[",
"]",
"fofxarray",
"=",
"new",
"BigInteger",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"size",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"xarray",
"[",
"i",
"]",
"=",
"usetheseshares",
".",
"get",
"(",
"i",
")",
".",
"getXasBigInteger",
"(",
")",
";",
"fofxarray",
"[",
"i",
"]",
"=",
"usetheseshares",
".",
"get",
"(",
"i",
")",
".",
"getShare",
"(",
")",
";",
"}",
"EasyLinearEquation",
"ele",
"=",
"EasyLinearEquation",
".",
"createForPolynomial",
"(",
"xarray",
",",
"fofxarray",
")",
";",
"if",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
"!=",
"null",
")",
"{",
"ele",
"=",
"ele",
".",
"createWithPrimeModulus",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
")",
";",
"}",
"BigInteger",
"solveSecret",
"=",
"null",
";",
"if",
"(",
"false",
")",
"{",
"EasyLinearEquation",
".",
"EasySolve",
"solve",
"=",
"ele",
".",
"solve",
"(",
")",
";",
"solveSecret",
"=",
"solve",
".",
"getAnswer",
"(",
"1",
")",
";",
"}",
"else",
"{",
"BigInteger",
"[",
"]",
"[",
"]",
"matrix",
"=",
"ele",
".",
"getMatrix",
"(",
")",
";",
"NumberMatrix",
".",
"print",
"(",
"\"SS.java\"",
",",
"matrix",
",",
"out",
")",
";",
"println",
"(",
"\"CVT matrix.height=\"",
"+",
"matrix",
".",
"length",
"+",
"\" width=\"",
"+",
"matrix",
"[",
"0",
"]",
".",
"length",
")",
";",
"BigRationalMatrix",
"brm",
"=",
"BigRationalMatrix",
".",
"create",
"(",
"matrix",
")",
";",
"NumberMatrix",
".",
"print",
"(",
"\"SS.java brm\"",
",",
"brm",
".",
"getArray",
"(",
")",
",",
"out",
")",
";",
"NumberSimplex",
"<",
"BigRational",
">",
"simplex",
"=",
"new",
"NumberSimplex",
"<",
"BigRational",
">",
"(",
"brm",
",",
"0",
")",
";",
"simplex",
".",
"initForSolve",
"(",
"out",
")",
";",
"simplex",
".",
"solve",
"(",
"out",
")",
";",
"BigRational",
"answer",
"=",
"simplex",
".",
"getAnswer",
"(",
"0",
")",
";",
"if",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
"!=",
"null",
")",
"{",
"solveSecret",
"=",
"answer",
".",
"computeBigIntegerMod",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
")",
";",
"}",
"else",
"{",
"solveSecret",
"=",
"answer",
".",
"bigIntegerValue",
"(",
")",
";",
"}",
"}",
"if",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
"!=",
"null",
")",
"{",
"solveSecret",
"=",
"solveSecret",
".",
"mod",
"(",
"publicInfo",
".",
"getPrimeModulus",
"(",
")",
")",
";",
"}",
"ret",
"=",
"new",
"CombineOutput",
"(",
"solveSecret",
")",
";",
"return",
"ret",
";",
"}"
] |
Combine the shares generated by the split to recover the secret.
@param usetheseshares shares to use - only the first "K" of size() will be used
@return the combine output instance [which in turn contains the recovered secret]
|
[
"Combine",
"the",
"shares",
"generated",
"by",
"the",
"split",
"to",
"recover",
"the",
"secret",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L594-L673
|
4,554 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.combineParanoid
|
public ParanoidOutput combineParanoid(List<ShareInfo> shares,
ParanoidInput paranoidInput)
{
ParanoidOutput ret = performParanoidCombines(shares, paranoidInput);
if (paranoidInput != null)
{
if (ret.getReconstructedMap().size() != 1)
{
throw new SecretShareException("Paranoid combine failed, on combination at count=" + ret.getCount());
}
}
return ret;
}
|
java
|
public ParanoidOutput combineParanoid(List<ShareInfo> shares,
ParanoidInput paranoidInput)
{
ParanoidOutput ret = performParanoidCombines(shares, paranoidInput);
if (paranoidInput != null)
{
if (ret.getReconstructedMap().size() != 1)
{
throw new SecretShareException("Paranoid combine failed, on combination at count=" + ret.getCount());
}
}
return ret;
}
|
[
"public",
"ParanoidOutput",
"combineParanoid",
"(",
"List",
"<",
"ShareInfo",
">",
"shares",
",",
"ParanoidInput",
"paranoidInput",
")",
"{",
"ParanoidOutput",
"ret",
"=",
"performParanoidCombines",
"(",
"shares",
",",
"paranoidInput",
")",
";",
"if",
"(",
"paranoidInput",
"!=",
"null",
")",
"{",
"if",
"(",
"ret",
".",
"getReconstructedMap",
"(",
")",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"Paranoid combine failed, on combination at count=\"",
"+",
"ret",
".",
"getCount",
"(",
")",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
This version does the combines, and throws an exception if there is not 100% agreement.
@param shares - all shares available to make unique subsets from
@param paranoidInput control over the process
@return ParanoidOutput
@throws SecretShareException if there is not 100% agreement on the reconstructed secret
|
[
"This",
"version",
"does",
"the",
"combines",
"and",
"throws",
"an",
"exception",
"if",
"there",
"is",
"not",
"100%",
"agreement",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L1142-L1156
|
4,555 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/engine/SecretShare.java
|
SecretShare.performParanoidCombines
|
public ParanoidOutput performParanoidCombines(List<ShareInfo> shares,
ParanoidInput paranoidInput)
{
if (paranoidInput == null)
{
return ParanoidOutput.createEmpty();
}
else
{
return performParanoidCombinesNonNull(shares, paranoidInput);
}
}
|
java
|
public ParanoidOutput performParanoidCombines(List<ShareInfo> shares,
ParanoidInput paranoidInput)
{
if (paranoidInput == null)
{
return ParanoidOutput.createEmpty();
}
else
{
return performParanoidCombinesNonNull(shares, paranoidInput);
}
}
|
[
"public",
"ParanoidOutput",
"performParanoidCombines",
"(",
"List",
"<",
"ShareInfo",
">",
"shares",
",",
"ParanoidInput",
"paranoidInput",
")",
"{",
"if",
"(",
"paranoidInput",
"==",
"null",
")",
"{",
"return",
"ParanoidOutput",
".",
"createEmpty",
"(",
")",
";",
"}",
"else",
"{",
"return",
"performParanoidCombinesNonNull",
"(",
"shares",
",",
"paranoidInput",
")",
";",
"}",
"}"
] |
This version just collects all of the reconstructed secrets.
@param shares to use
@param paranoidInput - control over process
if greater than 0 use that number
if less than 0 OR null no limit
@return ParanoidOutput
|
[
"This",
"version",
"just",
"collects",
"all",
"of",
"the",
"reconstructed",
"secrets",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/engine/SecretShare.java#L1167-L1178
|
4,556 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/PolyEquationImpl.java
|
PolyEquationImpl.create
|
public static PolyEquationImpl create(final int ...args)
{
BigInteger[] bigints = new BigInteger[args.length];
for (int i = 0, n = args.length; i < n; i++)
{
bigints[i] = BigInteger.valueOf(args[i]);
}
return new PolyEquationImpl(bigints);
}
|
java
|
public static PolyEquationImpl create(final int ...args)
{
BigInteger[] bigints = new BigInteger[args.length];
for (int i = 0, n = args.length; i < n; i++)
{
bigints[i] = BigInteger.valueOf(args[i]);
}
return new PolyEquationImpl(bigints);
}
|
[
"public",
"static",
"PolyEquationImpl",
"create",
"(",
"final",
"int",
"...",
"args",
")",
"{",
"BigInteger",
"[",
"]",
"bigints",
"=",
"new",
"BigInteger",
"[",
"args",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"args",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"bigints",
"[",
"i",
"]",
"=",
"BigInteger",
".",
"valueOf",
"(",
"args",
"[",
"i",
"]",
")",
";",
"}",
"return",
"new",
"PolyEquationImpl",
"(",
"bigints",
")",
";",
"}"
] |
Helper factory to create instances.
Accepts 'int', converts them to BigInteger, and calls the constructor.
@param args as int values
@return instance
|
[
"Helper",
"factory",
"to",
"create",
"instances",
".",
"Accepts",
"int",
"converts",
"them",
"to",
"BigInteger",
"and",
"calls",
"the",
"constructor",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/PolyEquationImpl.java#L76-L84
|
4,557 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.addMatrix
|
public E[][] addMatrix(E[][] matrix1, E[][] matrix2)
{
// Check bounds of the two matrices
if ((matrix1.length != matrix2.length) ||
(matrix1[0].length != matrix2[0].length))
{
throw new SecretShareException("The matrices do not have the same size");
}
E[][] result = //(E[][])new Number[matrix1.length][matrix1[0].length];
create(matrix1.length, matrix1[0].length);
// Perform addition
for (int i = 0; i < result.length; i++)
{
for (int j = 0; j < result[i].length; j++)
{
result[i][j] = add(matrix1[i][j], matrix2[i][j]);
}
}
return result;
}
|
java
|
public E[][] addMatrix(E[][] matrix1, E[][] matrix2)
{
// Check bounds of the two matrices
if ((matrix1.length != matrix2.length) ||
(matrix1[0].length != matrix2[0].length))
{
throw new SecretShareException("The matrices do not have the same size");
}
E[][] result = //(E[][])new Number[matrix1.length][matrix1[0].length];
create(matrix1.length, matrix1[0].length);
// Perform addition
for (int i = 0; i < result.length; i++)
{
for (int j = 0; j < result[i].length; j++)
{
result[i][j] = add(matrix1[i][j], matrix2[i][j]);
}
}
return result;
}
|
[
"public",
"E",
"[",
"]",
"[",
"]",
"addMatrix",
"(",
"E",
"[",
"]",
"[",
"]",
"matrix1",
",",
"E",
"[",
"]",
"[",
"]",
"matrix2",
")",
"{",
"// Check bounds of the two matrices",
"if",
"(",
"(",
"matrix1",
".",
"length",
"!=",
"matrix2",
".",
"length",
")",
"||",
"(",
"matrix1",
"[",
"0",
"]",
".",
"length",
"!=",
"matrix2",
"[",
"0",
"]",
".",
"length",
")",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"The matrices do not have the same size\"",
")",
";",
"}",
"E",
"[",
"]",
"[",
"]",
"result",
"=",
"//(E[][])new Number[matrix1.length][matrix1[0].length];",
"create",
"(",
"matrix1",
".",
"length",
",",
"matrix1",
"[",
"0",
"]",
".",
"length",
")",
";",
"// Perform addition",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"result",
"[",
"i",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"add",
"(",
"matrix1",
"[",
"i",
"]",
"[",
"j",
"]",
",",
"matrix2",
"[",
"i",
"]",
"[",
"j",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Add two matrices.
@param matrix1 first
@param matrix2 second
@return maxtrix 1 + 1
|
[
"Add",
"two",
"matrices",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L143-L165
|
4,558 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.multiplyMatrix
|
public E[][] multiplyMatrix(E[][] matrix1, E[][] matrix2)
{
// Check bounds
if (matrix1[0].length != matrix2.length)
{
throw new SecretShareException("The matrices do not have compatible size");
}
// Create result matrix
E[][] result = //(E[][]) new Number[matrix1.length][matrix2[0].length];
create(matrix1.length, matrix2[0].length);
// Perform multiplication of two matrices
for (int i = 0; i < result.length; i++)
{
for (int j = 0; j < result[0].length; j++)
{
result[i][j] = zero();
for (int k = 0; k < matrix1[0].length; k++)
{
result[i][j] = add(result[i][j],
multiply(matrix1[i][k], matrix2[k][j]));
}
}
}
return result;
}
|
java
|
public E[][] multiplyMatrix(E[][] matrix1, E[][] matrix2)
{
// Check bounds
if (matrix1[0].length != matrix2.length)
{
throw new SecretShareException("The matrices do not have compatible size");
}
// Create result matrix
E[][] result = //(E[][]) new Number[matrix1.length][matrix2[0].length];
create(matrix1.length, matrix2[0].length);
// Perform multiplication of two matrices
for (int i = 0; i < result.length; i++)
{
for (int j = 0; j < result[0].length; j++)
{
result[i][j] = zero();
for (int k = 0; k < matrix1[0].length; k++)
{
result[i][j] = add(result[i][j],
multiply(matrix1[i][k], matrix2[k][j]));
}
}
}
return result;
}
|
[
"public",
"E",
"[",
"]",
"[",
"]",
"multiplyMatrix",
"(",
"E",
"[",
"]",
"[",
"]",
"matrix1",
",",
"E",
"[",
"]",
"[",
"]",
"matrix2",
")",
"{",
"// Check bounds",
"if",
"(",
"matrix1",
"[",
"0",
"]",
".",
"length",
"!=",
"matrix2",
".",
"length",
")",
"{",
"throw",
"new",
"SecretShareException",
"(",
"\"The matrices do not have compatible size\"",
")",
";",
"}",
"// Create result matrix",
"E",
"[",
"]",
"[",
"]",
"result",
"=",
"//(E[][]) new Number[matrix1.length][matrix2[0].length];",
"create",
"(",
"matrix1",
".",
"length",
",",
"matrix2",
"[",
"0",
"]",
".",
"length",
")",
";",
"// Perform multiplication of two matrices",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"result",
"[",
"0",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"zero",
"(",
")",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"matrix1",
"[",
"0",
"]",
".",
"length",
";",
"k",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"add",
"(",
"result",
"[",
"i",
"]",
"[",
"j",
"]",
",",
"multiply",
"(",
"matrix1",
"[",
"i",
"]",
"[",
"k",
"]",
",",
"matrix2",
"[",
"k",
"]",
"[",
"j",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Multiply two matrices.
@param matrix1 array-array
@param matrix2 array-array
@return matrix 1 * 2
|
[
"Multiply",
"two",
"matrices",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L172-L200
|
4,559 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.determinant
|
public E determinant(E[][] matrix, int r, int s, int i, int j)
{
E a, b, c, d;
a = matrix[r][s];
b = matrix[r][j];
c = matrix[i][s];
d = matrix[i][j];
E ad = multiply(a, d); // matrix[r][s], matrix[i][j]);
E bc = multiply(b, c); // matrix[i][s], matrix[r][j]);
E ret = subtract(ad, bc);
return ret;
}
|
java
|
public E determinant(E[][] matrix, int r, int s, int i, int j)
{
E a, b, c, d;
a = matrix[r][s];
b = matrix[r][j];
c = matrix[i][s];
d = matrix[i][j];
E ad = multiply(a, d); // matrix[r][s], matrix[i][j]);
E bc = multiply(b, c); // matrix[i][s], matrix[r][j]);
E ret = subtract(ad, bc);
return ret;
}
|
[
"public",
"E",
"determinant",
"(",
"E",
"[",
"]",
"[",
"]",
"matrix",
",",
"int",
"r",
",",
"int",
"s",
",",
"int",
"i",
",",
"int",
"j",
")",
"{",
"E",
"a",
",",
"b",
",",
"c",
",",
"d",
";",
"a",
"=",
"matrix",
"[",
"r",
"]",
"[",
"s",
"]",
";",
"b",
"=",
"matrix",
"[",
"r",
"]",
"[",
"j",
"]",
";",
"c",
"=",
"matrix",
"[",
"i",
"]",
"[",
"s",
"]",
";",
"d",
"=",
"matrix",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"E",
"ad",
"=",
"multiply",
"(",
"a",
",",
"d",
")",
";",
"// matrix[r][s], matrix[i][j]);",
"E",
"bc",
"=",
"multiply",
"(",
"b",
",",
"c",
")",
";",
"// matrix[i][s], matrix[r][j]);",
"E",
"ret",
"=",
"subtract",
"(",
"ad",
",",
"bc",
")",
";",
"return",
"ret",
";",
"}"
] |
Return the determinant.
@param matrix array
@param r index
@param s index
@param i index
@param j index
@return element determinant
|
[
"Return",
"the",
"determinant",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L216-L228
|
4,560 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.print
|
public static void print(String string, Number[][] matrix2, PrintStream out)
{
if (out == null)
{
return;
}
out.println(string);
printResult(matrix2, out);
}
|
java
|
public static void print(String string, Number[][] matrix2, PrintStream out)
{
if (out == null)
{
return;
}
out.println(string);
printResult(matrix2, out);
}
|
[
"public",
"static",
"void",
"print",
"(",
"String",
"string",
",",
"Number",
"[",
"]",
"[",
"]",
"matrix2",
",",
"PrintStream",
"out",
")",
"{",
"if",
"(",
"out",
"==",
"null",
")",
"{",
"return",
";",
"}",
"out",
".",
"println",
"(",
"string",
")",
";",
"printResult",
"(",
"matrix2",
",",
"out",
")",
";",
"}"
] |
Print this array-array.
@param string header
@param matrix2 array-array
@param out printstream
|
[
"Print",
"this",
"array",
"-",
"array",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L245-L253
|
4,561 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.printResult
|
public static void printResult(Number[][] m1, PrintStream out)
{
if (out == null)
{
return;
}
for (int i = 0; i < m1.length; i++)
{
for (int j = 0; j < m1[0].length; j++)
{
out.print(" " + m1[i][j]);
}
out.println("");
}
}
|
java
|
public static void printResult(Number[][] m1, PrintStream out)
{
if (out == null)
{
return;
}
for (int i = 0; i < m1.length; i++)
{
for (int j = 0; j < m1[0].length; j++)
{
out.print(" " + m1[i][j]);
}
out.println("");
}
}
|
[
"public",
"static",
"void",
"printResult",
"(",
"Number",
"[",
"]",
"[",
"]",
"m1",
",",
"PrintStream",
"out",
")",
"{",
"if",
"(",
"out",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m1",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"m1",
"[",
"0",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"out",
".",
"print",
"(",
"\" \"",
"+",
"m1",
"[",
"i",
"]",
"[",
"j",
"]",
")",
";",
"}",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"}",
"}"
] |
Print array-array.
@param m1 array-array
@param out printstream
|
[
"Print",
"array",
"-",
"array",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L260-L274
|
4,562 |
timtiemens/secretshare
|
src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java
|
NumberMatrix.printResult
|
public static void printResult(Number[][] m1, Number[][] m2, Number[][] m3, char op, PrintStream out)
{
for (int i = 0; i < m1.length; i++)
{
for (int j = 0; j < m1[0].length; j++)
{
out.print(" " + m1[i][j]);
}
if (i == m1.length / 2)
{
out.print(" " + op + " ");
}
else
{
out.print(" ");
}
for (int j = 0; j < m2.length; j++)
{
out.print(" " + m2[i][j]);
}
if (i == m1.length / 2)
{
out.print(" = ");
}
else
{
out.print(" ");
}
for (int j = 0; j < m3.length; j++)
{
out.print(m3[i][j] + " ");
}
out.println();
}
}
|
java
|
public static void printResult(Number[][] m1, Number[][] m2, Number[][] m3, char op, PrintStream out)
{
for (int i = 0; i < m1.length; i++)
{
for (int j = 0; j < m1[0].length; j++)
{
out.print(" " + m1[i][j]);
}
if (i == m1.length / 2)
{
out.print(" " + op + " ");
}
else
{
out.print(" ");
}
for (int j = 0; j < m2.length; j++)
{
out.print(" " + m2[i][j]);
}
if (i == m1.length / 2)
{
out.print(" = ");
}
else
{
out.print(" ");
}
for (int j = 0; j < m3.length; j++)
{
out.print(m3[i][j] + " ");
}
out.println();
}
}
|
[
"public",
"static",
"void",
"printResult",
"(",
"Number",
"[",
"]",
"[",
"]",
"m1",
",",
"Number",
"[",
"]",
"[",
"]",
"m2",
",",
"Number",
"[",
"]",
"[",
"]",
"m3",
",",
"char",
"op",
",",
"PrintStream",
"out",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m1",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"m1",
"[",
"0",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"out",
".",
"print",
"(",
"\" \"",
"+",
"m1",
"[",
"i",
"]",
"[",
"j",
"]",
")",
";",
"}",
"if",
"(",
"i",
"==",
"m1",
".",
"length",
"/",
"2",
")",
"{",
"out",
".",
"print",
"(",
"\" \"",
"+",
"op",
"+",
"\" \"",
")",
";",
"}",
"else",
"{",
"out",
".",
"print",
"(",
"\" \"",
")",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"m2",
".",
"length",
";",
"j",
"++",
")",
"{",
"out",
".",
"print",
"(",
"\" \"",
"+",
"m2",
"[",
"i",
"]",
"[",
"j",
"]",
")",
";",
"}",
"if",
"(",
"i",
"==",
"m1",
".",
"length",
"/",
"2",
")",
"{",
"out",
".",
"print",
"(",
"\" = \"",
")",
";",
"}",
"else",
"{",
"out",
".",
"print",
"(",
"\" \"",
")",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"m3",
".",
"length",
";",
"j",
"++",
")",
"{",
"out",
".",
"print",
"(",
"m3",
"[",
"i",
"]",
"[",
"j",
"]",
"+",
"\" \"",
")",
";",
"}",
"out",
".",
"println",
"(",
")",
";",
"}",
"}"
] |
Print matrices, the operator, and their operation result.
@param m1 array-array
@param m2 array-array
@param m3 array-array
@param op operator
@param out printstream
|
[
"Print",
"matrices",
"the",
"operator",
"and",
"their",
"operation",
"result",
"."
] |
f5f88929af99ae0ed0df02dc802e40cdb25fceac
|
https://github.com/timtiemens/secretshare/blob/f5f88929af99ae0ed0df02dc802e40cdb25fceac/src/main/java/com/tiemens/secretshare/math/matrix/NumberMatrix.java#L283-L322
|
4,563 |
thorntail/wildfly-config-api
|
runtime/src/main/java/org/wildfly/swarm/config/runtime/invocation/IndexFactory.java
|
IndexFactory.createIndex
|
public synchronized static Index createIndex(Class<?> type) {
Index index = indices.get(type);
if (index == null) {
try {
Indexer indexer = new Indexer();
Class<?> currentType = type;
while ( currentType != null ) {
String className = currentType.getName().replace(".", "/") + ".class";
InputStream stream = type.getClassLoader()
.getResourceAsStream(className);
indexer.index(stream);
currentType = currentType.getSuperclass();
}
index = indexer.complete();
indices.put(type, index);
} catch (IOException e) {
throw new RuntimeException("Failed to initialize Indexer", e);
}
}
return index;
}
|
java
|
public synchronized static Index createIndex(Class<?> type) {
Index index = indices.get(type);
if (index == null) {
try {
Indexer indexer = new Indexer();
Class<?> currentType = type;
while ( currentType != null ) {
String className = currentType.getName().replace(".", "/") + ".class";
InputStream stream = type.getClassLoader()
.getResourceAsStream(className);
indexer.index(stream);
currentType = currentType.getSuperclass();
}
index = indexer.complete();
indices.put(type, index);
} catch (IOException e) {
throw new RuntimeException("Failed to initialize Indexer", e);
}
}
return index;
}
|
[
"public",
"synchronized",
"static",
"Index",
"createIndex",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"Index",
"index",
"=",
"indices",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"try",
"{",
"Indexer",
"indexer",
"=",
"new",
"Indexer",
"(",
")",
";",
"Class",
"<",
"?",
">",
"currentType",
"=",
"type",
";",
"while",
"(",
"currentType",
"!=",
"null",
")",
"{",
"String",
"className",
"=",
"currentType",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"+",
"\".class\"",
";",
"InputStream",
"stream",
"=",
"type",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"className",
")",
";",
"indexer",
".",
"index",
"(",
"stream",
")",
";",
"currentType",
"=",
"currentType",
".",
"getSuperclass",
"(",
")",
";",
"}",
"index",
"=",
"indexer",
".",
"complete",
"(",
")",
";",
"indices",
".",
"put",
"(",
"type",
",",
"index",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to initialize Indexer\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"index",
";",
"}"
] |
Creates an annotation index for the given entity type
|
[
"Creates",
"an",
"annotation",
"index",
"for",
"the",
"given",
"entity",
"type"
] |
ddb3f3bcb7b85b22c6371415546f567bc44493db
|
https://github.com/thorntail/wildfly-config-api/blob/ddb3f3bcb7b85b22c6371415546f567bc44493db/runtime/src/main/java/org/wildfly/swarm/config/runtime/invocation/IndexFactory.java#L31-L51
|
4,564 |
thorntail/wildfly-config-api
|
runtime/src/main/java/org/wildfly/swarm/config/runtime/invocation/EntityAdapter.java
|
EntityAdapter.fromChangeset
|
public ModelNode fromChangeset(Map<String, Object> changeSet, String... wildcards) {
ClassInfo clazz = null;
Class<?> currentType = getType();
while (clazz == null) {
clazz = index.getClassByName(DotName.createSimple(currentType.getCanonicalName()));
if (clazz == null) {
currentType = currentType.getSuperclass();
if (currentType == null) {
throw new RuntimeException("Unable to determine ClassInfo");
}
}
}
Address addressMeta = currentType.getDeclaredAnnotation(Address.class);
AddressTemplate address = AddressTemplate.of(addressMeta.value());
ModelNode protoType = new ModelNode();
protoType.get(ADDRESS).set(address.resolve(NOOP_CTX, wildcards));
protoType.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode operation = new ModelNode();
operation.get(OP).set(COMPOSITE);
operation.get(ADDRESS).setEmptyList();
List<ModelNode> steps = new ArrayList<ModelNode>();
for (MethodInfo method : clazz.methods()) {
if (method.hasAnnotation(IndexFactory.BINDING_META)) {
try {
Method target = currentType.getMethod(method.name());
Class<?> propertyType = target.getReturnType();
ModelNodeBinding binding = target.getDeclaredAnnotation(ModelNodeBinding.class);
String detypedName = binding.detypedName();
String javaPropName = method.name(); // in our case it's same as the method name
Object value = changeSet.get(javaPropName);
if (value == null) continue;
ModelNode step = protoType.clone();
step.get(NAME).set(javaPropName);
ModelNode modelNode = step.get(VALUE);
try {
ModelType dmrType = Types.resolveModelType(propertyType);
if (dmrType == ModelType.LIST) {
new ListTypeAdapter().toDmr(modelNode.get(detypedName), (List) value);
} else if (dmrType == ModelType.OBJECT) {
new MapTypeAdapter().toDmr(modelNode.get(detypedName), (Map) value);
} else {
new SimpleTypeAdapter().toDmr(modelNode.get(detypedName), dmrType, value);
}
} catch (RuntimeException e) {
throw new RuntimeException("Failed to adopt value " + propertyType.getName(), e);
}
steps.add(step);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
operation.get(STEPS).set(steps);
return operation;
}
|
java
|
public ModelNode fromChangeset(Map<String, Object> changeSet, String... wildcards) {
ClassInfo clazz = null;
Class<?> currentType = getType();
while (clazz == null) {
clazz = index.getClassByName(DotName.createSimple(currentType.getCanonicalName()));
if (clazz == null) {
currentType = currentType.getSuperclass();
if (currentType == null) {
throw new RuntimeException("Unable to determine ClassInfo");
}
}
}
Address addressMeta = currentType.getDeclaredAnnotation(Address.class);
AddressTemplate address = AddressTemplate.of(addressMeta.value());
ModelNode protoType = new ModelNode();
protoType.get(ADDRESS).set(address.resolve(NOOP_CTX, wildcards));
protoType.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode operation = new ModelNode();
operation.get(OP).set(COMPOSITE);
operation.get(ADDRESS).setEmptyList();
List<ModelNode> steps = new ArrayList<ModelNode>();
for (MethodInfo method : clazz.methods()) {
if (method.hasAnnotation(IndexFactory.BINDING_META)) {
try {
Method target = currentType.getMethod(method.name());
Class<?> propertyType = target.getReturnType();
ModelNodeBinding binding = target.getDeclaredAnnotation(ModelNodeBinding.class);
String detypedName = binding.detypedName();
String javaPropName = method.name(); // in our case it's same as the method name
Object value = changeSet.get(javaPropName);
if (value == null) continue;
ModelNode step = protoType.clone();
step.get(NAME).set(javaPropName);
ModelNode modelNode = step.get(VALUE);
try {
ModelType dmrType = Types.resolveModelType(propertyType);
if (dmrType == ModelType.LIST) {
new ListTypeAdapter().toDmr(modelNode.get(detypedName), (List) value);
} else if (dmrType == ModelType.OBJECT) {
new MapTypeAdapter().toDmr(modelNode.get(detypedName), (Map) value);
} else {
new SimpleTypeAdapter().toDmr(modelNode.get(detypedName), dmrType, value);
}
} catch (RuntimeException e) {
throw new RuntimeException("Failed to adopt value " + propertyType.getName(), e);
}
steps.add(step);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
operation.get(STEPS).set(steps);
return operation;
}
|
[
"public",
"ModelNode",
"fromChangeset",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"changeSet",
",",
"String",
"...",
"wildcards",
")",
"{",
"ClassInfo",
"clazz",
"=",
"null",
";",
"Class",
"<",
"?",
">",
"currentType",
"=",
"getType",
"(",
")",
";",
"while",
"(",
"clazz",
"==",
"null",
")",
"{",
"clazz",
"=",
"index",
".",
"getClassByName",
"(",
"DotName",
".",
"createSimple",
"(",
"currentType",
".",
"getCanonicalName",
"(",
")",
")",
")",
";",
"if",
"(",
"clazz",
"==",
"null",
")",
"{",
"currentType",
"=",
"currentType",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"currentType",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to determine ClassInfo\"",
")",
";",
"}",
"}",
"}",
"Address",
"addressMeta",
"=",
"currentType",
".",
"getDeclaredAnnotation",
"(",
"Address",
".",
"class",
")",
";",
"AddressTemplate",
"address",
"=",
"AddressTemplate",
".",
"of",
"(",
"addressMeta",
".",
"value",
"(",
")",
")",
";",
"ModelNode",
"protoType",
"=",
"new",
"ModelNode",
"(",
")",
";",
"protoType",
".",
"get",
"(",
"ADDRESS",
")",
".",
"set",
"(",
"address",
".",
"resolve",
"(",
"NOOP_CTX",
",",
"wildcards",
")",
")",
";",
"protoType",
".",
"get",
"(",
"OP",
")",
".",
"set",
"(",
"WRITE_ATTRIBUTE_OPERATION",
")",
";",
"ModelNode",
"operation",
"=",
"new",
"ModelNode",
"(",
")",
";",
"operation",
".",
"get",
"(",
"OP",
")",
".",
"set",
"(",
"COMPOSITE",
")",
";",
"operation",
".",
"get",
"(",
"ADDRESS",
")",
".",
"setEmptyList",
"(",
")",
";",
"List",
"<",
"ModelNode",
">",
"steps",
"=",
"new",
"ArrayList",
"<",
"ModelNode",
">",
"(",
")",
";",
"for",
"(",
"MethodInfo",
"method",
":",
"clazz",
".",
"methods",
"(",
")",
")",
"{",
"if",
"(",
"method",
".",
"hasAnnotation",
"(",
"IndexFactory",
".",
"BINDING_META",
")",
")",
"{",
"try",
"{",
"Method",
"target",
"=",
"currentType",
".",
"getMethod",
"(",
"method",
".",
"name",
"(",
")",
")",
";",
"Class",
"<",
"?",
">",
"propertyType",
"=",
"target",
".",
"getReturnType",
"(",
")",
";",
"ModelNodeBinding",
"binding",
"=",
"target",
".",
"getDeclaredAnnotation",
"(",
"ModelNodeBinding",
".",
"class",
")",
";",
"String",
"detypedName",
"=",
"binding",
".",
"detypedName",
"(",
")",
";",
"String",
"javaPropName",
"=",
"method",
".",
"name",
"(",
")",
";",
"// in our case it's same as the method name",
"Object",
"value",
"=",
"changeSet",
".",
"get",
"(",
"javaPropName",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"continue",
";",
"ModelNode",
"step",
"=",
"protoType",
".",
"clone",
"(",
")",
";",
"step",
".",
"get",
"(",
"NAME",
")",
".",
"set",
"(",
"javaPropName",
")",
";",
"ModelNode",
"modelNode",
"=",
"step",
".",
"get",
"(",
"VALUE",
")",
";",
"try",
"{",
"ModelType",
"dmrType",
"=",
"Types",
".",
"resolveModelType",
"(",
"propertyType",
")",
";",
"if",
"(",
"dmrType",
"==",
"ModelType",
".",
"LIST",
")",
"{",
"new",
"ListTypeAdapter",
"(",
")",
".",
"toDmr",
"(",
"modelNode",
".",
"get",
"(",
"detypedName",
")",
",",
"(",
"List",
")",
"value",
")",
";",
"}",
"else",
"if",
"(",
"dmrType",
"==",
"ModelType",
".",
"OBJECT",
")",
"{",
"new",
"MapTypeAdapter",
"(",
")",
".",
"toDmr",
"(",
"modelNode",
".",
"get",
"(",
"detypedName",
")",
",",
"(",
"Map",
")",
"value",
")",
";",
"}",
"else",
"{",
"new",
"SimpleTypeAdapter",
"(",
")",
".",
"toDmr",
"(",
"modelNode",
".",
"get",
"(",
"detypedName",
")",
",",
"dmrType",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to adopt value \"",
"+",
"propertyType",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"steps",
".",
"add",
"(",
"step",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"operation",
".",
"get",
"(",
"STEPS",
")",
".",
"set",
"(",
"steps",
")",
";",
"return",
"operation",
";",
"}"
] |
Turns a changeset into a composite write attribute operation.
The keys to the changeset are the java property names of the attributes that have been modified.
@param changeSet values of the java properties that changed
@return composite operation
|
[
"Turns",
"a",
"changeset",
"into",
"a",
"composite",
"write",
"attribute",
"operation",
".",
"The",
"keys",
"to",
"the",
"changeset",
"are",
"the",
"java",
"property",
"names",
"of",
"the",
"attributes",
"that",
"have",
"been",
"modified",
"."
] |
ddb3f3bcb7b85b22c6371415546f567bc44493db
|
https://github.com/thorntail/wildfly-config-api/blob/ddb3f3bcb7b85b22c6371415546f567bc44493db/runtime/src/main/java/org/wildfly/swarm/config/runtime/invocation/EntityAdapter.java#L185-L262
|
4,565 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/Preference.java
|
Preference.adaptIconTint
|
private void adaptIconTint() {
Drawable icon = getIcon();
if (icon != null) {
DrawableCompat.setTintList(icon, tintList);
DrawableCompat.setTintMode(icon, tintMode);
}
}
|
java
|
private void adaptIconTint() {
Drawable icon = getIcon();
if (icon != null) {
DrawableCompat.setTintList(icon, tintList);
DrawableCompat.setTintMode(icon, tintMode);
}
}
|
[
"private",
"void",
"adaptIconTint",
"(",
")",
"{",
"Drawable",
"icon",
"=",
"getIcon",
"(",
")",
";",
"if",
"(",
"icon",
"!=",
"null",
")",
"{",
"DrawableCompat",
".",
"setTintList",
"(",
"icon",
",",
"tintList",
")",
";",
"DrawableCompat",
".",
"setTintMode",
"(",
"icon",
",",
"tintMode",
")",
";",
"}",
"}"
] |
Adapts the tint of the preference's icon.
|
[
"Adapts",
"the",
"tint",
"of",
"the",
"preference",
"s",
"icon",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/Preference.java#L135-L142
|
4,566 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ActionPreference.java
|
ActionPreference.obtainTextColor
|
private void obtainTextColor(@NonNull final TypedArray typedArray) {
ColorStateList colorStateList =
typedArray.getColorStateList(R.styleable.ActionPreference_android_textColor);
if (colorStateList == null) {
colorStateList = ContextCompat
.getColorStateList(getContext(), R.color.action_preference_text_color);
}
setTextColor(colorStateList);
}
|
java
|
private void obtainTextColor(@NonNull final TypedArray typedArray) {
ColorStateList colorStateList =
typedArray.getColorStateList(R.styleable.ActionPreference_android_textColor);
if (colorStateList == null) {
colorStateList = ContextCompat
.getColorStateList(getContext(), R.color.action_preference_text_color);
}
setTextColor(colorStateList);
}
|
[
"private",
"void",
"obtainTextColor",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"ColorStateList",
"colorStateList",
"=",
"typedArray",
".",
"getColorStateList",
"(",
"R",
".",
"styleable",
".",
"ActionPreference_android_textColor",
")",
";",
"if",
"(",
"colorStateList",
"==",
"null",
")",
"{",
"colorStateList",
"=",
"ContextCompat",
".",
"getColorStateList",
"(",
"getContext",
"(",
")",
",",
"R",
".",
"color",
".",
"action_preference_text_color",
")",
";",
"}",
"setTextColor",
"(",
"colorStateList",
")",
";",
"}"
] |
Obtains the text color of the preference's title from a specific typed array.
@param typedArray
The typed array, the color should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"text",
"color",
"of",
"the",
"preference",
"s",
"title",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ActionPreference.java#L110-L120
|
4,567 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java
|
DigitPickerPreference.obtainNumberOfDigits
|
private void obtainNumberOfDigits(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.digit_picker_preference_default_number_of_digits);
setNumberOfDigits(typedArray
.getInteger(R.styleable.DigitPickerPreference_numberOfDigits, defaultValue));
}
|
java
|
private void obtainNumberOfDigits(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.digit_picker_preference_default_number_of_digits);
setNumberOfDigits(typedArray
.getInteger(R.styleable.DigitPickerPreference_numberOfDigits, defaultValue));
}
|
[
"private",
"void",
"obtainNumberOfDigits",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"digit_picker_preference_default_number_of_digits",
")",
";",
"setNumberOfDigits",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"DigitPickerPreference_numberOfDigits",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the number of digits of the numbers, the preference allows to choose, from a specific
typed array.
@param typedArray
The typed array, the number of digits should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"number",
"of",
"digits",
"of",
"the",
"numbers",
"the",
"preference",
"allows",
"to",
"choose",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java#L176-L181
|
4,568 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java
|
DigitPickerPreference.getDigit
|
private int getDigit(final int index, final int number) {
String format = "%0" + getNumberOfDigits() + "d";
String formattedNumber = String.format(Locale.getDefault(), format, number);
String digit = formattedNumber.substring(index, index + 1);
return Integer.valueOf(digit);
}
|
java
|
private int getDigit(final int index, final int number) {
String format = "%0" + getNumberOfDigits() + "d";
String formattedNumber = String.format(Locale.getDefault(), format, number);
String digit = formattedNumber.substring(index, index + 1);
return Integer.valueOf(digit);
}
|
[
"private",
"int",
"getDigit",
"(",
"final",
"int",
"index",
",",
"final",
"int",
"number",
")",
"{",
"String",
"format",
"=",
"\"%0\"",
"+",
"getNumberOfDigits",
"(",
")",
"+",
"\"d\"",
";",
"String",
"formattedNumber",
"=",
"String",
".",
"format",
"(",
"Locale",
".",
"getDefault",
"(",
")",
",",
"format",
",",
"number",
")",
";",
"String",
"digit",
"=",
"formattedNumber",
".",
"substring",
"(",
"index",
",",
"index",
"+",
"1",
")",
";",
"return",
"Integer",
".",
"valueOf",
"(",
"digit",
")",
";",
"}"
] |
Returns the the digit, which corresponds to a specific index of a number.
@param index
The index of the digit, which should be retrieved, as an {@link Integer} value
@param number
The number, which contains the digit, which should be retrieved, as an {@link
Integer} value
@return The digit, which corresponds to the given index, as an {@link Integer} value
|
[
"Returns",
"the",
"the",
"digit",
"which",
"corresponds",
"to",
"a",
"specific",
"index",
"of",
"a",
"number",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java#L219-L224
|
4,569 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java
|
DigitPickerPreference.getMaxNumber
|
private int getMaxNumber(final int numberOfDigits) {
int result = 0;
for (int i = 0; i < numberOfDigits; i++) {
result += (NUMERIC_SYTEM - 1) * Math.pow(NUMERIC_SYTEM, i);
}
return result;
}
|
java
|
private int getMaxNumber(final int numberOfDigits) {
int result = 0;
for (int i = 0; i < numberOfDigits; i++) {
result += (NUMERIC_SYTEM - 1) * Math.pow(NUMERIC_SYTEM, i);
}
return result;
}
|
[
"private",
"int",
"getMaxNumber",
"(",
"final",
"int",
"numberOfDigits",
")",
"{",
"int",
"result",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfDigits",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"(",
"NUMERIC_SYTEM",
"-",
"1",
")",
"*",
"Math",
".",
"pow",
"(",
"NUMERIC_SYTEM",
",",
"i",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns the maximum number, which can be created with a specific number of digits.
@param numberOfDigits
The number of digits as an {@link Integer} value
@return The maximum number, which can be created with the given number of digits, as an
{@link Integer} value
|
[
"Returns",
"the",
"maximum",
"number",
"which",
"can",
"be",
"created",
"with",
"a",
"specific",
"number",
"of",
"digits",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java#L234-L242
|
4,570 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java
|
DigitPickerPreference.setNumberOfDigits
|
public final void setNumberOfDigits(final int numberOfDigits) {
Condition.INSTANCE
.ensureAtLeast(numberOfDigits, 1, "The number of digits must be at least 1");
this.numberOfDigits = numberOfDigits;
setNumber(Math.min(getNumber(), getMaxNumber(numberOfDigits)));
}
|
java
|
public final void setNumberOfDigits(final int numberOfDigits) {
Condition.INSTANCE
.ensureAtLeast(numberOfDigits, 1, "The number of digits must be at least 1");
this.numberOfDigits = numberOfDigits;
setNumber(Math.min(getNumber(), getMaxNumber(numberOfDigits)));
}
|
[
"public",
"final",
"void",
"setNumberOfDigits",
"(",
"final",
"int",
"numberOfDigits",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"numberOfDigits",
",",
"1",
",",
"\"The number of digits must be at least 1\"",
")",
";",
"this",
".",
"numberOfDigits",
"=",
"numberOfDigits",
";",
"setNumber",
"(",
"Math",
".",
"min",
"(",
"getNumber",
"(",
")",
",",
"getMaxNumber",
"(",
"numberOfDigits",
")",
")",
")",
";",
"}"
] |
Sets the number of digits of the numbers, the preference should allow to choose.
@param numberOfDigits
The number of digits, which should be set, as an {@link Integer} value. The number of
digits must be at least 1
|
[
"Sets",
"the",
"number",
"of",
"digits",
"of",
"the",
"numbers",
"the",
"preference",
"should",
"allow",
"to",
"choose",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/DigitPickerPreference.java#L348-L353
|
4,571 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainDecimals
|
private void obtainDecimals(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_decimals);
setDecimals(typedArray.getInteger(R.styleable.SeekBarPreference_decimals, defaultValue));
}
|
java
|
private void obtainDecimals(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_decimals);
setDecimals(typedArray.getInteger(R.styleable.SeekBarPreference_decimals, defaultValue));
}
|
[
"private",
"void",
"obtainDecimals",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"seek_bar_preference_default_decimals",
")",
";",
"setDecimals",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"SeekBarPreference_decimals",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the number of decimals of the floating point numbers, the preference allows to
choose, from a specific typed array.
@param typedArray
The typed array, the number of decimals should be obtained from, as an instance of
the class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"number",
"of",
"decimals",
"of",
"the",
"floating",
"point",
"numbers",
"the",
"preference",
"allows",
"to",
"choose",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L261-L265
|
4,572 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainMinValue
|
private void obtainMinValue(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_min_value);
setMinValue(typedArray.getInteger(R.styleable.AbstractNumericPreference_min, defaultValue));
}
|
java
|
private void obtainMinValue(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_min_value);
setMinValue(typedArray.getInteger(R.styleable.AbstractNumericPreference_min, defaultValue));
}
|
[
"private",
"void",
"obtainMinValue",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"seek_bar_preference_default_min_value",
")",
";",
"setMinValue",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"AbstractNumericPreference_min",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the minimum value, the preference allows to choose, from a specific typed array.
@param typedArray
The typed array, the minimum value should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"minimum",
"value",
"the",
"preference",
"allows",
"to",
"choose",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L274-L278
|
4,573 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainMaxValue
|
private void obtainMaxValue(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_max_value);
setMaxValue(typedArray
.getInteger(R.styleable.AbstractNumericPreference_android_max, defaultValue));
}
|
java
|
private void obtainMaxValue(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.seek_bar_preference_default_max_value);
setMaxValue(typedArray
.getInteger(R.styleable.AbstractNumericPreference_android_max, defaultValue));
}
|
[
"private",
"void",
"obtainMaxValue",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"seek_bar_preference_default_max_value",
")",
";",
"setMaxValue",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"AbstractNumericPreference_android_max",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the maximum value, the preference allows to choose, from a specific typed array.
@param typedArray
The typed array, the maximum value should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"maximum",
"value",
"the",
"preference",
"allows",
"to",
"choose",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L287-L292
|
4,574 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainUnit
|
private void obtainUnit(@NonNull final TypedArray typedArray) {
setUnit(typedArray.getText(R.styleable.AbstractUnitPreference_unit));
}
|
java
|
private void obtainUnit(@NonNull final TypedArray typedArray) {
setUnit(typedArray.getText(R.styleable.AbstractUnitPreference_unit));
}
|
[
"private",
"void",
"obtainUnit",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"setUnit",
"(",
"typedArray",
".",
"getText",
"(",
"R",
".",
"styleable",
".",
"AbstractUnitPreference_unit",
")",
")",
";",
"}"
] |
Obtains the unit, which is used for textual representation of the preference's value, from a
specific typed array.
@param typedArray
The typed array, the unit should be obtained from, as an instance of the class {@link
TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"unit",
"which",
"is",
"used",
"for",
"textual",
"representation",
"of",
"the",
"preference",
"s",
"value",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L317-L319
|
4,575 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainFloatingPointSeparator
|
private void obtainFloatingPointSeparator(@NonNull final TypedArray typedArray) {
setFloatingPointSeparator(
typedArray.getText(R.styleable.SeekBarPreference_floatingPointSeparator));
}
|
java
|
private void obtainFloatingPointSeparator(@NonNull final TypedArray typedArray) {
setFloatingPointSeparator(
typedArray.getText(R.styleable.SeekBarPreference_floatingPointSeparator));
}
|
[
"private",
"void",
"obtainFloatingPointSeparator",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"setFloatingPointSeparator",
"(",
"typedArray",
".",
"getText",
"(",
"R",
".",
"styleable",
".",
"SeekBarPreference_floatingPointSeparator",
")",
")",
";",
"}"
] |
Obtains the symbol, which is used to separate floating point numbers for textual
representation, from a specific typed array.
@param typedArray
The typed array, the symbol should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"symbol",
"which",
"is",
"used",
"to",
"separate",
"floating",
"point",
"numbers",
"for",
"textual",
"representation",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L329-L332
|
4,576 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainShowProgress
|
private void obtainShowProgress(@NonNull final TypedArray typedArray) {
boolean defaultValue = getContext().getResources()
.getBoolean(R.bool.seek_bar_preference_default_show_progress);
showProgress(
typedArray.getBoolean(R.styleable.SeekBarPreference_showProgress, defaultValue));
}
|
java
|
private void obtainShowProgress(@NonNull final TypedArray typedArray) {
boolean defaultValue = getContext().getResources()
.getBoolean(R.bool.seek_bar_preference_default_show_progress);
showProgress(
typedArray.getBoolean(R.styleable.SeekBarPreference_showProgress, defaultValue));
}
|
[
"private",
"void",
"obtainShowProgress",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"boolean",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getBoolean",
"(",
"R",
".",
"bool",
".",
"seek_bar_preference_default_show_progress",
")",
";",
"showProgress",
"(",
"typedArray",
".",
"getBoolean",
"(",
"R",
".",
"styleable",
".",
"SeekBarPreference_showProgress",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the boolean value, which specifies whether the progress of the seek bar should be
shown, from a specific typed array.
@param typedArray
The typed array, the boolean value should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"boolean",
"value",
"which",
"specifies",
"whether",
"the",
"progress",
"of",
"the",
"seek",
"bar",
"should",
"be",
"shown",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L342-L347
|
4,577 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.obtainSummaries
|
private void obtainSummaries(@NonNull final TypedArray typedArray) {
try {
setSummaries(typedArray.getTextArray(R.styleable.SeekBarPreference_android_summary));
} catch (Resources.NotFoundException e) {
setSummaries(null);
}
}
|
java
|
private void obtainSummaries(@NonNull final TypedArray typedArray) {
try {
setSummaries(typedArray.getTextArray(R.styleable.SeekBarPreference_android_summary));
} catch (Resources.NotFoundException e) {
setSummaries(null);
}
}
|
[
"private",
"void",
"obtainSummaries",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"try",
"{",
"setSummaries",
"(",
"typedArray",
".",
"getTextArray",
"(",
"R",
".",
"styleable",
".",
"SeekBarPreference_android_summary",
")",
")",
";",
"}",
"catch",
"(",
"Resources",
".",
"NotFoundException",
"e",
")",
"{",
"setSummaries",
"(",
"null",
")",
";",
"}",
"}"
] |
Obtains the summaries, which are shown depending on the currently persisted value, from a
specific typed array.
@param typedArray
The typed array, the summaries should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"summaries",
"which",
"are",
"shown",
"depending",
"on",
"the",
"currently",
"persisted",
"value",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L357-L363
|
4,578 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.createSeekBarListener
|
private OnSeekBarChangeListener createSeekBarListener(
@NonNull final TextView progressTextView) {
return new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(final android.widget.SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(final android.widget.SeekBar seekBar) {
}
@Override
public void onProgressChanged(final android.widget.SeekBar seekBar, final int progress,
final boolean fromUser) {
currentValue = (float) getMinValue() + (float) progress / (float) getMultiplier();
currentValue = adaptToStepSize(currentValue);
progressTextView.setText(getProgressText(currentValue));
}
};
}
|
java
|
private OnSeekBarChangeListener createSeekBarListener(
@NonNull final TextView progressTextView) {
return new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(final android.widget.SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(final android.widget.SeekBar seekBar) {
}
@Override
public void onProgressChanged(final android.widget.SeekBar seekBar, final int progress,
final boolean fromUser) {
currentValue = (float) getMinValue() + (float) progress / (float) getMultiplier();
currentValue = adaptToStepSize(currentValue);
progressTextView.setText(getProgressText(currentValue));
}
};
}
|
[
"private",
"OnSeekBarChangeListener",
"createSeekBarListener",
"(",
"@",
"NonNull",
"final",
"TextView",
"progressTextView",
")",
"{",
"return",
"new",
"OnSeekBarChangeListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onStopTrackingTouch",
"(",
"final",
"android",
".",
"widget",
".",
"SeekBar",
"seekBar",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onStartTrackingTouch",
"(",
"final",
"android",
".",
"widget",
".",
"SeekBar",
"seekBar",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onProgressChanged",
"(",
"final",
"android",
".",
"widget",
".",
"SeekBar",
"seekBar",
",",
"final",
"int",
"progress",
",",
"final",
"boolean",
"fromUser",
")",
"{",
"currentValue",
"=",
"(",
"float",
")",
"getMinValue",
"(",
")",
"+",
"(",
"float",
")",
"progress",
"/",
"(",
"float",
")",
"getMultiplier",
"(",
")",
";",
"currentValue",
"=",
"adaptToStepSize",
"(",
"currentValue",
")",
";",
"progressTextView",
".",
"setText",
"(",
"getProgressText",
"(",
"currentValue",
")",
")",
";",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to display the currently chosen value of the
pereference's seek bar. The current value is internally stored, but it will not become
persisted, until the user's confirmation.
@param progressTextView
The text view, which should be used to display the currently chosen value, as an
instance of the class {@link TextView}. The text view may not be null
@return The listener, which has been created, as an instance of the type {@link
OnSeekBarChangeListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"display",
"the",
"currently",
"chosen",
"value",
"of",
"the",
"pereference",
"s",
"seek",
"bar",
".",
"The",
"current",
"value",
"is",
"internally",
"stored",
"but",
"it",
"will",
"not",
"become",
"persisted",
"until",
"the",
"user",
"s",
"confirmation",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L399-L422
|
4,579 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.adaptToStepSize
|
private float adaptToStepSize(final float value) {
if (getStepSize() > 0) {
float offset = value - getMinValue();
float mod = offset % getStepSize();
float halfStepSize = (float) getStepSize() / 2.0f;
float result = ((mod > halfStepSize) ? offset + getStepSize() - mod : offset - mod) +
getMinValue();
return Math.min(result, getMaxValue());
}
return value;
}
|
java
|
private float adaptToStepSize(final float value) {
if (getStepSize() > 0) {
float offset = value - getMinValue();
float mod = offset % getStepSize();
float halfStepSize = (float) getStepSize() / 2.0f;
float result = ((mod > halfStepSize) ? offset + getStepSize() - mod : offset - mod) +
getMinValue();
return Math.min(result, getMaxValue());
}
return value;
}
|
[
"private",
"float",
"adaptToStepSize",
"(",
"final",
"float",
"value",
")",
"{",
"if",
"(",
"getStepSize",
"(",
")",
">",
"0",
")",
"{",
"float",
"offset",
"=",
"value",
"-",
"getMinValue",
"(",
")",
";",
"float",
"mod",
"=",
"offset",
"%",
"getStepSize",
"(",
")",
";",
"float",
"halfStepSize",
"=",
"(",
"float",
")",
"getStepSize",
"(",
")",
"/",
"2.0f",
";",
"float",
"result",
"=",
"(",
"(",
"mod",
">",
"halfStepSize",
")",
"?",
"offset",
"+",
"getStepSize",
"(",
")",
"-",
"mod",
":",
"offset",
"-",
"mod",
")",
"+",
"getMinValue",
"(",
")",
";",
"return",
"Math",
".",
"min",
"(",
"result",
",",
"getMaxValue",
"(",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Adapts a specific value to the step size, which is currently set. The value will be decreased
or increased to the numerically closest value, which matches the step size.
@param value
The value, which should be adapted to the step size, as a {@link Float} value
@return The adapted value as a {@link Float} value
|
[
"Adapts",
"a",
"specific",
"value",
"to",
"the",
"step",
"size",
"which",
"is",
"currently",
"set",
".",
"The",
"value",
"will",
"be",
"decreased",
"or",
"increased",
"to",
"the",
"numerically",
"closest",
"value",
"which",
"matches",
"the",
"step",
"size",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L432-L443
|
4,580 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.getProgressText
|
private String getProgressText(final float value) {
NumberFormat numberFormat = NumberFormat.getInstance();
if (getFloatingPointSeparator() != null && numberFormat instanceof DecimalFormat) {
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
decimalFormatSymbols.setDecimalSeparator(getFloatingPointSeparator().charAt(0));
((DecimalFormat) numberFormat).setDecimalFormatSymbols(decimalFormatSymbols);
}
numberFormat.setMinimumFractionDigits(getDecimals());
numberFormat.setMaximumFractionDigits(getDecimals());
String valueString = numberFormat.format(value);
if (!TextUtils.isEmpty(getUnit())) {
return valueString + " " + getUnit();
}
return valueString;
}
|
java
|
private String getProgressText(final float value) {
NumberFormat numberFormat = NumberFormat.getInstance();
if (getFloatingPointSeparator() != null && numberFormat instanceof DecimalFormat) {
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
decimalFormatSymbols.setDecimalSeparator(getFloatingPointSeparator().charAt(0));
((DecimalFormat) numberFormat).setDecimalFormatSymbols(decimalFormatSymbols);
}
numberFormat.setMinimumFractionDigits(getDecimals());
numberFormat.setMaximumFractionDigits(getDecimals());
String valueString = numberFormat.format(value);
if (!TextUtils.isEmpty(getUnit())) {
return valueString + " " + getUnit();
}
return valueString;
}
|
[
"private",
"String",
"getProgressText",
"(",
"final",
"float",
"value",
")",
"{",
"NumberFormat",
"numberFormat",
"=",
"NumberFormat",
".",
"getInstance",
"(",
")",
";",
"if",
"(",
"getFloatingPointSeparator",
"(",
")",
"!=",
"null",
"&&",
"numberFormat",
"instanceof",
"DecimalFormat",
")",
"{",
"DecimalFormatSymbols",
"decimalFormatSymbols",
"=",
"new",
"DecimalFormatSymbols",
"(",
")",
";",
"decimalFormatSymbols",
".",
"setDecimalSeparator",
"(",
"getFloatingPointSeparator",
"(",
")",
".",
"charAt",
"(",
"0",
")",
")",
";",
"(",
"(",
"DecimalFormat",
")",
"numberFormat",
")",
".",
"setDecimalFormatSymbols",
"(",
"decimalFormatSymbols",
")",
";",
"}",
"numberFormat",
".",
"setMinimumFractionDigits",
"(",
"getDecimals",
"(",
")",
")",
";",
"numberFormat",
".",
"setMaximumFractionDigits",
"(",
"getDecimals",
"(",
")",
")",
";",
"String",
"valueString",
"=",
"numberFormat",
".",
"format",
"(",
"value",
")",
";",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"getUnit",
"(",
")",
")",
")",
"{",
"return",
"valueString",
"+",
"\" \"",
"+",
"getUnit",
"(",
")",
";",
"}",
"return",
"valueString",
";",
"}"
] |
Returns a textual representation of a specific value. The text is formatted depending on the
decimal separator, which is currently set and contains the unit, if currently set.
@param value
The value, whose textual representation should be returned, as a {@link Float} value
@return A textual representation of the given value as a {@link String}
|
[
"Returns",
"a",
"textual",
"representation",
"of",
"a",
"specific",
"value",
".",
"The",
"text",
"is",
"formatted",
"depending",
"on",
"the",
"decimal",
"separator",
"which",
"is",
"currently",
"set",
"and",
"contains",
"the",
"unit",
"if",
"currently",
"set",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L453-L471
|
4,581 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.setMinValue
|
public final void setMinValue(final int minValue) {
Condition.INSTANCE.ensureSmaller(minValue, getMaxValue(),
"The minimum value must be less than the maximum value");
this.minValue = minValue;
setValue(Math.max(getValue(), minValue));
}
|
java
|
public final void setMinValue(final int minValue) {
Condition.INSTANCE.ensureSmaller(minValue, getMaxValue(),
"The minimum value must be less than the maximum value");
this.minValue = minValue;
setValue(Math.max(getValue(), minValue));
}
|
[
"public",
"final",
"void",
"setMinValue",
"(",
"final",
"int",
"minValue",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureSmaller",
"(",
"minValue",
",",
"getMaxValue",
"(",
")",
",",
"\"The minimum value must be less than the maximum value\"",
")",
";",
"this",
".",
"minValue",
"=",
"minValue",
";",
"setValue",
"(",
"Math",
".",
"max",
"(",
"getValue",
"(",
")",
",",
"minValue",
")",
")",
";",
"}"
] |
Sets the minimum value, the preference should allow to choose.
@param minValue
The minimum value, which should be set, as an {@link Integer} value. The value must
be less than the maximum value, the preference allows to choose
|
[
"Sets",
"the",
"minimum",
"value",
"the",
"preference",
"should",
"allow",
"to",
"choose",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L611-L616
|
4,582 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.setMaxValue
|
public final void setMaxValue(final int maxValue) {
Condition.INSTANCE.ensureGreater(maxValue, getMinValue(),
"The maximum value must be greater than the minimum value");
this.maxValue = maxValue;
setValue(Math.min(getValue(), maxValue));
}
|
java
|
public final void setMaxValue(final int maxValue) {
Condition.INSTANCE.ensureGreater(maxValue, getMinValue(),
"The maximum value must be greater than the minimum value");
this.maxValue = maxValue;
setValue(Math.min(getValue(), maxValue));
}
|
[
"public",
"final",
"void",
"setMaxValue",
"(",
"final",
"int",
"maxValue",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureGreater",
"(",
"maxValue",
",",
"getMinValue",
"(",
")",
",",
"\"The maximum value must be greater than the minimum value\"",
")",
";",
"this",
".",
"maxValue",
"=",
"maxValue",
";",
"setValue",
"(",
"Math",
".",
"min",
"(",
"getValue",
"(",
")",
",",
"maxValue",
")",
")",
";",
"}"
] |
Sets the maximum value, the preference should allow to choose.
@param maxValue
The maximum value, which should be set, as an {@link Integer} value. The value must
be greater than the minimum value, that preference allows to choose
|
[
"Sets",
"the",
"maximum",
"value",
"the",
"preference",
"should",
"allow",
"to",
"choose",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L634-L639
|
4,583 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.setStepSize
|
public final void setStepSize(final int stepSize) {
if (stepSize != -1) {
Condition.INSTANCE.ensureAtLeast(stepSize, 1, "The step size must be at least 1");
Condition.INSTANCE.ensureAtMaximum(stepSize, getRange(),
"The step size must be at maximum the range");
}
this.stepSize = stepSize;
setValue(adaptToStepSize(getValue()));
}
|
java
|
public final void setStepSize(final int stepSize) {
if (stepSize != -1) {
Condition.INSTANCE.ensureAtLeast(stepSize, 1, "The step size must be at least 1");
Condition.INSTANCE.ensureAtMaximum(stepSize, getRange(),
"The step size must be at maximum the range");
}
this.stepSize = stepSize;
setValue(adaptToStepSize(getValue()));
}
|
[
"public",
"final",
"void",
"setStepSize",
"(",
"final",
"int",
"stepSize",
")",
"{",
"if",
"(",
"stepSize",
"!=",
"-",
"1",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"stepSize",
",",
"1",
",",
"\"The step size must be at least 1\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureAtMaximum",
"(",
"stepSize",
",",
"getRange",
"(",
")",
",",
"\"The step size must be at maximum the range\"",
")",
";",
"}",
"this",
".",
"stepSize",
"=",
"stepSize",
";",
"setValue",
"(",
"adaptToStepSize",
"(",
"getValue",
"(",
")",
")",
")",
";",
"}"
] |
Sets the step size, the value should be increased or decreased by, when moving the seek bar.
@param stepSize
The step size, which should be set, as an {@link Integer} value. The value must be at
least 1 and at maximum the value of the method <code>getRange():int</code> or -1, if
the preference should allow to select a value from a continuous range
|
[
"Sets",
"the",
"step",
"size",
"the",
"value",
"should",
"be",
"increased",
"or",
"decreased",
"by",
"when",
"moving",
"the",
"seek",
"bar",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L669-L678
|
4,584 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.setDecimals
|
public final void setDecimals(final int decimals) {
Condition.INSTANCE.ensureAtLeast(decimals, 0, "The decimals must be at least 0");
this.decimals = decimals;
setValue(roundToDecimals(getValue()));
}
|
java
|
public final void setDecimals(final int decimals) {
Condition.INSTANCE.ensureAtLeast(decimals, 0, "The decimals must be at least 0");
this.decimals = decimals;
setValue(roundToDecimals(getValue()));
}
|
[
"public",
"final",
"void",
"setDecimals",
"(",
"final",
"int",
"decimals",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"decimals",
",",
"0",
",",
"\"The decimals must be at least 0\"",
")",
";",
"this",
".",
"decimals",
"=",
"decimals",
";",
"setValue",
"(",
"roundToDecimals",
"(",
"getValue",
"(",
")",
")",
")",
";",
"}"
] |
Sets the number of decimals of the floating point numbers, the preference should allow to
choose. If the number of decimals is set to 0, the preference will only allow to choose
integer values.
@param decimals
The number of decimals, which should be set, as an {@link Integer} value. The value
must be at least 0. If the value is set to 0, the preference will only allow to
choose integer values
|
[
"Sets",
"the",
"number",
"of",
"decimals",
"of",
"the",
"floating",
"point",
"numbers",
"the",
"preference",
"should",
"allow",
"to",
"choose",
".",
"If",
"the",
"number",
"of",
"decimals",
"is",
"set",
"to",
"0",
"the",
"preference",
"will",
"only",
"allow",
"to",
"choose",
"integer",
"values",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L702-L706
|
4,585 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java
|
SeekBarPreference.setFloatingPointSeparator
|
public final void setFloatingPointSeparator(
@Nullable final CharSequence floatingPointSeparator) {
if (floatingPointSeparator != null) {
Condition.INSTANCE.ensureAtMaximum(floatingPointSeparator.length(), 1,
"The floating point separator's length must be 1");
}
this.floatingPointSeparator = floatingPointSeparator;
}
|
java
|
public final void setFloatingPointSeparator(
@Nullable final CharSequence floatingPointSeparator) {
if (floatingPointSeparator != null) {
Condition.INSTANCE.ensureAtMaximum(floatingPointSeparator.length(), 1,
"The floating point separator's length must be 1");
}
this.floatingPointSeparator = floatingPointSeparator;
}
|
[
"public",
"final",
"void",
"setFloatingPointSeparator",
"(",
"@",
"Nullable",
"final",
"CharSequence",
"floatingPointSeparator",
")",
"{",
"if",
"(",
"floatingPointSeparator",
"!=",
"null",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtMaximum",
"(",
"floatingPointSeparator",
".",
"length",
"(",
")",
",",
"1",
",",
"\"The floating point separator's length must be 1\"",
")",
";",
"}",
"this",
".",
"floatingPointSeparator",
"=",
"floatingPointSeparator",
";",
"}"
] |
Sets the symbol, which should be used to separate floating point numbers for textual
representation.
@param floatingPointSeparator
The symbol, which should be set, as an instance of the type {@link CharSequence} or
null, if the default symbol should be used. The length of the symbol must be 1
|
[
"Sets",
"the",
"symbol",
"which",
"should",
"be",
"used",
"to",
"separate",
"floating",
"point",
"numbers",
"for",
"textual",
"representation",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SeekBarPreference.java#L760-L767
|
4,586 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/view/SeekBar.java
|
SeekBar.applyTheme
|
private void applyTheme() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setSeekBarColor(ThemeUtil.getColor(getContext(), R.attr.colorAccent));
}
}
|
java
|
private void applyTheme() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setSeekBarColor(ThemeUtil.getColor(getContext(), R.attr.colorAccent));
}
}
|
[
"private",
"void",
"applyTheme",
"(",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"{",
"setSeekBarColor",
"(",
"ThemeUtil",
".",
"getColor",
"(",
"getContext",
"(",
")",
",",
"R",
".",
"attr",
".",
"colorAccent",
")",
")",
";",
"}",
"}"
] |
Applies the attributes of the context's theme on the seek bar.
|
[
"Applies",
"the",
"attributes",
"of",
"the",
"context",
"s",
"theme",
"on",
"the",
"seek",
"bar",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/view/SeekBar.java#L55-L59
|
4,587 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/view/SeekBar.java
|
SeekBar.setSeekBarColor
|
public final void setSeekBarColor(@ColorInt final int color) {
this.seekBarColor = color;
ColorFilter colorFilter = new PorterDuffColorFilter(color, Mode.SRC_IN);
getProgressDrawable().setColorFilter(colorFilter);
getThumbDrawable().setColorFilter(colorFilter);
}
|
java
|
public final void setSeekBarColor(@ColorInt final int color) {
this.seekBarColor = color;
ColorFilter colorFilter = new PorterDuffColorFilter(color, Mode.SRC_IN);
getProgressDrawable().setColorFilter(colorFilter);
getThumbDrawable().setColorFilter(colorFilter);
}
|
[
"public",
"final",
"void",
"setSeekBarColor",
"(",
"@",
"ColorInt",
"final",
"int",
"color",
")",
"{",
"this",
".",
"seekBarColor",
"=",
"color",
";",
"ColorFilter",
"colorFilter",
"=",
"new",
"PorterDuffColorFilter",
"(",
"color",
",",
"Mode",
".",
"SRC_IN",
")",
";",
"getProgressDrawable",
"(",
")",
".",
"setColorFilter",
"(",
"colorFilter",
")",
";",
"getThumbDrawable",
"(",
")",
".",
"setColorFilter",
"(",
"colorFilter",
")",
";",
"}"
] |
Sets the color of the seek bar.
@param color
The color, which should be set as an {@link Integer} value
|
[
"Sets",
"the",
"color",
"of",
"the",
"seek",
"bar",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/view/SeekBar.java#L123-L128
|
4,588 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/adapter/ColorPaletteAdapter.java
|
ColorPaletteAdapter.indexOf
|
public final int indexOf(@ColorInt final int color) {
for (int i = 0; i < colorPalette.length; i++) {
if (colorPalette[i] == color) {
return i;
}
}
return -1;
}
|
java
|
public final int indexOf(@ColorInt final int color) {
for (int i = 0; i < colorPalette.length; i++) {
if (colorPalette[i] == color) {
return i;
}
}
return -1;
}
|
[
"public",
"final",
"int",
"indexOf",
"(",
"@",
"ColorInt",
"final",
"int",
"color",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"colorPalette",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"colorPalette",
"[",
"i",
"]",
"==",
"color",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Returns the index of a specific color.
@param color
The color, whose index should be returned, as an {@link Integer} value
@return The index of the given color or -1, if the adapter does not contain the color
|
[
"Returns",
"the",
"index",
"of",
"a",
"specific",
"color",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/adapter/ColorPaletteAdapter.java#L110-L118
|
4,589 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SwitchPreference.java
|
SwitchPreference.obtainSwitchTextOn
|
private void obtainSwitchTextOn(@NonNull final TypedArray typedArray) {
setSwitchTextOn(typedArray.getText(R.styleable.SwitchPreference_android_switchTextOn));
}
|
java
|
private void obtainSwitchTextOn(@NonNull final TypedArray typedArray) {
setSwitchTextOn(typedArray.getText(R.styleable.SwitchPreference_android_switchTextOn));
}
|
[
"private",
"void",
"obtainSwitchTextOn",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"setSwitchTextOn",
"(",
"typedArray",
".",
"getText",
"(",
"R",
".",
"styleable",
".",
"SwitchPreference_android_switchTextOn",
")",
")",
";",
"}"
] |
Obtains the text, which should be displayed on the preference's switch, when it is checked,
from a specific typed array.
@param typedArray
The typed array, the text should be obtained from, as an instance of the class {@link
TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"text",
"which",
"should",
"be",
"displayed",
"on",
"the",
"preference",
"s",
"switch",
"when",
"it",
"is",
"checked",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SwitchPreference.java#L117-L119
|
4,590 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SwitchPreference.java
|
SwitchPreference.obtainSwitchTextOff
|
private void obtainSwitchTextOff(@NonNull final TypedArray typedArray) {
setSwitchTextOff(typedArray.getText(R.styleable.SwitchPreference_android_switchTextOff));
}
|
java
|
private void obtainSwitchTextOff(@NonNull final TypedArray typedArray) {
setSwitchTextOff(typedArray.getText(R.styleable.SwitchPreference_android_switchTextOff));
}
|
[
"private",
"void",
"obtainSwitchTextOff",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"setSwitchTextOff",
"(",
"typedArray",
".",
"getText",
"(",
"R",
".",
"styleable",
".",
"SwitchPreference_android_switchTextOff",
")",
")",
";",
"}"
] |
Obtains the text, which should be displayed on the preference's switch, when it is not
checked, from a specific typed array.
@param typedArray
The typed array, the text should be obtained from, as an instance of the class {@link
TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"text",
"which",
"should",
"be",
"displayed",
"on",
"the",
"preference",
"s",
"switch",
"when",
"it",
"is",
"not",
"checked",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SwitchPreference.java#L129-L131
|
4,591 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SwitchPreference.java
|
SwitchPreference.adaptSwitch
|
private void adaptSwitch() {
if (switchWidget != null) {
switchWidget.setTextOn(getSwitchTextOn());
switchWidget.setTextOff(getSwitchTextOff());
switchWidget.setShowText(!TextUtils.isEmpty(getSwitchTextOn()) ||
!TextUtils.isEmpty(getSwitchTextOff()));
switchWidget.setChecked(isChecked());
}
}
|
java
|
private void adaptSwitch() {
if (switchWidget != null) {
switchWidget.setTextOn(getSwitchTextOn());
switchWidget.setTextOff(getSwitchTextOff());
switchWidget.setShowText(!TextUtils.isEmpty(getSwitchTextOn()) ||
!TextUtils.isEmpty(getSwitchTextOff()));
switchWidget.setChecked(isChecked());
}
}
|
[
"private",
"void",
"adaptSwitch",
"(",
")",
"{",
"if",
"(",
"switchWidget",
"!=",
"null",
")",
"{",
"switchWidget",
".",
"setTextOn",
"(",
"getSwitchTextOn",
"(",
")",
")",
";",
"switchWidget",
".",
"setTextOff",
"(",
"getSwitchTextOff",
"(",
")",
")",
";",
"switchWidget",
".",
"setShowText",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"getSwitchTextOn",
"(",
")",
")",
"||",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"getSwitchTextOff",
"(",
")",
")",
")",
";",
"switchWidget",
".",
"setChecked",
"(",
"isChecked",
"(",
")",
")",
";",
"}",
"}"
] |
Adapts the preference's switch, depending on the preference's properties and on whether it is
currently checked or not.
|
[
"Adapts",
"the",
"preference",
"s",
"switch",
"depending",
"on",
"the",
"preference",
"s",
"properties",
"and",
"on",
"whether",
"it",
"is",
"currently",
"checked",
"or",
"not",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SwitchPreference.java#L137-L145
|
4,592 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/SwitchPreference.java
|
SwitchPreference.createCheckedChangeListener
|
private OnCheckedChangeListener createCheckedChangeListener() {
return new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (getOnPreferenceChangeListener() == null || getOnPreferenceChangeListener()
.onPreferenceChange(SwitchPreference.this, isChecked)) {
setChecked(isChecked);
} else {
setChecked(!isChecked);
}
}
};
}
|
java
|
private OnCheckedChangeListener createCheckedChangeListener() {
return new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (getOnPreferenceChangeListener() == null || getOnPreferenceChangeListener()
.onPreferenceChange(SwitchPreference.this, isChecked)) {
setChecked(isChecked);
} else {
setChecked(!isChecked);
}
}
};
}
|
[
"private",
"OnCheckedChangeListener",
"createCheckedChangeListener",
"(",
")",
"{",
"return",
"new",
"OnCheckedChangeListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCheckedChanged",
"(",
"final",
"CompoundButton",
"buttonView",
",",
"final",
"boolean",
"isChecked",
")",
"{",
"if",
"(",
"getOnPreferenceChangeListener",
"(",
")",
"==",
"null",
"||",
"getOnPreferenceChangeListener",
"(",
")",
".",
"onPreferenceChange",
"(",
"SwitchPreference",
".",
"this",
",",
"isChecked",
")",
")",
"{",
"setChecked",
"(",
"isChecked",
")",
";",
"}",
"else",
"{",
"setChecked",
"(",
"!",
"isChecked",
")",
";",
"}",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to change the preference's value, depending on
the preference's switch's state.
@return The listener, which has been created, as an instance of the type {@link
OnCheckedChangeListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"change",
"the",
"preference",
"s",
"value",
"depending",
"on",
"the",
"preference",
"s",
"switch",
"s",
"state",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/SwitchPreference.java#L154-L168
|
4,593 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainColorPalette
|
private void obtainColorPalette(@NonNull final TypedArray typedArray) {
int resourceId =
typedArray.getResourceId(R.styleable.ColorPalettePreference_colorPalette, -1);
if (resourceId != -1) {
int[] obtainedColorPalette = getContext().getResources().getIntArray(resourceId);
setColorPalette(obtainedColorPalette);
}
}
|
java
|
private void obtainColorPalette(@NonNull final TypedArray typedArray) {
int resourceId =
typedArray.getResourceId(R.styleable.ColorPalettePreference_colorPalette, -1);
if (resourceId != -1) {
int[] obtainedColorPalette = getContext().getResources().getIntArray(resourceId);
setColorPalette(obtainedColorPalette);
}
}
|
[
"private",
"void",
"obtainColorPalette",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"resourceId",
"=",
"typedArray",
".",
"getResourceId",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_colorPalette",
",",
"-",
"1",
")",
";",
"if",
"(",
"resourceId",
"!=",
"-",
"1",
")",
"{",
"int",
"[",
"]",
"obtainedColorPalette",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getIntArray",
"(",
"resourceId",
")",
";",
"setColorPalette",
"(",
"obtainedColorPalette",
")",
";",
"}",
"}"
] |
Obtains the color palette from a specific typed array.
@param typedArray
The typed array, the color palette, should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"color",
"palette",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L164-L172
|
4,594 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainDialogPreviewSize
|
private void obtainDialogPreviewSize(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources().getDimensionPixelSize(
R.dimen.color_palette_preference_default_dialog_preview_size);
setDialogPreviewSize(typedArray
.getDimensionPixelSize(R.styleable.ColorPalettePreference_dialogPreviewSize,
defaultValue));
}
|
java
|
private void obtainDialogPreviewSize(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources().getDimensionPixelSize(
R.dimen.color_palette_preference_default_dialog_preview_size);
setDialogPreviewSize(typedArray
.getDimensionPixelSize(R.styleable.ColorPalettePreference_dialogPreviewSize,
defaultValue));
}
|
[
"private",
"void",
"obtainDialogPreviewSize",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"color_palette_preference_default_dialog_preview_size",
")",
";",
"setDialogPreviewSize",
"(",
"typedArray",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewSize",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the size, which should be used to preview colors in the preference's dialog, from a
specific typed array.
@param typedArray
The typed array, the size should be obtained from, as an instance of the class {@link
TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"size",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L182-L188
|
4,595 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainDialogPreviewShape
|
private void obtainDialogPreviewShape(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.color_palette_preference_default_dialog_preview_shape);
setDialogPreviewShape(PreviewShape.fromValue(typedArray
.getInteger(R.styleable.ColorPalettePreference_dialogPreviewShape, defaultValue)));
}
|
java
|
private void obtainDialogPreviewShape(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.color_palette_preference_default_dialog_preview_shape);
setDialogPreviewShape(PreviewShape.fromValue(typedArray
.getInteger(R.styleable.ColorPalettePreference_dialogPreviewShape, defaultValue)));
}
|
[
"private",
"void",
"obtainDialogPreviewShape",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"color_palette_preference_default_dialog_preview_shape",
")",
";",
"setDialogPreviewShape",
"(",
"PreviewShape",
".",
"fromValue",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewShape",
",",
"defaultValue",
")",
")",
")",
";",
"}"
] |
Obtains the shape, which should be used to preview colors in the preference's dialog, from a
specific typed array.
@param typedArray
The typed array, the shape should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"shape",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L198-L203
|
4,596 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainDialogPreviewBorderWidth
|
private void obtainDialogPreviewBorderWidth(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources().getDimensionPixelSize(
R.dimen.color_palette_preference_default_dialog_preview_border_width);
setDialogPreviewBorderWidth(typedArray
.getDimensionPixelSize(R.styleable.ColorPalettePreference_dialogPreviewBorderWidth,
defaultValue));
}
|
java
|
private void obtainDialogPreviewBorderWidth(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources().getDimensionPixelSize(
R.dimen.color_palette_preference_default_dialog_preview_border_width);
setDialogPreviewBorderWidth(typedArray
.getDimensionPixelSize(R.styleable.ColorPalettePreference_dialogPreviewBorderWidth,
defaultValue));
}
|
[
"private",
"void",
"obtainDialogPreviewBorderWidth",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"color_palette_preference_default_dialog_preview_border_width",
")",
";",
"setDialogPreviewBorderWidth",
"(",
"typedArray",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewBorderWidth",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the border width, which should be used to preview colors in the preference's dialog,
from a specific typed array.
@param typedArray
The typed array, the border width should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"border",
"width",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L213-L219
|
4,597 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainDialogPreviewBorderColor
|
private void obtainDialogPreviewBorderColor(@NonNull final TypedArray typedArray) {
int defaultValue = ContextCompat.getColor(getContext(),
R.color.color_palette_preference_default_dialog_preview_border_color);
setDialogPreviewBorderColor(typedArray
.getColor(R.styleable.ColorPalettePreference_dialogPreviewBorderColor,
defaultValue));
}
|
java
|
private void obtainDialogPreviewBorderColor(@NonNull final TypedArray typedArray) {
int defaultValue = ContextCompat.getColor(getContext(),
R.color.color_palette_preference_default_dialog_preview_border_color);
setDialogPreviewBorderColor(typedArray
.getColor(R.styleable.ColorPalettePreference_dialogPreviewBorderColor,
defaultValue));
}
|
[
"private",
"void",
"obtainDialogPreviewBorderColor",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"ContextCompat",
".",
"getColor",
"(",
"getContext",
"(",
")",
",",
"R",
".",
"color",
".",
"color_palette_preference_default_dialog_preview_border_color",
")",
";",
"setDialogPreviewBorderColor",
"(",
"typedArray",
".",
"getColor",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewBorderColor",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the border color, which should be used to preview colors in the preference's dialog,
from a specific typed array.
@param typedArray
The typed array, the border color should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"border",
"color",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L229-L235
|
4,598 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainDialogPreviewBackground
|
private void obtainDialogPreviewBackground(@NonNull final TypedArray typedArray) {
int backgroundColor =
typedArray.getColor(R.styleable.ColorPalettePreference_dialogPreviewBackground, -1);
if (backgroundColor != -1) {
setPreviewBackgroundColor(backgroundColor);
} else {
int resourceId = typedArray
.getResourceId(R.styleable.ColorPalettePreference_dialogPreviewBackground,
R.drawable.color_picker_default_preview_background);
setDialogPreviewBackground(ContextCompat.getDrawable(getContext(), resourceId));
}
}
|
java
|
private void obtainDialogPreviewBackground(@NonNull final TypedArray typedArray) {
int backgroundColor =
typedArray.getColor(R.styleable.ColorPalettePreference_dialogPreviewBackground, -1);
if (backgroundColor != -1) {
setPreviewBackgroundColor(backgroundColor);
} else {
int resourceId = typedArray
.getResourceId(R.styleable.ColorPalettePreference_dialogPreviewBackground,
R.drawable.color_picker_default_preview_background);
setDialogPreviewBackground(ContextCompat.getDrawable(getContext(), resourceId));
}
}
|
[
"private",
"void",
"obtainDialogPreviewBackground",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"backgroundColor",
"=",
"typedArray",
".",
"getColor",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewBackground",
",",
"-",
"1",
")",
";",
"if",
"(",
"backgroundColor",
"!=",
"-",
"1",
")",
"{",
"setPreviewBackgroundColor",
"(",
"backgroundColor",
")",
";",
"}",
"else",
"{",
"int",
"resourceId",
"=",
"typedArray",
".",
"getResourceId",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_dialogPreviewBackground",
",",
"R",
".",
"drawable",
".",
"color_picker_default_preview_background",
")",
";",
"setDialogPreviewBackground",
"(",
"ContextCompat",
".",
"getDrawable",
"(",
"getContext",
"(",
")",
",",
"resourceId",
")",
")",
";",
"}",
"}"
] |
Obtains the background, which should be used to preview colors in the preference's dialog,
from a specific typed array.
@param typedArray
The typed array, the background should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"background",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L245-L257
|
4,599 |
michael-rapp/AndroidMaterialPreferences
|
library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java
|
ColorPalettePreference.obtainNumberOfColumns
|
private void obtainNumberOfColumns(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.color_palette_preference_default_number_of_columns);
setNumberOfColumns(typedArray
.getInteger(R.styleable.ColorPalettePreference_android_numColumns, defaultValue));
}
|
java
|
private void obtainNumberOfColumns(@NonNull final TypedArray typedArray) {
int defaultValue = getContext().getResources()
.getInteger(R.integer.color_palette_preference_default_number_of_columns);
setNumberOfColumns(typedArray
.getInteger(R.styleable.ColorPalettePreference_android_numColumns, defaultValue));
}
|
[
"private",
"void",
"obtainNumberOfColumns",
"(",
"@",
"NonNull",
"final",
"TypedArray",
"typedArray",
")",
"{",
"int",
"defaultValue",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getInteger",
"(",
"R",
".",
"integer",
".",
"color_palette_preference_default_number_of_columns",
")",
";",
"setNumberOfColumns",
"(",
"typedArray",
".",
"getInteger",
"(",
"R",
".",
"styleable",
".",
"ColorPalettePreference_android_numColumns",
",",
"defaultValue",
")",
")",
";",
"}"
] |
Obtains the number of columns, which should be used to preview colors in the preference's
dialog, from a specific typed array.
@param typedArray
The typed array, the number of columns should be obtained from, as an instance of the
class {@link TypedArray}. The typed array may not be null
|
[
"Obtains",
"the",
"number",
"of",
"columns",
"which",
"should",
"be",
"used",
"to",
"preview",
"colors",
"in",
"the",
"preference",
"s",
"dialog",
"from",
"a",
"specific",
"typed",
"array",
"."
] |
73a7e449458313bd041fc8d6038e290506b68eb1
|
https://github.com/michael-rapp/AndroidMaterialPreferences/blob/73a7e449458313bd041fc8d6038e290506b68eb1/library/src/main/java/de/mrapp/android/preference/ColorPalettePreference.java#L267-L272
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.