signature:
public class BaseNamingStrategy { /** * Replaces action path macros in the path .
 * If one of the provided paths is < code > null < / code >
 * it will not be replaced - so to emphasize the problem . */
protected String replaceActionNameMacros ( String path , final ActionNames actionNames ) { } }

implementation: final String packageName = actionNames . packageName ( ) ; final String className = actionNames . className ( ) ; final String methodName = actionNames . methodName ( ) ; final String httpMethod = actionNames . httpMethod ( ) ; if ( packageName != null ) { path = StringUtil . replace ( path , PACKAGE_MACRO , packageName ) ; } if ( className != null ) { path = StringUtil . replace ( path , CLASS_MACRO , className ) ; } if ( methodName != null ) { path = StringUtil . replace ( path , METHOD_MACRO , methodName ) ; } if ( httpMethod != null ) { path = StringUtil . replace ( path , HTTPMETHOD_MACRO , httpMethod ) ; } return path ;


signature:
public class BaseNamingStrategy { /** * Single point of { @ link ActionDefinition } creation .
 * Also performs the replacement of action path macros ! */
protected ActionDefinition createActionDef ( String path , String httpMethod , String resultBasePath , final ActionNames actionNames ) { } }

implementation: path = replaceActionNameMacros ( path , actionNames ) ; if ( httpMethod != null ) { httpMethod = replaceActionNameMacros ( httpMethod , actionNames ) ; } if ( resultBasePath != null ) { resultBasePath = replaceActionNameMacros ( resultBasePath , actionNames ) ; } return new ActionDefinition ( path , httpMethod , resultBasePath ) ;


signature:
public class BaseNamingStrategy { /** * Returns { @ code true } if path is absolute . */
protected boolean isAbsolutePath ( final String path ) { } }

implementation: if ( path == null ) { return false ; } return path . startsWith ( StringPool . SLASH ) ;


signature:
public class PropertiesUtil { /** * Create properties from the file .
 * @ param file properties file to load */
public static Properties createFromFile ( final File file ) throws IOException { } }

implementation: Properties prop = new Properties ( ) ; loadFromFile ( prop , file ) ; return prop ;


signature:
public class PropertiesUtil { /** * Loads properties from the file . Properties are appended to the existing
 * properties object .
 * @ param p properties to fill in
 * @ param fileName properties file name to load */
public static void loadFromFile ( final Properties p , final String fileName ) throws IOException { } }

implementation: loadFromFile ( p , new File ( fileName ) ) ;


signature:
public class PropertiesUtil { /** * Loads properties from the file . Properties are appended to the existing
 * properties object .
 * @ param p properties to fill in
 * @ param file file to read properties from */
public static void loadFromFile ( final Properties p , final File file ) throws IOException { } }

implementation: FileInputStream fis = null ; try { fis = new FileInputStream ( file ) ; p . load ( fis ) ; } finally { StreamUtil . close ( fis ) ; }


signature:
public class PropertiesUtil { /** * Writes properties to a file .
 * @ param p properties to write to file
 * @ param fileName destination file name */
public static void writeToFile ( final Properties p , final String fileName ) throws IOException { } }

implementation: writeToFile ( p , new File ( fileName ) , null ) ;


signature:
public class PropertiesUtil { /** * Writes properties to a file .
 * @ param p properties to write to file
 * @ param fileName destination file name
 * @ param header optional header */
public static void writeToFile ( final Properties p , final String fileName , final String header ) throws IOException { } }

implementation: writeToFile ( p , new File ( fileName ) , header ) ;


signature:
public class PropertiesUtil { /** * Writes properties to a file .
 * @ param p properties to write to file
 * @ param file destination file */
public static void writeToFile ( final Properties p , final File file ) throws IOException { } }

implementation: writeToFile ( p , file , null ) ;


signature:
public class PropertiesUtil { /** * Writes properties to a file .
 * @ param p properties to write to file
 * @ param file destination file
 * @ param header optional header */
public static void writeToFile ( final Properties p , final File file , final String header ) throws IOException { } }

implementation: FileOutputStream fos = null ; try { fos = new FileOutputStream ( file ) ; p . store ( fos , header ) ; } finally { StreamUtil . close ( fos ) ; }


signature:
public class PropertiesUtil { /** * Creates properties from string . */
public static Properties createFromString ( final String data ) throws IOException { } }

implementation: Properties p = new Properties ( ) ; loadFromString ( p , data ) ; return p ;


signature:
public class PropertiesUtil { /** * Loads properties from string . */
public static void loadFromString ( final Properties p , final String data ) throws IOException { } }

implementation: try ( ByteArrayInputStream is = new ByteArrayInputStream ( data . getBytes ( StringPool . ISO_8859_1 ) ) ) { p . load ( is ) ; }


signature:
public class PropertiesUtil { /** * Creates new Properties object from the original one , by copying
 * those properties that have specified first part of the key name .
 * Prefix may be optionally stripped during this process .
 * @ param p source properties , from which new object will be created
 * @ param prefix key names prefix
 * @ return subset properties */
public static Properties subset ( final Properties p , String prefix , final boolean stripPrefix ) { } }

implementation: if ( StringUtil . isBlank ( prefix ) ) { return p ; } if ( ! prefix . endsWith ( StringPool . DOT ) ) { prefix += '.' ; } Properties result = new Properties ( ) ; int baseLen = prefix . length ( ) ; for ( Object o : p . keySet ( ) ) { String key = ( String ) o ; if ( key . startsWith ( prefix ) ) { result . setProperty ( stripPrefix ? key . substring ( baseLen ) : key , p . getProperty ( key ) ) ; } } return result ;


signature:
public class PropertiesUtil { /** * Creates properties from classpath . */
public static Properties createFromClasspath ( final String ... rootTemplate ) { } }

implementation: Properties p = new Properties ( ) ; return loadFromClasspath ( p , rootTemplate ) ;


signature:
public class PropertiesUtil { /** * Loads properties from classpath file ( s ) . Properties are specified using wildcards . */
public static Properties loadFromClasspath ( final Properties p , final String ... rootTemplate ) { } }

implementation: ClassScanner . create ( ) . registerEntryConsumer ( entryData -> UncheckedException . runAndWrapException ( ( ) -> p . load ( entryData . openInputStream ( ) ) ) ) . includeResources ( true ) . ignoreException ( true ) . excludeAllEntries ( true ) . includeEntries ( rootTemplate ) . scanDefaultClasspath ( ) ; return p ;


signature:
public class PropertiesUtil { /** * Returns String property from a map . If key is not found , or if value is not a String , returns < code > null < / code > .
 * Mimics < code > Property . getProperty < / code > but on map . */
public static String getProperty ( final Map map , final String key ) { } }

implementation: return getProperty ( map , key , null ) ;


signature:
public class PropertiesUtil { /** * Returns String property from a map .
 * @ see # getProperty ( java . util . Map , String ) */
public static String getProperty ( final Map map , final String key , final String defaultValue ) { } }

implementation: Object val = map . get ( key ) ; return ( val instanceof String ) ? ( String ) val : defaultValue ;


signature:
public class PropertiesUtil { /** * Resolves all variables . */
public static void resolveAllVariables ( final Properties prop ) { } }

implementation: for ( Object o : prop . keySet ( ) ) { String key = ( String ) o ; String value = resolveProperty ( prop , key ) ; prop . setProperty ( key , value ) ; }


signature:
public class PropertiesUtil { /** * Returns property with resolved variables . */
public static String resolveProperty ( final Map map , final String key ) { } }

implementation: String value = getProperty ( map , key ) ; if ( value == null ) { return null ; } value = stp . parse ( value , macroName -> getProperty ( map , macroName ) ) ; return value ;


signature:
public class AnnotationTxAdviceManager { /** * Resolves tx scope from scope pattern . */
public String resolveScope ( final Class type , final String methodName ) { } }

implementation: if ( scopePattern == null ) { return null ; } String ctx = scopePattern ; ctx = StringUtil . replace ( ctx , JTXCTX_PATTERN_CLASS , type . getName ( ) ) ; ctx = StringUtil . replace ( ctx , JTXCTX_PATTERN_METHOD , methodName ) ; return ctx ;


signature:
public class AnnotationTxAdviceManager { /** * Reads transaction mode from method annotation . Annotations are cached for better performances .
 * @ param type target class
 * @ param methodName target method name over which the transaction should be wrapped
 * @ param methodArgTypes types of arguments , used to find the method
 * @ param unique unique method fingerprint that contains return and arguments type information */
public synchronized JtxTransactionMode getTxMode ( final Class type , final String methodName , final Class [ ] methodArgTypes , final String unique ) { } }

implementation: String signature = type . getName ( ) + '#' + methodName + '%' + unique ; JtxTransactionMode txMode = txmap . get ( signature ) ; if ( txMode == null ) { if ( ! txmap . containsKey ( signature ) ) { final Method m ; try { m = type . getMethod ( methodName , methodArgTypes ) ; } catch ( NoSuchMethodException nsmex ) { throw new ProxettaException ( nsmex ) ; } final TransactionAnnotationValues txAnn = readTransactionAnnotation ( m ) ; if ( txAnn != null ) { txMode = new JtxTransactionMode ( txAnn . propagation ( ) , txAnn . isolation ( ) , txAnn . readOnly ( ) , txAnn . timeout ( ) ) ; } else { txMode = defaultTransactionMode ; } txmap . put ( signature , txMode ) ; } } return txMode ;


signature:
public class AnnotationTxAdviceManager { /** * Registers new TX annotations . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public void registerAnnotations ( final Class < ? extends Annotation > [ ] annotations ) { this . annotations = annotations ; this . annotationParsers = new AnnotationParser [ annotations . length ] ; for ( int i = 0 ; i < annotations . length ; i ++ ) { annotationParsers [ i ] = TransactionAnnotationValues . parserFor ( annotations [ i ] ) ; }


signature:
public class AnnotationTxAdviceManager { /** * Finds TX annotation . */
protected TransactionAnnotationValues readTransactionAnnotation ( final Method method ) { } }

implementation: for ( AnnotationParser annotationParser : annotationParsers ) { TransactionAnnotationValues tad = TransactionAnnotationValues . of ( annotationParser , method ) ; if ( tad != null ) { return tad ; } } return null ;


signature:
public class CssSelector { /** * - - - - - attributes */
public void addIdSelector ( String id ) { } }

implementation: id = unescape ( id ) ; selectors . add ( new AttributeSelector ( ID , EQUALS , id ) ) ;


signature:
public class CssSelector { /** * Accepts single node . */
@ Override public boolean accept ( final Node node ) { } }

implementation:
// match element name with node name
if ( ! matchElement ( node ) ) { return false ; } // match attributes
int totalSelectors = selectorsCount ( ) ; for ( int i = 0 ; i < totalSelectors ; i ++ ) { Selector selector = getSelector ( i ) ; // just attr name existence
switch ( selector . getType ( ) ) { case ATTRIBUTE : if ( ! ( ( AttributeSelector ) selector ) . accept ( node ) ) { return false ; } break ; case PSEUDO_CLASS : if ( ! ( ( PseudoClassSelector ) selector ) . accept ( node ) ) { return false ; } break ; case PSEUDO_FUNCTION : if ( ! ( ( PseudoFunctionSelector ) selector ) . accept ( node ) ) { return false ; } break ; } } return true ;


signature:
public class CssSelector { /** * Matches element to css selector . All non - element types are ignored . */
protected boolean matchElement ( final Node node ) { } }

implementation: if ( node . getNodeType ( ) != Node . NodeType . ELEMENT ) { return false ; } String element = getElement ( ) ; String nodeName = node . getNodeName ( ) ; return element . equals ( StringPool . STAR ) || element . equals ( nodeName ) ;


signature:
public class CssSelector { /** * Accepts node within current results . */
public boolean accept ( final List < Node > currentResults , final Node node , final int index ) { } }

implementation:
// match attributes
int totalSelectors = selectorsCount ( ) ; for ( int i = 0 ; i < totalSelectors ; i ++ ) { Selector selector = getSelector ( i ) ; // just attr name existence
switch ( selector . getType ( ) ) { case PSEUDO_FUNCTION : if ( ! ( ( PseudoFunctionSelector ) selector ) . accept ( currentResults , node , index ) ) { return false ; } break ; case PSEUDO_CLASS : if ( ! ( ( PseudoClassSelector ) selector ) . accept ( currentResults , node , index ) ) { return false ; } break ; default : } } return true ;


