idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
10,400
@ SuppressWarnings ( "unckecked" ) public static Class < ? > getRawType ( Type type ) { if ( type instanceof Class < ? > ) { return ( Class < ? > ) type ; } else if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; Type rawType = parameterizedType . getRawType ( ) ; checkArgument ( rawType instanceof Class , "Expected a Class, but <%s> is of type %s" , type , type . getClass ( ) . getName ( ) ) ; return ( Class < ? > ) rawType ; } else if ( type instanceof GenericArrayType ) { Type componentType = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; return Array . newInstance ( getRawType ( componentType ) , 0 ) . getClass ( ) ; } else if ( type instanceof TypeVariable ) { return Object . class ; } else { throw new IllegalArgumentException ( "Expected a Class, ParameterizedType, or " + "GenericArrayType, but <" + type + "> is of type " + type . getClass ( ) . getName ( ) ) ; } }
Copy paste from Guice MoreTypes
10,401
public TaskRec eventQueueReserveTask ( long taskId ) { String sqlLogId = "reserve_task" ; String sql = "update tedtask set status = 'WORK', startTs = $now, nextTs = null" + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid in (" + " select taskid from tedtask " + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid = ?" + " for update skip locked" + ") returning tedtask.*" ; sql = sql . replace ( "$now" , dbType . sql . now ( ) ) ; sql = sql . replace ( "$sys" , thisSystem ) ; List < TaskRec > tasks = selectData ( sqlLogId , sql , TaskRec . class , asList ( sqlParam ( taskId , JetJdbcParamType . LONG ) ) ) ; return tasks . isEmpty ( ) ? null : tasks . get ( 0 ) ; }
used in eventQueue
10,402
public static void initialize ( ) { if ( InfinispanCache . get ( ) . exists ( Field . IDCACHE ) ) { InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) ; InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) . addListener ( new CacheLogListener ( Field . LOG ) ) ; } }
Reset the cache .
10,403
public void configure ( ) throws LRException { nodeHost = StringUtil . nullifyBadInput ( nodeHost ) ; publishAuthUser = StringUtil . nullifyBadInput ( publishAuthUser ) ; publishAuthPassword = StringUtil . nullifyBadInput ( publishAuthPassword ) ; if ( nodeHost == null ) { throw new LRException ( LRException . NULL_FIELD ) ; } if ( batchSize == 0 ) { throw new LRException ( LRException . BATCH_ZERO ) ; } this . batchSize = batchSize ; this . publishFullUrl = publishProtocol + "://" + nodeHost + publishServiceUrl ; this . publishAuthUser = publishAuthUser ; this . publishAuthPassword = publishAuthPassword ; this . configured = true ; }
Attempt to configure the exporter with the values used in the constructor This must be called before an exporter can be used and after any setting of configuration values
10,404
public void addDocument ( LREnvelope envelope ) throws LRException { if ( ! configured ) { throw new LRException ( LRException . NOT_CONFIGURED ) ; } docs . add ( envelope . getSendableData ( ) ) ; }
Adds an envelope to the exporter
10,405
public void forward ( String controllerName ) throws Throwable { SilentGo instance = SilentGo . me ( ) ; ( ( ActionChain ) instance . getConfig ( ) . getActionChain ( ) . getObject ( ) ) . doAction ( instance . getConfig ( ) . getCtx ( ) . get ( ) . getActionParam ( ) ) ; }
forward to another controller
10,406
public void characters ( char [ ] ch , int start , int length ) throws SAXException { if ( vIsOpen ) { value . append ( ch , start , length ) ; } if ( fIsOpen ) { formula . append ( ch , start , length ) ; } if ( hfIsOpen ) { headerFooter . append ( ch , start , length ) ; } }
Captures characters only if a suitable element is open . Originally was just v ; extended for inlineStr also .
10,407
private void checkForEmptyCellComments ( XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType type ) { if ( commentCellRefs != null && ! commentCellRefs . isEmpty ( ) ) { if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_SHEET_DATA ) { while ( ! commentCellRefs . isEmpty ( ) ) { outputEmptyCellComment ( commentCellRefs . remove ( ) ) ; } return ; } if ( this . cellRef == null ) { if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_ROW ) { while ( ! commentCellRefs . isEmpty ( ) ) { if ( commentCellRefs . peek ( ) . getRow ( ) == rowNum ) { outputEmptyCellComment ( commentCellRefs . remove ( ) ) ; } else { return ; } } return ; } else { throw new IllegalStateException ( "Cell ref should be null only if there are only empty cells in the row; rowNum: " + rowNum ) ; } } CellAddress nextCommentCellRef ; do { CellAddress cellRef = new CellAddress ( this . cellRef ) ; CellAddress peekCellRef = commentCellRefs . peek ( ) ; if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . CELL && cellRef . equals ( peekCellRef ) ) { commentCellRefs . remove ( ) ; return ; } else { int comparison = peekCellRef . compareTo ( cellRef ) ; if ( comparison > 0 && type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_ROW && peekCellRef . getRow ( ) <= rowNum ) { nextCommentCellRef = commentCellRefs . remove ( ) ; outputEmptyCellComment ( nextCommentCellRef ) ; } else if ( comparison < 0 && type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . CELL && peekCellRef . getRow ( ) <= rowNum ) { nextCommentCellRef = commentCellRefs . remove ( ) ; outputEmptyCellComment ( nextCommentCellRef ) ; } else { nextCommentCellRef = null ; } } } while ( nextCommentCellRef != null && ! commentCellRefs . isEmpty ( ) ) ; } }
Do a check for and output comments in otherwise empty cells .
10,408
private void outputEmptyCellComment ( CellAddress cellRef ) { XSSFComment comment = commentsTable . findCellComment ( cellRef ) ; output . cell ( cellRef . formatAsString ( ) , null , comment ) ; }
Output an empty - cell comment .
10,409
public String format ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return "geometry" + index . getValue ( ) + "." + format ( index . getChild ( ) ) ; } switch ( index . getType ( ) ) { case TYPE_VERTEX : return "vertex" + index . getValue ( ) ; case TYPE_EDGE : return "edge" + index . getValue ( ) ; default : return "geometry" + index . getValue ( ) ; } }
Format a given geometry index creating something like geometry2 . vertex1 .
10,410
public Coordinate getVertex ( Geometry geometry , GeometryIndex index ) throws GeometryIndexNotFoundException { if ( index . hasChild ( ) ) { if ( geometry . getGeometries ( ) != null && geometry . getGeometries ( ) . length > index . getValue ( ) ) { return getVertex ( geometry . getGeometries ( ) [ index . getValue ( ) ] , index . getChild ( ) ) ; } throw new GeometryIndexNotFoundException ( "Could not match index with given geometry" ) ; } if ( index . getType ( ) == GeometryIndexType . TYPE_VERTEX && geometry . getCoordinates ( ) != null && geometry . getCoordinates ( ) . length > index . getValue ( ) && index . getValue ( ) >= 0 ) { return geometry . getCoordinates ( ) [ index . getValue ( ) ] ; } throw new GeometryIndexNotFoundException ( "Could not match index with given geometry" ) ; }
Given a certain geometry get the vertex the index points to . This only works if the index actually points to a vertex .
10,411
public boolean isVertex ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isVertex ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_VERTEX ; }
Does the given index point to a vertex or not? We look at the deepest level to check this .
10,412
public boolean isEdge ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isEdge ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_EDGE ; }
Does the given index point to an edge or not? We look at the deepest level to check this .
10,413
public boolean isGeometry ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isGeometry ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_GEOMETRY ; }
Does the given index point to a sub - geometry or not? We look at the deepest level to check this .
10,414
public GeometryIndexType getType ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return getType ( index . getChild ( ) ) ; } return index . getType ( ) ; }
Get the type of sub - part the given index points to . We look at the deepest level to check this .
10,415
public String getGeometryType ( Geometry geometry , GeometryIndex index ) throws GeometryIndexNotFoundException { if ( index != null && index . getType ( ) == GeometryIndexType . TYPE_GEOMETRY ) { if ( geometry . getGeometries ( ) != null && geometry . getGeometries ( ) . length > index . getValue ( ) ) { return getGeometryType ( geometry . getGeometries ( ) [ index . getValue ( ) ] , index . getChild ( ) ) ; } else { throw new GeometryIndexNotFoundException ( "Can't find the geometry referred to in the given index." ) ; } } return geometry . getGeometryType ( ) ; }
What is the geometry type of the sub - geometry pointed to by the given index? If the index points to a vertex or edge the geometry type at the parent level is returned .
10,416
public int getValue ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return getValue ( index . getChild ( ) ) ; } return index . getValue ( ) ; }
Returns the value of the innermost child index .
10,417
public GeometryIndex getParent ( GeometryIndex index ) { GeometryIndex parent = new GeometryIndex ( index ) ; GeometryIndex deepestParent = null ; GeometryIndex p = parent ; while ( p . hasChild ( ) ) { deepestParent = p ; p = p . getChild ( ) ; } if ( deepestParent != null ) { deepestParent . setChild ( null ) ; } return parent ; }
Returns a new index that is one level higher than this index . Useful to get the index of a ring for a vertex .
10,418
public GeometryIndex getNextVertex ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return new GeometryIndex ( index . getType ( ) , index . getValue ( ) , getNextVertex ( index . getChild ( ) ) ) ; } else { return new GeometryIndex ( GeometryIndexType . TYPE_VERTEX , index . getValue ( ) + 1 , null ) ; } }
Given a certain index find the next vertex in line .
10,419
public Coordinate [ ] getSiblingVertices ( Geometry geometry , GeometryIndex index ) throws GeometryIndexNotFoundException { if ( index . hasChild ( ) && geometry . getGeometries ( ) != null && geometry . getGeometries ( ) . length > index . getValue ( ) ) { return getSiblingVertices ( geometry . getGeometries ( ) [ index . getValue ( ) ] , index . getChild ( ) ) ; } switch ( index . getType ( ) ) { case TYPE_VERTEX : case TYPE_EDGE : return geometry . getCoordinates ( ) ; case TYPE_GEOMETRY : default : throw new GeometryIndexNotFoundException ( "Given index is of wrong type. Can't find sibling vertices " + "for a geometry type of index." ) ; } }
Get the full list of sibling vertices in the form of a coordinate array .
10,420
public static LeetLevel fromString ( String str ) throws Exception { if ( str == null || str . equalsIgnoreCase ( "null" ) || str . length ( ) == 0 ) return LEVEL1 ; try { int i = Integer . parseInt ( str ) ; if ( i >= 1 && i <= LEVELS . length ) return LEVELS [ i - 1 ] ; } catch ( Exception ignored ) { } String exceptionStr = String . format ( "Invalid LeetLevel '%1s', valid values are '1' to '9'" , str ) ; throw new Exception ( exceptionStr ) ; }
Converts a string to a leet level .
10,421
public void addLocalTypeVariable ( VariableElement ve , String signature , int index ) { localTypeVariables . add ( new LocalTypeVariable ( ve , signature , index ) ) ; }
Adds a entry into LocalTypeVariableTable if variable is of generic type
10,422
private static File writePartToFile ( File splitDir , List < String > data ) { BufferedWriter writer = null ; File splitFile ; try { splitFile = File . createTempFile ( "split-" , ".part" , splitDir ) ; writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( splitFile . getAbsoluteFile ( ) , false ) , DataUtilDefaults . charSet ) ) ; for ( String item : data ) { writer . write ( item + DataUtilDefaults . lineTerminator ) ; } writer . flush ( ) ; writer . close ( ) ; writer = null ; } catch ( UnsupportedEncodingException e ) { throw new DataUtilException ( e ) ; } catch ( FileNotFoundException e ) { throw new DataUtilException ( e ) ; } catch ( IOException e ) { throw new DataUtilException ( e ) ; } finally { if ( writer != null ) { try { writer . close ( ) ; } catch ( IOException e ) { } } } return splitFile ; }
This method writes a partial input file to a split file
10,423
private static long storageCalculation ( int rows , int lineChars , long totalCharacters ) { long size = ( long ) Math . ceil ( ( rows * ARRAY_LIST_ROW_OVERHEAD + lineChars + totalCharacters ) * LIST_CAPACITY_MULTIPLIER ) ; return size ; }
This calculation attempts to calculate how much storage x number of rows may use in an ArrayList assuming that capacity may be up to 1 . 5 times the actual space used .
10,424
private String extractBoundary ( String line ) { int index = line . lastIndexOf ( "boundary=" ) ; if ( index == - 1 ) { return null ; } String boundary = line . substring ( index + 9 ) ; if ( boundary . charAt ( 0 ) == '"' ) { index = boundary . lastIndexOf ( '"' ) ; boundary = boundary . substring ( 1 , index ) ; } boundary = "--" + boundary ; return boundary ; }
Extracts and returns the boundary token from a line .
10,425
private static String extractContentType ( String line ) throws IOException { line = line . toLowerCase ( ) ; int end = line . indexOf ( ";" ) ; if ( end == - 1 ) { end = line . length ( ) ; } return line . substring ( 13 , end ) . trim ( ) ; }
Extracts and returns the content type from a line or null if the line was empty .
10,426
private String readLine ( ) throws IOException { StringBuffer sbuf = new StringBuffer ( ) ; int result ; String line ; do { result = in . readLine ( buf , 0 , buf . length ) ; if ( result != - 1 ) { sbuf . append ( new String ( buf , 0 , result , encoding ) ) ; } } while ( result == buf . length ) ; if ( sbuf . length ( ) == 0 ) { return null ; } int len = sbuf . length ( ) ; if ( len >= 2 && sbuf . charAt ( len - 2 ) == '\r' ) { sbuf . setLength ( len - 2 ) ; } else if ( len >= 1 && sbuf . charAt ( len - 1 ) == '\n' ) { sbuf . setLength ( len - 1 ) ; } return sbuf . toString ( ) ; }
Read the next line of input .
10,427
public Set < String > getNeverGroupedIds ( ) { String s = props . getProperty ( "neverGroupedIds" ) ; if ( s == null ) return Collections . emptySet ( ) ; Set < String > res = new HashSet < String > ( ) ; String [ ] parts = s . split ( "[,]" ) ; for ( String part : parts ) { res . add ( part ) ; } return res ; }
Returns the set of ids of SNOMED roles that should never be placed in a role group .
10,428
public Map < String , String > getRightIdentityIds ( ) { String s = props . getProperty ( "rightIdentityIds" ) ; if ( s == null ) return Collections . emptyMap ( ) ; Map < String , String > res = new HashMap < String , String > ( ) ; String [ ] parts = s . split ( "[,]" ) ; res . put ( parts [ 0 ] , parts [ 1 ] ) ; return res ; }
Returns the right identity axioms that cannot be represented in RF1 or RF2 formats . An example is direct - substance o has - active - ingredient [ direct - substance . The key of the returned map is the first element in the LHS and the value is the second element in the LHS . The RHS because it is a right identity axiom is always the same as the first element in the LHS .
10,429
public String serialize ( Object object ) { ObjectOutputStream oos = null ; ByteArrayOutputStream bos = null ; try { bos = new ByteArrayOutputStream ( ) ; oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( object ) ; return new String ( Base64 . encodeBase64 ( bos . toByteArray ( ) ) ) ; } catch ( IOException e ) { LOGGER . error ( "Can't serialize data on Base 64" , e ) ; throw new IllegalArgumentException ( e ) ; } catch ( Exception e ) { LOGGER . error ( "Can't serialize data on Base 64" , e ) ; throw new IllegalArgumentException ( e ) ; } finally { try { if ( bos != null ) { bos . close ( ) ; } } catch ( Exception e ) { LOGGER . error ( "Can't close ObjetInputStream used for serialize data on Base 64" , e ) ; } } }
Serialize object to an encoded base64 string .
10,430
public Object deserialize ( String data ) { if ( ( data == null ) || ( data . length ( ) == 0 ) ) { return null ; } ObjectInputStream ois = null ; ByteArrayInputStream bis = null ; try { bis = new ByteArrayInputStream ( Base64 . decodeBase64 ( data . getBytes ( ) ) ) ; ois = new ObjectInputStream ( bis ) ; return ois . readObject ( ) ; } catch ( ClassNotFoundException e ) { LOGGER . error ( "Can't deserialize data from Base64" , e ) ; throw new IllegalArgumentException ( e ) ; } catch ( IOException e ) { LOGGER . error ( "Can't deserialize data from Base64" , e ) ; throw new IllegalArgumentException ( e ) ; } catch ( Exception e ) { LOGGER . error ( "Can't deserialize data from Base64" , e ) ; throw new IllegalArgumentException ( e ) ; } finally { try { if ( ois != null ) { ois . close ( ) ; } } catch ( Exception e ) { LOGGER . error ( "Can't close ObjetInputStream used for deserialize data from Base64" , e ) ; } } }
Deserialze base 64 encoded string data to Object .
10,431
int getMethodIndex ( ExecutableElement method ) { TypeElement declaringClass = ( TypeElement ) method . getEnclosingElement ( ) ; String fullyQualifiedname = declaringClass . getQualifiedName ( ) . toString ( ) ; return getRefIndex ( Methodref . class , fullyQualifiedname , method . getSimpleName ( ) . toString ( ) , Descriptor . getDesriptor ( method ) ) ; }
Returns the constant map index to method
10,432
protected int getRefIndex ( Class < ? extends Ref > refType , String fullyQualifiedname , String name , String descriptor ) { String internalForm = fullyQualifiedname . replace ( '.' , '/' ) ; for ( ConstantInfo ci : listConstantInfo ( refType ) ) { Ref mr = ( Ref ) ci ; int classIndex = mr . getClass_index ( ) ; Clazz clazz = ( Clazz ) getConstantInfo ( classIndex ) ; String cn = getString ( clazz . getName_index ( ) ) ; if ( internalForm . equals ( cn ) ) { int nameAndTypeIndex = mr . getName_and_type_index ( ) ; NameAndType nat = ( NameAndType ) getConstantInfo ( nameAndTypeIndex ) ; int nameIndex = nat . getName_index ( ) ; String str = getString ( nameIndex ) ; if ( name . equals ( str ) ) { int descriptorIndex = nat . getDescriptor_index ( ) ; String descr = getString ( descriptorIndex ) ; if ( descriptor . equals ( descr ) ) { return constantPoolIndexMap . get ( ci ) ; } } } } return - 1 ; }
Returns the constant map index to reference
10,433
public int getNameIndex ( CharSequence name ) { for ( ConstantInfo ci : listConstantInfo ( Utf8 . class ) ) { Utf8 utf8 = ( Utf8 ) ci ; String str = utf8 . getString ( ) ; if ( str . contentEquals ( name ) ) { return constantPoolIndexMap . get ( ci ) ; } } return - 1 ; }
Returns the constant map index to name
10,434
public int getNameAndTypeIndex ( String name , String descriptor ) { for ( ConstantInfo ci : listConstantInfo ( NameAndType . class ) ) { NameAndType nat = ( NameAndType ) ci ; int nameIndex = nat . getName_index ( ) ; String str = getString ( nameIndex ) ; if ( name . equals ( str ) ) { int descriptorIndex = nat . getDescriptor_index ( ) ; String descr = getString ( descriptorIndex ) ; if ( descriptor . equals ( descr ) ) { return constantPoolIndexMap . get ( ci ) ; } } } return - 1 ; }
Returns the constant map index to name and type
10,435
public final int getConstantIndex ( int constant ) { for ( ConstantInfo ci : listConstantInfo ( ConstantInteger . class ) ) { ConstantInteger ic = ( ConstantInteger ) ci ; if ( constant == ic . getConstant ( ) ) { return constantPoolIndexMap . get ( ci ) ; } } return - 1 ; }
Returns the constant map index to integer constant
10,436
Object getIndexedType ( int index ) { Object ae = indexedElementMap . get ( index ) ; if ( ae == null ) { throw new VerifyError ( "constant pool at " + index + " not proper type" ) ; } return ae ; }
Returns a element from constant map
10,437
public String getFieldDescription ( int index ) { ConstantInfo constantInfo = getConstantInfo ( index ) ; if ( constantInfo instanceof Fieldref ) { Fieldref fr = ( Fieldref ) getConstantInfo ( index ) ; int nt = fr . getName_and_type_index ( ) ; NameAndType nat = ( NameAndType ) getConstantInfo ( nt ) ; int ni = nat . getName_index ( ) ; int di = nat . getDescriptor_index ( ) ; return getString ( ni ) + " " + getString ( di ) ; } return "unknown " + constantInfo ; }
Returns a descriptor to fields at index .
10,438
public String getMethodDescription ( int index ) { ConstantInfo constantInfo = getConstantInfo ( index ) ; if ( constantInfo instanceof Methodref ) { Methodref mr = ( Methodref ) getConstantInfo ( index ) ; int nt = mr . getName_and_type_index ( ) ; NameAndType nat = ( NameAndType ) getConstantInfo ( nt ) ; int ni = nat . getName_index ( ) ; int di = nat . getDescriptor_index ( ) ; return getString ( ni ) + " " + getString ( di ) ; } if ( constantInfo instanceof InterfaceMethodref ) { InterfaceMethodref mr = ( InterfaceMethodref ) getConstantInfo ( index ) ; int nt = mr . getName_and_type_index ( ) ; NameAndType nat = ( NameAndType ) getConstantInfo ( nt ) ; int ni = nat . getName_index ( ) ; int di = nat . getDescriptor_index ( ) ; return getString ( ni ) + " " + getString ( di ) ; } return "unknown " + constantInfo ; }
Returns a descriptor to method at index .
10,439
public String getClassDescription ( int index ) { Clazz cz = ( Clazz ) getConstantInfo ( index ) ; int ni = cz . getName_index ( ) ; return getString ( ni ) ; }
Returns a descriptor to class at index .
10,440
public boolean referencesMethod ( ExecutableElement method ) { TypeElement declaringClass = ( TypeElement ) method . getEnclosingElement ( ) ; String fullyQualifiedname = declaringClass . getQualifiedName ( ) . toString ( ) ; String name = method . getSimpleName ( ) . toString ( ) ; assert name . indexOf ( '.' ) == - 1 ; String descriptor = Descriptor . getDesriptor ( method ) ; return getRefIndex ( Methodref . class , fullyQualifiedname , name , descriptor ) != - 1 ; }
Return true if class contains method ref to given method
10,441
public final String getString ( int index ) { Utf8 utf8 = ( Utf8 ) getConstantInfo ( index ) ; return utf8 . getString ( ) ; }
Return a constant string at index .
10,442
public static ExecutableElement getMethod ( TypeElement typeElement , String name , TypeMirror ... parameters ) { List < ExecutableElement > allMethods = getAllMethods ( typeElement , name , parameters ) ; if ( allMethods . isEmpty ( ) ) { return null ; } else { Collections . sort ( allMethods , new SpecificMethodComparator ( ) ) ; return allMethods . get ( 0 ) ; } }
Returns the most specific named method in typeElement or null if such method was not found
10,443
public static List < ? extends ExecutableElement > getEffectiveMethods ( TypeElement cls ) { List < ExecutableElement > list = new ArrayList < > ( ) ; while ( cls != null ) { for ( ExecutableElement method : ElementFilter . methodsIn ( cls . getEnclosedElements ( ) ) ) { if ( ! overrides ( list , method ) ) { list . add ( method ) ; } } cls = ( TypeElement ) Typ . asElement ( cls . getSuperclass ( ) ) ; } return list ; }
Return effective methods for a class . All methods accessible at class are returned . That includes superclass methods which are not override .
10,444
public static < T > List < T > createList ( T ... args ) { ArrayList < T > newList = new ArrayList < T > ( ) ; Collections . addAll ( newList , args ) ; return newList ; }
Convenience method for building a list from vararg arguments
10,445
public static < T > List < T > arrayToList ( T [ ] array ) { return new ArrayList < T > ( Arrays . asList ( array ) ) ; }
Convenience method for building a list from an array
10,446
public static < T > List < T > subList ( List < T > list , Criteria < T > criteria ) { ArrayList < T > subList = new ArrayList < T > ( ) ; for ( T item : list ) { if ( criteria . meetsCriteria ( item ) ) { subList . add ( item ) ; } } return subList ; }
Extract a sub list from another list
10,447
public String generateAuthnRequest ( final String requestId ) throws SAMLException { final String request = _createAuthnRequest ( requestId ) ; try { final byte [ ] compressed = deflate ( request . getBytes ( "UTF-8" ) ) ; return DatatypeConverter . printBase64Binary ( compressed ) ; } catch ( UnsupportedEncodingException e ) { throw new SAMLException ( "Apparently your platform lacks UTF-8. That's too bad." , e ) ; } catch ( IOException e ) { throw new SAMLException ( "Unable to compress the AuthnRequest" , e ) ; } }
Create a new AuthnRequest suitable for sending to an HTTPRedirect binding endpoint on the IdP . The SPConfig will be used to fill in the ACS and issuer and the IdP will be used to set the destination .
10,448
public AttributeSet validateResponsePOST ( final String _authnResponse ) throws SAMLException { final byte [ ] decoded = DatatypeConverter . parseBase64Binary ( _authnResponse ) ; final String authnResponse ; try { authnResponse = new String ( decoded , "UTF-8" ) ; if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( authnResponse ) ; } } catch ( UnsupportedEncodingException e ) { throw new SAMLException ( "UTF-8 is missing, oh well." , e ) ; } final Response response = parseResponse ( authnResponse ) ; try { validatePOST ( response ) ; } catch ( ValidationException e ) { throw new SAMLException ( e ) ; } return getAttributeSet ( response ) ; }
Check an authnResponse and return the subject if validation succeeds . The NameID from the subject in the first valid assertion is returned along with the attributes .
10,449
private void treeWalker ( Node node , int level , List < PathQueryMatcher > queryMatchers , List < Node > collector ) { MatchType matchType = queryMatchers . get ( level ) . match ( level , node ) ; if ( matchType == MatchType . NOT_A_MATCH ) { return ; } else if ( matchType == MatchType . NODE_MATCH ) { if ( level == queryMatchers . size ( ) - 1 ) { collector . add ( node ) ; } else if ( node instanceof Element ) { Element element = ( Element ) node ; List < Node > childElements = element . getChildElements ( ) ; for ( Node childElement : childElements ) { treeWalker ( childElement , level + 1 , queryMatchers , collector ) ; } } } else { throw new PathQueryException ( "Unknown MatchType: " + matchType ) ; } }
Recursive BFS tree walker
10,450
public String capitalize ( String string ) { if ( string == null || string . length ( ) < 1 ) { return "" ; } return string . substring ( 0 , 1 ) . toUpperCase ( ) + string . substring ( 1 ) ; }
Changes the first character to uppercase .
10,451
public String singularize ( String noun ) { String singular = noun ; if ( singulars . get ( noun ) != null ) { singular = singulars . get ( noun ) ; } else if ( noun . matches ( ".*is$" ) ) { singular = noun . substring ( 0 , noun . length ( ) - 2 ) + "es" ; } else if ( noun . matches ( ".*ies$" ) ) { singular = noun . substring ( 0 , noun . length ( ) - 3 ) + "y" ; } else if ( noun . matches ( ".*ves$" ) ) { singular = noun . substring ( 0 , noun . length ( ) - 3 ) + "f" ; } else if ( noun . matches ( ".*es$" ) ) { if ( noun . matches ( ".*les$" ) ) { singular = noun . substring ( 0 , noun . length ( ) - 1 ) ; } else { singular = noun . substring ( 0 , noun . length ( ) - 2 ) ; } } else if ( noun . matches ( ".*s$" ) ) { singular = noun . substring ( 0 , noun . length ( ) - 1 ) ; } return singular ; }
Gets the singular of a plural .
10,452
public String getExtension ( String url ) { int dotIndex = url . lastIndexOf ( '.' ) ; String extension = null ; if ( dotIndex > 0 ) { extension = url . substring ( dotIndex + 1 ) ; } return extension ; }
Gets the extension used in the URL if any .
10,453
public void write ( String ... columns ) throws DataUtilException { if ( columns . length != tableColumns ) { throw new DataUtilException ( "Invalid column count. Expected " + tableColumns + " but found: " + columns . length ) ; } try { if ( currentRow == 0 ) { this . headerRowColumns = columns ; writeTop ( ) ; writeRow ( headerRowColumns ) ; } else if ( maxRowsPerPage > 1 && currentRow % maxRowsPerPage == 0 ) { writeBottom ( true ) ; currentPageNumber = ( currentRow / maxRowsPerPage ) + 1 ; writeTop ( ) ; writeRow ( headerRowColumns ) ; currentRow += 1 ; writeRow ( columns ) ; } else { writeRow ( columns ) ; } currentRow += 1 ; } catch ( Exception e ) { throw new DataUtilException ( e ) ; } }
Write a row to the table . The first row will be the header row
10,454
private void writeRow ( String ... columns ) throws IOException { StringBuilder html = new StringBuilder ( ) ; html . append ( "<tr>" ) ; for ( String data : columns ) { html . append ( "<td>" ) . append ( data ) . append ( "</td>" ) ; } html . append ( "</tr>\n" ) ; writer . write ( html . toString ( ) ) ; }
Write data to file
10,455
private void writeTop ( ) throws IOException { File outputFile = new File ( outputDirectory , createFilename ( currentPageNumber ) ) ; writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( outputFile , false ) , Charset . forName ( encoding ) ) ) ; Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "pageTitle" , pageTitle ) ; if ( pageHeader != null && pageHeader . length ( ) > 0 ) { map . put ( "header" , "<h1>" + pageHeader + "</h1>" ) ; } else { map . put ( "header" , "" ) ; } if ( pageDescription != null && pageDescription . length ( ) > 0 ) { map . put ( "description" , "<p>" + pageDescription + "</p>" ) ; } else { map . put ( "description" , "" ) ; } String template = Template . readResourceAsStream ( "com/btaz/util/templates/html-table-header.ftl" ) ; String output = Template . transform ( template , map ) ; writer . write ( output ) ; }
Write the top part of the HTML document
10,456
private void writeBottom ( boolean hasNext ) throws IOException { String template = Template . readResourceAsStream ( "com/btaz/util/templates/html-table-footer.ftl" ) ; Map < String , Object > map = new HashMap < String , Object > ( ) ; String prev = " " ; String next = "" ; if ( currentPageNumber > 1 ) { prev = "<a href=\"" + createFilename ( 1 ) + "\">First</a> &nbsp; " + "<a href=\"" + createFilename ( currentPageNumber - 1 ) + "\">Previous</a> &nbsp; " ; } if ( hasNext ) { next = "<a href=\"" + createFilename ( currentPageNumber + 1 ) + "\">Next</a>" ; } map . put ( "pageNavigation" , prev + next ) ; template = Template . transform ( template , map ) ; writer . write ( template ) ; writer . close ( ) ; writer = null ; }
Write bottom part of the HTML page
10,457
public void close ( ) throws DataUtilException { try { if ( writer != null ) { writeBottom ( false ) ; } } catch ( IOException e ) { throw new DataUtilException ( "Failed to close the HTML table file" , e ) ; } }
Close the HTML table and resources
10,458
public static void setEnableFileLog ( boolean enable , String path , String fileName ) { sEnableFileLog = enable ; if ( enable && path != null && fileName != null ) { sLogFilePath = path . trim ( ) ; sLogFileName = fileName . trim ( ) ; if ( ! sLogFilePath . endsWith ( "/" ) ) { sLogFilePath = sLogFilePath + "/" ; } } }
Enable writing debugging log to a target file
10,459
public static List < String > buildList ( String ... args ) { List < String > newList = new ArrayList < String > ( ) ; Collections . addAll ( newList , args ) ; return newList ; }
This method builds a list of string object from a variable argument list as input
10,460
public static String asCommaSeparatedValues ( String ... args ) { List < String > newList = new ArrayList < String > ( ) ; Collections . addAll ( newList , args ) ; return Strings . asTokenSeparatedValues ( "," , newList ) ; }
This method converts a collection of strings to a comma separated list of strings
10,461
public static String asTokenSeparatedValues ( String token , Collection < String > strings ) { StringBuilder newString = new StringBuilder ( ) ; boolean first = true ; for ( String str : strings ) { if ( ! first ) { newString . append ( token ) ; } first = false ; newString . append ( str ) ; } return newString . toString ( ) ; }
This method converts a collection of strings to a token separated list of strings
10,462
public SecureCharArray generatePassword ( CharSequence masterPassword , String inputText ) { return generatePassword ( masterPassword , inputText , null ) ; }
Same as the other version with username being sent null .
10,463
public SecureUTF8String generatePassword ( CharSequence masterPassword , String inputText , String username ) { SecureUTF8String securedMasterPassword ; if ( ! ( masterPassword instanceof SecureUTF8String ) ) { securedMasterPassword = new SecureUTF8String ( masterPassword . toString ( ) ) ; } else { securedMasterPassword = ( SecureUTF8String ) masterPassword ; } SecureUTF8String result = null ; try { Account accountToUse = getAccountForInputText ( inputText ) ; if ( username != null ) result = pwm . makePassword ( securedMasterPassword , accountToUse , inputText , username ) ; else result = pwm . makePassword ( securedMasterPassword , accountToUse , inputText ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( result != null ) { return result ; } return new SecureUTF8String ( ) ; }
Generate the password based on the masterPassword from the matching account from the inputtext
10,464
public Account getAccountForInputText ( String inputText ) { if ( selectedProfile != null ) return selectedProfile ; Account account = pwmProfiles . findAccountByUrl ( inputText ) ; if ( account == null ) return getDefaultAccount ( ) ; return account ; }
Public for testing
10,465
public void decodeFavoritesUrls ( String encodedUrlList , boolean clearFirst ) { int start = 0 ; int end = encodedUrlList . length ( ) ; if ( encodedUrlList . startsWith ( "<" ) ) start ++ ; if ( encodedUrlList . endsWith ( ">" ) ) end -- ; encodedUrlList = encodedUrlList . substring ( start , end ) ; if ( clearFirst ) favoriteUrls . clear ( ) ; for ( String url : Splitter . on ( ">,<" ) . omitEmptyStrings ( ) . split ( encodedUrlList ) ) { favoriteUrls . add ( url ) ; } }
Decodes a list of favorites urls from a series of &lt ; url1&gt ; &lt ; url2&gt ; ...
10,466
public void setCurrentPasswordHashPassword ( String newPassword ) { this . passwordSalt = UUID . randomUUID ( ) . toString ( ) ; try { this . currentPasswordHash = pwm . makePassword ( new SecureUTF8String ( newPassword ) , masterPwdHashAccount , getPasswordSalt ( ) ) ; } catch ( Exception ignored ) { } setStorePasswordHash ( true ) ; }
This will salt and hash the password to store
10,467
private Boolean isMainId ( String id , String resource , String lastElement ) { Boolean isMainId = false ; if ( id == null ) { if ( ! utils . singularize ( utils . cleanURL ( lastElement ) ) . equals ( resource ) && resource == null ) { isMainId = true ; } } return isMainId ; }
Checks if is the main id or it is a secondary id .
10,468
Boolean isResource ( String resource ) { Boolean isResource = false ; if ( ! utils . isIdentifier ( resource ) ) { try { String clazz = getControllerClass ( resource ) ; if ( clazz != null ) { Class . forName ( clazz ) ; isResource = true ; } } catch ( ClassNotFoundException e ) { } } return isResource ; }
Checks if a string represents a resource or not . If there is a class which could be instantiated then is a resource elsewhere it isn t
10,469
String getControllerClass ( String resource ) { ControllerFinder finder = new ControllerFinder ( config ) ; String controllerClass = finder . findResource ( resource ) ; LOGGER . debug ( "Controller class: {}" , controllerClass ) ; return controllerClass ; }
Gets controller class for a resource .
10,470
protected String getSerializerClass ( String resource , String urlLastElement ) { String serializerClass = null ; String extension = this . utils . getExtension ( urlLastElement ) ; if ( extension != null ) { SerializerFinder finder = new SerializerFinder ( config , extension ) ; serializerClass = finder . findResource ( resource ) ; } return serializerClass ; }
Gets serializer class for a resource . If the last part of the URL has an extension then could be a Serializer class to render the result in a specific way . If the extension is . xml it hopes that a ResourceNameXmlSerializer exists to render the resource as Xml . The extension can be anything .
10,471
public static void concatenate ( List < File > files , File concatenatedFile ) { BufferedWriter writer ; try { writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( concatenatedFile . getAbsoluteFile ( ) , false ) , DataUtilDefaults . charSet ) ) ; FileInputStream inputStream ; for ( File input : files ) { inputStream = new FileInputStream ( input ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream , "UTF-8" ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { writer . write ( line + DataUtilDefaults . lineTerminator ) ; } inputStream . close ( ) ; } writer . flush ( ) ; writer . close ( ) ; } catch ( UnsupportedEncodingException e ) { throw new DataUtilException ( e ) ; } catch ( FileNotFoundException e ) { throw new DataUtilException ( e ) ; } catch ( IOException e ) { throw new DataUtilException ( e ) ; } }
This method will concatenate one or more files
10,472
public static String getMessage ( int code ) { Code codeEnum = getCode ( code ) ; if ( codeEnum != null ) { return codeEnum . getMessage ( ) ; } else { return Integer . toString ( code ) ; } }
Get the status message for a specific code .
10,473
public static Pair < AlgorithmType , Boolean > fromRdfString ( String str , boolean convert ) throws IncompatibleException { if ( str . length ( ) == 0 ) return pair ( MD5 , true ) ; for ( AlgorithmType algoType : TYPES ) { String name = algoType . rdfName . toLowerCase ( ) ; String hmacName = algoType . rdfHmacName . toLowerCase ( ) ; if ( str . compareTo ( name ) == 0 || str . compareTo ( hmacName ) == 0 ) return pair ( algoType , true ) ; } if ( str . compareTo ( "md5-v0.6" ) == 0 || str . compareTo ( "hmac-md5-v0.6" ) == 0 ) return pair ( AlgorithmType . MD5 , false ) ; if ( convert && str . compareTo ( "hmac-sha256" ) == 0 ) { return pair ( AlgorithmType . SHA256 , true ) ; } if ( str . compareTo ( "hmac-sha256" ) == 0 ) throw new IncompatibleException ( "Original hmac-sha256-v1.5.1 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-SHA256\" in the PasswordMaker settings." ) ; if ( str . compareTo ( "md5-v0.6" ) == 0 ) throw new IncompatibleException ( "Original md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"MD5\" in the PasswordMaker settings." ) ; if ( str . compareTo ( "hmac-md5-v0.6" ) == 0 ) throw new IncompatibleException ( "Original hmac-md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-MD5\" in the PasswordMaker settings." ) ; throw new IncompatibleException ( String . format ( "Invalid algorithm type '%1s'" , str ) ) ; }
Converts a string to an algorithm type .
10,474
protected void log ( final String msg ) { if ( config . getLogLevel ( ) . equals ( LogLevel . DEBUG ) ) { logger . debug ( msg ) ; } else if ( config . getLogLevel ( ) . equals ( LogLevel . TRACE ) ) { logger . trace ( msg ) ; } else if ( config . getLogLevel ( ) . equals ( LogLevel . INFO ) ) { logger . info ( msg ) ; } else if ( config . getLogLevel ( ) . equals ( LogLevel . WARN ) ) { logger . warn ( msg ) ; } else if ( config . getLogLevel ( ) . equals ( LogLevel . ERROR ) ) { logger . error ( msg ) ; } }
Log the statement passed in
10,475
public Object getRequest ( String restUrl , Map < String , String > params ) throws IOException , WebServiceException { HttpURLConnection conn = null ; try { urlString = new StringBuilder ( this . host ) . append ( restUrl ) ; urlString . append ( this . makeParamsString ( params , true ) ) ; LOGGER . debug ( "Doing HTTP request: GET [{}]" , urlString . toString ( ) ) ; URL url = new URL ( urlString . toString ( ) ) ; conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setRequestMethod ( HttpMethod . GET . name ( ) ) ; conn . setRequestProperty ( "Connection" , "Keep-Alive" ) ; return this . readResponse ( restUrl , conn ) ; } catch ( WebServiceException e ) { LOGGER . debug ( "WebServiceException catched. Request error" , e ) ; throw e ; } catch ( IOException e ) { LOGGER . debug ( "IOException catched. Request error" , e ) ; throw e ; } catch ( Exception e ) { LOGGER . debug ( "Exception catched, throwing a new IOException. Request error" , e ) ; throw new IOException ( e . getLocalizedMessage ( ) ) ; } finally { if ( conn != null ) { conn . disconnect ( ) ; } } }
Do a GET HTTP request to the given REST - URL .
10,476
public Object putRequest ( String restUrl , Map < String , String > params ) throws IOException , WebServiceException { return this . postRequest ( HttpMethod . PUT , restUrl , params ) ; }
Do a PUT HTTP request to the given REST - URL .
10,477
public Object deleteRequest ( String restUrl , Map < String , String > params ) throws IOException , WebServiceException { return this . postRequest ( HttpMethod . DELETE , restUrl , params ) ; }
Do a DELETE HTTP request to the given REST - URL .
10,478
private String makeParamsString ( Map < String , String > params , boolean isGet ) { StringBuilder url = new StringBuilder ( ) ; if ( params != null ) { boolean first = true ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( first ) { if ( isGet ) { url . append ( "?" ) ; } first = false ; } else { url . append ( "&" ) ; } try { if ( entry . getValue ( ) != null ) { url . append ( entry . getKey ( ) ) . append ( "=" ) . append ( URLEncoder . encode ( entry . getValue ( ) , CHARSET ) ) ; } else { LOGGER . debug ( "WARN - Param {} is null" , entry . getKey ( ) ) ; url . append ( entry . getKey ( ) ) . append ( "=" ) . append ( "" ) ; } } catch ( UnsupportedEncodingException ex ) { LOGGER . error ( ex . getLocalizedMessage ( ) ) ; } } } return url . toString ( ) ; }
Adds params to a query string . It will encode params values to not get errors in the connection .
10,479
private Object deserialize ( String serializedObject , String extension ) throws IOException { LOGGER . debug ( "Deserializing object [{}] to [{}]" , serializedObject , extension ) ; SerializerFinder finder = new SerializerFinder ( extension ) ; String serializerClass = finder . findResource ( null ) ; if ( serializerClass == null ) { LOGGER . warn ( "Serializer not found for extension [{}]" , extension ) ; return null ; } else { try { LOGGER . debug ( "Deserializing using {}" , serializerClass ) ; Class < ? > clazz = Class . forName ( serializerClass ) ; Method deserializeMethod = clazz . getMethod ( "deserialize" , new Class [ ] { String . class } ) ; LOGGER . debug ( "Calling {}.deserialize" , serializerClass ) ; return deserializeMethod . invoke ( clazz . newInstance ( ) , serializedObject ) ; } catch ( Exception e ) { LOGGER . debug ( e . getLocalizedMessage ( ) , e ) ; LOGGER . debug ( "Can't deserialize object with {} serializer" , serializerClass ) ; throw new IOException ( e . getLocalizedMessage ( ) ) ; } } }
Deserializes a serialized object that came within the response after a REST call .
10,480
public HttpResponse execute ( final HttpUriRequest request ) throws IOException , ReadOnlyException { if ( readOnly ) { switch ( request . getMethod ( ) . toLowerCase ( ) ) { case "copy" : case "delete" : case "move" : case "patch" : case "post" : case "put" : throw new ReadOnlyException ( ) ; default : break ; } } return httpClient . execute ( request , httpContext ) ; }
Execute a request for a subclass .
10,481
private static String queryString ( final Map < String , List < String > > params ) { final StringBuilder builder = new StringBuilder ( ) ; if ( params != null && params . size ( ) > 0 ) { for ( final Iterator < String > it = params . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { final String key = it . next ( ) ; final List < String > values = params . get ( key ) ; for ( final String value : values ) { try { builder . append ( key + "=" + URLEncoder . encode ( value , "UTF-8" ) + "&" ) ; } catch ( final UnsupportedEncodingException e ) { builder . append ( key + "=" + value + "&" ) ; } } } return builder . length ( ) > 0 ? "?" + builder . substring ( 0 , builder . length ( ) - 1 ) : "" ; } return "" ; }
Encode URL parameters as a query string .
10,482
public HttpGet createGetMethod ( final String path , final Map < String , List < String > > params ) { return new HttpGet ( repositoryURL + path + queryString ( params ) ) ; }
Create GET method with list of parameters
10,483
public HttpPatch createPatchMethod ( final String path , final String sparqlUpdate ) throws FedoraException { if ( isBlank ( sparqlUpdate ) ) { throw new FedoraException ( "SPARQL Update command must not be blank" ) ; } final HttpPatch patch = new HttpPatch ( repositoryURL + path ) ; patch . setEntity ( new ByteArrayEntity ( sparqlUpdate . getBytes ( ) ) ) ; patch . setHeader ( "Content-Type" , contentTypeSPARQLUpdate ) ; return patch ; }
Create a request to update triples with SPARQL Update .
10,484
public HttpPost createPostMethod ( final String path , final Map < String , List < String > > params ) { return new HttpPost ( repositoryURL + path + queryString ( params ) ) ; }
Create POST method with list of parameters
10,485
public HttpPut createPutMethod ( final String path , final Map < String , List < String > > params ) { return new HttpPut ( repositoryURL + path + queryString ( params ) ) ; }
Create PUT method with list of parameters
10,486
public HttpPut createTriplesPutMethod ( final String path , final InputStream updatedProperties , final String contentType ) throws FedoraException { if ( updatedProperties == null ) { throw new FedoraException ( "updatedProperties must not be null" ) ; } else if ( isBlank ( contentType ) ) { throw new FedoraException ( "contentType must not be blank" ) ; } final HttpPut put = new HttpPut ( repositoryURL + path ) ; put . setEntity ( new InputStreamEntity ( updatedProperties ) ) ; put . setHeader ( "Content-Type" , contentType ) ; return put ; }
Create a request to update triples .
10,487
public HttpCopy createCopyMethod ( final String sourcePath , final String destinationPath ) { return new HttpCopy ( repositoryURL + sourcePath , repositoryURL + destinationPath ) ; }
Create COPY method
10,488
public HttpMove createMoveMethod ( final String sourcePath , final String destinationPath ) { return new HttpMove ( repositoryURL + sourcePath , repositoryURL + destinationPath ) ; }
Create MOVE method
10,489
public static void leetConvert ( LeetLevel level , SecureCharArray message ) throws Exception { SecureCharArray ret = new SecureCharArray ( message . size ( ) * 4 ) ; char [ ] messageBytes = message . getData ( ) ; char [ ] retBytes = ret . getData ( ) ; int currentRetByte = 0 ; if ( level . compareTo ( LeetLevel . LEVEL1 ) >= 0 && level . compareTo ( LeetLevel . LEVEL9 ) <= 0 ) { for ( char messageByte : messageBytes ) { char b = Character . toLowerCase ( messageByte ) ; if ( b >= 'a' && b <= 'z' ) { for ( int j = 0 ; j < LEVELS [ level . getLevel ( ) - 1 ] [ b - 'a' ] . length ( ) ; j ++ ) retBytes [ currentRetByte ++ ] = LEVELS [ level . getLevel ( ) - 1 ] [ b - 'a' ] . charAt ( j ) ; } else { retBytes [ currentRetByte ++ ] = b ; } } } ret . resize ( currentRetByte , true ) ; message . replace ( ret ) ; ret . erase ( ) ; }
Converts a SecureCharArray into a new SecureCharArray with any applicable characters converted to leet - speak .
10,490
public String getValue ( final ConfigParam param ) { if ( param == null ) { return null ; } Object obj = System . getProperty ( param . getName ( ) ) ; if ( obj == null ) { obj = this . props . get ( param . getName ( ) ) ; } if ( obj == null ) { log . warn ( "Property [{}] not found" , param . getName ( ) ) ; obj = param . getDefaultValue ( ) ; } return ( String ) obj ; }
Devuelve el valor del parametro de configuracion que se recibe . Si el valor es null y el parametro tiene un valor por defecto entonces este valor es el que se devuelve .
10,491
private void init ( ) throws ConfigFileIOException { this . props = new Properties ( ) ; log . info ( "Reading config file: {}" , this . configFile ) ; boolean ok = true ; try { this . props . load ( SystemConfig . class . getResourceAsStream ( this . configFile ) ) ; } catch ( Exception e ) { log . warn ( "File not found in the Classpath" ) ; try { this . props . load ( new FileInputStream ( this . configFile ) ) ; } catch ( IOException ioe ) { log . error ( "Can't open file: {}" , ioe . getLocalizedMessage ( ) ) ; ok = false ; ioe . printStackTrace ( ) ; throw new ConfigFileIOException ( ioe . getLocalizedMessage ( ) ) ; } } if ( ok ) { log . info ( "Configuration loaded successfully" ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( this . toString ( ) ) ; } } }
Inicializa la configuracion .
10,492
public static void sortFile ( File sortDir , File inputFile , File outputFile , Comparator < String > comparator , boolean skipHeader ) { sortFile ( sortDir , inputFile , outputFile , comparator , skipHeader , DEFAULT_MAX_BYTES , MERGE_FACTOR ) ; }
Sort a file write sorted data to output file . Use the default max bytes size and the default merge factor .
10,493
public static void sortFile ( File sortDir , File inputFile , File outputFile , Comparator < String > comparator , boolean skipHeader , long maxBytes , int mergeFactor ) { if ( comparator == null ) { comparator = Lexical . ascending ( ) ; } List < File > splitFiles = split ( sortDir , inputFile , maxBytes , skipHeader ) ; List < File > sortedFiles = sort ( sortDir , splitFiles , comparator ) ; merge ( sortDir , sortedFiles , outputFile , comparator , mergeFactor ) ; }
Sort a file write sorted data to output file .
10,494
public void setWideIndex ( boolean wideIndex ) { this . wideIndex = wideIndex ; if ( types != null ) { for ( TypeASM t : types . values ( ) ) { Assembler as = ( Assembler ) t ; as . setWideIndex ( wideIndex ) ; } } }
Set goto and jsr to use wide index
10,495
public void fixAddress ( String name ) throws IOException { Label label = labels . get ( name ) ; if ( label == null ) { label = new Label ( name ) ; labels . put ( name , label ) ; } int pos = position ( ) ; label . setAddress ( pos ) ; labelMap . put ( pos , label ) ; }
Fixes address here for object
10,496
public Branch createBranch ( String name ) throws IOException { Label label = labels . get ( name ) ; if ( label == null ) { label = new Label ( name ) ; labels . put ( name , label ) ; } return label . createBranch ( position ( ) ) ; }
Creates a branch for possibly unknown address
10,497
public void ifeq ( String target ) throws IOException { if ( wideIndex ) { out . writeByte ( NOT_IFEQ ) ; out . writeShort ( WIDEFIXOFFSET ) ; Branch branch = createBranch ( target ) ; out . writeByte ( GOTO_W ) ; out . writeInt ( branch ) ; } else { Branch branch = createBranch ( target ) ; out . writeOpCode ( IFEQ ) ; out . writeShort ( branch ) ; } }
eq succeeds if and only if value == 0
10,498
public void ifne ( String target ) throws IOException { if ( wideIndex ) { out . writeByte ( NOT_IFNE ) ; out . writeShort ( WIDEFIXOFFSET ) ; Branch branch = createBranch ( target ) ; out . writeByte ( GOTO_W ) ; out . writeInt ( branch ) ; } else { Branch branch = createBranch ( target ) ; out . writeOpCode ( IFNE ) ; out . writeShort ( branch ) ; } }
ne succeeds if and only if value ! = 0
10,499
public void iflt ( String target ) throws IOException { if ( wideIndex ) { out . writeByte ( NOT_IFLT ) ; out . writeShort ( WIDEFIXOFFSET ) ; Branch branch = createBranch ( target ) ; out . writeByte ( GOTO_W ) ; out . writeInt ( branch ) ; } else { Branch branch = createBranch ( target ) ; out . writeOpCode ( IFLT ) ; out . writeShort ( branch ) ; } }
lt succeeds if and only if value &lt ; 0