signature:
public class GeometryReader { /** * Read a Curve Polygon
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return curve polygon */
public static CurvePolygon < Curve > readCurvePolygon ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: CurvePolygon < Curve > curvePolygon = new CurvePolygon < Curve > ( hasZ , hasM ) ; int numRings = reader . readInt ( ) ; for ( int i = 0 ; i < numRings ; i ++ ) { Curve ring = readGeometry ( reader , Curve . class ) ; curvePolygon . addRing ( ring ) ; } return curvePolygon ;


signature:
public class GeometryReader { /** * Read a Polyhedral Surface
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return polyhedral surface */
public static PolyhedralSurface readPolyhedralSurface ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: PolyhedralSurface polyhedralSurface = new PolyhedralSurface ( hasZ , hasM ) ; int numPolygons = reader . readInt ( ) ; for ( int i = 0 ; i < numPolygons ; i ++ ) { Polygon polygon = readGeometry ( reader , Polygon . class ) ; polyhedralSurface . addPolygon ( polygon ) ; } return polyhedralSurface ;


signature:
public class GeometryReader { /** * Read a TIN
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return TIN */
public static TIN readTIN ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: TIN tin = new TIN ( hasZ , hasM ) ; int numPolygons = reader . readInt ( ) ; for ( int i = 0 ; i < numPolygons ; i ++ ) { Polygon polygon = readGeometry ( reader , Polygon . class ) ; tin . addPolygon ( polygon ) ; } return tin ;


signature:
public class GeometryReader { /** * Read a Triangle
 * @ param reader
 * @ param hasZ
 * @ param hasM
 * @ return triangle */
public static Triangle readTriangle ( ByteReader reader , boolean hasZ , boolean hasM ) { } }

implementation: Triangle triangle = new Triangle ( hasZ , hasM ) ; int numRings = reader . readInt ( ) ; for ( int i = 0 ; i < numRings ; i ++ ) { LineString ring = readLineString ( reader , hasZ , hasM ) ; triangle . addRing ( ring ) ; } return triangle ;


signature:
public class GeometryWriter { /** * Write a geometry to the byte writer
 * @ param writer
 * @ param geometry
 * @ throws IOException */
public static void writeGeometry ( ByteWriter writer , Geometry geometry ) throws IOException { } }

implementation:
// Write the single byte order byte
byte byteOrder = writer . getByteOrder ( ) == ByteOrder . BIG_ENDIAN ? ( byte ) 0 : ( byte ) 1 ; writer . writeByte ( byteOrder ) ; // Write the geometry type integer
writer . writeInt ( GeometryCodes . getCode ( geometry ) ) ; GeometryType geometryType = geometry . getGeometryType ( ) ; switch ( geometryType ) { case GEOMETRY : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case POINT : writePoint ( writer , ( Point ) geometry ) ; break ; case LINESTRING : writeLineString ( writer , ( LineString ) geometry ) ; break ; case POLYGON : writePolygon ( writer , ( Polygon ) geometry ) ; break ; case MULTIPOINT : writeMultiPoint ( writer , ( MultiPoint ) geometry ) ; break ; case MULTILINESTRING : writeMultiLineString ( writer , ( MultiLineString ) geometry ) ; break ; case MULTIPOLYGON : writeMultiPolygon ( writer , ( MultiPolygon ) geometry ) ; break ; case GEOMETRYCOLLECTION : case MULTICURVE : case MULTISURFACE : writeGeometryCollection ( writer , ( GeometryCollection < ? > ) geometry ) ; break ; case CIRCULARSTRING : writeCircularString ( writer , ( CircularString ) geometry ) ; break ; case COMPOUNDCURVE : writeCompoundCurve ( writer , ( CompoundCurve ) geometry ) ; break ; case CURVEPOLYGON : writeCurvePolygon ( writer , ( CurvePolygon < ? > ) geometry ) ; break ; case CURVE : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case SURFACE : throw new SFException ( "Unexpected Geometry Type of " + geometryType . name ( ) + " which is abstract" ) ; case POLYHEDRALSURFACE : writePolyhedralSurface ( writer , ( PolyhedralSurface ) geometry ) ; break ; case TIN : writeTIN ( writer , ( TIN ) geometry ) ; break ; case TRIANGLE : writeTriangle ( writer , ( Triangle ) geometry ) ; break ; default : throw new SFException ( "Geometry Type not supported: " + geometryType ) ; }


signature:
public class GeometryWriter { /** * Write a Point
 * @ param writer
 * @ param point
 * @ throws IOException */
public static void writePoint ( ByteWriter writer , Point point ) throws IOException { } }

implementation: writer . writeDouble ( point . getX ( ) ) ; writer . writeDouble ( point . getY ( ) ) ; if ( point . hasZ ( ) ) { writer . writeDouble ( point . getZ ( ) ) ; } if ( point . hasM ( ) ) { writer . writeDouble ( point . getM ( ) ) ; }


signature:
public class GeometryWriter { /** * Write a Line String
 * @ param writer
 * @ param lineString
 * @ throws IOException */
public static void writeLineString ( ByteWriter writer , LineString lineString ) throws IOException { } }

implementation: writer . writeInt ( lineString . numPoints ( ) ) ; for ( Point point : lineString . getPoints ( ) ) { writePoint ( writer , point ) ; }


signature:
public class GeometryWriter { /** * Write a Polygon
 * @ param writer
 * @ param polygon
 * @ throws IOException */
public static void writePolygon ( ByteWriter writer , Polygon polygon ) throws IOException { } }

implementation: writer . writeInt ( polygon . numRings ( ) ) ; for ( LineString ring : polygon . getRings ( ) ) { writeLineString ( writer , ring ) ; }


signature:
public class GeometryWriter { /** * Write a Multi Point
 * @ param writer
 * @ param multiPoint
 * @ throws IOException */
public static void writeMultiPoint ( ByteWriter writer , MultiPoint multiPoint ) throws IOException { } }

implementation: writer . writeInt ( multiPoint . numPoints ( ) ) ; for ( Point point : multiPoint . getPoints ( ) ) { writeGeometry ( writer , point ) ; }


signature:
public class GeometryWriter { /** * Write a Multi Line String
 * @ param writer
 * @ param multiLineString
 * @ throws IOException */
public static void writeMultiLineString ( ByteWriter writer , MultiLineString multiLineString ) throws IOException { } }

implementation: writer . writeInt ( multiLineString . numLineStrings ( ) ) ; for ( LineString lineString : multiLineString . getLineStrings ( ) ) { writeGeometry ( writer , lineString ) ; }


signature:
public class GeometryWriter { /** * Write a Multi Polygon
 * @ param writer
 * @ param multiPolygon
 * @ throws IOException */
public static void writeMultiPolygon ( ByteWriter writer , MultiPolygon multiPolygon ) throws IOException { } }

implementation: writer . writeInt ( multiPolygon . numPolygons ( ) ) ; for ( Polygon polygon : multiPolygon . getPolygons ( ) ) { writeGeometry ( writer , polygon ) ; }


signature:
public class GeometryWriter { /** * Write a Geometry Collection
 * @ param writer
 * @ param geometryCollection
 * @ throws IOException */
public static void writeGeometryCollection ( ByteWriter writer , GeometryCollection < ? > geometryCollection ) throws IOException { } }

implementation: writer . writeInt ( geometryCollection . numGeometries ( ) ) ; for ( Geometry geometry : geometryCollection . getGeometries ( ) ) { writeGeometry ( writer , geometry ) ; }


signature:
public class GeometryWriter { /** * Write a Circular String
 * @ param writer
 * @ param circularString
 * @ throws IOException */
public static void writeCircularString ( ByteWriter writer , CircularString circularString ) throws IOException { } }

implementation: writer . writeInt ( circularString . numPoints ( ) ) ; for ( Point point : circularString . getPoints ( ) ) { writePoint ( writer , point ) ; }


signature:
public class GeometryWriter { /** * Write a Compound Curve
 * @ param writer
 * @ param compoundCurve
 * @ throws IOException */
public static void writeCompoundCurve ( ByteWriter writer , CompoundCurve compoundCurve ) throws IOException { } }

implementation: writer . writeInt ( compoundCurve . numLineStrings ( ) ) ; for ( LineString lineString : compoundCurve . getLineStrings ( ) ) { writeGeometry ( writer , lineString ) ; }


signature:
public class GeometryWriter { /** * Write a Curve Polygon
 * @ param writer
 * @ param curvePolygon
 * @ throws IOException */
public static void writeCurvePolygon ( ByteWriter writer , CurvePolygon < ? > curvePolygon ) throws IOException { } }

implementation: writer . writeInt ( curvePolygon . numRings ( ) ) ; for ( Curve ring : curvePolygon . getRings ( ) ) { writeGeometry ( writer , ring ) ; }


signature:
public class GeometryWriter { /** * Write a Polyhedral Surface
 * @ param writer
 * @ param polyhedralSurface
 * @ throws IOException */
public static void writePolyhedralSurface ( ByteWriter writer , PolyhedralSurface polyhedralSurface ) throws IOException { } }

implementation: writer . writeInt ( polyhedralSurface . numPolygons ( ) ) ; for ( Polygon polygon : polyhedralSurface . getPolygons ( ) ) { writeGeometry ( writer , polygon ) ; }


signature:
public class GeometryWriter { /** * Write a TIN
 * @ param writer
 * @ param tin
 * @ throws IOException */
public static void writeTIN ( ByteWriter writer , TIN tin ) throws IOException { } }

implementation: writer . writeInt ( tin . numPolygons ( ) ) ; for ( Polygon polygon : tin . getPolygons ( ) ) { writeGeometry ( writer , polygon ) ; }


signature:
public class GeometryWriter { /** * Write a Triangle
 * @ param writer
 * @ param triangle
 * @ throws IOException */
public static void writeTriangle ( ByteWriter writer , Triangle triangle ) throws IOException { } }

implementation: writer . writeInt ( triangle . numRings ( ) ) ; for ( LineString ring : triangle . getRings ( ) ) { writeLineString ( writer , ring ) ; }


signature:
public class GeometryCodes { /** * Get the geometry code from the geometry
 * @ param geometry
 * geometry
 * @ return geometry code */
public static int getCode ( Geometry geometry ) { } }

implementation: int code = getCode ( geometry . getGeometryType ( ) ) ; if ( geometry . hasZ ( ) ) { code += 1000 ; } if ( geometry . hasM ( ) ) { code += 2000 ; } return code ;


signature:
public class GeometryCodes { /** * Get the geometry code from the geometry type
 * @ param geometryType
 * geometry type
 * @ return geometry code */
public static int getCode ( GeometryType geometryType ) { } }

implementation: int code ; switch ( geometryType ) { case GEOMETRY : code = 0 ; break ; case POINT : code = 1 ; break ; case LINESTRING : code = 2 ; break ; case POLYGON : code = 3 ; break ; case MULTIPOINT : code = 4 ; break ; case MULTILINESTRING : code = 5 ; break ; case MULTIPOLYGON : code = 6 ; break ; case GEOMETRYCOLLECTION : code = 7 ; break ; case CIRCULARSTRING : code = 8 ; break ; case COMPOUNDCURVE : code = 9 ; break ; case CURVEPOLYGON : code = 10 ; break ; case MULTICURVE : code = 11 ; break ; case MULTISURFACE : code = 12 ; break ; case CURVE : code = 13 ; break ; case SURFACE : code = 14 ; break ; case POLYHEDRALSURFACE : code = 15 ; break ; case TIN : code = 16 ; break ; case TRIANGLE : code = 17 ; break ; default : throw new SFException ( "Unsupported Geometry Type for code retrieval: " + geometryType ) ; } return code ;


signature:
public class GeometryCodes { /** * Get the Geometry Type from the code
 * @ param code
 * geometry type code
 * @ return geometry type */
public static GeometryType getGeometryType ( int code ) { } }

implementation:
// Look at the last 2 digits to find the geometry type code
int geometryTypeCode = code % 1000 ; GeometryType geometryType = null ; switch ( geometryTypeCode ) { case 0 : geometryType = GeometryType . GEOMETRY ; break ; case 1 : geometryType = GeometryType . POINT ; break ; case 2 : geometryType = GeometryType . LINESTRING ; break ; case 3 : geometryType = GeometryType . POLYGON ; break ; case 4 : geometryType = GeometryType . MULTIPOINT ; break ; case 5 : geometryType = GeometryType . MULTILINESTRING ; break ; case 6 : geometryType = GeometryType . MULTIPOLYGON ; break ; case 7 : geometryType = GeometryType . GEOMETRYCOLLECTION ; break ; case 8 : geometryType = GeometryType . CIRCULARSTRING ; break ; case 9 : geometryType = GeometryType . COMPOUNDCURVE ; break ; case 10 : geometryType = GeometryType . CURVEPOLYGON ; break ; case 11 : geometryType = GeometryType . MULTICURVE ; break ; case 12 : geometryType = GeometryType . MULTISURFACE ; break ; case 13 : geometryType = GeometryType . CURVE ; break ; case 14 : geometryType = GeometryType . SURFACE ; break ; case 15 : geometryType = GeometryType . POLYHEDRALSURFACE ; break ; case 16 : geometryType = GeometryType . TIN ; break ; case 17 : geometryType = GeometryType . TRIANGLE ; break ; default : throw new SFException ( "Unsupported Geometry code for type retrieval: " + code ) ; } return geometryType ;


signature:
public class GeometryCodes { /** * Determine if the geometry code has a Z ( 3D ) value
 * @ param code
 * geometry code
 * @ return true is has Z */
public static boolean hasZ ( int code ) { } }

implementation: boolean hasZ = false ; int mode = getGeometryMode ( code ) ; switch ( mode ) { case 0 : case 2 : break ; case 1 : case 3 : hasZ = true ; break ; default : throw new SFException ( "Unexpected Geometry code for Z determination: " + code ) ; } return hasZ ;


signature:
public class GeometryCodes { /** * Determine if the geometry code has a M ( linear referencing system ) value
 * @ param code
 * geometry code
 * @ return true is has M */
public static boolean hasM ( int code ) { } }

implementation: boolean hasM = false ; int mode = getGeometryMode ( code ) ; switch ( mode ) { case 0 : case 1 : break ; case 2 : case 3 : hasM = true ; break ; default : throw new SFException ( "Unexpected Geometry code for M determination: " + code ) ; } return hasM ;


signature:
public class AbstractResource { /** * This implementation checks whether a File can be opened ,
 * falling back to whether an InputStream can be opened .
 * This will cover both directories and content resources . */
@ Override public boolean exists ( ) { } }

implementation:
// Try file existence : can we find the file in the file system ?
try { return getFile ( ) . exists ( ) ; } catch ( IoRuntimeException ex ) { // Fall back to stream existence : can we open the stream ?
try { try ( InputStream is = getInputStream ( ) ) { return true ; } } catch ( Throwable isEx ) { return false ; } }


signature:
public class GcdCalculator { /** * Finds the greatest common divisor of all numbers in the list .
 * @ return the GCD or Long . MAX _ VALUE if the list is empty . */
public static long gcd ( List < Long > l ) { } }

implementation: if ( l . isEmpty ( ) ) { throw new IllegalArgumentException ( "List must contain at least one element" ) ; } BigInteger gcd = BigInteger . valueOf ( l . get ( 0 ) ) ; for ( Long num : l . subList ( 1 , l . size ( ) ) ) { gcd = gcd . gcd ( BigInteger . valueOf ( num ) ) ; } return gcd . longValue ( ) ;


signature:
public class ZabbixMetricMessageBuilder { /** * Builds a metric string to send to a Graphite instance .
 * @ return The metric json string without trailing newline */
public String buildMessage ( String metricName , Object value , long timestamp ) { } }

implementation: String valueToString = "null" ; if ( value != null ) { valueToString = value . toString ( ) ; } JsonObject jsonValue = new JsonObject ( ) ; jsonValue . add ( "host" , getHostName ( ) ) ; jsonValue . add ( "key" , metricName ) ; jsonValue . add ( "value" , valueToString ) ; jsonValue . add ( "clock" , timestamp ) ; return jsonValue . toString ( ) ;


signature:
public class IoUtils { /** * Simple implementation without chunking if the source file is big .
 * @ param source
 * @ param destination
 * @ throws java . io . IOException */
private static void doCopySmallFile ( File source , File destination ) throws IOException { } }

implementation: if ( destination . exists ( ) && destination . isDirectory ( ) ) { throw new IOException ( "Can not copy file, destination is a directory: " + destination . getAbsolutePath ( ) ) ; } FileInputStream fis = null ; FileOutputStream fos = null ; FileChannel input = null ; FileChannel output = null ; try { fis = new FileInputStream ( source ) ; fos = new FileOutputStream ( destination , false ) ; input = fis . getChannel ( ) ; output = fos . getChannel ( ) ; output . transferFrom ( input , 0 , input . size ( ) ) ; } finally { closeQuietly ( output ) ; closeQuietly ( input ) ; closeQuietly ( fis ) ; closeQuietly ( fos ) ; } if ( destination . length ( ) != source . length ( ) ) { throw new IOException ( "Failed to copy content from '" + source + "' (" + source . length ( ) + "bytes) to '" + destination + "' (" + destination . length ( ) + ")" ) ; }


signature:
public class IoUtils { /** * Simple implementation without chunking if the source file is big .
 * @ param source
 * @ param destination
 * @ throws java . io . IOException */
private static void doCopySmallFile ( File source , File destination , boolean append , boolean prependNewLine ) throws IOException { } }

implementation: if ( destination . exists ( ) && destination . isDirectory ( ) ) { throw new IOException ( "Can not copy file, destination is a directory: " + destination . getAbsolutePath ( ) ) ; } else if ( ! destination . exists ( ) ) { boolean renamed = source . renameTo ( destination ) ; if ( renamed ) return ; } FileInputStream fis = null ; FileOutputStream fos = null ; FileChannel input = null ; FileChannel output = null ; long initialSize = destination . length ( ) ; try { fos = new FileOutputStream ( destination , append ) ; if ( prependNewLine ) { fos . write ( ( "\n" ) . getBytes ( StandardCharsets . UTF_8 ) ) ; } fos . write ( Files . readAllBytes ( Paths . get ( source . getAbsolutePath ( ) ) ) ) ; } finally { closeQuietly ( output ) ; closeQuietly ( input ) ; closeQuietly ( fis ) ; closeQuietly ( fos ) ; } if ( ! append && destination . length ( ) != source . length ( ) ) { throw new IOException ( "Failed to copy content from '" + source + "' (" + source . length ( ) + "bytes) to '" + destination + "' (" + destination . length ( ) + "). isAppend? " + append ) ; } else if ( append && destination . length ( ) <= initialSize ) { throw new IOException ( "Failed to append content from '" + source + "' (" + source . length ( ) + "bytes) to '" + destination + "' (" + destination . length ( ) + "). isAppend? " + append ) ; }


signature:
public class StringUtils2 { /** * Split given String . Delimiters are { @ code " , " } , { @ code " ; " } and { @ code " \ n " } .
 * @ param delimitedString
 * @ return splitted string or { @ code null } if given { @ code delimitedString } is { @ code null } */
public static List < String > delimitedStringToList ( @ Nullable String delimitedString ) { } }

implementation: if ( delimitedString == null ) { return null ; } String [ ] splits = delimitedString . split ( "[,;\\n]" ) ; List < String > result = new ArrayList < > ( ) ; for ( String split : splits ) { split = split . trim ( ) ; if ( ! split . isEmpty ( ) ) { result . add ( split ) ; } } return result ;


signature:
public class StringUtils2 { /** * Join given { @ code tokens } with given { @ code delimiter } .
 * Sample : tokens { @ code " com " , " mycompany , " ecommerce " , " server1 " } with delimiter { @ code " . " }
 * returns { @ code " com . mycompany . ecommerce . server1 " } .
 * @ param tokens
 * @ param delimiter
 * @ return the joined tokens ( { @ code null } if given { @ code tokens } is { @ code null } */
public static String join ( @ Nullable List < String > tokens , @ Nonnull String delimiter ) { } }

implementation: if ( tokens == null ) { return null ; } Preconditions2 . checkNotNull ( delimiter , "given delimiter can not be null" ) ; Iterator < String > it = tokens . iterator ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( it . hasNext ( ) ) { String token = it . next ( ) ; sb . append ( token ) ; if ( it . hasNext ( ) ) { sb . append ( delimiter ) ; } } return sb . toString ( ) ;


signature:
public class StringUtils2 { /** * < p > Reverse tokens of given tokenized { @ code str } . < / p >
 * < p > Sample : " server1 . ecommerce . mycompany . com " returns { @ code " com . mycompany . ecommerce . server1 " } . < / p >
 * @ param str
 * @ param delimiter
 * @ return reversed string or { @ code null } if given string is { @ code null } */
public static String reverseTokens ( @ Nullable String str , @ Nonnull String delimiter ) { } }

implementation: if ( str == null ) { return null ; } Preconditions2 . checkNotNull ( delimiter , "given delimiter can not be null" ) ; StringTokenizer st = new StringTokenizer ( str , delimiter ) ; List < String > tokens = new ArrayList < > ( ) ; while ( st . hasMoreTokens ( ) ) { tokens . add ( st . nextToken ( ) ) ; } Collections . reverse ( tokens ) ; return join ( tokens , delimiter ) ;


signature:
public class StringUtils2 { /** * Escape all non ' a ' to ' z ' , ' A ' to ' Z ' , ' 0 ' to ' 9 ' and ' - ' with a ' _ ' .
 * @ param str the string to escape
 * @ param result the { @ linkplain StringBuilder } in which the escaped string is appended */
public static void appendEscapedNonAlphaNumericChars ( @ Nonnull String str , @ Nonnull StringBuilder result ) { } }

implementation: appendEscapedNonAlphaNumericChars ( str , true , result ) ;


signature:
public class StringUtils2 { /** * Abbreviates a String using ellipses . This will turn " Now is the time for all good men " into " Now is the time for . . . "
 * @ param str the String to abbreviate
 * @ param max the max number of chars of the abbreviated String
 * @ return the abbreviated string */
@ Nonnull public static String abbreviate ( String str , int max ) { } }

implementation: if ( str == null ) { return "" ; } else if ( str . length ( ) <= max ) { return str ; } else { return str . substring ( 0 , max - 3 ) + "..." ; }


signature:
public class StringUtils2 { /** * if the given string is { @ code null } , return { @ code " " } , else return { @ link String # trim ( ) } .
 * @ param str the string to trim
 * @ return the trimmed string */
@ Nonnull public static String trimToEmpty ( @ Nullable String str ) { } }

implementation: if ( str == null ) { return "" ; } else { return str . trim ( ) ; }


signature:
public class ExpressionLanguageEngineImpl { /** * Replace all the ' # ' based keywords ( e . g . < code > # hostname # < / code > ) by their value .
 * @ param expression the expression to resolve ( e . g . < code > " servers . # hostname # . " < / code > )
 * @ return the resolved expression ( e . g . < code > " servers . tomcat5 " < / code > ) */
@ Nonnull public String resolveExpression ( @ Nonnull String expression ) { } }

implementation: StringBuilder result = new StringBuilder ( expression . length ( ) ) ; int position = 0 ; while ( position < expression . length ( ) ) { char c = expression . charAt ( position ) ; if ( c == '#' ) { int beginningSeparatorPosition = position ; int endingSeparatorPosition = expression . indexOf ( '#' , beginningSeparatorPosition + 1 ) ; if ( endingSeparatorPosition == - 1 ) { throw new IllegalStateException ( "Invalid expression '" + expression + "', no ending '#' after beginning '#' at position " + beginningSeparatorPosition ) ; } String key = expression . substring ( beginningSeparatorPosition + 1 , endingSeparatorPosition ) ; Function expressionProcessor = functionsByName . get ( key ) ; String value ; if ( expressionProcessor == null ) { value = "#unsupported_expression#" ; logger . info ( "Unsupported expression '" + key + "'" ) ; } else { try { value = expressionProcessor . evaluate ( ) ; } catch ( Exception e ) { value = "#expression_error#" ; logger . log ( Level . WARNING , "Error evaluating expression '" + key + "'" , e ) ; } } StringUtils2 . appendEscapedNonAlphaNumericChars ( value , false , result ) ; position = endingSeparatorPosition + 1 ; } else { result . append ( c ) ; position ++ ; } } if ( logger . isLoggable ( Level . FINEST ) ) logger . log ( Level . FINEST , "resolveExpression(" + expression + "): " + result ) ; return result . toString ( ) ;


signature:
public class ExpressionLanguageEngineImpl { /** * Registers an expression evaluator with a static value . */
public void registerExpressionEvaluator ( @ Nonnull String expression , @ Nonnull Function evaluator ) { } }

implementation: functionsByName . put ( expression , evaluator ) ;


signature:
public class IoRuntimeException { /** * This method returns an instance { @ link IoRuntimeException } .
 * Inspired by { @ code com . google . common . base . Throwables # propagate ( java . lang . Throwable ) } .
 * < pre >
 * try {
 * } catch ( IOException e ) {
 * throw IoRuntimeException . propagate ( e ) ;
 * < / pre >
 * @ param e */
public static IoRuntimeException propagate ( IOException e ) { } }

implementation: if ( e instanceof FileNotFoundException ) { return new FileNotFoundRuntimeException ( e ) ; } else { return new IoRuntimeException ( e ) ; }


signature:
public class ApiFacade { /** * This method creates a custom metric with arbitrary names , description ,
 * and units . */
private static void createCustomMetricDescriptor ( @ Nonnull String metricName , @ Nonnull String metricKind , @ Nonnull String metricUnit , @ Nonnull String metricValueType , @ Nonnull List < String > classificationLabels ) throws Exception { } }

implementation:
logger . info ( "Registering new custom metric : " + metricName + " : " + metricKind + " : " + metricUnit + " : " + metricValueType + " : " + classificationLabels ) ; String url = "projects/" + projectId + "/metricDescriptors" ; String fullName = "custom.googleapis.com/" + metricName ; JsonObject md = new JsonObject ( ) ; md . add ( "name" , url + "/" + URLEncoder . encode ( fullName , "UTF-8" ) ) ; md . add ( "type" , fullName ) ; md . add ( "metricKind" , metricKind . toUpperCase ( ) ) ; md . add ( "valueType" , metricValueType . toUpperCase ( ) ) ; md . add ( "unit" , metricUnit ) ; // Metric Labels
JsonArray labels = new JsonArray ( ) ; for ( String entry : classificationLabels ) { JsonObject label = new JsonObject ( ) ; label . add ( "key" , entry ) ; label . add ( "description" , entry ) ; label . add ( "valueType" , "STRING" ) ; labels . add ( label ) ; } md . add ( "labels" , labels ) ; String request = md . toString ( ) ; logger . fine ( "Metric creation request : " + request ) ; String response = cf . doPost ( url , md . toString ( ) ) ; logger . finer ( "Metric creation response" + response ) ; logger . info ( "Created custom metric : " + metricName ) ;


signature:
public class JsonValue { /** * Writes the JSON representation of this value to the given writer using the given formatting .
 * Writing performance can be improved by using a { @ link java . io . BufferedWriter BufferedWriter } .
 * @ param writer
 * the writer to write this value to
 * @ param config
 * a configuration that controls the formatting or < code > null < / code > for the minimal form
 * @ throws IOException
 * if an I / O error occurs in the writer */
public void writeTo ( Writer writer , WriterConfig config ) throws IOException { } }

implementation: if ( writer == null ) { throw new NullPointerException ( "writer is null" ) ; } if ( config == null ) { throw new NullPointerException ( "config is null" ) ; } WritingBuffer buffer = new WritingBuffer ( writer , 128 ) ; write ( config . createWriter ( buffer ) ) ; buffer . flush ( ) ;


signature:
public class Json { /** * Returns a JsonValue instance that represents the given < code > int < / code > value .
 * @ param value
 * the value to get a JSON representation for
 * @ return a JSON value that represents the given value */
public static org . jmxtrans . agent . util . json . JsonValue value ( int value ) { } }

implementation: return new org . jmxtrans . agent . util . json . JsonNumber ( Integer . toString ( value , 10 ) ) ;


signature:
public class Json { /** * Returns a JsonValue instance that represents the given < code > float < / code > value .
 * @ param value
 * the value to get a JSON representation for
 * @ return a JSON value that represents the given value */
public static org . jmxtrans . agent . util . json . JsonValue value ( float value ) { } }

implementation: if ( Float . isInfinite ( value ) || Float . isNaN ( value ) ) { throw new IllegalArgumentException ( "Infinite and NaN values not permitted in JSON" ) ; } return new org . jmxtrans . agent . util . json . JsonNumber ( cutOffPointZero ( Float . toString ( value ) ) ) ;


signature:
public class Json { /** * Returns a JsonValue instance that represents the given string .
 * @ param string
 * the string to get a JSON representation for
 * @ return a JSON value that represents the given string */
public static org . jmxtrans . agent . util . json . JsonValue value ( String string ) { } }

implementation: return string == null ? NULL : new JsonString ( string ) ;


signature:
public class Json { /** * Returns a JsonValue instance that represents the given < code > boolean < / code > value .
 * @ param value
 * the value to get a JSON representation for
 * @ return a JSON value that represents the given value */
public static org . jmxtrans . agent . util . json . JsonValue value ( boolean value ) { } }

implementation: return value ? TRUE : FALSE ;


signature:
public class Json { /** * Creates a new empty JsonObject . This is equivalent to creating a new JsonObject using the
 * constructor .
 * @ return a new empty JSON object */
public static org . jmxtrans . agent . util . json . JsonObject object ( ) { } }

implementation: return new org . jmxtrans . agent . util . json . JsonObject ( ) ;


signature:
public class Json { /** * Parses the given input string as JSON . The input must contain a valid JSON value , optionally
 * padded with whitespace .
 * @ param string
 * the input string , must be valid JSON
 * @ return a value that represents the parsed JSON
 * @ throws ParseException
 * if the input is not valid JSON */
public static org . jmxtrans . agent . util . json . JsonValue parse ( String string ) { } }

implementation: if ( string == null ) { throw new NullPointerException ( "string is null" ) ; } DefaultHandler handler = new DefaultHandler ( ) ; new JsonParser ( handler ) . parse ( string ) ; return handler . getValue ( ) ;


signature:
public class Json { /** * Reads the entire input from the given reader and parses it as JSON . The input must contain a
 * valid JSON value , optionally padded with whitespace .
 * Characters are read in chunks into an input buffer . Hence , wrapping a reader in an additional
 * < code > BufferedReader < / code > likely won ' t improve reading performance .
 * @ param reader
 * the reader to read the JSON value from
 * @ return a value that represents the parsed JSON
 * @ throws IOException
 * if an I / O error occurs in the reader
 * @ throws ParseException
 * if the input is not valid JSON */
public static org . jmxtrans . agent . util . json . JsonValue parse ( Reader reader ) throws IOException { } }

implementation: if ( reader == null ) { throw new NullPointerException ( "reader is null" ) ; } DefaultHandler handler = new DefaultHandler ( ) ; new JsonParser ( handler ) . parse ( reader ) ; return handler . getValue ( ) ;


signature:
public class ConfigurationUtils { /** * Convert value of this setting to a Java < b > int < / b > .
 * If the setting is not found or is not an int , an exception is thrown .
 * @ param name name of the setting / property
 * @ return int value of the setting / property
 * @ throws IllegalArgumentException if setting is not found or is not an integer . */
public static int getInt ( Map < String , String > settings , String name ) throws IllegalArgumentException { } }

implementation: String value = getString ( settings , name ) ; try { return Integer . parseInt ( value ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Setting '" + name + "=" + value + "' is not an integer on " + settings ) ; }


signature:
public class ConfigurationUtils { /** * Convert value of this setting to a Java < b > int < / b > .
 * If the property is not found , the < code > defaultValue < / code > is returned . If the property is not an int , an exception is thrown .
 * @ param name name of the property
 * @ param defaultValue default value if the property is not defined .
 * @ return int value of the property or < code > defaultValue < / code > if the property is not defined .
 * @ throws IllegalArgumentException if setting is not is not an integer . */
public static int getInt ( Map < String , String > settings , String name , int defaultValue ) throws IllegalArgumentException { } }

implementation: if ( settings . containsKey ( name ) ) { String value = settings . get ( name ) ; try { return Integer . parseInt ( value ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Setting '" + name + "=" + value + "' is not an integer on " + settings ) ; } } else { return defaultValue ; }


signature:
public class ConfigurationUtils { /** * Convert value of this setting to a Java < b > long < / b > .
 * If the property is not found , the < code > defaultValue < / code > is returned . If the property is not a long , an exception is thrown .
 * @ param name name of the property
 * @ param defaultValue default value if the property is not defined .
 * @ return int value of the property or < code > defaultValue < / code > if the property is not defined .
 * @ throws IllegalArgumentException if setting is not is not a long . */
public static long getLong ( Map < String , String > settings , String name , long defaultValue ) throws IllegalArgumentException { } }

implementation: if ( settings . containsKey ( name ) ) { String value = settings . get ( name ) ; try { return Long . parseLong ( value ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Setting '" + name + "=" + value + "' is not a long on " + settings ) ; } } else { return defaultValue ; }


signature:
public class ConfigurationUtils { /** * Convert value of this setting to a Java < b > boolean < / b > ( via { @ link Boolean # parseBoolean ( String ) } ) .
 * If the property is not found , the < code > defaultValue < / code > is returned .
 * @ param name name of the property
 * @ param defaultValue default value if the property is not defined .
 * @ return int value of the property or < code > defaultValue < / code > if the property is not defined . */
public static boolean getBoolean ( Map < String , String > settings , String name , boolean defaultValue ) { } }

implementation: if ( settings . containsKey ( name ) ) { String value = settings . get ( name ) ; return Boolean . parseBoolean ( value ) ; } else { return defaultValue ; }


signature:
public class ConfigurationUtils { /** * Convert value of this setting to a Java < b > int < / b > .
 * If the setting is not found , an exception is thrown .
 * @ param name name of the property
 * @ return value of the property
 * @ throws IllegalArgumentException if setting is not found . */
public static String getString ( Map < String , String > settings , String name ) throws IllegalArgumentException { } }

implementation: if ( ! settings . containsKey ( name ) ) { throw new IllegalArgumentException ( "No setting '" + name + "' found" ) ; } return settings . get ( name ) ;


signature:
public class ConfigurationUtils { /** * Return the value of the given property .
 * If the property is not found , the < code > defaultValue < / code > is returned .
 * @ param name name of the property
 * @ param defaultValue default value if the property is not defined .
 * @ return value of the property or < code > defaultValue < / code > if the property is not defined . */
public static String getString ( Map < String , String > settings , String name , String defaultValue ) { } }

implementation: if ( settings . containsKey ( name ) ) { return settings . get ( name ) ; } else { return defaultValue ; }


signature:
public class JsonObject { /** * Reads a JSON object from the given reader .
 * Characters are read in chunks and buffered internally , therefore wrapping an existing reader in
 * an additional < code > BufferedReader < / code > does < strong > not < / strong > improve reading
 * performance .
 * @ param reader
 * the reader to read the JSON object from
 * @ return the JSON object that has been read
 * @ throws IOException
 * if an I / O error occurs in the reader
 * @ throws ParseException
 * if the input is not valid JSON
 * @ throws UnsupportedOperationException
 * if the input does not contain a JSON object
 * @ deprecated Use { @ link Json # parse ( Reader ) } { @ link org . jmxtrans . agent . util . json . JsonValue # asObject ( ) . asObject ( ) } instead */
@ Deprecated public static JsonObject readFrom ( Reader reader ) throws IOException { } }

implementation: return org . jmxtrans . agent . util . json . JsonValue . readFrom ( reader ) . asObject ( ) ;


signature:
public class JsonObject { /** * Reads a JSON object from the given string .
 * @ param string
 * the string that contains the JSON object
 * @ return the JSON object that has been read
 * @ throws ParseException
 * if the input is not valid JSON
 * @ throws UnsupportedOperationException
 * if the input does not contain a JSON object
 * @ deprecated Use { @ link Json # parse ( String ) } { @ link org . jmxtrans . agent . util . json . JsonValue # asObject ( ) . asObject ( ) } instead */
@ Deprecated public static JsonObject readFrom ( String string ) { } }

implementation: return org . jmxtrans . agent . util . json . JsonValue . readFrom ( string ) . asObject ( ) ;


signature:
public class JsonObject { /** * Appends a new member to the end of this object , with the specified name and the specified JSON
 * value .
 * This method < strong > does not prevent duplicate names < / strong > . Calling this method with a name
 * that already exists in the object will append another member with the same name . In order to
 * replace existing members , use the method < code > set ( name , value ) < / code > instead . However ,
 * < strong > < em > add < / em > is much faster than < em > set < / em > < / strong > ( because it does not need to
 * search for existing members ) . Therefore < em > add < / em > should be preferred when constructing new
 * objects .
 * @ param name
 * the name of the member to add
 * @ param value
 * the value of the member to add , must not be < code > null < / code >
 * @ return the object itself , to enable method chaining */
public JsonObject add ( String name , org . jmxtrans . agent . util . json . JsonValue value ) { } }

implementation: if ( name == null ) { throw new NullPointerException ( "name is null" ) ; } if ( value == null ) { throw new NullPointerException ( "value is null" ) ; } table . add ( name , names . size ( ) ) ; names . add ( name ) ; values . add ( value ) ; return this ;


signature:
public class JsonObject { /** * Returns the value of the member with the specified name in this object . If this object contains
 * multiple members with the given name , this method will return the last one .
 * @ param name
 * the name of the member whose value is to be returned
 * @ return the value of the last member with the specified name , or < code > null < / code > if this
 * object does not contain a member with that name */
public org . jmxtrans . agent . util . json . JsonValue get ( String name ) { } }

implementation: if ( name == null ) { throw new NullPointerException ( "name is null" ) ; } int index = indexOf ( name ) ; return index != - 1 ? values . get ( index ) : null ;


signature:
public class JsonObject { /** * Returns the < code > int < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one will be picked . If this
 * member ' s value does not represent a JSON number or if it cannot be interpreted as Java
 * < code > int < / code > , an exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public int getInt ( String name , int defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asInt ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns the < code > long < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one will be picked . If this
 * member ' s value does not represent a JSON number or if it cannot be interpreted as Java
 * < code > long < / code > , an exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public long getLong ( String name , long defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asLong ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns the < code > float < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one will be picked . If this
 * member ' s value does not represent a JSON number or if it cannot be interpreted as Java
 * < code > float < / code > , an exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public float getFloat ( String name , float defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asFloat ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns the < code > double < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one will be picked . If this
 * member ' s value does not represent a JSON number or if it cannot be interpreted as Java
 * < code > double < / code > , an exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public double getDouble ( String name , double defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asDouble ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns the < code > boolean < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one will be picked . If this
 * member ' s value does not represent a JSON < code > true < / code > or < code > false < / code > value , an
 * exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public boolean getBoolean ( String name , boolean defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asBoolean ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns the < code > String < / code > value of the member with the specified name in this object . If
 * this object does not contain a member with this name , the given default value is returned . If
 * this object contains multiple members with the given name , the last one is picked . If this
 * member ' s value does not represent a JSON string , an exception is thrown .
 * @ param name
 * the name of the member whose value is to be returned
 * @ param defaultValue
 * the value to be returned if the requested member is missing
 * @ return the value of the last member with the specified name , or the given default value if
 * this object does not contain a member with that name */
public String getString ( String name , String defaultValue ) { } }

implementation: org . jmxtrans . agent . util . json . JsonValue value = get ( name ) ; return value != null ? value . asString ( ) : defaultValue ;


signature:
public class JsonObject { /** * Returns an iterator over the members of this object in document order . The returned iterator
 * cannot be used to modify this object .
 * @ return an iterator over the members of this object */
public Iterator < Member > iterator ( ) { } }

implementation: final Iterator < String > namesIterator = names . iterator ( ) ; final Iterator < org . jmxtrans . agent . util . json . JsonValue > valuesIterator = values . iterator ( ) ; return new Iterator < JsonObject . Member > ( ) { public boolean hasNext ( ) { return namesIterator . hasNext ( ) ; } public Member next ( ) { String name = namesIterator . next ( ) ; org . jmxtrans . agent . util . json . JsonValue value = valuesIterator . next ( ) ; return new Member ( name , value ) ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ;


signature:
public class PropertyPlaceholderResolver { /** * Parse the given < code > string < / code > resolving property placeholders ( < code > $ { my - property [ : default - value ] } < / code > )
 * @ param string the string to parse .
 * @ return the parsed string . Non < code > null < / code > .
 * @ throws IllegalStateException a property placeholder could not be resolved and no default value has been defined . */
public String resolveString ( String string ) throws IllegalStateException { } }

implementation: StringBuilder result = new StringBuilder ( string . length ( ) ) ; int position = 0 ; while ( position < string . length ( ) ) { char c = string . charAt ( position ) ; if ( c == '$' && ( position < string . length ( ) - 1 ) && string . charAt ( position + 1 ) == '{' ) { int beginningBracketPosition = position + 1 ; int endingBracketPosition = string . indexOf ( '}' , beginningBracketPosition ) ; int colonPosition = string . indexOf ( ':' , beginningBracketPosition ) ; if ( colonPosition > endingBracketPosition ) { colonPosition = - 1 ; } String placeholder ; String defaultValue ; if ( colonPosition == - 1 ) { placeholder = string . substring ( beginningBracketPosition + 1 , endingBracketPosition ) ; defaultValue = null ; } else { placeholder = string . substring ( beginningBracketPosition + 1 , colonPosition ) ; defaultValue = string . substring ( colonPosition + 1 , endingBracketPosition ) ; } String resolvedPlaceHolder = resolvePlaceholder ( placeholder , defaultValue ) ; result . append ( resolvedPlaceHolder ) ; position = endingBracketPosition + 1 ; } else { result . append ( c ) ; position ++ ; } } return result . toString ( ) ;


signature:
public class PropertyPlaceholderResolver { /** * Search for the given placeholder in system properties then in environment variables .
 * @ param property property to resolve
 * @ param defaultValue Default value if the placeholder is not found . < code > null < / code > means not default value is
 * defined and the placeholder must exist
 * @ return the resolved property or the default value if the placeholder is not found and the default value is defined . Non null .
 * @ throws IllegalStateException if the placeholder is not found and the given < code > defaultValue < / code > is not
 * defined ( < code > null < / code > ) */
protected String resolvePlaceholder ( String property , String defaultValue ) throws IllegalStateException { } }

implementation:
// " graphite . host " - > " GRAPHITE _ HOST "
String environmentVariableStyleProperty = property . toUpperCase ( ) ; environmentVariableStyleProperty = environmentVariableStyleProperty . replaceAll ( "\\." , "_" ) ; String result ; if ( externalProperties . containsKey ( property ) ) { result = externalProperties . get ( property ) ; } else if ( System . getProperties ( ) . containsKey ( property ) ) { result = System . getProperty ( property ) ; } else if ( System . getenv ( ) . containsKey ( property ) ) { result = System . getenv ( property ) ; } else if ( System . getenv ( ) . containsKey ( environmentVariableStyleProperty ) ) { result = System . getenv ( environmentVariableStyleProperty ) ; } else if ( defaultValue != null ) { result = defaultValue ; } else { throw new IllegalStateException ( "Property '" + property + "' not found in System properties nor in Environment variables" ) ; } return result ;


signature:
public class Iterables2 { /** * Returns the element at the specified position in an iterable .
 * @ param iterable the iterable to search into
 * @ param position the position of the entry to return
 * @ return the entry at the given < code > location < / code > in the given < code > iterable < / code >
 * throws
 * @ throws IndexOutOfBoundsException if given { @ code position } is negative or
 * greater than or equal to the size of given < code > iterable < / code > */
@ Nullable public static < T > T get ( @ Nonnull Iterable < T > iterable , @ Nonnegative int position ) throws NullPointerException , IndexOutOfBoundsException { } }

implementation: if ( iterable == null ) throw new NullPointerException ( "iterable" ) ; if ( iterable instanceof List ) { return ( ( List < T > ) iterable ) . get ( position ) ; } if ( position < 0 ) throw new IndexOutOfBoundsException ( "Requested position must be greater than 0, '" + position + "' is invalid" ) ; int idx = 0 ; for ( T value : iterable ) { if ( idx == position ) { return value ; } idx ++ ; } throw new IndexOutOfBoundsException ( "Requested position must be smaller than iterable size (" + idx + "), '" + position + "' is invalid" ) ;


signature:
public class JmxTransAgent { /** * Human readable name and version .
 * @ return project name and version or " { @ code jmxtrans - agent } " if package information not found */
@ Nonnull public static String getVersionInfo ( ) { } }

implementation: Package pkg = JmxTransAgent . class . getPackage ( ) ; if ( pkg == null ) { return "jmxtrans-agent" ; } else { return pkg . getImplementationTitle ( ) + ": " + pkg . getImplementationVersion ( ) ; }


signature:
public class JmxTransAgent { /** * Polls every second to see if any { @ link javax . management . MBeanServer } have been created
 * by another thread up to { @ code timeoutInSeconds } . If interrupted or timed out , returns
 * { @ code false } .
 * @ param timeoutInSeconds Maximum number of seconds to wait before giving up .
 * @ return { @ code true } if found an { @ code MBeanServer } within { @ code timeoutInSeconds } .
 * { @ code false } otherwise . */
private static boolean waitForCustomMBeanServer ( int timeoutInSeconds ) { } }

implementation: long startInMs = System . currentTimeMillis ( ) ; while ( ! isCustomMBeanServerConfigured ( ) && secondsSince ( startInMs ) < timeoutInSeconds ) { try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { Thread . interrupted ( ) ; return false ; } } if ( secondsSince ( startInMs ) >= timeoutInSeconds ) { logger . info ( "jmxagent initialization timed out waiting for custom MBeanServer" ) ; return false ; } return true ;


signature:
public class GraphiteMetricMessageBuilder { /** * Builds a metric string to send to a Graphite instance .
 * @ return The metric string without trailing newline */
public String buildMessage ( String metricName , Object value , long timestamp ) { } }

implementation: if ( value instanceof Boolean ) { return metricPathPrefix + metricName + " " + ( ( Boolean ) value ? 1 : 0 ) + " " + timestamp ; } return metricPathPrefix + metricName + " " + value + " " + timestamp ;


signature:
public class GraphiteMetricMessageBuilder { /** * { @ link java . net . InetAddress # getLocalHost ( ) } may not be known at JVM startup when the process is launched as a Linux service . */
private static String buildMetricPathPrefix ( String configuredMetricPathPrefix ) { } }

implementation: if ( configuredMetricPathPrefix != null ) { return configuredMetricPathPrefix ; } String hostname ; try { hostname = InetAddress . getLocalHost ( ) . getHostName ( ) . replaceAll ( "\\." , "_" ) ; } catch ( UnknownHostException e ) { hostname = "#unknown#" ; } return String . format ( DEFAULT_METRIC_PATH_PREFIX_FORMAT , hostname ) ;


signature:
public class ResultNameStrategyImpl { /** * Transforms an { @ linkplain javax . management . ObjectName } into a plain { @ linkplain String } only composed of ( ' a ' to ' Z ' , ' A ' to ' Z ' , ' _ ' ) .
 * ' _ ' is the escape char for not compliant chars . */
protected String escapeObjectName ( @ Nonnull ObjectName objectName ) { } }

implementation: StringBuilder result = new StringBuilder ( ) ; StringUtils2 . appendEscapedNonAlphaNumericChars ( objectName . getDomain ( ) , result ) ; result . append ( '.' ) ; List < String > keys = Collections . list ( objectName . getKeyPropertyList ( ) . keys ( ) ) ; Collections . sort ( keys ) ; for ( Iterator < String > it = keys . iterator ( ) ; it . hasNext ( ) ; ) { String key = it . next ( ) ; StringUtils2 . appendEscapedNonAlphaNumericChars ( key , result ) ; result . append ( "__" ) ; StringUtils2 . appendEscapedNonAlphaNumericChars ( objectName . getKeyProperty ( key ) , result ) ; if ( it . hasNext ( ) ) { result . append ( '.' ) ; } } if ( logger . isLoggable ( Level . FINEST ) ) logger . log ( Level . FINEST , "escapeObjectName(" + objectName + "): " + result ) ; return result . toString ( ) ;


signature:
public class JsonArray { /** * Reads a JSON array from the given reader .
 * Characters are read in chunks and buffered internally , therefore wrapping an existing reader in
 * an additional < code > BufferedReader < / code > does < strong > not < / strong > improve reading
 * performance .
 * @ param reader
 * the reader to read the JSON array from
 * @ return the JSON array that has been read
 * @ throws IOException
 * if an I / O error occurs in the reader
 * @ throws ParseException
 * if the input is not valid JSON
 * @ throws UnsupportedOperationException
 * if the input does not contain a JSON array
 * @ deprecated Use { @ link Json # parse ( Reader ) } { @ link org . jmxtrans . agent . util . json . JsonValue # asArray ( ) . asArray ( ) } instead */
@ Deprecated public static JsonArray readFrom ( Reader reader ) throws IOException { } }

implementation: return org . jmxtrans . agent . util . json . JsonValue . readFrom ( reader ) . asArray ( ) ;


signature:
public class JsonArray { /** * Reads a JSON array from the given string .
 * @ param string
 * the string that contains the JSON array
 * @ return the JSON array that has been read
 * @ throws ParseException
 * if the input is not valid JSON
 * @ throws UnsupportedOperationException
 * if the input does not contain a JSON array
 * @ deprecated Use { @ link Json # parse ( String ) } { @ link org . jmxtrans . agent . util . json . JsonValue # asArray ( ) . asArray ( ) } instead */
@ Deprecated public static JsonArray readFrom ( String string ) { } }

implementation: return org . jmxtrans . agent . util . json . JsonValue . readFrom ( string ) . asArray ( ) ;


signature:
public class JsonArray { /** * Appends the specified JSON value to the end of this array .
 * @ param value
 * the JsonValue to add to the array , must not be < code > null < / code >
 * @ return the array itself , to enable method chaining */
public JsonArray add ( org . jmxtrans . agent . util . json . JsonValue value ) { } }

implementation: if ( value == null ) { throw new NullPointerException ( "value is null" ) ; } values . add ( value ) ; return this ;


signature:
public class JsonArray { /** * Replaces the element at the specified position in this array with the specified JSON value .
 * @ param index
 * the index of the array element to replace
 * @ param value
 * the value to be stored at the specified array position , must not be < code > null < / code >
 * @ return the array itself , to enable method chaining
 * @ throws IndexOutOfBoundsException
 * if the index is out of range , i . e . < code > index & lt ; 0 < / code > or
 * < code > index & gt ; = size < / code > */
public JsonArray set ( int index , org . jmxtrans . agent . util . json . JsonValue value ) { } }

implementation: if ( value == null ) { throw new NullPointerException ( "value is null" ) ; } values . set ( index , value ) ; return this ;


signature:
public class JsonArray { /** * Returns the value of the element at the specified position in this array .
 * @ param index
 * the index of the array element to return
 * @ return the value of the element at the specified position
 * @ throws IndexOutOfBoundsException
 * if the index is out of range , i . e . < code > index & lt ; 0 < / code > or
 * < code > index & gt ; = size < / code > */
public org . jmxtrans . agent . util . json . JsonValue get ( int index ) { } }

implementation: return values . get ( index ) ;


signature:
public class JsonArray { /** * Returns a list of the values in this array in document order . The returned list is backed by
 * this array and will reflect subsequent changes . It cannot be used to modify this array .
 * Attempts to modify the returned list will result in an exception .
 * @ return a list of the values in this array */
public List < org . jmxtrans . agent . util . json . JsonValue > values ( ) { } }

implementation: return Collections . unmodifiableList ( values ) ;


signature:
public class JsonArray { /** * Returns an iterator over the values of this array in document order . The returned iterator
 * cannot be used to modify this array .
 * @ return an iterator over the values of this array */
public Iterator < org . jmxtrans . agent . util . json . JsonValue > iterator ( ) { } }

implementation: final Iterator < org . jmxtrans . agent . util . json . JsonValue > iterator = values . iterator ( ) ; return new Iterator < org . jmxtrans . agent . util . json . JsonValue > ( ) { public boolean hasNext ( ) { return iterator . hasNext ( ) ; } public org . jmxtrans . agent . util . json . JsonValue next ( ) { return iterator . next ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ;


signature:
public class EventMonitor { /** * SECTION : INSTANCE METHODS */
public synchronized boolean register ( EventHandler handler ) { } }

implementation: boolean result = handlers . add ( handler ) ; handlersByEvent . clear ( ) ; return result ;


signature:
public class EventMonitor { /** * SECTION : RUNNABLE / THREAD */
@ Override public void run ( ) { } }

implementation:
System . out . println ( "Event monitor starting..." ) ; while ( ! shouldShutDown ) { try { synchronized ( eventQueue ) { if ( eventQueue . isEmpty ( ) ) { eventQueue . wait ( delay ) ; // Support wake - up via eventQueue . notify ( )
} } } catch ( InterruptedException e ) { e . printStackTrace ( ) ; System . err . println ( "Interrupted (use shutdown() to terminate).  Continuing..." ) ; continue ; } Object event = null ; while ( ( event = eventQueue . poll ( ) ) != null ) { processEvent ( event ) ; } } System . out . println ( "Event monitor exiting..." ) ; clearAllHandlers ( ) ;


signature:
public class EventMonitor { /** * Runs each appropriate EventHandler in an Executor .
 * @ param event */
private void processEvent ( final Object event ) { } }

implementation: System . out . println ( "Processing event: " + event . toString ( ) ) ; for ( final EventHandler handler : getConsumersFor ( event . getClass ( ) ) ) { EVENT_EXECUTOR . execute ( new Runnable ( ) { @ Override public void run ( ) { try { handler . handle ( event ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; if ( shouldReRaiseOnError ) { System . out . println ( "Event handler failed. Re-publishing event: " + event . toString ( ) ) ; eventQueue . publish ( event ) ; } } } } ) ; }


signature:
public class DomainEvents { /** * SECTION : INSTANCE METHODS */
private boolean addEventBus ( String name , EventBus bus ) { } }

implementation: if ( ! eventBusses . containsKey ( name ) ) { eventBusses . put ( name , bus ) ; return true ; } return false ;


signature:
public class DomainEvents { /** * Raise an event on all event busses , passing it to applicable consumers asynchronously .
 * @ param event */
private void publishEvent ( Object event ) { } }

implementation: assert ( hasEventBusses ( ) ) ; for ( EventBus eventBus : eventBusses . values ( ) ) { eventBus . publish ( event ) ; }


signature:
public class DomainEvents { /** * Raise an event on a named event bus , passing it to applicable consumers asynchronously .
 * @ param name the name of an event bus , assigned during calls to addEventBus ( String , EventBus ) .
 * @ param event the event to publish . */
private void publishEvent ( String name , Object event ) { } }

implementation: assert ( hasEventBusses ( ) ) ; EventBus eventBus = getEventBus ( name ) ; if ( eventBus == null ) { throw new RuntimeException ( "Unknown event bus name: " + name ) ; } eventBus . publish ( event ) ;


signature:
public class Padding { /** * sets the top , right , bottom and left width in { @ code Padding } . If the
 * given argument is already used by another object , then the
 * existing / cloned object will be used . And throws
 * { @ code NullValueException } if any of the given argument is null .
 * @ param paddingTop
 * @ param paddingRight
 * @ param paddingBottom
 * @ param paddingLeft
 * @ author WFF
 * @ since 1.0.0 */
public void setPadding ( final PaddingTop paddingTop , final PaddingRight paddingRight , final PaddingBottom paddingBottom , final PaddingLeft paddingLeft ) { } }

implementation: if ( paddingTop != null && paddingRight != null && paddingBottom != null && paddingLeft != null ) { if ( PaddingTop . INITIAL . equals ( paddingTop . getCssValue ( ) ) || PaddingTop . INHERIT . equals ( paddingTop . getCssValue ( ) ) || PaddingRight . INITIAL . equals ( paddingRight . getCssValue ( ) ) || PaddingRight . INHERIT . equals ( paddingRight . getCssValue ( ) ) || PaddingBottom . INITIAL . equals ( paddingBottom . getCssValue ( ) ) || PaddingBottom . INHERIT . equals ( paddingBottom . getCssValue ( ) ) || PaddingLeft . INITIAL . equals ( paddingLeft . getCssValue ( ) ) || PaddingLeft . INHERIT . equals ( paddingLeft . getCssValue ( ) ) ) { throw new InvalidValueException ( "Any or all of the given arguments have initial/inherit constant value as its cssValue" ) ; } try { final PaddingTop paddingTopTemp ; final PaddingRight paddingRightTemp ; final PaddingBottom paddingBottomTemp ; final PaddingLeft paddingLeftTemp ; if ( this . paddingTop != null ) { this . paddingTop . setAlreadyInUse ( false ) ; this . paddingRight . setAlreadyInUse ( false ) ; this . paddingBottom . setAlreadyInUse ( false ) ; this . paddingLeft . setAlreadyInUse ( false ) ; } if ( paddingTop . isAlreadyInUse ( ) && this . paddingTop != paddingTop ) { if ( this . paddingTop != null ) { paddingTopTemp = this . paddingTop . setCssValue ( paddingTop . getCssValue ( ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingTop is already used by another object so the existing object is used" ) ; } } else { paddingTopTemp = paddingTop . clone ( ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingTop is already used by another object so its clone is assigned" ) ; } } } else { paddingTopTemp = paddingTop ; } if ( paddingRight . isAlreadyInUse ( ) && this . paddingRight != paddingRight ) { if ( this . paddingRight != null ) { paddingRightTemp = this . paddingRight . setCssValue ( paddingTop . getCssValue ( ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingRight is already used by another object so the existing object is used" ) ; } } else { paddingRightTemp = paddingRight . clone ( ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingRight is already used by another object so its clone is assigned" ) ; } } } else { paddingRightTemp = paddingRight ; } if ( paddingBottom . isAlreadyInUse ( ) && this . paddingBottom != paddingBottom ) { if ( this . paddingBottom != null ) { paddingBottomTemp = this . paddingBottom . setCssValue ( paddingTop . getCssValue ( ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingBottom is already used by another object so the existing object is used" ) ; } } else { paddingBottomTemp = paddingBottom . clone ( ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingBottom is already used by another object so its clone is assigned" ) ; } } } else { paddingBottomTemp = paddingBottom ; } if ( paddingLeft . isAlreadyInUse ( ) && this . paddingLeft != paddingLeft ) { if ( this . paddingLeft != null ) { paddingLeftTemp = this . paddingLeft . setCssValue ( paddingTop . getCssValue ( ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingLeft is already used by another object so the existing object is used" ) ; } } else { paddingLeftTemp = paddingLeft . clone ( ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( "the given paddingLeft is already used by another object so its clone is assigned" ) ; } } } else { paddingLeftTemp = paddingLeft ; } paddingTopTemp . setAlreadyInUse ( true ) ; paddingTopTemp . setStateChangeInformer ( this ) ; paddingRightTemp . setAlreadyInUse ( true ) ; paddingRightTemp . setStateChangeInformer ( this ) ; paddingBottomTemp . setAlreadyInUse ( true ) ; paddingBottomTemp . setStateChangeInformer ( this ) ; paddingLeftTemp . setAlreadyInUse ( true ) ; paddingLeftTemp . setStateChangeInformer ( this ) ; assignProducedCssValue ( paddingTop , paddingRight , paddingBottom , paddingLeft ) ; this . paddingTop = paddingTopTemp ; this . paddingRight = paddingRightTemp ; this . paddingBottom = paddingBottomTemp ; this . paddingLeft = paddingLeftTemp ; } catch ( final CloneNotSupportedException e ) { throw new InvalidValueException ( e ) ; } catch ( final Exception e ) { throw new InvalidValueException ( e ) ; } } else { throw new NullValueException ( "cannot accept null arguments" ) ; }


signature:
public class Padding { /** * ( non - Javadoc )
 * @ see
 * com . webfirmframework . wffweb . informer . StateChangeInformer # stateChanged (
 * java . lang . Object ) */
@ Override public void stateChanged ( final CssProperty stateChangedObject ) { } }

implementation: if ( stateChangedObject instanceof PaddingTop ) { final PaddingTop paddingTop = ( PaddingTop ) stateChangedObject ; if ( PaddingTop . INITIAL . equals ( paddingTop . getCssValue ( ) ) || PaddingTop . INHERIT . equals ( paddingTop . getCssValue ( ) ) ) { throw new InvalidValueException ( "paddingTop cannot have initial/inherit as its cssValue" ) ; } } else if ( stateChangedObject instanceof PaddingRight ) { final PaddingRight paddingRight = ( PaddingRight ) stateChangedObject ; if ( PaddingRight . INITIAL . equals ( paddingRight . getCssValue ( ) ) || PaddingRight . INHERIT . equals ( paddingRight . getCssValue ( ) ) ) { throw new InvalidValueException ( "paddingRight cannot have initial/inherit as its cssValue" ) ; } } else if ( stateChangedObject instanceof PaddingBottom ) { final PaddingBottom paddingBottom = ( PaddingBottom ) stateChangedObject ; if ( PaddingBottom . INITIAL . equals ( paddingBottom . getCssValue ( ) ) || PaddingBottom . INHERIT . equals ( paddingBottom . getCssValue ( ) ) ) { throw new InvalidValueException ( "paddingBottom cannot have initial/inherit as its cssValue" ) ; } } else if ( stateChangedObject instanceof PaddingLeft ) { final PaddingLeft paddingLeft = ( PaddingLeft ) stateChangedObject ; if ( PaddingLeft . INITIAL . equals ( paddingLeft . getCssValue ( ) ) || PaddingLeft . INHERIT . equals ( paddingLeft . getCssValue ( ) ) ) { throw new InvalidValueException ( "paddingLeft cannot have initial/inherit as its cssValue" ) ; } } assignProducedCssValue ( paddingTop , paddingRight , paddingBottom , paddingLeft ) ;


signature:
public class CssValueUtil { /** * splits each cssValue part based on the css rule . < br >
 * This extraction is done based on the Web Firm Framework Index Based
 * Extraction algorithm . It will throw InvalidValueException if the given
 * cssValue contains no space in between any valid cssValue part , eg : -
 * < code > rgb ( 1 , 2 , 5 ) rgb ( 11 , 12 , 15 ) < / code > . And , it doesn ' t validate the
 * extracted cssValue parts so the extracted cssValue parts ( i . e . the
 * returned { @ code List < String > } ) may contain invalid cssValue part . < br >
 * < br >
 * Sample code to test
 * < pre >
 * final List & lt ; String & gt ; splitTest = CssValueUtil . split ( & quot ; hsla ( 7 , 8 , 9 , 1 ) red rgb ( 3 , 5 , 6 ) rgb ( 7 , 8 , 9 ) rgba ( 7 , 8 , 9 , 1 ) middle hsl ( 10 , 11 , 12 ) green blue & quot ; ) ;
 * for ( final String each : splitTest ) {
 * System . out . println ( each ) ;
 * gives out as :
 * hsla ( 7 , 8 , 9 , 1)
 * red
 * rgb ( 3 , 5 , 6)
 * rgb ( 7 , 8 , 9)
 * rgba ( 7 , 8 , 9 , 1)
 * middle
 * hsl ( 10 , 11 , 12)
 * green
 * blue < / i >
 * < / pre >
 * @ param cssValue
 * the value from which the css parts will be extracted
 * @ return the list containing cssValue parts
 * @ author WFF
 * @ since 1.0.0 */
public static List < String > split ( final String cssValue ) { } }

implementation:
try { final Map < Integer , int [ ] > startAndEndIndexes = new TreeMap < > ( ) ; for ( final Entry < String , String > entry : CSS_VALUE_PART_START_END_VALUES . entrySet ( ) ) { final int [ ] [ ] rgbStartAndEndIndexesOf = StringUtil . startAndEndIndexesOf ( cssValue , entry . getKey ( ) , entry . getValue ( ) ) ; for ( final int [ ] each : rgbStartAndEndIndexesOf ) { startAndEndIndexes . put ( each [ 0 ] , each ) ; } } if ( startAndEndIndexes . size ( ) == 0 ) { return Arrays . asList ( StringUtil . splitBySpace ( StringUtil . convertToSingleSpace ( cssValue ) ) ) ; } final List < String > cssValueParts = new ArrayList < > ( ) ; int count = 0 ; final int startAndEndIndexesSize = startAndEndIndexes . size ( ) ; int [ ] previousStartEndIndex = null ; for ( final Entry < Integer , int [ ] > entry : startAndEndIndexes . entrySet ( ) ) { count ++ ; final int [ ] currentStartEndIndex = entry . getValue ( ) ; final int zerothSlotCurrent = currentStartEndIndex [ 0 ] ; final int firstSlotCurrent = currentStartEndIndex [ 1 ] ; if ( previousStartEndIndex != null ) { final int firstSlotOfPrevious = previousStartEndIndex [ 1 ] ; // the difference should be more than two , 1 for at least
// one char ( css value having length one ) + one for space
// char .
if ( ( zerothSlotCurrent - firstSlotOfPrevious ) > 2 ) { final String cssValuePart2 = cssValue . substring ( firstSlotOfPrevious + 1 , zerothSlotCurrent ) ; final String trimmedCssValuePart2 = StringUtil . strip ( cssValuePart2 ) ; if ( StringUtil . startsWithWhitespace ( cssValuePart2 ) && StringUtil . endsWithWhitespace ( cssValuePart2 ) ) { if ( ! trimmedCssValuePart2 . isEmpty ( ) ) { for ( final String each : StringUtil . splitBySpace ( trimmedCssValuePart2 ) ) { final String trimmed ; if ( ! ( trimmed = StringUtil . strip ( each ) ) . isEmpty ( ) ) { cssValueParts . add ( trimmed ) ; } } } } else { throw new InvalidValueException ( "there must be a space between each part of cssValue, a space is expected before and/or after '" + cssValuePart2 + "'" ) ; } } else if ( ( zerothSlotCurrent - firstSlotOfPrevious ) == 1 ) { throw new InvalidValueException ( "there must be a space between each part of cssValue, a space is expected before '" + cssValue . substring ( zerothSlotCurrent ) + "'" ) ; } cssValueParts . add ( cssValue . substring ( currentStartEndIndex [ 0 ] , currentStartEndIndex [ 1 ] + 1 ) ) ; } else { // to check whether the starting cssValue part has at least
// two chars , 1 for at least one char ( css value having
// length one ) + one for space char .
// greater than 1 is enough since zerothSlotCurrent is an
// index number .
if ( ( zerothSlotCurrent ) > 1 ) { final String cssValuePart2 = cssValue . substring ( 0 , zerothSlotCurrent ) ; final String trimmedCssValuePart2 = StringUtil . strip ( cssValuePart2 ) ; if ( StringUtil . endsWithWhitespace ( cssValuePart2 ) ) { for ( final String each : StringUtil . splitBySpace ( trimmedCssValuePart2 ) ) { final String trimmed ; if ( ! ( trimmed = StringUtil . strip ( each ) ) . isEmpty ( ) ) { cssValueParts . add ( trimmed ) ; } } } else { throw new InvalidValueException ( "there must be a space between each part of cssValue, a space is expected after '" + cssValuePart2 + "'" ) ; } } cssValueParts . add ( cssValue . substring ( currentStartEndIndex [ 0 ] , currentStartEndIndex [ 1 ] + 1 ) ) ; } final int cssValueLength = cssValue . length ( ) ; if ( count == startAndEndIndexesSize && ( firstSlotCurrent < ( cssValueLength - 1 ) ) ) { final String cssValuePart2 = cssValue . substring ( firstSlotCurrent + 1 ) ; final String trimmedCssValuePart2 = StringUtil . strip ( cssValuePart2 ) ; if ( StringUtil . startsWithWhitespace ( cssValuePart2 ) ) { for ( final String each : StringUtil . splitBySpace ( trimmedCssValuePart2 ) ) { if ( ! each . isEmpty ( ) ) { cssValueParts . add ( each ) ; } } } else { throw new InvalidValueException ( "there must be a space between each part of cssValue, a space is expected before '" + cssValuePart2 + "'" ) ; } } previousStartEndIndex = currentStartEndIndex ; } return cssValueParts ; } catch ( final RuntimeException e ) { throw new InvalidValueException ( e ) ; }


signature:
public class CssValueUtil { /** * This method throws { @ code NullValueException } if the given
 * { @ code cssValue } is null or { @ code InvalidValueException } if the given
 * { @ code cssValue } is blank .
 * @ param cssValue
 * @ throws NullValueException
 * @ throws InvalidValueException
 * @ author WFF
 * @ since 1.0.0 */
public static void throwExceptionForInvalidValue ( final String cssValue ) throws NullValueException , InvalidValueException { } }

implementation: if ( cssValue == null ) { throw new NullValueException ( "the cssValue should not be null." ) ; } else if ( StringUtil . isBlank ( cssValue ) ) { throw new InvalidValueException ( "the cssValue should not be blank." ) ; }


signature:
public class ColumnCount { /** * validates if the given cssValue is valid for this class .
 * @ param cssValue
 * the value to check .
 * @ return true if valid and false if invalid .
 * @ author WFF
 * @ since 1.0.0 */
public static boolean isValid ( final String cssValue ) { } }

implementation: final String trimmedCssValue = TagStringUtil . toLowerCase ( StringUtil . strip ( cssValue ) ) ; if ( StringUtil . containsSpace ( trimmedCssValue ) ) { return false ; } try { final int parsedValue = Integer . parseInt ( trimmedCssValue ) ; return ! ( parsedValue == 0 && ( StringUtil . containsMinus ( trimmedCssValue ) || StringUtil . containsPlus ( trimmedCssValue ) ) ) ; } catch ( final NumberFormatException e ) { } return PREDEFINED_CONSTANTS . contains ( trimmedCssValue ) ;


signature:
public class NoTag { /** * removes the the child content .
 * @ param child
 * @ since 1.0.0
 * @ author WFF */
public void removeChild ( final String child ) { } }

implementation: final StringBuilder htmlMiddleSB = getHtmlMiddleSB ( ) ; final String sb = htmlMiddleSB . toString ( ) ; final String replaced = sb . replace ( child , "" ) ; final int lastIndex = htmlMiddleSB . length ( ) - 1 ; htmlMiddleSB . delete ( 0 , lastIndex ) ; htmlMiddleSB . append ( replaced ) ;


signature:
public class BackgroundSize { /** * validates if the given cssValue is valid for this class .
 * @ param cssValue
 * the value to check .
 * @ return true if valid and false if invalid .
 * @ author WFF
 * @ since 1.0.0 */
public static boolean isValid ( final String cssValue ) { } }

implementation: final String trimmedCssValue = TagStringUtil . toLowerCase ( StringUtil . strip ( cssValue ) ) ; final String [ ] cssValueParts = StringUtil . splitBySpace ( trimmedCssValue ) ; if ( cssValueParts . length > 2 ) { return false ; } if ( PREDEFINED_CONSTANTS . contains ( trimmedCssValue ) ) { return true ; } boolean valid = false ; for ( final String each : cssValueParts ) { final Object [ ] lengthValueAndUnit = CssLengthUtil . getLengthValueAsPremitiveAndUnit ( each ) ; if ( lengthValueAndUnit . length != 2 ) { return false ; } valid = true ; } return valid ;


signature:
public class InnerHtmlAddListenerImpl { /** * adds to wffid map
 * @ param tag
 * @ since 2.0.0
 * @ author WFF */
private void addInWffIdMap ( final AbstractHtml tag ) { } }

implementation:
final Deque < Set < AbstractHtml > > childrenStack = new ArrayDeque < > ( ) ; // passed 2 instead of 1 because the load factor is 0.75f
final Set < AbstractHtml > initialSet = new HashSet < > ( 2 ) ; initialSet . add ( tag ) ; childrenStack . push ( initialSet ) ; Set < AbstractHtml > children ; while ( ( children = childrenStack . poll ( ) ) != null ) { for ( final AbstractHtml child : children ) { final DataWffId wffIdAttr = child . getDataWffId ( ) ; if ( wffIdAttr != null ) { tagByWffId . put ( wffIdAttr . getValue ( ) , child ) ; } final Set < AbstractHtml > subChildren = child . getChildren ( accessObject ) ; if ( subChildren != null && subChildren . size ( ) > 0 ) { childrenStack . push ( subChildren ) ; } } }


signature:
public class BorderRight { /** * checks the given css value is valid for this class . It does ' t do a strict
 * validation .
 * @ param cssValue
 * @ return
 * @ since 1.0.0
 * @ author WFF */
public static boolean isValid ( final String cssValue ) { } }

implementation:
// TODO modify to make a strict validation
if ( cssValue == null || StringUtil . isBlank ( cssValue ) ) { return false ; } final List < String > cssValueParts = CssValueUtil . split ( cssValue ) ; BorderRightWidth borderRightWidth = null ; BorderRightStyle borderRightStyle = null ; BorderRightColor borderRightColor = null ; for ( final String eachPart : cssValueParts ) { boolean invalid = true ; if ( borderRightWidth == null && BorderRightWidth . isValid ( eachPart ) ) { borderRightWidth = new BorderRightWidth ( eachPart ) ; invalid = false ; } else if ( borderRightStyle == null && BorderRightStyle . isValid ( eachPart ) ) { borderRightStyle = BorderRightStyle . getThis ( eachPart ) ; invalid = false ; } else if ( borderRightColor == null && BorderRightColor . isValid ( eachPart ) ) { borderRightColor = new BorderRightColor ( eachPart ) ; invalid = false ; } if ( invalid ) { return false ; } } return borderRightWidth != null || borderRightStyle != null || borderRightColor != null ;


signature:
public class Left { /** * validates if the given cssValue is valid for this class .
 * @ param cssValue
 * the value to check .
 * @ return true if valid and false if invalid .
 * @ author WFF
 * @ since 1.0.0 */
public static boolean isValid ( final String cssValue ) { } }

implementation:
final String trimmedCssValue = TagStringUtil . toLowerCase ( StringUtil . strip ( cssValue ) ) ; if ( StringUtil . containsSpace ( trimmedCssValue ) ) { return false ; } for ( final CssLengthUnit cssLengthUnit : CssLengthUnit . values ( ) ) { final String unit = cssLengthUnit . getUnit ( ) ; if ( trimmedCssValue . endsWith ( unit ) ) { final String valueOnly = trimmedCssValue . replaceFirst ( unit , "" ) ; try { // it could be negative
Float . parseFloat ( valueOnly ) ; } catch ( final NumberFormatException e ) { break ; } return true ; } } return PREDEFINED_CONSTANTS . contains ( trimmedCssValue ) ;


signature:
public class AbstractAttribute { /** * gets the attribute name and value in the format of name = value . < br >
 * Eg : style = color : green ; background : blue < br >
 * This reduces 2 bytes taken for " .
 * @ return the attribute name and value in the format of name = value . Eg :
 * style = color : green ; background : blue
 * @ since 2.0.0
 * @ author WFF */
protected String getWffPrintStructure ( ) { } }

implementation: final String attributeValue = this . attributeValue ; String result = "" ; beforeWffPrintStructure ( ) ; final StringBuilder attrBuilder = new StringBuilder ( ) ; attrBuilder . append ( attributeName ) ; if ( attributeValue != null ) { attrBuilder . append ( new char [ ] { '=' } ) . append ( attributeValue ) ; result = StringBuilderUtil . getTrimmedString ( attrBuilder ) ; } else if ( attributeValueMap != null && attributeValueMap . size ( ) > 0 ) { attrBuilder . append ( new char [ ] { '=' } ) ; final Set < Entry < String , String > > entrySet = getAttributeValueMap ( ) . entrySet ( ) ; for ( final Entry < String , String > entry : entrySet ) { attrBuilder . append ( entry . getKey ( ) ) . append ( ':' ) . append ( entry . getValue ( ) ) . append ( ';' ) ; } result = StringBuilderUtil . getTrimmedString ( attrBuilder ) ; } else if ( attributeValueSet != null && attributeValueSet . size ( ) > 0 ) { attrBuilder . append ( new char [ ] { '=' } ) ; for ( final String each : getAttributeValueSet ( ) ) { attrBuilder . append ( each ) . append ( ' ' ) ; } result = StringBuilderUtil . getTrimmedString ( attrBuilder ) ; } else { result = attrBuilder . toString ( ) ; } return result ;


signature:
public class AbstractAttribute { /** * gives compressed by index bytes for the attribute and value . The first
 * byte represents the attribute name index bytes length , the next bytes
 * represent the attribute name index bytes and the remaining bytes
 * represent attribute value without < i > = < / i > and < i > " < / i > .
 * @ param rebuild
 * @ return the compressed by index bytes .
 * @ throws IOException
 * @ since 1.1.3
 * @ author WFF */
protected byte [ ] getBinaryStructureCompressedByIndex ( final boolean rebuild ) throws IOException { } }

implementation:
final String attributeValue = this . attributeValue ; final Charset charset = this . charset ; // TODO review code
final ByteArrayOutputStream compressedByIndexBytes = new ByteArrayOutputStream ( ) ; byte [ ] compressedBytes = new byte [ 0 ] ; // String result = " " ;
if ( rebuild || isRebuild ( ) || isModified ( ) ) { beforePrintStructureCompressedByIndex ( ) ; // tagBuildzer . append ( ' ' ) ;
final int attributeNameIndex = AttributeRegistry . getAttributeNames ( ) . indexOf ( attributeName ) ; if ( attributeNameIndex == - 1 ) { compressedByIndexBytes . write ( new byte [ ] { ( byte ) 0 } ) ; compressedByIndexBytes . write ( attributeName . concat ( "=" ) . getBytes ( charset ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( attributeName + " is not indexed, please register it with AttributeRegistrar" ) ; } } else { final byte [ ] optimizedBytesFromInt = WffBinaryMessageUtil . getOptimizedBytesFromInt ( attributeNameIndex ) ; compressedByIndexBytes . write ( new byte [ ] { ( byte ) optimizedBytesFromInt . length } ) ; compressedByIndexBytes . write ( optimizedBytesFromInt ) ; } if ( attributeValue != null ) { compressedByIndexBytes . write ( attributeValue . getBytes ( charset ) ) ; compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else if ( attributeValueMap != null && attributeValueMap . size ( ) > 0 ) { final Set < Entry < String , String > > entrySet = getAttributeValueMap ( ) . entrySet ( ) ; for ( final Entry < String , String > entry : entrySet ) { compressedByIndexBytes . write ( entry . getKey ( ) . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ':' } ) ; compressedByIndexBytes . write ( entry . getValue ( ) . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ';' } ) ; } compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else if ( attributeValueSet != null && attributeValueSet . size ( ) > 0 ) { for ( final String each : getAttributeValueSet ( ) ) { compressedByIndexBytes . write ( each . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ' ' } ) ; } compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else { compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } setRebuild ( false ) ; } return compressedBytes ;


signature:
public class AbstractAttribute { /** * ( non - Javadoc )
 * @ see com . webfirmframework . wffweb . tag . core . TagBase # toHtmlString ( boolean ,
 * java . nio . charset . Charset ) */
@ Override public String toHtmlString ( final boolean rebuild , final Charset charset ) { } }

implementation: final Charset previousCharset = this . charset ; try { this . charset = charset ; return toHtmlString ( rebuild ) ; } finally { this . charset = previousCharset ; }


signature:
public class AbstractAttribute { /** * adds the given key value .
 * @ param key
 * @ param value
 * @ return true if it is modified
 * @ since 1.0.0
 * @ author WFF */
protected boolean addToAttributeValueMap ( final String key , final String value ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { final Map < String , String > attributeValueMap = getAttributeValueMap ( ) ; final String previousValue = attributeValueMap . put ( key , value ) ; if ( ! Objects . equals ( previousValue , value ) ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; return listenerInvoked ;


signature:
public class AbstractAttribute { /** * this method should be called after changing of attribute value not before
 * changing value */
private void invokeValueChangeListeners ( final Collection < AbstractHtml5SharedObject > sharedObjects ) { } }

implementation:
for ( final AbstractHtml5SharedObject sharedObject : sharedObjects ) { final AttributeValueChangeListener valueChangeListener = sharedObject . getValueChangeListener ( ACCESS_OBJECT ) ; if ( valueChangeListener != null ) { // ownerTags should not be modified in the consuming
// part , here
// skipped it making unmodifiable to gain
// performance
final AttributeValueChangeListener . Event event = new AttributeValueChangeListener . Event ( this , ownerTags ) ; valueChangeListener . valueChanged ( event ) ; } } if ( valueChangeListeners != null ) { for ( final AttributeValueChangeListener listener : valueChangeListeners ) { final AttributeValueChangeListener . Event event = new AttributeValueChangeListener . Event ( this , Collections . unmodifiableSet ( ownerTags ) ) ; listener . valueChanged ( event ) ; } }


signature:
public class AbstractAttribute { /** * adds all to the attribute value map .
 * @ param map
 * @ since 1.0.0
 * @ author WFF
 * @ return true if it is modified */
protected boolean addAllToAttributeValueMap ( final Map < String , String > map ) { } }

implementation: if ( map != null && map . size ( ) > 0 ) { final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { getAttributeValueMap ( ) . putAll ( map ) ; setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; return listenerInvoked ; } return false ;


signature:
public class AbstractAttribute { /** * removes the key value for the input key .
 * @ param keys
 * @ since 3.0.1
 * @ author WFF
 * @ return true if any of the given keys ( as well as value contained
 * corresponding to it ) has been removed . */
protected boolean removeFromAttributeValueMapByKeys ( final String ... keys ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; boolean result = false ; try { final Map < String , String > valueMap = getAttributeValueMap ( ) ; if ( nullableAttrValueMapValue ) { for ( final String key : keys ) { result = valueMap . containsKey ( key ) ; if ( result ) { break ; } } } for ( final String key : keys ) { final String previous = valueMap . remove ( key ) ; if ( previous != null ) { result = true ; } } if ( result ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; return result ;


signature:
public class AbstractAttribute { /** * pushes PushQueue from all shared object of parent tags .
 * @ param sharedObjects
 * @ param listenerInvoked */
private void pushQueues ( final Collection < AbstractHtml5SharedObject > sharedObjects , final boolean listenerInvoked ) { } }

implementation: if ( listenerInvoked ) { for ( final AbstractHtml5SharedObject sharedObject : sharedObjects ) { final PushQueue pushQueue = sharedObject . getPushQueue ( ACCESS_OBJECT ) ; if ( pushQueue != null ) { pushQueue . push ( ) ; } } }


signature:
public class AbstractAttribute { /** * removes only if the key and value matches in the map for any particular
 * entry .
 * @ param key
 * @ param value
 * @ since 1.0.0
 * @ author WFF
 * @ return true if it is modified */
protected boolean removeFromAttributeValueMap ( final String key , final String value ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; boolean listenerInvoked = false ; try { final boolean removed = getAttributeValueMap ( ) . remove ( key , value ) ; if ( removed ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; return listenerInvoked ;


signature:
public class AbstractAttribute { /** * NB : - this is only for getting values . Use addToAttributeValueSet method
 * for adding
 * @ return the attributeValueSet
 * @ since 1.0.0
 * @ author WFF */
protected Set < String > getAttributeValueSet ( ) { } }

implementation:
if ( attributeValueSet == null ) { synchronized ( this ) { if ( attributeValueSet == null ) { // because the load factor is 0.75f
attributeValueSet = new LinkedHashSet < > ( 2 ) ; } } } return attributeValueSet ;


signature:
public class AbstractAttribute { /** * adds to the attribute value set .
 * @ param value
 * @ since 1.0.0
 * @ author WFF
 * @ return */
protected boolean addToAttributeValueSet ( final String value ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { final boolean added = getAttributeValueSet ( ) . add ( value ) ; if ( added ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; return listenerInvoked ;


signature:
public class AbstractAttribute { /** * adds all to the attribute value set .
 * @ param values
 * @ since 1.0.0
 * @ author WFF */
protected void addAllToAttributeValueSet ( final Collection < String > values ) { } }

implementation: if ( values != null ) { final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { final boolean added = getAttributeValueSet ( ) . addAll ( values ) ; if ( added ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ; }


signature:
public class AbstractAttribute { /** * removes the value from the the attribute set .
 * @ param values
 * @ since 1.0.0
 * @ author WFF */
protected void removeAllFromAttributeValueSet ( final Collection < String > values ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { final boolean removedAll = getAttributeValueSet ( ) . removeAll ( values ) ; if ( removedAll ) { setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ;


signature:
public class AbstractAttribute { /** * clears all values from the value set .
 * @ since 1.0.0
 * @ author WFF */
protected void removeAllFromAttributeValueSet ( ) { } }

implementation: final Collection < AbstractHtml5SharedObject > sharedObjects = getSharedObjects ( ) ; boolean listenerInvoked = false ; final Collection < WriteLock > writeLocks = lockAndGetWriteLocks ( ) ; try { getAttributeValueSet ( ) . clear ( ) ; setModified ( true ) ; invokeValueChangeListeners ( sharedObjects ) ; listenerInvoked = true ; } finally { for ( final Lock lock : writeLocks ) { lock . unlock ( ) ; } } pushQueues ( sharedObjects , listenerInvoked ) ;


signature:
public class AbstractAttribute { /** * adds value change lister which will be invoked when the value changed
 * @ param valueChangeListener
 * @ since 2.0.0
 * @ author WFF */
public void addValueChangeListener ( final AttributeValueChangeListener valueChangeListener ) { } }

implementation: if ( valueChangeListeners == null ) { synchronized ( this ) { if ( valueChangeListeners == null ) { valueChangeListeners = new LinkedHashSet < > ( ) ; } } } valueChangeListeners . add ( valueChangeListener ) ;


signature:
public class AbstractAttribute { /** * NB : this may not return the same locks as there could be the its
 * ownerTags change . Use it for only unlock .
 * @ return the set of read locks after locking */
protected Collection < ReadLock > lockAndGetReadLocks ( ) { } }

implementation:
// internally ownerTags . size ( ) ( WeakHashMap ) contains synchronization
// better avoid calling it
// normally there will be one sharedObject so the capacity may be
// considered as 2 because the load factor is 0.75f
final Collection < ReadLock > readLocks = new HashSet < > ( 2 ) ; for ( final AbstractHtml ownerTag : ownerTags ) { final ReadLock readLock = ownerTag . getSharedObject ( ) . getLock ( ACCESS_OBJECT ) . readLock ( ) ; if ( readLock != null ) { readLocks . add ( readLock ) ; } } // must be separately locked
for ( final ReadLock readLock : readLocks ) { try { readLock . lock ( ) ; readLocks . add ( readLock ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } } return readLocks ;


signature:
public class AbstractAttribute { /** * NB : this may not return the same locks as there could be the its
 * ownerTags change . So call only once and reuse it for both lock and unlock
 * call .
 * @ return the set of write locks */
protected Collection < WriteLock > getWriteLocks ( ) { } }

implementation: final Collection < WriteLock > writeLocks = new TreeSet < > ( ( o1 , o2 ) -> Integer . compare ( o2 . getHoldCount ( ) , o1 . getHoldCount ( ) ) ) ; for ( final AbstractHtml ownerTag : ownerTags ) { final WriteLock writeLock = ownerTag . getSharedObject ( ) . getLock ( ACCESS_OBJECT ) . writeLock ( ) ; if ( writeLock != null ) { try { writeLocks . add ( writeLock ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } } } return writeLocks ;


signature:
public class AbstractAttribute { /** * NB : this may not return the same locks as there could be the its
 * ownerTags change . So call only once and reuse it for both lock and unlock
 * call .
 * @ return the set of read locks */
protected Collection < ReadLock > getReadLocks ( ) { } }

implementation:
// internally ownerTags . size ( ) ( WeakHashMap ) contains synchronization
// better avoid calling it
// normally there will be one sharedObject so the capacity may be
// considered as 2 because the load factor is 0.75f
final Collection < ReadLock > readLocks = new HashSet < > ( 2 ) ; for ( final AbstractHtml ownerTag : ownerTags ) { final ReadLock readLock = ownerTag . getSharedObject ( ) . getLock ( ACCESS_OBJECT ) . readLock ( ) ; if ( readLock != null ) { readLocks . add ( readLock ) ; } } return readLocks ;