signature:
public class CssSelector { /** * Unescapes CSS string by removing all backslash characters from it . */
protected String unescape ( final String value ) { } }

implementation: if ( value . indexOf ( '\\' ) == - 1 ) { return value ; } return StringUtil . remove ( value , '\\' ) ;


signature:
public class JavaInfo { /** * Builds a set of java core packages . */
private String [ ] buildJrePackages ( final int javaVersionNumber ) { } }

implementation:
final ArrayList < String > packages = new ArrayList < > ( ) ; switch ( javaVersionNumber ) { case 9 : case 8 : case 7 : case 6 : case 5 : // in Java1.5 , the apache stuff moved
packages . add ( "com.sun.org.apache" ) ; // fall through . . .
case 4 : if ( javaVersionNumber == 4 ) { packages . add ( "org.apache.crimson" ) ; packages . add ( "org.apache.xalan" ) ; packages . add ( "org.apache.xml" ) ; packages . add ( "org.apache.xpath" ) ; } packages . add ( "org.ietf.jgss" ) ; packages . add ( "org.w3c.dom" ) ; packages . add ( "org.xml.sax" ) ; // fall through . . .
case 3 : packages . add ( "org.omg" ) ; packages . add ( "com.sun.corba" ) ; packages . add ( "com.sun.jndi" ) ; packages . add ( "com.sun.media" ) ; packages . add ( "com.sun.naming" ) ; packages . add ( "com.sun.org.omg" ) ; packages . add ( "com.sun.rmi" ) ; packages . add ( "sunw.io" ) ; packages . add ( "sunw.util" ) ; // fall through . . .
case 2 : packages . add ( "com.sun.java" ) ; packages . add ( "com.sun.image" ) ; // fall through . . .
case 1 : default : // core stuff
packages . add ( "sun" ) ; packages . add ( "java" ) ; packages . add ( "javax" ) ; break ; } return packages . toArray ( new String [ 0 ] ) ;


signature:
public class JavaInfo { /** * - - - - - java checks */
private int detectJavaVersionNumber ( ) { } }

implementation:
String javaVersion = JAVA_VERSION ; final int lastDashNdx = javaVersion . lastIndexOf ( '-' ) ; if ( lastDashNdx != - 1 ) { javaVersion = javaVersion . substring ( 0 , lastDashNdx ) ; } if ( javaVersion . startsWith ( "1." ) ) { // up to java 8
final int index = javaVersion . indexOf ( '.' , 2 ) ; return Integer . parseInt ( javaVersion . substring ( 2 , index ) ) ; } else { final int index = javaVersion . indexOf ( '.' ) ; return Integer . parseInt ( index == - 1 ? javaVersion : javaVersion . substring ( 0 , index ) ) ; }


signature:
public class Node { /** * Copies all non - final values to the empty cloned object .
 * Cache - related values are not copied . */
protected < T extends Node > T cloneTo ( final T dest ) { } }

implementation:
// dest . nodeValue = nodeValue ; / / already in clone implementations !
dest . parentNode = parentNode ; if ( attributes != null ) { dest . attributes = new ArrayList < > ( attributes . size ( ) ) ; for ( int i = 0 , attributesSize = attributes . size ( ) ; i < attributesSize ; i ++ ) { Attribute attr = attributes . get ( i ) ; dest . attributes . add ( attr . clone ( ) ) ; } } if ( childNodes != null ) { dest . childNodes = new ArrayList < > ( childNodes . size ( ) ) ; for ( int i = 0 , childNodesSize = childNodes . size ( ) ; i < childNodesSize ; i ++ ) { Node child = childNodes . get ( i ) ; Node childClone = child . clone ( ) ; childClone . parentNode = dest ; // fix parent !
dest . childNodes . add ( childClone ) ; } } return dest ;


signature:
public class Node { /** * Removes this node from DOM tree . */
public void detachFromParent ( ) { } }

implementation: if ( parentNode == null ) { return ; } if ( parentNode . childNodes != null ) { parentNode . childNodes . remove ( siblingIndex ) ; parentNode . reindexChildren ( ) ; } parentNode = null ;


signature:
public class Node { /** * Appends child node . Don ' t use this node in the loop ,
 * since it might be slow due to { @ link # reindexChildren ( ) } . */
public void addChild ( final Node node ) { } }

implementation: node . detachFromParent ( ) ; node . parentNode = this ; initChildNodes ( node ) ; childNodes . add ( node ) ; reindexChildrenOnAdd ( 1 ) ;


signature:
public class Node { /** * Appends several child nodes at once .
 * Reindex is done only once , after all children are added . */
public void addChild ( final Node ... nodes ) { } }

implementation:
if ( nodes . length == 0 ) { return ; // nothing to add
} for ( Node node : nodes ) { node . detachFromParent ( ) ; node . parentNode = this ; initChildNodes ( node ) ; childNodes . add ( node ) ; } reindexChildrenOnAdd ( nodes . length ) ;


signature:
public class Node { /** * Inserts node at given index . */
public void insertChild ( final Node node , final int index ) { } }

implementation: node . detachFromParent ( ) ; node . parentNode = this ; try { initChildNodes ( node ) ; childNodes . add ( index , node ) ; } catch ( IndexOutOfBoundsException ignore ) { throw new LagartoDOMException ( "Invalid node index: " + index ) ; } reindexChildren ( ) ;


signature:
public class Node { /** * Inserts node before provided node . */
public void insertBefore ( final Node newChild , final Node refChild ) { } }

implementation: int siblingIndex = refChild . getSiblingIndex ( ) ; refChild . parentNode . insertChild ( newChild , siblingIndex ) ;


signature:
public class Node { /** * Inserts several child nodes before provided node . */
public void insertBefore ( final Node [ ] newChilds , final Node refChild ) { } }

implementation: if ( newChilds . length == 0 ) { return ; } int siblingIndex = refChild . getSiblingIndex ( ) ; refChild . parentNode . insertChild ( newChilds , siblingIndex ) ;


signature:
public class Node { /** * Inserts node after provided node . */
public void insertAfter ( final Node newChild , final Node refChild ) { } }

implementation: int siblingIndex = refChild . getSiblingIndex ( ) + 1 ; if ( siblingIndex == refChild . parentNode . getChildNodesCount ( ) ) { refChild . parentNode . addChild ( newChild ) ; } else { refChild . parentNode . insertChild ( newChild , siblingIndex ) ; }


signature:
public class Node { /** * Inserts several child nodes after referent node . */
public void insertAfter ( final Node [ ] newChilds , final Node refChild ) { } }

implementation: if ( newChilds . length == 0 ) { return ; } int siblingIndex = refChild . getSiblingIndex ( ) + 1 ; if ( siblingIndex == refChild . parentNode . getChildNodesCount ( ) ) { refChild . parentNode . addChild ( newChilds ) ; } else { refChild . parentNode . insertChild ( newChilds , siblingIndex ) ; }


signature:
public class Node { /** * Removes child node at given index .
 * Returns removed node or < code > null < / code > if index is invalid . */
public Node removeChild ( final int index ) { } }

implementation: if ( childNodes == null ) { return null ; } Node node ; try { node = childNodes . get ( index ) ; } catch ( IndexOutOfBoundsException ignore ) { return null ; } node . detachFromParent ( ) ; return node ;


signature:
public class Node { /** * Removes all child nodes . Each child node will be detached from this parent . */
public void removeAllChilds ( ) { } }

implementation: List < Node > removedNodes = childNodes ; childNodes = null ; childElementNodes = null ; childElementNodesCount = 0 ; if ( removedNodes != null ) { for ( int i = 0 , removedNodesSize = removedNodes . size ( ) ; i < removedNodesSize ; i ++ ) { Node removedNode = removedNodes . get ( i ) ; removedNode . detachFromParent ( ) ; } }


signature:
public class Node { /** * Returns attribute at given index or < code > null < / code > if index not found . */
public Attribute getAttribute ( final int index ) { } }

implementation: if ( attributes == null ) { return null ; } if ( ( index < 0 ) || ( index >= attributes . size ( ) ) ) { return null ; } return attributes . get ( index ) ;


signature:
public class Node { /** * Returns < code > true < / code > if node contains an attribute . */
public boolean hasAttribute ( String name ) { } }

implementation: if ( attributes == null ) { return false ; } if ( ! ownerDocument . config . isCaseSensitive ( ) ) { name = name . toLowerCase ( ) ; } for ( int i = 0 , attributesSize = attributes . size ( ) ; i < attributesSize ; i ++ ) { Attribute attr = attributes . get ( i ) ; if ( attr . getName ( ) . equals ( name ) ) { return true ; } } return false ;


signature:
public class Node { /** * Returns attribute value . Returns < code > null < / code > when
 * attribute doesn ' t exist or when attribute exist but doesn ' t
 * specify a value . */
public String getAttribute ( final String name ) { } }

implementation: Attribute attribute = getAttributeInstance ( name ) ; if ( attribute == null ) { return null ; } return attribute . getValue ( ) ;


signature:
public class Node { /** * Sets attribute value . Value may be < code > null < / code > . */
public void setAttribute ( String name , final String value ) { } }

implementation:
initAttributes ( ) ; String rawAttributeName = name ; if ( ! ownerDocument . config . isCaseSensitive ( ) ) { name = name . toLowerCase ( ) ; } // search if attribute with the same name exist
for ( int i = 0 , attributesSize = attributes . size ( ) ; i < attributesSize ; i ++ ) { Attribute attr = attributes . get ( i ) ; if ( attr . getName ( ) . equals ( name ) ) { attr . setValue ( value ) ; return ; } } attributes . add ( new Attribute ( rawAttributeName , name , value ) ) ;


signature:
public class Node { /** * Returns < code > true < / code > if attribute containing some word . */
public boolean isAttributeContaining ( final String name , final String word ) { } }

implementation: Attribute attr = getAttributeInstance ( name ) ; if ( attr == null ) { return false ; } return attr . isContaining ( word ) ;


signature:
public class Node { /** * Finds the first child node with given node name . */
public Node findChildNodeWithName ( final String name ) { } }

implementation: if ( childNodes == null ) { return null ; } for ( final Node childNode : childNodes ) { if ( childNode . getNodeName ( ) . equals ( name ) ) { return childNode ; } } return null ;


signature:
public class Node { /** * Filters child nodes . */
public Node [ ] filterChildNodes ( final Predicate < Node > nodePredicate ) { } }

implementation: if ( childNodes == null ) { return new Node [ 0 ] ; } return childNodes . stream ( ) . filter ( nodePredicate ) . toArray ( Node [ ] :: new ) ;


signature:
public class Node { /** * Returns a child node at given index or < code > null < / code >
 * if child doesn ' t exist for that index . */
public Node getChild ( final int index ) { } }

implementation: if ( childNodes == null ) { return null ; } if ( ( index < 0 ) || ( index >= childNodes . size ( ) ) ) { return null ; } return childNodes . get ( index ) ;


signature:
public class Node { /** * Returns a child node with given hierarchy .
 * Just a shortcut for successive calls of { @ link # getChild ( int ) } . */
public Node getChild ( final int ... indexes ) { } }

implementation: Node node = this ; for ( int index : indexes ) { node = node . getChild ( index ) ; } return node ;


signature:
public class Node { /** * Returns a child element node at given index .
 * If index is out of bounds , < code > null < / code > is returned . */
public Element getChildElement ( final int index ) { } }

implementation: initChildElementNodes ( ) ; if ( ( index < 0 ) || ( index >= childElementNodes . length ) ) { return null ; } return childElementNodes [ index ] ;


signature:
public class Node { /** * Returns first child or < code > null < / code > if no children exist . */
public Node getFirstChild ( ) { } }

implementation: if ( childNodes == null ) { return null ; } if ( childNodes . isEmpty ( ) ) { return null ; } return childNodes . get ( 0 ) ;


signature:
public class Node { /** * Returns last child or < code > null < / code > if no children exist . */
public Node getLastChild ( ) { } }

implementation: if ( childNodes == null ) { return null ; } if ( childNodes . isEmpty ( ) ) { return null ; } return childNodes . get ( getChildNodesCount ( ) - 1 ) ;


signature:
public class Node { /** * Returns last child < b > element < / b > with given name or
 * < code > null < / code > if no such child node exist . */
public Element getLastChildElement ( final String elementName ) { } }

implementation: if ( childNodes == null ) { return null ; } int from = childNodes . size ( ) - 1 ; for ( int i = from ; i >= 0 ; i -- ) { Node child = childNodes . get ( i ) ; if ( child . getNodeType ( ) == NodeType . ELEMENT && elementName . equals ( child . getNodeName ( ) ) ) { child . initSiblingNames ( ) ; return ( Element ) child ; } } return null ;


signature:
public class Node { /** * Checks the health of child nodes . Useful during complex tree manipulation ,
 * to check if everything is OK . Not optimized for speed , should be used just
 * for testing purposes . */
public boolean check ( ) { } }

implementation:
if ( childNodes == null ) { return true ; } // children
int siblingElementIndex = 0 ; for ( int i = 0 , childNodesSize = childNodes . size ( ) ; i < childNodesSize ; i ++ ) { Node childNode = childNodes . get ( i ) ; if ( childNode . siblingIndex != i ) { return false ; } if ( childNode . getNodeType ( ) == NodeType . ELEMENT ) { if ( childNode . siblingElementIndex != siblingElementIndex ) { return false ; } siblingElementIndex ++ ; } } if ( childElementNodesCount != siblingElementIndex ) { return false ; } // child element nodes
if ( childElementNodes != null ) { if ( childElementNodes . length != childElementNodesCount ) { return false ; } int childCount = getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Node child = getChild ( i ) ; if ( child . siblingElementIndex >= 0 ) { if ( childElementNodes [ child . siblingElementIndex ] != child ) { return false ; } } } } // sibling names
if ( siblingNameIndex != - 1 ) { List < Node > siblings = parentNode . childNodes ; int index = 0 ; for ( int i = 0 , siblingsSize = siblings . size ( ) ; i < siblingsSize ; i ++ ) { Node sibling = siblings . get ( i ) ; if ( sibling . siblingNameIndex == - 1 && nodeType == NodeType . ELEMENT && nodeName . equals ( sibling . getNodeName ( ) ) ) { if ( sibling . siblingNameIndex != index ++ ) { return false ; } } } } // process children
for ( Node childNode : childNodes ) { if ( ! childNode . check ( ) ) { return false ; } } return true ;


signature:
public class Node { /** * Reindex children nodes . Must be called on every children addition / removal .
 * Iterates { @ link # childNodes } list and :
 * < ul >
 * < li > calculates three different sibling indexes , < / li >
 * < li > calculates total child element node count , < / li >
 * < li > resets child element nodes array ( will be init lazy later by @ { # initChildElementNodes } . < / li >
 * < / ul > */
protected void reindexChildren ( ) { } }

implementation:
int siblingElementIndex = 0 ; for ( int i = 0 , childNodesSize = childNodes . size ( ) ; i < childNodesSize ; i ++ ) { Node childNode = childNodes . get ( i ) ; childNode . siblingIndex = i ; childNode . siblingNameIndex = - 1 ; // reset sibling name info
if ( childNode . getNodeType ( ) == NodeType . ELEMENT ) { childNode . siblingElementIndex = siblingElementIndex ; siblingElementIndex ++ ; } } childElementNodesCount = siblingElementIndex ; childElementNodes = null ; // reset child element nodes


signature:
public class Node { /** * Initializes list of child elements . */
protected void initChildElementNodes ( ) { } }

implementation: if ( childElementNodes == null ) { childElementNodes = new Element [ childElementNodesCount ] ; int childCount = getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Node child = getChild ( i ) ; if ( child . siblingElementIndex >= 0 ) { childElementNodes [ child . siblingElementIndex ] = ( Element ) child ; } } }


signature:
public class Node { /** * Initializes siblings elements of the same name . */
protected void initSiblingNames ( ) { } }

implementation: if ( siblingNameIndex == - 1 ) { List < Node > siblings = parentNode . childNodes ; int index = 0 ; for ( int i = 0 , siblingsSize = siblings . size ( ) ; i < siblingsSize ; i ++ ) { Node sibling = siblings . get ( i ) ; if ( sibling . siblingNameIndex == - 1 && nodeType == NodeType . ELEMENT && nodeName . equals ( sibling . getNodeName ( ) ) ) { sibling . siblingNameIndex = index ++ ; } } }


signature:
public class Node { /** * Initializes child nodes list when needed .
 * Also fix owner document for new node , if needed . */
protected void initChildNodes ( final Node newNode ) { } }

implementation: if ( childNodes == null ) { childNodes = new ArrayList < > ( ) ; } if ( ownerDocument != null ) { if ( newNode . ownerDocument != ownerDocument ) { changeOwnerDocument ( newNode , ownerDocument ) ; } }


signature:
public class Node { /** * Changes owner document for given node and all its children . */
protected void changeOwnerDocument ( final Node node , final Document ownerDocument ) { } }

implementation: node . ownerDocument = ownerDocument ; int childCount = node . getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Node child = node . getChild ( i ) ; changeOwnerDocument ( child , ownerDocument ) ; }


signature:
public class Node { /** * Returns this node ' s next sibling of < b > any < / b > type or
 * < code > null < / code > if this is the last sibling . */
public Node getNextSibling ( ) { } }

implementation: List < Node > siblings = parentNode . childNodes ; int index = siblingIndex + 1 ; if ( index >= siblings . size ( ) ) { return null ; } return siblings . get ( index ) ;


signature:
public class Node { /** * Returns this node ' s next < b > element < / b > . */
public Node getNextSiblingElement ( ) { } }

implementation: parentNode . initChildElementNodes ( ) ; if ( siblingElementIndex == - 1 ) { int max = parentNode . getChildNodesCount ( ) ; for ( int i = siblingIndex ; i < max ; i ++ ) { Node sibling = parentNode . childNodes . get ( i ) ; if ( sibling . getNodeType ( ) == NodeType . ELEMENT ) { return sibling ; } } return null ; } int index = siblingElementIndex + 1 ; if ( index >= parentNode . childElementNodesCount ) { return null ; } return parentNode . childElementNodes [ index ] ;


signature:
public class Node { /** * Returns this node ' s next < b > element < / b > with the same name . */
public Node getNextSiblingName ( ) { } }

implementation: if ( nodeName == null ) { return null ; } initSiblingNames ( ) ; int index = siblingNameIndex + 1 ; int max = parentNode . getChildNodesCount ( ) ; for ( int i = siblingIndex + 1 ; i < max ; i ++ ) { Node sibling = parentNode . childNodes . get ( i ) ; if ( ( index == sibling . siblingNameIndex ) && nodeName . equals ( sibling . getNodeName ( ) ) ) { return sibling ; } } return null ;


signature:
public class Node { /** * Returns this node ' s previous sibling of < b > any < / b > type
 * or < code > null < / code > if this is the first sibling . */
public Node getPreviousSibling ( ) { } }

implementation: List < Node > siblings = parentNode . childNodes ; int index = siblingIndex - 1 ; if ( index < 0 ) { return null ; } return siblings . get ( index ) ;


signature:
public class Node { /** * Returns this node ' s previous sibling of < b > element < / b > type
 * or < code > null < / code > if this is the first sibling . */
public Node getPreviousSiblingElement ( ) { } }

implementation: parentNode . initChildElementNodes ( ) ; if ( siblingElementIndex == - 1 ) { for ( int i = siblingIndex - 1 ; i >= 0 ; i -- ) { Node sibling = parentNode . childNodes . get ( i ) ; if ( sibling . getNodeType ( ) == NodeType . ELEMENT ) { return sibling ; } } return null ; } int index = siblingElementIndex - 1 ; if ( index < 0 ) { return null ; } return parentNode . childElementNodes [ index ] ;


signature:
public class Node { /** * Returns this node ' s previous sibling element with the same name . */
public Node getPreviousSiblingName ( ) { } }

implementation: if ( nodeName == null ) { return null ; } initSiblingNames ( ) ; int index = siblingNameIndex - 1 ; for ( int i = siblingIndex ; i >= 0 ; i -- ) { Node sibling = parentNode . childNodes . get ( i ) ; if ( ( index == sibling . siblingNameIndex ) && nodeName . equals ( sibling . getNodeName ( ) ) ) { return sibling ; } } return null ;


signature:
public class Node { /** * Returns the text content of this node and its descendants .
 * @ see # appendTextContent ( Appendable ) */
public String getTextContent ( ) { } }

implementation: StringBuilder sb = new StringBuilder ( getChildNodesCount ( ) + 1 ) ; appendTextContent ( sb ) ; return sb . toString ( ) ;


signature:
public class Node { /** * Appends the text content to an < code > Appendable < / code >
 * ( < code > StringBuilder < / code > , < code > CharBuffer < / code > . . . ) .
 * This way we can reuse the < code > Appendable < / code > instance
 * during the creation of text content and have better performances . */
public void appendTextContent ( final Appendable appendable ) { } }

implementation: if ( nodeValue != null ) { if ( ( nodeType == NodeType . TEXT ) || ( nodeType == NodeType . CDATA ) ) { try { appendable . append ( nodeValue ) ; } catch ( IOException ioex ) { throw new LagartoDOMException ( ioex ) ; } } } if ( childNodes != null ) { for ( int i = 0 , childNodesSize = childNodes . size ( ) ; i < childNodesSize ; i ++ ) { Node childNode = childNodes . get ( i ) ; childNode . appendTextContent ( appendable ) ; } }


signature:
public class Node { /** * Generates HTML . */
public String getHtml ( ) { } }

implementation: LagartoDomBuilderConfig lagartoDomBuilderConfig ; if ( ownerDocument == null ) { lagartoDomBuilderConfig = ( ( Document ) this ) . getConfig ( ) ; } else { lagartoDomBuilderConfig = ownerDocument . getConfig ( ) ; } LagartoHtmlRenderer lagartoHtmlRenderer = lagartoDomBuilderConfig . getLagartoHtmlRenderer ( ) ; return lagartoHtmlRenderer . toHtml ( this , new StringBuilder ( ) ) ;


signature:
public class Node { /** * Generates inner HTML . */
public String getInnerHtml ( ) { } }

implementation: LagartoDomBuilderConfig lagartoDomBuilderConfig ; if ( ownerDocument == null ) { lagartoDomBuilderConfig = ( ( Document ) this ) . getConfig ( ) ; } else { lagartoDomBuilderConfig = ownerDocument . getConfig ( ) ; } LagartoHtmlRenderer lagartoHtmlRenderer = lagartoDomBuilderConfig . getLagartoHtmlRenderer ( ) ; return lagartoHtmlRenderer . toInnerHtml ( this , new StringBuilder ( ) ) ;


signature:
public class Node { /** * Visits children nodes . */
protected void visitChildren ( final NodeVisitor nodeVisitor ) { } }

implementation: if ( childNodes != null ) { for ( int i = 0 , childNodesSize = childNodes . size ( ) ; i < childNodesSize ; i ++ ) { Node childNode = childNodes . get ( i ) ; childNode . visit ( nodeVisitor ) ; } }


signature:
public class Node { /** * Returns CSS path to this node from document root . */
public String getCssPath ( ) { } }

implementation: StringBuilder path = new StringBuilder ( ) ; Node node = this ; while ( node != null ) { String nodeName = node . getNodeName ( ) ; if ( nodeName != null ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( ' ' ) . append ( nodeName ) ; String id = node . getAttribute ( "id" ) ; if ( id != null ) { sb . append ( '#' ) . append ( id ) ; } path . insert ( 0 , sb ) ; } node = node . getParentNode ( ) ; } if ( path . charAt ( 0 ) == ' ' ) { return path . substring ( 1 ) ; } return path . toString ( ) ;


signature:
public class DecoratorTagVisitor { /** * Handle Decora tags . */
protected void onDecoraTag ( final Tag tag ) { } }

implementation:
String tagName = tag . getName ( ) . toString ( ) ; if ( tag . getType ( ) == TagType . SELF_CLOSING ) { checkNestedDecoraTags ( ) ; decoraTagName = tagName . substring ( 7 ) ; decoraTagStart = tag . getTagPosition ( ) ; decoraTagEnd = tag . getTagPosition ( ) + tag . getTagLength ( ) ; defineDecoraTag ( ) ; return ; } if ( tag . getType ( ) == TagType . START ) { checkNestedDecoraTags ( ) ; decoraTagName = tagName . substring ( 7 ) ; decoraTagStart = tag . getTagPosition ( ) ; decoraTagDefaultValueStart = tag . getTagPosition ( ) + tag . getTagLength ( ) ; return ; } // closed tag type
decoraTagEnd = tag . getTagPosition ( ) + tag . getTagLength ( ) ; decoraTagDefaultValueEnd = tag . getTagPosition ( ) ; defineDecoraTag ( ) ;


signature:
public class DecoratorTagVisitor { /** * Handle open and empty ID attribute tags . */
protected void onIdAttrStart ( final Tag tag ) { } }

implementation: String id = tag . getId ( ) . toString ( ) . substring ( 7 ) ; String tagName ; String idName ; int dashIndex = id . indexOf ( '-' ) ; if ( dashIndex == - 1 ) { tagName = id ; idName = null ; } else { tagName = id . substring ( 0 , dashIndex ) ; idName = id . substring ( dashIndex + 1 ) ; } if ( tag . getType ( ) == TagType . SELF_CLOSING ) { checkNestedDecoraTags ( ) ; decoraTagName = tagName ; decoraIdName = idName ; decoraTagStart = tag . getTagPosition ( ) ; decoraTagEnd = tag . getTagPosition ( ) + tag . getTagLength ( ) ; defineDecoraTag ( ) ; return ; } if ( tag . getType ( ) == TagType . START ) { checkNestedDecoraTags ( ) ; decoraTagName = tagName ; decoraIdName = idName ; decoraTagStart = tag . getTagPosition ( ) ; decoraTagDefaultValueStart = tag . getTagPosition ( ) + tag . getTagLength ( ) ; closingTagName = tag . getName ( ) . toString ( ) ; closingTagDeepLevel = tag . getDeepLevel ( ) ; }


signature:
public class DecoratorTagVisitor { /** * Defines Decora tag position inside decorator content .
 * Resets current Decora tag tracking . */
protected void defineDecoraTag ( ) { } }

implementation: DecoraTag decoraTag = decoraTagDefaultValueStart == 0 ? new DecoraTag ( decoraTagName , decoraIdName , decoraTagStart , decoraTagEnd ) : new DecoraTag ( decoraTagName , decoraIdName , decoraTagStart , decoraTagEnd , decoraTagDefaultValueStart , decoraTagDefaultValueEnd - decoraTagDefaultValueStart ) ; decoraTags . add ( decoraTag ) ; decoraTagName = null ; decoraIdName = null ; closingTagName = null ; decoraTagDefaultValueStart = 0 ;


signature:
public class JoyProxetta { /** * Adds a proxy aspect . */
@ Override public JoyProxetta addProxyAspect ( final ProxyAspect proxyAspect ) { } }

implementation: requireNotStarted ( proxetta ) ; this . proxyAspects . add ( proxyAspect ) ; return this ;


signature:
public class JoyProxetta { /** * Creates Proxetta with all aspects . The following aspects are created :
 * < ul >
 * < li > Transaction proxy - applied on all classes that contains public top - level methods
 * annotated with < code > @ Transaction < / code > annotation . This is just one way how proxies
 * can be applied - since base configuration is in Java , everything is possible . < / li >
 * < / ul > */
@ Override public void start ( ) { } }

implementation:
initLogger ( ) ; log . info ( "PROXETTA start ----------" ) ; final ProxyAspect [ ] proxyAspectsArray = this . proxyAspects . toArray ( new ProxyAspect [ 0 ] ) ; log . debug ( "Total proxy aspects: " + proxyAspectsArray . length ) ; // proxetta = Proxetta . wrapperProxetta ( ) . setCreateTargetInDefaultCtor ( true ) . withAspects ( proxyAspectsArray ) ;
proxetta = Proxetta . proxyProxetta ( ) . withAspects ( proxyAspectsArray ) ; log . info ( "PROXETTA OK!" ) ;


signature:
public class TypeCacheBenchmark { /** * - - - - - benchmark */
@ Benchmark public Object map ( ) { } }

implementation: final FastCharBuffer sb = new FastCharBuffer ( ) ; for ( final int index : indexes ) { sb . append ( map . get ( TYPES [ index ] ) ) ; } return sb ;


signature:
public class TimestampSqlType { /** * { @ inheritDoc } */
@ Override public Timestamp get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return rs . getTimestamp ( index ) ;


signature:
public class TimestampSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Timestamp value , final int dbSqlType ) throws SQLException { } }

implementation: st . setTimestamp ( index , value ) ;


signature:
public class MimeTypes { /** * Returns the corresponding MIME type to the given extension .
 * If no MIME type was found it returns < code > application / octet - stream < / code > type . */
public static String getMimeType ( final String ext ) { } }

implementation: String mimeType = lookupMimeType ( ext ) ; if ( mimeType == null ) { mimeType = MIME_APPLICATION_OCTET_STREAM ; } return mimeType ;


signature:
public class MimeTypes { /** * Finds all extensions that belong to given mime type ( s ) .
 * If wildcard mode is on , provided mime type is wildcard pattern .
 * @ param mimeType list of mime types , separated by comma
 * @ param useWildcard if set , mime types are wildcard patterns */
public static String [ ] findExtensionsByMimeTypes ( String mimeType , final boolean useWildcard ) { } }

implementation: final ArrayList < String > extensions = new ArrayList < > ( ) ; mimeType = mimeType . toLowerCase ( ) ; final String [ ] mimeTypes = StringUtil . splitc ( mimeType , ", " ) ; for ( final Map . Entry < String , String > entry : MIME_TYPE_MAP . entrySet ( ) ) { final String entryExtension = entry . getKey ( ) ; final String entryMimeType = entry . getValue ( ) . toLowerCase ( ) ; final int matchResult = useWildcard ? Wildcard . matchOne ( entryMimeType , mimeTypes ) : StringUtil . equalsOne ( entryMimeType , mimeTypes ) ; if ( matchResult != - 1 ) { extensions . add ( entryExtension ) ; } } if ( extensions . isEmpty ( ) ) { return StringPool . EMPTY_ARRAY ; } return extensions . toArray ( new String [ 0 ] ) ;


signature:
public class BooleanSqlType { /** * { @ inheritDoc } */
@ Override public Boolean get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return Boolean . valueOf ( rs . getBoolean ( index ) ) ;


signature:
public class BooleanSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Boolean value , final int dbSqlType ) throws SQLException { } }

implementation: st . setBoolean ( index , value . booleanValue ( ) ) ;


signature:
public class RootPackages { /** * Adds root package and its path mapping . Duplicate root packages
 * are ignored , if mapping path is equals , otherwise exception is thrown . */
public void addRootPackage ( final String rootPackage , String mapping ) { } }

implementation:
if ( packages == null ) { packages = new String [ 0 ] ; } if ( mappings == null ) { mappings = new String [ 0 ] ; } // fix mapping
if ( mapping . length ( ) > 0 ) { // mapping must start with the slash
if ( ! mapping . startsWith ( StringPool . SLASH ) ) { mapping = StringPool . SLASH + mapping ; } // mapping must NOT end with the slash
if ( mapping . endsWith ( StringPool . SLASH ) ) { mapping = StringUtil . substring ( mapping , 0 , - 1 ) ; } } // detect duplicates
for ( int i = 0 ; i < packages . length ; i ++ ) { if ( packages [ i ] . equals ( rootPackage ) ) { if ( mappings [ i ] . equals ( mapping ) ) { // both package and the mappings are the same
return ; } throw new MadvocException ( "Different mappings for the same root package: " + rootPackage ) ; } } packages = ArraysUtil . append ( packages , rootPackage ) ; mappings = ArraysUtil . append ( mappings , mapping ) ;


signature:
public class RootPackages { /** * Sets root package to package of given class . */
public void addRootPackageOf ( final Class actionClass , final String mapping ) { } }

implementation: addRootPackage ( actionClass . getPackage ( ) . getName ( ) , mapping ) ;


signature:
public class RootPackages { /** * Finds closest root package for the given action path . */
public String findRootPackageForActionPath ( final String actionPath ) { } }

implementation: if ( mappings == null ) { return null ; } int ndx = - 1 ; int delta = Integer . MAX_VALUE ; for ( int i = 0 ; i < mappings . length ; i ++ ) { String mapping = mappings [ i ] ; boolean found = false ; if ( actionPath . equals ( mapping ) ) { found = true ; } else { mapping += StringPool . SLASH ; if ( actionPath . startsWith ( mapping ) ) { found = true ; } } if ( found ) { int distance = actionPath . length ( ) - mapping . length ( ) ; if ( distance < delta ) { ndx = i ; delta = distance ; } } } if ( ndx == - 1 ) { return null ; } return packages [ ndx ] ;


signature:
public class RootPackages { /** * Finds mapping for given action class . Returns < code > null < / code >
 * if no mapping is found . If there is more then one matching root
 * package , the closest one will be returned . */
public String findPackagePathForActionPackage ( final String actionPackage ) { } }

implementation:
if ( packages == null ) { return null ; } if ( packagePaths == null ) { packagePaths = new HashMap < > ( ) ; } String packagePath = packagePaths . get ( actionPackage ) ; if ( packagePath != null ) { return packagePath ; } int ndx = - 1 ; int delta = Integer . MAX_VALUE ; for ( int i = 0 ; i < packages . length ; i ++ ) { String rootPackage = packages [ i ] ; if ( rootPackage . equals ( actionPackage ) ) { // exact match
ndx = i ; delta = 0 ; break ; } rootPackage += '.' ; if ( actionPackage . startsWith ( rootPackage ) ) { // found , action package contains root package
int distanceFromTheRoot = actionPackage . length ( ) - rootPackage . length ( ) ; if ( distanceFromTheRoot < delta ) { ndx = i ; delta = distanceFromTheRoot ; } } } if ( ndx == - 1 ) { return null ; } String packageActionPath = delta == 0 ? StringPool . EMPTY : StringUtil . substring ( actionPackage , - delta - 1 , 0 ) ; packageActionPath = packageActionPath . replace ( '.' , '/' ) ; String result = mappings [ ndx ] + packageActionPath ; packagePaths . put ( actionPackage , result ) ; return result ;


signature:
public class DbJtxResourceManager { /** * { @ inheritDoc } */
public DbSession beginTransaction ( final JtxTransactionMode jtxMode , final boolean active ) { } }

implementation: DbSession session = new DbSession ( connectionProvider ) ; if ( active ) { log . debug ( "begin jtx" ) ; session . beginTransaction ( JtxDbUtil . convertToDbMode ( jtxMode ) ) ; } return session ;


signature:
public class DbJtxResourceManager { /** * { @ inheritDoc } */
public void commitTransaction ( final DbSession resource ) { } }

implementation: if ( resource . isTransactionActive ( ) ) { log . debug ( "commit jtx" ) ; resource . commitTransaction ( ) ; } resource . closeSession ( ) ;


signature:
public class DbJtxResourceManager { /** * { @ inheritDoc } */
public void rollbackTransaction ( final DbSession resource ) { } }

implementation: try { if ( resource . isTransactionActive ( ) ) { log . debug ( "rollback tx" ) ; resource . rollbackTransaction ( ) ; } } catch ( Exception ex ) { throw new JtxException ( ex ) ; } finally { resource . closeSession ( ) ; }


signature:
public class VtorUtil { /** * Returns JSON violations string . Contains javascript array with elements that contain :
 * < ul >
 * < li > name - violation name < / li >
 * < li > msg - message code i . e . constraint class name < / li >
 * < / ul > */
public static String createViolationsJsonString ( final HttpServletRequest request , final List < Violation > violations ) { } }

implementation: if ( violations == null ) { return StringPool . EMPTY ; } StringBuilder sb = new StringBuilder ( ) . append ( '[' ) ; for ( int i = 0 , violationsSize = violations . size ( ) ; i < violationsSize ; i ++ ) { Violation violation = violations . get ( i ) ; if ( i != 0 ) { sb . append ( ',' ) ; } sb . append ( '{' ) ; sb . append ( "\"name\":\"" ) . append ( violation . getName ( ) ) . append ( '"' ) . append ( ',' ) ; sb . append ( "\"msg\":\"" ) . append ( resolveValidationMessage ( request , violation ) ) . append ( '"' ) ; sb . append ( '}' ) ; } sb . append ( ']' ) ; return sb . toString ( ) ;


signature:
public class VtorUtil { /** * Prepares validation messages .
 * Key is either validation constraint class name or violation name . */
public static String resolveValidationMessage ( final HttpServletRequest request , final Violation violation ) { } }

implementation: ValidationConstraint vc = violation . getConstraint ( ) ; String key = vc != null ? vc . getClass ( ) . getName ( ) : violation . getName ( ) ; String msg = LocalizationUtil . findMessage ( request , key ) ; if ( msg != null ) { return beanTemplateParser . parseWithBean ( msg , violation ) ; } return null ;


signature:
public class BeanReferences { /** * Removes later duplicated references in an array .
 * Returns new instance of BeanReferences if there was changes ,
 * otherwise returns the same instance . */
public BeanReferences removeDuplicateNames ( ) { } }

implementation: if ( names . length < 2 ) { return this ; } int nullCount = 0 ; for ( int i = 1 ; i < names . length ; i ++ ) { String thisRef = names [ i ] ; if ( thisRef == null ) { nullCount ++ ; continue ; } for ( int j = 0 ; j < i ; j ++ ) { if ( names [ j ] == null ) { continue ; } if ( thisRef . equals ( names [ j ] ) ) { names [ i ] = null ; break ; } } } if ( nullCount == 0 ) { return this ; } String [ ] newRefs = new String [ names . length - nullCount ] ; int ndx = 0 ; for ( String name : names ) { if ( name == null ) { continue ; } newRefs [ ndx ] = name ; ndx ++ ; } return new BeanReferences ( newRefs ) ;


signature:
public class JoyProps { /** * Adds props files or patterns . */
@ Override public JoyProps addPropsFile ( final String namePattern ) { } }

implementation: requireNotStarted ( props ) ; this . propsNamePatterns . add ( namePattern ) ; return this ;


signature:
public class JoyProps { /** * Creates and loads application props .
 * It first loads system properties ( registered as < code > sys . * < / code > )
 * and then environment properties ( registered as < code > env . * < / code > ) .
 * Finally , props files are read from the classpath . All properties
 * are loaded using
 * If props have been already loaded , does nothing . */
@ Override public void start ( ) { } }

implementation:
initLogger ( ) ; log . info ( "PROPS start ----------" ) ; props = createProps ( ) ; props . loadSystemProperties ( "sys" ) ; props . loadEnvironment ( "env" ) ; log . debug ( "Loaded sys&env props: " + props . countTotalProperties ( ) + " properties." ) ; props . setActiveProfiles ( propsProfiles . toArray ( new String [ 0 ] ) ) ; // prepare patterns
final String [ ] patterns = new String [ propsNamePatterns . size ( ) + 1 ] ; patterns [ 0 ] = "/" + nameSupplier . get ( ) + "*.prop*" ; for ( int i = 0 ; i < propsNamePatterns . size ( ) ; i ++ ) { patterns [ i + 1 ] = propsNamePatterns . get ( i ) ; } log . debug ( "Loading props from classpath..." ) ; final long startTime = System . currentTimeMillis ( ) ; props . loadFromClasspath ( patterns ) ; log . debug ( "Props scanning completed in " + ( System . currentTimeMillis ( ) - startTime ) + "ms." ) ; log . debug ( "Total properties: " + props . countTotalProperties ( ) ) ; log . info ( "PROPS OK!" ) ;


signature:
public class JoyProps { /** * Creates new { @ link Props } with default configuration .
 * Empty props will be ignored , and missing macros will be
 * resolved as empty string . */
protected Props createProps ( ) { } }

implementation: final Props props = new Props ( ) ; props . setSkipEmptyProps ( true ) ; props . setIgnoreMissingMacros ( true ) ; return props ;


signature:
public class Targets { /** * Iterates all targets . */
public void forEachTarget ( final Consumer < Target > targetConsumer ) { } }

implementation: for ( final Target target : targets ) { targetConsumer . accept ( target ) ; }


signature:
public class Targets { /** * Iterates all targets and for each target iterates all IN injection points of given scope . */
public void forEachTargetAndIn ( final MadvocScope scope , final BiConsumer < Target , InjectionPoint > biConsumer ) { } }

implementation: for ( final Target target : targets ) { final ScopeData scopeData = target . scopeData ( ) ; if ( scopeData . in ( ) == null ) { continue ; } for ( final InjectionPoint in : scopeData . in ( ) ) { if ( in . scope ( ) != scope ) { continue ; } biConsumer . accept ( target , in ) ; } }


signature:
public class Targets { /** * Iterates all targets and for each target iterates all OUT injection points of given scope . */
public void forEachTargetAndOut ( final MadvocScope scope , final BiConsumer < Target , InjectionPoint > biConsumer ) { } }

implementation: for ( final Target target : targets ) { final ScopeData scopeData = target . scopeData ( ) ; if ( scopeData . out ( ) == null ) { continue ; } for ( final InjectionPoint out : scopeData . out ( ) ) { if ( out . scope ( ) != scope ) { continue ; } biConsumer . accept ( target , out ) ; } }


signature:
public class Targets { /** * Collects all parameters from target into an array . */
public Object [ ] extractParametersValues ( ) { } }

implementation: final Object [ ] values = new Object [ targets . length - 1 ] ; for ( int i = 1 ; i < targets . length ; i ++ ) { values [ i - 1 ] = targets [ i ] . value ( ) ; } return values ;


signature:
public class Targets { /** * Joins action and parameters into one single array of Targets . */
protected Target [ ] makeTargets ( final Target actionTarget , final MethodParam [ ] methodParams ) { } }

implementation:
if ( methodParams == null ) { // action does not have method parameters , so there is just one target
return new Target [ ] { actionTarget } ; } // action has method arguments , so there is more then one target
final Target [ ] target = new Target [ methodParams . length + 1 ] ; target [ 0 ] = actionTarget ; final Object action = actionTarget . value ( ) ; for ( int i = 0 ; i < methodParams . length ; i ++ ) { final MethodParam methodParam = methodParams [ i ] ; final Class paramType = methodParam . type ( ) ; final Target paramTarget ; if ( methodParam . annotationType ( ) == null ) { // parameter is NOT annotated , create new value for the target
// the class itself will be a base class , and should be scanned
final ScopeData newScopeData = methodParam . scopeData ( ) . inspector ( ) . inspectClassScopesWithCache ( paramType ) ; paramTarget = Target . ofValue ( createActionMethodArgument ( paramType , action ) , newScopeData ) ; } else if ( methodParam . annotationType ( ) == Out . class ) { // parameter is annotated with * only * OUT annotation
// create the output value now AND to save the type
paramTarget = Target . ofMethodParam ( methodParam , createActionMethodArgument ( paramType , action ) ) ; } else { // parameter is annotated with any IN annotation
// create target with NO value , as the value will be created later
paramTarget = Target . ofMethodParam ( methodParam , type -> createActionMethodArgument ( type , action ) ) ; } target [ i + 1 ] = paramTarget ; } return target ;


signature:
public class Targets { /** * Creates action method arguments . */
@ SuppressWarnings ( { } }

implementation:
"unchecked" , "NullArgumentToVariableArgMethod" } ) protected Object createActionMethodArgument ( final Class type , final Object action ) { try { if ( type . getEnclosingClass ( ) == null || Modifier . isStatic ( type . getModifiers ( ) ) ) { // regular or static class
return ClassUtil . newInstance ( type ) ; } else { // member class
Constructor ctor = type . getDeclaredConstructor ( type . getDeclaringClass ( ) ) ; ctor . setAccessible ( true ) ; return ctor . newInstance ( action ) ; } } catch ( Exception ex ) { throw new MadvocException ( ex ) ; }


signature:
public class SessionMonitor { /** * Stores session in map and broadcasts event to registered listeners . */
@ Override public void sessionCreated ( final HttpSessionEvent httpSessionEvent ) { } }

implementation: HttpSession session = httpSessionEvent . getSession ( ) ; sessionMap . putIfAbsent ( session . getId ( ) , session ) ; for ( HttpSessionListener listener : listeners ) { listener . sessionCreated ( httpSessionEvent ) ; }


signature:
public class SessionMonitor { /** * Removes session from a map and broadcasts event to registered listeners . */
@ Override public void sessionDestroyed ( final HttpSessionEvent httpSessionEvent ) { } }

implementation: HttpSession session = httpSessionEvent . getSession ( ) ; sessionMap . remove ( session . getId ( ) ) ; for ( HttpSessionListener listener : listeners ) { listener . sessionDestroyed ( httpSessionEvent ) ; }


signature:
public class JsonArray { /** * Returns the string at position { @ code pos } in the array . */
public String getString ( final int pos ) { } }

implementation: CharSequence cs = ( CharSequence ) list . get ( pos ) ; return cs == null ? null : cs . toString ( ) ;


signature:
public class JsonArray { /** * Returns the integer at position { @ code pos } in the array . */
public Integer getInteger ( final int pos ) { } }

implementation:
Number number = ( Number ) list . get ( pos ) ; if ( number == null ) { return null ; } if ( number instanceof Integer ) { // avoid unnecessary unbox / box
return ( Integer ) number ; } return number . intValue ( ) ;


signature:
public class JsonArray { /** * Returns the long at position { @ code pos } in the array . */
public Long getLong ( final int pos ) { } }

implementation:
Number number = ( Number ) list . get ( pos ) ; if ( number == null ) { return null ; } if ( number instanceof Long ) { // avoids unnecessary unbox / box
return ( Long ) number ; } return number . longValue ( ) ;


signature:
public class JsonArray { /** * Returns the double at position { @ code pos } in the array . */
public Double getDouble ( final int pos ) { } }

implementation:
Number number = ( Number ) list . get ( pos ) ; if ( number == null ) { return null ; } if ( number instanceof Double ) { // avoids unnecessary unbox / box
return ( Double ) number ; } return number . doubleValue ( ) ;


signature:
public class JsonArray { /** * Returns the Float at position { @ code pos } in the array . */
public Float getFloat ( final int pos ) { } }

implementation:
Number number = ( Number ) list . get ( pos ) ; if ( number == null ) { return null ; } if ( number instanceof Float ) { // avoids unnecessary unbox / box
return ( Float ) number ; } return number . floatValue ( ) ;


signature:
public class JsonArray { /** * Retruns the JsonObject at position { @ code pos } in the array . */
public JsonObject getJsonObject ( final int pos ) { } }

implementation: Object val = list . get ( pos ) ; if ( val instanceof Map ) { val = new JsonObject ( ( Map ) val ) ; } return ( JsonObject ) val ;


signature:
public class JsonArray { /** * Returns the JsonArray at position { @ code pos } in the array . */
public JsonArray getJsonArray ( final int pos ) { } }

implementation: Object val = list . get ( pos ) ; if ( val instanceof List ) { val = new JsonArray ( ( List ) val ) ; } return ( JsonArray ) val ;


signature:
public class JsonArray { /** * Returns the byte [ ] at position { @ code pos } in the array .
 * JSON itself has no notion of a binary , so this method assumes there is a String value and
 * it contains a Base64 encoded binary , which it decodes if found and returns . */
public byte [ ] getBinary ( final int pos ) { } }

implementation: String val = ( String ) list . get ( pos ) ; if ( val == null ) { return null ; } return Base64 . getDecoder ( ) . decode ( val ) ;


signature:
public class JsonArray { /** * Returns the object value at position { @ code pos } in the array . */
public Object getValue ( final int pos ) { } }

implementation: Object val = list . get ( pos ) ; if ( val instanceof Map ) { val = new JsonObject ( ( Map ) val ) ; } else if ( val instanceof List ) { val = new JsonArray ( ( List ) val ) ; } return val ;


signature:
public class JsonArray { /** * Adds an enum to the JSON array .
 * JSON has no concept of encoding Enums , so the Enum will be converted to a String using the { @ link java . lang . Enum # name }
 * method and the value added as a String . */
public JsonArray add ( final Enum value ) { } }

implementation: if ( value == null ) { list . add ( null ) ; } else { list . add ( value . name ( ) ) ; } return this ;


signature:
public class JsonArray { /** * Adds an object to the JSON array . */
public JsonArray add ( Object value ) { } }

implementation: Objects . requireNonNull ( value ) ; value = JsonObject . resolveValue ( value ) ; list . add ( value ) ; return this ;


signature:
public class JsonArray { /** * Appends all of the elements in the specified array to the end of this JSON array . */
public JsonArray addAll ( final JsonArray array ) { } }

implementation: Objects . requireNonNull ( array ) ; list . addAll ( array . list ) ; return this ;


signature:
public class JsonArray { /** * Removes the value at the specified position in the JSON array . */
public Object remove ( final int pos ) { } }

implementation: Object removed = list . remove ( pos ) ; if ( removed instanceof Map ) { return new JsonObject ( ( Map ) removed ) ; } if ( removed instanceof ArrayList ) { return new JsonArray ( ( List ) removed ) ; } return removed ;


signature:
public class AbstractTemplateViewActionResult { /** * Dispatches to the template location created from result value and JSP extension .
 * Does its forward via a < code > RequestDispatcher < / code > . If the dispatch fails , a 404 error
 * will be sent back in the http response . */
@ Override public void render ( final ActionRequest actionRequest , final Object resultValue ) throws Exception { } }

implementation:
final PathResult pathResult ; if ( resultValue == null ) { pathResult = resultOf ( StringPool . EMPTY ) ; } else { if ( resultValue instanceof String ) { pathResult = resultOf ( resultValue ) ; } else { pathResult = ( PathResult ) resultValue ; } } final String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; final String path = pathResult != null ? pathResult . path ( ) : StringPool . EMPTY ; final String actionAndResultPath = resultBasePath + ( pathResult != null ? ':' + path : StringPool . EMPTY ) ; String target = targetCache . get ( actionAndResultPath ) ; if ( target == null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "new target: " + actionAndResultPath ) ; } target = resolveTarget ( actionRequest , path ) ; if ( target == null ) { targetNotFound ( actionRequest , actionAndResultPath ) ; return ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "target found: " + target ) ; } // store target in cache
targetCache . put ( actionAndResultPath , target ) ; } // the target exists , continue
renderView ( actionRequest , target ) ;


signature:
public class AbstractTemplateViewActionResult { /** * Locates the target file from action path and the result value . */
protected String resolveTarget ( final ActionRequest actionRequest , final String resultValue ) { } }

implementation:
String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; ResultPath resultPath = resultMapper . resolveResultPath ( resultBasePath , resultValue ) ; String actionPath = resultPath . path ( ) ; String path = actionPath ; String value = resultPath . value ( ) ; if ( StringUtil . isEmpty ( value ) ) { value = null ; } String target ; while ( true ) { // variant # 1 : with value
if ( value != null ) { if ( path == null ) { // only value remains
int lastSlashNdx = actionPath . lastIndexOf ( '/' ) ; if ( lastSlashNdx != - 1 ) { target = actionPath . substring ( 0 , lastSlashNdx + 1 ) + value ; } else { target = '/' + value ; } } else { target = path + '.' + value ; } target = locateTarget ( actionRequest , target ) ; if ( target != null ) { break ; } } if ( path != null ) { // variant # 2 : without value
target = locateTarget ( actionRequest , path ) ; if ( target != null ) { break ; } } // continue
if ( path == null ) { // path not found
return null ; } int dotNdx = MadvocUtil . lastIndexOfDotAfterSlash ( path ) ; if ( dotNdx == - 1 ) { path = null ; } else { path = path . substring ( 0 , dotNdx ) ; } } return target ;


signature:
public class AbstractTemplateViewActionResult { /** * Called when target not found . By default sends 404 to the response . */
protected void targetNotFound ( final ActionRequest actionRequest , final String actionAndResultPath ) throws IOException { } }

implementation: final HttpServletResponse response = actionRequest . getHttpServletResponse ( ) ; if ( ! response . isCommitted ( ) ) { response . sendError ( SC_NOT_FOUND , "Result not found: " + actionAndResultPath ) ; }


signature:
public class ServletRedirectActionResult { /** * Redirects to the given location . Provided path is parsed , action is used as a value context . */
@ Override public void render ( final ActionRequest actionRequest , final Object resultValue ) throws Exception { } }

implementation: final Redirect redirectResult ; if ( resultValue == null ) { redirectResult = Redirect . to ( StringPool . EMPTY ) ; } else { if ( resultValue instanceof String ) { redirectResult = Redirect . to ( ( String ) resultValue ) ; } else { redirectResult = ( Redirect ) resultValue ; } } final String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; final String redirectPath = redirectResult . path ( ) ; final String resultPath ; if ( redirectPath . startsWith ( "http://" ) || redirectPath . startsWith ( "https://" ) ) { resultPath = redirectPath ; } else { resultPath = resultMapper . resolveResultPathString ( resultBasePath , redirectPath ) ; } HttpServletRequest request = actionRequest . getHttpServletRequest ( ) ; HttpServletResponse response = actionRequest . getHttpServletResponse ( ) ; String path = resultPath ; path = beanTemplateParser . parseWithBean ( path , actionRequest . getAction ( ) ) ; DispatcherUtil . redirect ( request , response , path ) ;


signature:
public class FormProcessorVisitor { /** * - - - - - input */
private void processInputStartTag ( final Tag tag ) { } }

implementation:
// INPUT
CharSequence tagType = tag . getAttributeValue ( TYPE ) ; if ( tagType == null ) { return ; } CharSequence nameSequence = tag . getAttributeValue ( NAME ) ; if ( nameSequence == null ) { return ; } String name = nameSequence . toString ( ) ; Object valueObject = resolver . value ( name ) ; if ( valueObject == null ) { return ; } String tagTypeName = tagType . toString ( ) . toLowerCase ( ) ; if ( tagTypeName . equals ( TEXT ) || tagTypeName . equals ( HIDDEN ) || tagTypeName . equals ( IMAGE ) || tagTypeName . equals ( PASSWORD ) ) { String value = valueToString ( name , valueObject ) ; if ( value == null ) { return ; } tag . setAttribute ( VALUE , value ) ; } else if ( tagTypeName . equals ( CHECKBOX ) ) { CharSequence tagValue = tag . getAttributeValue ( VALUE ) ; if ( tagValue == null ) { tagValue = TRUE ; } tagValue = tagValue . toString ( ) ; if ( valueObject . getClass ( ) . isArray ( ) ) { // checkbox group
String [ ] vs = StringUtil . toStringArray ( valueObject ) ; for ( String vsk : vs ) { if ( ( vsk != null ) && ( vsk . contentEquals ( tagValue ) ) ) { tag . setAttribute ( CHECKED , null ) ; } } } else if ( tagValue . equals ( valueObject . toString ( ) ) ) { tag . setAttribute ( CHECKED , null ) ; } } else if ( tagType . equals ( RADIO ) ) { CharSequence tagValue = tag . getAttributeValue ( VALUE ) ; if ( tagValue != null ) { tagValue = tagValue . toString ( ) ; if ( tagValue . equals ( valueObject . toString ( ) ) ) { tag . setAttribute ( CHECKED , null ) ; } } }


signature:
public class FormProcessorVisitor { /** * Converts value to a string . */
protected String valueToString ( final String name , final Object valueObject ) { } }

implementation:
if ( ! valueObject . getClass ( ) . isArray ( ) ) { return valueObject . toString ( ) ; } // array
String [ ] array = ( String [ ] ) valueObject ; if ( valueNameIndexes == null ) { valueNameIndexes = new HashMap < > ( ) ; } MutableInteger index = valueNameIndexes . get ( name ) ; if ( index == null ) { index = new MutableInteger ( 0 ) ; valueNameIndexes . put ( name , index ) ; } if ( index . value >= array . length ) { return null ; } String result = array [ index . value ] ; index . value ++ ; return result ;


signature:
public class MadvocRouter { /** * Configures an interceptor . */
@ SuppressWarnings ( "unchecked" ) public < T extends ActionInterceptor > MadvocRouter interceptor ( final Class < T > actionInterceptorClass ) { } }

implementation: interceptorsManager . resolve ( actionInterceptorClass ) ; return this ;


signature:
public class MadvocRouter { /** * Configures an interceptor . */
@ SuppressWarnings ( "unchecked" ) public < T extends ActionInterceptor > MadvocRouter interceptor ( final Class < T > actionInterceptorClass , final Consumer < T > interceptorConsumer ) { } }

implementation: T interceptor = ( T ) interceptorsManager . resolve ( actionInterceptorClass ) ; interceptorConsumer . accept ( interceptor ) ; return this ;


signature:
public class MadvocRouter { /** * Returns action filter instance for further configuration . */
@ SuppressWarnings ( "unchecked" ) public < T extends ActionFilter > MadvocRouter filter ( final Class < T > actionFilterClass ) { } }

implementation: filtersManager . resolve ( actionFilterClass ) ; return this ;


signature:
public class PseudoFunction { /** * Returns < code > true < / code > if node matches the pseudoclass within current results . */
public boolean match ( final List < Node > currentResults , final Node node , final int index , final E expression ) { } }

implementation: return true ;


signature:
public class PseudoFunction { /** * Returns pseudo - function name . */
public String getPseudoFunctionName ( ) { } }

implementation: String name = getClass ( ) . getSimpleName ( ) . toLowerCase ( ) ; name = name . replace ( '_' , '-' ) ; return name ;


signature:
public class ActionRuntime { /** * Returns action string in form ' actionClass # actionMethod ' . */
public String createActionString ( ) { } }

implementation: if ( actionHandler != null ) { return actionHandler . getClass ( ) . getName ( ) ; } String className = actionClass . getName ( ) ; final int ndx = className . indexOf ( "$$" ) ; if ( ndx != - 1 ) { className = className . substring ( 0 , ndx ) ; } return className + '#' + actionClassMethod . getName ( ) ;


signature:
public class IntegerSqlType { /** * { @ inheritDoc } */
@ Override public Integer get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return Integer . valueOf ( rs . getInt ( index ) ) ;


signature:
public class IntegerSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Integer value , final int dbSqlType ) throws SQLException { } }

implementation: st . setInt ( index , value . intValue ( ) ) ;


signature:
public class PropertyResolver { /** * Resolves all properties for given type . */
public PropertyInjectionPoint [ ] resolve ( Class type , final boolean autowire ) { } }

implementation:
final List < PropertyInjectionPoint > list = new ArrayList < > ( ) ; final Set < String > usedPropertyNames = new HashSet < > ( ) ; // lookup fields
while ( type != Object . class ) { final ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( type ) ; final PropertyDescriptor [ ] allPropertyDescriptors = cd . getAllPropertyDescriptors ( ) ; for ( PropertyDescriptor propertyDescriptor : allPropertyDescriptors ) { if ( propertyDescriptor . isGetterOnly ( ) ) { continue ; } if ( usedPropertyNames . contains ( propertyDescriptor . getName ( ) ) ) { continue ; } Class propertyType = propertyDescriptor . getType ( ) ; if ( ClassUtil . isTypeOf ( propertyType , Collection . class ) ) { continue ; } BeanReferences reference = referencesResolver . readReferenceFromAnnotation ( propertyDescriptor ) ; if ( reference == null ) { if ( ! autowire ) { continue ; } else { reference = referencesResolver . buildDefaultReference ( propertyDescriptor ) ; } } list . add ( new PropertyInjectionPoint ( propertyDescriptor , reference ) ) ; usedPropertyNames . add ( propertyDescriptor . getName ( ) ) ; } // go to the supertype
type = type . getSuperclass ( ) ; } final PropertyInjectionPoint [ ] fields ; if ( list . isEmpty ( ) ) { fields = PropertyInjectionPoint . EMPTY ; } else { fields = list . toArray ( new PropertyInjectionPoint [ 0 ] ) ; } return fields ;


signature:
public class Socks4ProxySocketFactory { /** * Connects to the SOCKS4 proxy and returns proxified socket . */
private Socket createSocks4ProxySocket ( final String host , final int port ) { } }

implementation:
Socket socket = null ; final String proxyHost = proxy . getProxyAddress ( ) ; final int proxyPort = proxy . getProxyPort ( ) ; final String user = proxy . getProxyUsername ( ) ; try { socket = Sockets . connect ( proxyHost , proxyPort , connectionTimeout ) ; final InputStream in = socket . getInputStream ( ) ; final OutputStream out = socket . getOutputStream ( ) ; socket . setTcpNoDelay ( true ) ; byte [ ] buf = new byte [ 1024 ] ; // 1 ) CONNECT
int index = 0 ; buf [ index ++ ] = 4 ; buf [ index ++ ] = 1 ; buf [ index ++ ] = ( byte ) ( port >>> 8 ) ; buf [ index ++ ] = ( byte ) ( port & 0xff ) ; InetAddress addr = InetAddress . getByName ( host ) ; byte [ ] byteAddress = addr . getAddress ( ) ; for ( byte byteAddres : byteAddress ) { buf [ index ++ ] = byteAddres ; } if ( user != null ) { System . arraycopy ( user . getBytes ( ) , 0 , buf , index , user . length ( ) ) ; index += user . length ( ) ; } buf [ index ++ ] = 0 ; out . write ( buf , 0 , index ) ; // 2 ) RESPONSE
int len = 6 ; int s = 0 ; while ( s < len ) { int i = in . read ( buf , s , len - s ) ; if ( i <= 0 ) { throw new HttpException ( ProxyInfo . ProxyType . SOCKS4 , "stream is closed" ) ; } s += i ; } if ( buf [ 0 ] != 0 ) { throw new HttpException ( ProxyInfo . ProxyType . SOCKS4 , "proxy returned VN " + buf [ 0 ] ) ; } if ( buf [ 1 ] != 90 ) { try { socket . close ( ) ; } catch ( Exception ignore ) { } throw new HttpException ( ProxyInfo . ProxyType . SOCKS4 , "proxy returned CD " + buf [ 1 ] ) ; } byte [ ] temp = new byte [ 2 ] ; in . read ( temp , 0 , 2 ) ; return socket ; } catch ( RuntimeException rtex ) { closeSocket ( socket ) ; throw rtex ; } catch ( Exception ex ) { closeSocket ( socket ) ; throw new HttpException ( ProxyInfo . ProxyType . SOCKS4 , ex . toString ( ) , ex ) ; }


signature:
public class Attribute { /** * Reads a { @ link # type } attribute . This method must return a < i > new < / i > { @ link Attribute } object ,
 * of type { @ link # type } , corresponding to the ' length ' bytes starting at ' offset ' , in the given
 * ClassReader .
 * @ param classReader the class that contains the attribute to be read .
 * @ param offset index of the first byte of the attribute ' s content in { @ link ClassReader # b } . The
 * 6 attribute header bytes ( attribute _ name _ index and attribute _ length ) are not taken into
 * account here .
 * @ param length the length of the attribute ' s content ( excluding the 6 attribute header bytes ) .
 * @ param charBuffer the buffer to be used to call the ClassReader methods requiring a
 * ' charBuffer ' parameter .
 * @ param codeAttributeOffset index of the first byte of content of the enclosing Code attribute
 * in { @ link ClassReader # b } , or - 1 if the attribute to be read is not a code attribute . The 6
 * attribute header bytes ( attribute _ name _ index and attribute _ length ) are not taken into
 * account here .
 * @ param labels the labels of the method ' s code , or { @ literal null } if the attribute to be read
 * is not a code attribute .
 * @ return a < i > new < / i > { @ link Attribute } object corresponding to the specified bytes . */
protected Attribute read ( final ClassReader classReader , final int offset , final int length , final char [ ] charBuffer , final int codeAttributeOffset , final Label [ ] labels ) { } }

implementation: Attribute attribute = new Attribute ( type ) ; attribute . content = new byte [ length ] ; System . arraycopy ( classReader . b , offset , attribute . content , 0 , length ) ; return attribute ;


signature:
public class Attribute { /** * Returns the byte array form of the content of this attribute . The 6 header bytes
 * ( attribute _ name _ index and attribute _ length ) must < i > not < / i > be added in the returned
 * ByteVector .
 * @ param classWriter the class to which this attribute must be added . This parameter can be used
 * to add the items that corresponds to this attribute to the constant pool of this class .
 * @ param code the bytecode of the method corresponding to this code attribute , or { @ literal null }
 * if this attribute is not a code attribute . Corresponds to the ' code ' field of the Code
 * attribute .
 * @ param codeLength the length of the bytecode of the method corresponding to this code
 * attribute , or 0 if this attribute is not a code attribute . Corresponds to the ' code _ length '
 * field of the Code attribute .
 * @ param maxStack the maximum stack size of the method corresponding to this code attribute , or
 * - 1 if this attribute is not a code attribute .
 * @ param maxLocals the maximum number of local variables of the method corresponding to this code
 * attribute , or - 1 if this attribute is not a code attribute .
 * @ return the byte array form of this attribute . */
protected ByteVector write ( final ClassWriter classWriter , final byte [ ] code , final int codeLength , final int maxStack , final int maxLocals ) { } }

implementation: return new ByteVector ( content ) ;


signature:
public class Attribute { /** * Returns the number of attributes of the attribute list that begins with this attribute .
 * @ return the number of attributes of the attribute list that begins with this attribute . */
final int getAttributeCount ( ) { } }

implementation: int count = 0 ; Attribute attribute = this ; while ( attribute != null ) { count += 1 ; attribute = attribute . nextAttribute ; } return count ;


signature:
public class Attribute { /** * Returns the total size in bytes of all the attributes in the attribute list that begins with
 * this attribute . This size includes the 6 header bytes ( attribute _ name _ index and
 * attribute _ length ) per attribute . Also adds the attribute type names to the constant pool .
 * @ param symbolTable where the constants used in the attributes must be stored .
 * @ return the size of all the attributes in this attribute list . This size includes the size of
 * the attribute headers . */
final int computeAttributesSize ( final SymbolTable symbolTable ) { } }

implementation: final byte [ ] code = null ; final int codeLength = 0 ; final int maxStack = - 1 ; final int maxLocals = - 1 ; return computeAttributesSize ( symbolTable , code , codeLength , maxStack , maxLocals ) ;


signature:
public class Attribute { /** * Returns the total size in bytes of all the attributes in the attribute list that begins with
 * this attribute . This size includes the 6 header bytes ( attribute _ name _ index and
 * attribute _ length ) per attribute . Also adds the attribute type names to the constant pool .
 * @ param symbolTable where the constants used in the attributes must be stored .
 * @ param code the bytecode of the method corresponding to these code attributes , or { @ literal
 * null } if they are not code attributes . Corresponds to the ' code ' field of the Code
 * attribute .
 * @ param codeLength the length of the bytecode of the method corresponding to these code
 * attributes , or 0 if they are not code attributes . Corresponds to the ' code _ length ' field of
 * the Code attribute .
 * @ param maxStack the maximum stack size of the method corresponding to these code attributes , or
 * - 1 if they are not code attributes .
 * @ param maxLocals the maximum number of local variables of the method corresponding to these
 * code attributes , or - 1 if they are not code attribute .
 * @ return the size of all the attributes in this attribute list . This size includes the size of
 * the attribute headers . */
final int computeAttributesSize ( final SymbolTable symbolTable , final byte [ ] code , final int codeLength , final int maxStack , final int maxLocals ) { } }

implementation: final ClassWriter classWriter = symbolTable . classWriter ; int size = 0 ; Attribute attribute = this ; while ( attribute != null ) { symbolTable . addConstantUtf8 ( attribute . type ) ; size += 6 + attribute . write ( classWriter , code , codeLength , maxStack , maxLocals ) . length ; attribute = attribute . nextAttribute ; } return size ;


signature:
public class Attribute { /** * Puts all the attributes of the attribute list that begins with this attribute , in the given
 * byte vector . This includes the 6 header bytes ( attribute _ name _ index and attribute _ length ) per
 * attribute .
 * @ param symbolTable where the constants used in the attributes must be stored .
 * @ param output where the attributes must be written . */
final void putAttributes ( final SymbolTable symbolTable , final ByteVector output ) { } }

implementation: final byte [ ] code = null ; final int codeLength = 0 ; final int maxStack = - 1 ; final int maxLocals = - 1 ; putAttributes ( symbolTable , code , codeLength , maxStack , maxLocals , output ) ;


signature:
public class Attribute { /** * Puts all the attributes of the attribute list that begins with this attribute , in the given
 * byte vector . This includes the 6 header bytes ( attribute _ name _ index and attribute _ length ) per
 * attribute .
 * @ param symbolTable where the constants used in the attributes must be stored .
 * @ param code the bytecode of the method corresponding to these code attributes , or { @ literal
 * null } if they are not code attributes . Corresponds to the ' code ' field of the Code
 * attribute .
 * @ param codeLength the length of the bytecode of the method corresponding to these code
 * attributes , or 0 if they are not code attributes . Corresponds to the ' code _ length ' field of
 * the Code attribute .
 * @ param maxStack the maximum stack size of the method corresponding to these code attributes , or
 * - 1 if they are not code attributes .
 * @ param maxLocals the maximum number of local variables of the method corresponding to these
 * code attributes , or - 1 if they are not code attribute .
 * @ param output where the attributes must be written . */
final void putAttributes ( final SymbolTable symbolTable , final byte [ ] code , final int codeLength , final int maxStack , final int maxLocals , final ByteVector output ) { } }

implementation:
final ClassWriter classWriter = symbolTable . classWriter ; Attribute attribute = this ; while ( attribute != null ) { ByteVector attributeContent = attribute . write ( classWriter , code , codeLength , maxStack , maxLocals ) ; // Put attribute _ name _ index and attribute _ length .
output . putShort ( symbolTable . addConstantUtf8 ( attribute . type ) ) . putInt ( attributeContent . length ) ; output . putByteArray ( attributeContent . data , 0 , attributeContent . length ) ; attribute = attribute . nextAttribute ; }


signature:
public class ResultsManager { /** * Returns all action results as new set . */
public Set < ActionResult > getAllActionResults ( ) { } }

implementation: final Set < ActionResult > set = new HashSet < > ( allResults . size ( ) ) ; allResults . forEachValue ( set :: add ) ; return set ;


signature:
public class ResultsManager { /** * Registers new action result instance . If action result of the same class is already
 * registered , registration will be skipped . If result for the same result type or
 * same target class exist , it will be replaced ! However , default Jodd results will
 * < i > never < / i > replace other results . After the registration , results are initialized . */
protected ActionResult register ( final ActionResult result ) { } }

implementation:
Class < ? extends ActionResult > actionResultClass = result . getClass ( ) ; // check existing
ActionResult existingResult = allResults . get ( actionResultClass ) ; if ( existingResult != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "ActionResult already registered: " + actionResultClass ) ; } return existingResult ; } allResults . put ( actionResultClass , result ) ; // + init
initializeResult ( result ) ; return result ;


signature:
public class ResultsManager { /** * Lookups for action result and { @ link # register ( Class ) registers } it if missing . */
private ActionResult lookupAndRegisterIfMissing ( final Class < ? extends ActionResult > actionResultClass ) { } }

implementation: ActionResult actionResult = allResults . get ( actionResultClass ) ; if ( actionResult == null ) { actionResult = register ( actionResultClass ) ; } return actionResult ;


signature:
public class ResultsManager { /** * Lookups for { @ link jodd . madvoc . result . ActionResult action result handler }
 * based on current { @ link jodd . madvoc . ActionRequest action request } and action method
 * result object . */
public ActionResult lookup ( final ActionRequest actionRequest , final Object resultObject ) { } }

implementation:
ActionResult actionResultHandler = null ; // + read @ RenderWith value on method
{ final ActionRuntime actionRuntime = actionRequest . getActionRuntime ( ) ; final Class < ? extends ActionResult > actionResultClass = actionRuntime . getActionResult ( ) ; if ( actionResultClass != null ) { actionResultHandler = lookupAndRegisterIfMissing ( actionResultClass ) ; } } // + use @ RenderWith value on resulting object if exist
if ( actionResultHandler == null && resultObject != null ) { final RenderWith renderWith = resultObject . getClass ( ) . getAnnotation ( RenderWith . class ) ; if ( renderWith != null ) { actionResultHandler = lookupAndRegisterIfMissing ( renderWith . value ( ) ) ; } else if ( resultObject instanceof ActionResult ) { // special case - returned value is already the ActionResult
actionResultHandler = ( ActionResult ) resultObject ; } } // + use action configuration
if ( actionResultHandler == null ) { final ActionRuntime actionRuntime = actionRequest . getActionRuntime ( ) ; final Class < ? extends ActionResult > actionResultClass = actionRuntime . getDefaultActionResult ( ) ; if ( actionResultClass != null ) { actionResultHandler = lookupAndRegisterIfMissing ( actionResultClass ) ; } } if ( actionResultHandler == null ) { throw new MadvocException ( "ActionResult not found for: " + resultObject ) ; } // set action result object into action request !
actionRequest . bindActionResult ( resultObject ) ; return actionResultHandler ;


signature:
public class ResultsManager { /** * Creates new { @ link jodd . madvoc . result . ActionResult } . */
protected ActionResult createResult ( final Class < ? extends ActionResult > actionResultClass ) { } }

implementation: try { return ClassUtil . newInstance ( actionResultClass ) ; } catch ( Exception ex ) { throw new MadvocException ( "Invalid Madvoc result: " + actionResultClass , ex ) ; }


signature:
public class CharSequenceUtil { /** * Match if one character equals to any of the given character .
 * @ return < code > true < / code > if characters match any character from given array ,
 * otherwise < code > false < / code > */
public static boolean equalsOne ( final char c , final CharSequence match ) { } }

implementation: for ( int i = 0 ; i < match . length ( ) ; i ++ ) { char aMatch = match . charAt ( i ) ; if ( c == aMatch ) { return true ; } } return false ;


signature:
public class CharSequenceUtil { /** * Finds index of the first character in given charsequence the matches any from the
 * given set of characters .
 * @ return index of matched character or - 1 */
public static int findFirstEqual ( final CharSequence source , final int index , final CharSequence match ) { } }

implementation: for ( int i = index ; i < source . length ( ) ; i ++ ) { if ( equalsOne ( source . charAt ( i ) , match ) ) { return i ; } } return - 1 ;


signature:
public class CharSequenceUtil { /** * Finds index of the first character in given array the matches any from the
 * given set of characters .
 * @ return index of matched character or - 1 */
public static int findFirstEqual ( final char [ ] source , final int index , final char match ) { } }

implementation: for ( int i = index ; i < source . length ; i ++ ) { if ( source [ i ] == match ) { return i ; } } return - 1 ;


signature:
public class CommandLine { /** * Adds several arguments . */
public CommandLine args ( final String ... arguments ) { } }

implementation: if ( arguments != null && arguments . length > 0 ) { Collections . addAll ( cmdLine , arguments ) ; } return this ;


signature:
public class CommandLine { /** * Sets environment variable . */
public CommandLine env ( final String key , final String value ) { } }

implementation: if ( env == null ) { env = new HashMap < > ( ) ; } env . put ( key , value ) ; return this ;


signature:
public class CommandLine { /** * Runs command and returns process result . */
public ProcessRunner . ProcessResult run ( ) { } }

implementation: ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; out = err = baos ; try { baos . write ( StringUtil . join ( cmdLine , ' ' ) . getBytes ( ) ) ; baos . write ( StringPool . BYTES_NEW_LINE ) ; } catch ( IOException ignore ) { } ProcessBuilder processBuilder = new ProcessBuilder ( ) ; processBuilder . command ( cmdLine ) ; if ( cleanEnvironment ) { processBuilder . environment ( ) . clear ( ) ; } if ( env != null ) { processBuilder . environment ( ) . putAll ( env ) ; } processBuilder . directory ( workingDirectory ) ; Process process = null ; try { process = processBuilder . start ( ) ; } catch ( IOException ioex ) { return writeException ( baos , ioex ) ; } StreamGobbler outputGobbler = new StreamGobbler ( process . getInputStream ( ) , out , outPrefix ) ; StreamGobbler errorGobbler = new StreamGobbler ( process . getErrorStream ( ) , err , errPrefix ) ; outputGobbler . start ( ) ; errorGobbler . start ( ) ; int result ; try { result = process . waitFor ( ) ; } catch ( InterruptedException iex ) { return writeException ( baos , iex ) ; } outputGobbler . waitFor ( ) ; errorGobbler . waitFor ( ) ; return new ProcessRunner . ProcessResult ( result , baos . toString ( ) ) ;


signature:
public class MadvocComponentLifecycle { /** * Invoke the listener based on type .
 * Not very OOP , but works . */
public static void invoke ( final Object listener , final Class listenerType ) { } }

implementation: if ( listenerType == Init . class ) { ( ( Init ) listener ) . init ( ) ; return ; } if ( listenerType == Start . class ) { ( ( Start ) listener ) . start ( ) ; return ; } if ( listenerType == Ready . class ) { ( ( Ready ) listener ) . ready ( ) ; return ; } if ( listenerType == Stop . class ) { ( ( Stop ) listener ) . stop ( ) ; return ; } throw new MadvocException ( "Invalid listener" ) ;


signature:
public class Frame { /** * Sets this frame to the value of the given frame .
 * < p > WARNING : after this method is called the two frames share the same data structures . It is
 * recommended to discard the given frame to avoid unexpected side effects .
 * @ param frame The new frame value . */
final void copyFrom ( final Frame frame ) { } }

implementation: inputLocals = frame . inputLocals ; inputStack = frame . inputStack ; outputStackStart = 0 ; outputLocals = frame . outputLocals ; outputStack = frame . outputStack ; outputStackTop = frame . outputStackTop ; initializationCount = frame . initializationCount ; initializations = frame . initializations ;


signature:
public class Frame { /** * Returns the abstract type corresponding to the given public API frame element type .
 * @ param symbolTable the type table to use to lookup and store type { @ link Symbol } .
 * @ param type a frame element type described using the same format as in { @ link
 * MethodVisitor # visitFrame } , i . e . either { @ link Opcodes # TOP } , { @ link Opcodes # INTEGER } , { @ link
 * Opcodes # FLOAT } , { @ link Opcodes # LONG } , { @ link Opcodes # DOUBLE } , { @ link Opcodes # NULL } , or
 * { @ link Opcodes # UNINITIALIZED _ THIS } , or the internal name of a class , or a Label designating
 * a NEW instruction ( for uninitialized types ) .
 * @ return the abstract type corresponding to the given frame element type . */
static int getAbstractTypeFromApiFormat ( final SymbolTable symbolTable , final Object type ) { } }

implementation: if ( type instanceof Integer ) { return CONSTANT_KIND | ( ( Integer ) type ) . intValue ( ) ; } else if ( type instanceof String ) { String descriptor = Type . getObjectType ( ( String ) type ) . getDescriptor ( ) ; return getAbstractTypeFromDescriptor ( symbolTable , descriptor , 0 ) ; } else { return UNINITIALIZED_KIND | symbolTable . addUninitializedType ( "" , ( ( Label ) type ) . bytecodeOffset ) ; }


signature:
public class Frame { /** * Returns the abstract type corresponding to the given type descriptor .
 * @ param symbolTable the type table to use to lookup and store type { @ link Symbol } .
 * @ param buffer a string ending with a type descriptor .
 * @ param offset the start offset of the type descriptor in buffer .
 * @ return the abstract type corresponding to the given type descriptor . */
private static int getAbstractTypeFromDescriptor ( final SymbolTable symbolTable , final String buffer , final int offset ) { } }

implementation: String internalName ; switch ( buffer . charAt ( offset ) ) { case 'V' : return 0 ; case 'Z' : case 'C' : case 'B' : case 'S' : case 'I' : return INTEGER ; case 'F' : return FLOAT ; case 'J' : return LONG ; case 'D' : return DOUBLE ; case 'L' : internalName = buffer . substring ( offset + 1 , buffer . length ( ) - 1 ) ; return REFERENCE_KIND | symbolTable . addType ( internalName ) ; case '[' : int elementDescriptorOffset = offset + 1 ; while ( buffer . charAt ( elementDescriptorOffset ) == '[' ) { ++ elementDescriptorOffset ; } int typeValue ; switch ( buffer . charAt ( elementDescriptorOffset ) ) { case 'Z' : typeValue = BOOLEAN ; break ; case 'C' : typeValue = CHAR ; break ; case 'B' : typeValue = BYTE ; break ; case 'S' : typeValue = SHORT ; break ; case 'I' : typeValue = INTEGER ; break ; case 'F' : typeValue = FLOAT ; break ; case 'J' : typeValue = LONG ; break ; case 'D' : typeValue = DOUBLE ; break ; case 'L' : internalName = buffer . substring ( elementDescriptorOffset + 1 , buffer . length ( ) - 1 ) ; typeValue = REFERENCE_KIND | symbolTable . addType ( internalName ) ; break ; default : throw new IllegalArgumentException ( ) ; } return ( ( elementDescriptorOffset - offset ) << DIM_SHIFT ) | typeValue ; default : throw new IllegalArgumentException ( ) ; }


signature:
public class Frame { /** * Sets the input frame from the given method description . This method is used to initialize the
 * first frame of a method , which is implicit ( i . e . not stored explicitly in the StackMapTable
 * attribute ) .
 * @ param symbolTable the type table to use to lookup and store type { @ link Symbol } .
 * @ param access the method ' s access flags .
 * @ param descriptor the method descriptor .
 * @ param maxLocals the maximum number of local variables of the method . */
final void setInputFrameFromDescriptor ( final SymbolTable symbolTable , final int access , final String descriptor , final int maxLocals ) { } }

implementation: inputLocals = new int [ maxLocals ] ; inputStack = new int [ 0 ] ; int inputLocalIndex = 0 ; if ( ( access & Opcodes . ACC_STATIC ) == 0 ) { if ( ( access & Constants . ACC_CONSTRUCTOR ) == 0 ) { inputLocals [ inputLocalIndex ++ ] = REFERENCE_KIND | symbolTable . addType ( symbolTable . getClassName ( ) ) ; } else { inputLocals [ inputLocalIndex ++ ] = UNINITIALIZED_THIS ; } } for ( Type argumentType : Type . getArgumentTypes ( descriptor ) ) { int abstractType = getAbstractTypeFromDescriptor ( symbolTable , argumentType . getDescriptor ( ) , 0 ) ; inputLocals [ inputLocalIndex ++ ] = abstractType ; if ( abstractType == LONG || abstractType == DOUBLE ) { inputLocals [ inputLocalIndex ++ ] = TOP ; } } while ( inputLocalIndex < maxLocals ) { inputLocals [ inputLocalIndex ++ ] = TOP ; }


signature:
public class Frame { /** * Sets the input frame from the given public API frame description .
 * @ param symbolTable the type table to use to lookup and store type { @ link Symbol } .
 * @ param numLocal the number of local variables .
 * @ param local the local variable types , described using the same format as in { @ link
 * MethodVisitor # visitFrame } .
 * @ param numStack the number of operand stack elements .
 * @ param stack the operand stack types , described using the same format as in { @ link
 * MethodVisitor # visitFrame } . */
final void setInputFrameFromApiFormat ( final SymbolTable symbolTable , final int numLocal , final Object [ ] local , final int numStack , final Object [ ] stack ) { } }

implementation: int inputLocalIndex = 0 ; for ( int i = 0 ; i < numLocal ; ++ i ) { inputLocals [ inputLocalIndex ++ ] = getAbstractTypeFromApiFormat ( symbolTable , local [ i ] ) ; if ( local [ i ] == Opcodes . LONG || local [ i ] == Opcodes . DOUBLE ) { inputLocals [ inputLocalIndex ++ ] = TOP ; } } while ( inputLocalIndex < inputLocals . length ) { inputLocals [ inputLocalIndex ++ ] = TOP ; } int numStackTop = 0 ; for ( int i = 0 ; i < numStack ; ++ i ) { if ( stack [ i ] == Opcodes . LONG || stack [ i ] == Opcodes . DOUBLE ) { ++ numStackTop ; } } inputStack = new int [ numStack + numStackTop ] ; int inputStackIndex = 0 ; for ( int i = 0 ; i < numStack ; ++ i ) { inputStack [ inputStackIndex ++ ] = getAbstractTypeFromApiFormat ( symbolTable , stack [ i ] ) ; if ( stack [ i ] == Opcodes . LONG || stack [ i ] == Opcodes . DOUBLE ) { inputStack [ inputStackIndex ++ ] = TOP ; } } outputStackTop = 0 ; initializationCount = 0 ;