idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
21,400 | public Optional < List < FormItem > > parseRequestMultiPartItems ( String encoding ) { DiskFileItemFactory factory = new DiskFileItemFactory ( ) ; factory . setSizeThreshold ( properties . getInt ( Constants . PROPERTY_UPLOADS_MAX_SIZE ) ) ; factory . setRepository ( new File ( System . getProperty ( "java.io.tmpdir" )... | Gets the FileItemIterator of the input . |
21,401 | public void printRuleSet ( RuleSet ruleSet ) throws RuleException { RuleSelection ruleSelection = RuleSelection . builder ( ) . conceptIds ( ruleSet . getConceptBucket ( ) . getIds ( ) ) . constraintIds ( ruleSet . getConstraintBucket ( ) . getIds ( ) ) . groupIds ( ruleSet . getGroupsBucket ( ) . getIds ( ) ) . build ... | Logs the given rule set on level info . |
21,402 | private void printValidRules ( CollectRulesVisitor visitor ) { logger . info ( "Groups [" + visitor . getGroups ( ) . size ( ) + "]" ) ; for ( Group group : visitor . getGroups ( ) ) { logger . info ( LOG_LINE_PREFIX + group . getId ( ) + "\"" ) ; } logger . info ( "Constraints [" + visitor . getConstraints ( ) . size ... | Prints all valid rules . |
21,403 | private CollectRulesVisitor getAllRules ( RuleSet ruleSet , RuleSelection ruleSelection ) throws RuleException { CollectRulesVisitor visitor = new CollectRulesVisitor ( ) ; RuleSetExecutor executor = new RuleSetExecutor ( visitor , new RuleSetExecutorConfiguration ( ) ) ; executor . execute ( ruleSet , ruleSelection ) ... | Determines all rules . |
21,404 | private boolean printMissingRules ( CollectRulesVisitor visitor ) { Set < String > missingConcepts = visitor . getMissingConcepts ( ) ; if ( ! missingConcepts . isEmpty ( ) ) { logger . info ( "Missing concepts [" + missingConcepts . size ( ) + "]" ) ; for ( String missingConcept : missingConcepts ) { logger . warn ( L... | Prints all missing rule ids . |
21,405 | public String getTemplateNameForResult ( Route route , Result response ) { String template = response . template ( ) ; if ( template == null ) { if ( route != null ) { String controllerPath = RouterHelper . getReverseRouteFast ( route . getController ( ) ) ; if ( new File ( realPath + controllerPath + templateSuffix ) ... | If the template is specified by the user with a suffix corresponding to the template engine suffix then this is removed before returning the template . Suffixes such as . st or . ftl . html |
21,406 | public T locateLayoutTemplate ( String controller , final String layout , final boolean useCache ) throws ViewException { final String controllerLayoutCombined = controller + '/' + layout ; if ( useCache && cachedTemplates . containsKey ( controllerLayoutCombined ) ) return engine . clone ( cachedTemplates . get ( cont... | If found uses the provided layout within the controller folder . If not found it looks for the default template within the controller folder then use this to override the root default template |
21,407 | protected void flash ( Map < String , String > values ) { for ( Object key : values . keySet ( ) ) { flash ( key . toString ( ) , values . get ( key ) ) ; } } | Convenience method takes in a map of values to flash . |
21,408 | protected void flash ( String name , String value ) { context . getFlash ( ) . put ( name , value ) ; } | Sends value to flash . Flash survives one more request . Using flash is typical for POST - > REDIRECT - > GET pattern |
21,409 | protected void redirectToReferrer ( ) { String referrer = context . requestHeader ( "Referer" ) ; referrer = referrer == null ? context . contextPath ( ) : referrer ; redirect ( referrer ) ; } | Redirects to referrer if one exists . If a referrer does not exist it will be redirected to the root of the application . |
21,410 | protected String cookieValue ( String name ) { Cookie cookie = cookie ( name ) ; return cookie != null ? cookie . getValue ( ) : null ; } | Convenience method returns cookie value . |
21,411 | public < T > Class < T > getType ( String typeName ) { try { return ( Class < T > ) classLoader . loadClass ( typeName ) ; } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException ( "Cannot find class " + typeName , e ) ; } } | Create and return an instance of the given type name . |
21,412 | private Map < String , ReportPlugin > selectReportPlugins ( ExecutableRule rule ) throws ReportException { Set < String > selection = rule . getReport ( ) . getSelectedTypes ( ) ; Map < String , ReportPlugin > reportPlugins = new HashMap < > ( ) ; if ( selection != null ) { for ( String type : selection ) { ReportPlugi... | Select the report writers for the given rule . |
21,413 | static Set < String > labels ( final ResultSet results ) throws SQLException { final ResultSetMetaData metadata = results . getMetaData ( ) ; final int count = metadata . getColumnCount ( ) ; final Set < String > labels = new HashSet < > ( count ) ; for ( int i = 1 ; i <= count ; i ++ ) { labels . add ( metadata . getC... | Returns a set of column labels of given result set . |
21,414 | private void writeStatus ( Result . Status status ) throws XMLStreamException { xmlStreamWriter . writeStartElement ( "status" ) ; xmlStreamWriter . writeCharacters ( status . name ( ) . toLowerCase ( ) ) ; xmlStreamWriter . writeEndElement ( ) ; } | Write the status of the current result . |
21,415 | private void writeColumn ( String columnName , Object value ) throws XMLStreamException { xmlStreamWriter . writeStartElement ( "column" ) ; xmlStreamWriter . writeAttribute ( "name" , columnName ) ; String stringValue = null ; if ( value instanceof CompositeObject ) { CompositeObject descriptor = ( CompositeObject ) v... | Determines the language and language element of a descriptor from a result column . |
21,416 | private void writeDuration ( long beginTime ) throws XMLStreamException { xmlStreamWriter . writeStartElement ( "duration" ) ; xmlStreamWriter . writeCharacters ( Long . toString ( System . currentTimeMillis ( ) - beginTime ) ) ; xmlStreamWriter . writeEndElement ( ) ; } | Writes the duration . |
21,417 | private void writeSeverity ( Severity severity ) throws XMLStreamException { xmlStreamWriter . writeStartElement ( "severity" ) ; xmlStreamWriter . writeAttribute ( "level" , severity . getLevel ( ) . toString ( ) ) ; xmlStreamWriter . writeCharacters ( severity . getValue ( ) ) ; xmlStreamWriter . writeEndElement ( ) ... | Writes the severity of the rule . |
21,418 | private void run ( XmlOperation operation ) throws ReportException { try { operation . run ( ) ; } catch ( XMLStreamException | IOException e ) { throw new ReportException ( "Cannot write to XML report." , e ) ; } } | Defines an operation to write XML elements . |
21,419 | private final CompiledST loadTemplateResource ( String prefix , String unqualifiedFileName ) { if ( resourceRoots . isEmpty ( ) ) return null ; CompiledST template = null ; for ( URL resourceRoot : resourceRoots ) { if ( ( template = loadTemplate ( resourceRoot , prefix , unqualifiedFileName ) ) != null ) return templa... | Loads from a jar or similar resource if the template could not be found directly on the filesystem . |
21,420 | private final void renderContentTemplate ( final ST contentTemplate , final Writer writer , final Map < String , Object > values , final ErrorBuffer error ) { injectTemplateValues ( contentTemplate , values ) ; contentTemplate . write ( createSTWriter ( writer ) , error ) ; } | Renders template directly to writer |
21,421 | private final String renderContentTemplate ( final ST contentTemplate , final Map < String , Object > values , final ErrorBuffer error , boolean inErrorState ) { if ( contentTemplate != null ) { try ( Writer sw = new StringBuilderWriter ( ) ) { final ErrorBuffer templateErrors = new ErrorBuffer ( ) ; renderContentTempl... | Renders template into string |
21,422 | public static Integer toInteger ( Object value ) throws ConversionException { if ( value == null ) { return null ; } else if ( value instanceof Number ) { return ( ( Number ) value ) . intValue ( ) ; } else { NumberFormat nf = new DecimalFormat ( ) ; try { return nf . parse ( value . toString ( ) ) . intValue ( ) ; } c... | Converts value to Integer if it can . If value is an Integer it is returned if it is a Number it is promoted to Integer and then returned in all other cases it converts the value to String then tries to parse Integer from it . |
21,423 | public static Boolean toBoolean ( Object value ) { if ( value == null ) { return false ; } else if ( value instanceof Boolean ) { return ( Boolean ) value ; } else if ( value instanceof BigDecimal ) { return value . equals ( BigDecimal . ONE ) ; } else if ( value instanceof Long ) { return value . equals ( 1L ) ; } els... | Returns true if the value is any numeric type and has a value of 1 or if string type has a value of y t true or yes . Otherwise return false . |
21,424 | public static Long toLong ( Object value ) throws ConversionException { if ( value == null ) { return null ; } else if ( value instanceof Number ) { return ( ( Number ) value ) . longValue ( ) ; } else { NumberFormat nf = new DecimalFormat ( ) ; try { return nf . parse ( value . toString ( ) ) . longValue ( ) ; } catch... | Converts value to Long if c it can . If value is a Long it is returned if it is a Number it is promoted to Long and then returned in all other cases it converts the value to String then tries to parse Long from it . |
21,425 | protected < T > Class < T > getType ( String typeName ) throws PluginRepositoryException { try { return ( Class < T > ) classLoader . loadClass ( typeName . trim ( ) ) ; } catch ( ClassNotFoundException | LinkageError e ) { throw new PluginRepositoryException ( "Cannot find or load class " + typeName , e ) ; } } | Get the class for the given type name . |
21,426 | protected < T > T createInstance ( String typeName ) throws PluginRepositoryException { Class < T > type = getType ( typeName . trim ( ) ) ; try { return type . newInstance ( ) ; } catch ( InstantiationException e ) { throw new PluginRepositoryException ( "Cannot create instance of class " + type . getName ( ) , e ) ; ... | Create an instance of the given scanner plugin class . |
21,427 | private final Route calculateRoute ( HttpMethod httpMethod , String requestUri ) throws RouteException { if ( routes == null ) throw new IllegalStateException ( "Routes have not been compiled. Call #compileRoutes() first" ) ; final Route route = matchCustom ( httpMethod , requestUri ) ; if ( route != null ) return rout... | It is not consistent that this particular injector handles implementations from both core and server |
21,428 | private Route matchStandard ( HttpMethod httpMethod , String requestUri , ActionInvoker invoker ) throws ClassLoadException { for ( InternalRoute internalRoute : internalRoutes ) { if ( internalRoute . matches ( requestUri ) ) { Route deferred = deduceRoute ( internalRoute , httpMethod , requestUri , invoker ) ; if ( d... | Only to be used in DEV mode |
21,429 | @ SuppressWarnings ( "NullableProblems" ) public Iterator < T > iterator ( ) { return new Iterator < T > ( ) { private int index = 0 ; public boolean hasNext ( ) { return this . index < size ( ) ; } public T next ( ) { if ( this . index >= size ( ) ) { throw new NoSuchElementException ( this . index + ">=" + size ( ) )... | Generates an iterator to allow the array processing in loops . |
21,430 | private static void assertArrayLength ( final int length , final JBBPNamedFieldInfo name ) { if ( length < 0 ) { throw new JBBPParsingException ( "Detected negative calculated array length for field '" + ( name == null ? "<NO NAME>" : name . getFieldPath ( ) ) + "\' [" + JBBPUtils . int2msg ( length ) + ']' ) ; } } | Ensure that an array length is not a negative one . |
21,431 | public static JBBPParser prepare ( final String script , final JBBPBitOrder bitOrder ) { return new JBBPParser ( script , bitOrder , null , 0 ) ; } | Prepare a parser for a script and a bit order . |
21,432 | public static JBBPParser prepare ( final String script , final JBBPBitOrder bitOrder , final JBBPCustomFieldTypeProcessor customFieldTypeProcessor , final int flags ) { return new JBBPParser ( script , bitOrder , customFieldTypeProcessor , flags ) ; } | Prepare a parser for a script with defined bit order and special flags . |
21,433 | public JBBPFieldStruct parse ( final InputStream in , final JBBPVarFieldProcessor varFieldProcessor , final JBBPExternalValueProvider externalValueProvider ) throws IOException { final JBBPBitInputStream bitInStream = in instanceof JBBPBitInputStream ? ( JBBPBitInputStream ) in : new JBBPBitInputStream ( in , bitOrder ... | Parse am input stream with defined external value provider . |
21,434 | public List < ResultSrcItem > convertToSrc ( final TargetSources target , final String name ) { JBBPUtils . assertNotNull ( name , "Name must not be null" ) ; if ( target == TargetSources . JAVA_1_6 ) { final Properties metadata = new Properties ( ) ; metadata . setProperty ( "script" , this . compiledBlock . getSource... | Convert the prepared parser into sources . It doesn t provide way to define different flag for conversion it uses default flags for converters and provided for short fast way . |
21,435 | public static String ensureEncodingName ( final String charsetName ) { final Charset defaultCharset = Charset . defaultCharset ( ) ; try { return ( charsetName == null ) ? defaultCharset . name ( ) : Charset . forName ( charsetName . trim ( ) ) . name ( ) ; } catch ( IllegalCharsetNameException ex ) { throw new Illegal... | Get charset name . If name is null then default charset name provided . |
21,436 | public static String extractClassName ( final String canonicalJavaClassName ) { final int lastDot = canonicalJavaClassName . lastIndexOf ( '.' ) ; if ( lastDot < 0 ) { return canonicalJavaClassName . trim ( ) ; } return canonicalJavaClassName . substring ( lastDot + 1 ) . trim ( ) ; } | Extract class name from canonical Java class name |
21,437 | public static String extractPackageName ( final String fileNameWithoutExtension ) { final int lastDot = fileNameWithoutExtension . lastIndexOf ( '.' ) ; if ( lastDot < 0 ) { return "" ; } return fileNameWithoutExtension . substring ( 0 , lastDot ) . trim ( ) ; } | Extract package name from canonical Java class name |
21,438 | public static File scriptFileToJavaFile ( final File targetDir , final String classPackage , final File scriptFile ) { final String rawFileName = FilenameUtils . getBaseName ( scriptFile . getName ( ) ) ; final String className = CommonUtils . extractClassName ( rawFileName ) ; final String packageName = classPackage =... | Convert script file into path to Java class file . |
21,439 | public static byte [ ] strToUtf8 ( final String str ) { final ByteBuffer buffer = CHARSET_UTF8 . encode ( str ) ; final byte [ ] bytesArray = new byte [ buffer . remaining ( ) ] ; buffer . get ( bytesArray , 0 , bytesArray . length ) ; return bytesArray ; } | Convert a string into its UTF8 representation . |
21,440 | public static boolean isNumber ( final String num ) { if ( num == null || num . length ( ) == 0 ) { return false ; } final boolean firstIsDigit = Character . isDigit ( num . charAt ( 0 ) ) ; if ( ! firstIsDigit && num . charAt ( 0 ) != '-' ) { return false ; } boolean dig = firstIsDigit ; for ( int i = 1 ; i < num . le... | Check that a string is a number . |
21,441 | public static byte [ ] packInt ( final int value ) { if ( ( value & 0xFFFFFF80 ) == 0 ) { return new byte [ ] { ( byte ) value } ; } else if ( ( value & 0xFFFF0000 ) == 0 ) { return new byte [ ] { ( byte ) 0x80 , ( byte ) ( value >>> 8 ) , ( byte ) value } ; } else { return new byte [ ] { ( byte ) 0x81 , ( byte ) ( val... | Pack an integer value as a byte array . |
21,442 | public static int packInt ( final byte [ ] array , final JBBPIntCounter position , final int value ) { if ( ( value & 0xFFFFFF80 ) == 0 ) { array [ position . getAndIncrement ( ) ] = ( byte ) value ; return 1 ; } else if ( ( value & 0xFFFF0000 ) == 0 ) { array [ position . getAndIncrement ( ) ] = ( byte ) 0x80 ; array ... | Pack an integer value and save that into a byte array since defined position . |
21,443 | public static int unpackInt ( final byte [ ] array , final JBBPIntCounter position ) { final int code = array [ position . getAndIncrement ( ) ] & 0xFF ; if ( code < 0x80 ) { return code ; } final int result ; switch ( code ) { case 0x80 : { result = ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 8 ) | ( arra... | Unpack an integer value from defined position in a byte array . |
21,444 | public static String byteArray2String ( final byte [ ] array , final String prefix , final String delimiter , final boolean brackets , final int radix ) { if ( array == null ) { return null ; } final int maxlen = Integer . toString ( 0xFF , radix ) . length ( ) ; final String zero = "00000000" ; final String normDelim ... | Convert a byte array into string representation |
21,445 | public static byte reverseBitsInByte ( final JBBPBitNumber bitNumber , final byte value ) { final byte reversed = reverseBitsInByte ( value ) ; return ( byte ) ( ( reversed >>> ( 8 - bitNumber . getBitNumber ( ) ) ) & bitNumber . getMask ( ) ) ; } | Reverse lower part of a byte defined by bits number constant . |
21,446 | public static String bin2str ( final byte [ ] values , final JBBPBitOrder bitOrder , final boolean separateBytes ) { if ( values == null ) { return null ; } final StringBuilder result = new StringBuilder ( values . length * ( separateBytes ? 9 : 8 ) ) ; boolean nofirst = false ; for ( final byte b : values ) { if ( sep... | Convert a byte array into string binary representation with defined bit order and possibility to separate bytes . |
21,447 | public static List < JBBPAbstractField > fieldsAsList ( final JBBPAbstractField ... fields ) { final List < JBBPAbstractField > result = new ArrayList < > ( ) ; Collections . addAll ( result , fields ) ; return result ; } | Convert array of JBBP fields into a list . |
21,448 | public static String [ ] splitString ( final String str , final char splitChar ) { final int length = str . length ( ) ; final StringBuilder bulder = new StringBuilder ( Math . max ( 8 , length ) ) ; int counter = 1 ; for ( int i = 0 ; i < length ; i ++ ) { if ( str . charAt ( i ) == splitChar ) { counter ++ ; } } fina... | Split a string for a char used as the delimeter . |
21,449 | public static void assertNotNull ( final Object object , final String message ) { if ( object == null ) { throw new NullPointerException ( message == null ? "Object is null" : message ) ; } } | Check that an object is null and throw NullPointerException in the case . |
21,450 | public static String int2msg ( final int number ) { return number + " (0x" + Long . toHexString ( ( long ) number & 0xFFFFFFFFL ) . toUpperCase ( Locale . ENGLISH ) + ')' ; } | Convert an integer number into human readable hexadecimal format . |
21,451 | public static String normalizeFieldNameOrPath ( final String nameOrPath ) { assertNotNull ( nameOrPath , "Name of path must not be null" ) ; return nameOrPath . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; } | Normalize field name or path . |
21,452 | public static byte [ ] str2UnicodeByteArray ( final JBBPByteOrder byteOrder , final String str ) { final byte [ ] result = new byte [ str . length ( ) << 1 ] ; int index = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { final int val = str . charAt ( i ) ; switch ( byteOrder ) { case BIG_ENDIAN : { result [ index... | Convert chars of a string into a byte array contains the unicode codes . |
21,453 | public static byte [ ] reverseArray ( final byte [ ] nullableArrayToBeInverted ) { if ( nullableArrayToBeInverted != null && nullableArrayToBeInverted . length > 0 ) { int indexStart = 0 ; int indexEnd = nullableArrayToBeInverted . length - 1 ; while ( indexStart < indexEnd ) { final byte a = nullableArrayToBeInverted ... | Reverse order of bytes in a byte array . |
21,454 | public static byte [ ] splitInteger ( final int value , final boolean valueInLittleEndian , final byte [ ] buffer ) { final byte [ ] result ; if ( buffer == null || buffer . length < 4 ) { result = new byte [ 4 ] ; } else { result = buffer ; } int tmpvalue = value ; if ( valueInLittleEndian ) { for ( int i = 0 ; i < 4 ... | Split an integer value to bytes and returns as a byte array . |
21,455 | public static byte [ ] concat ( final byte [ ] ... arrays ) { int len = 0 ; for ( final byte [ ] arr : arrays ) { len += arr . length ; } final byte [ ] result = new byte [ len ] ; int pos = 0 ; for ( final byte [ ] arr : arrays ) { System . arraycopy ( arr , 0 , result , pos , arr . length ) ; pos += arr . length ; } ... | Concatenate byte arrays into one byte array sequentially . |
21,456 | public static long reverseByteOrder ( long value , int numOfLowerBytesToInvert ) { if ( numOfLowerBytesToInvert < 1 || numOfLowerBytesToInvert > 8 ) { throw new IllegalArgumentException ( "Wrong number of bytes [" + numOfLowerBytesToInvert + ']' ) ; } long result = 0 ; int offsetInResult = ( numOfLowerBytesToInvert - 1... | Revert order for defined number of bytes in a value . |
21,457 | public static String double2str ( final double doubleValue , final int radix ) { if ( radix != 10 && radix != 16 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ']' ) ; } final String result ; if ( radix == 16 ) { String converted = Double . toHexString ( doubleValue ) ; boolean minus = converted .... | Convert double value into string representation with defined radix base . |
21,458 | public static String float2str ( final float floatValue , final int radix ) { if ( radix != 10 && radix != 16 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ']' ) ; } final String result ; if ( radix == 16 ) { String converted = Double . toHexString ( floatValue ) ; boolean minus = converted . sta... | Convert float value into string representation with defined radix base . |
21,459 | public static String ulong2str ( final long ulongValue , final int radix , final char [ ] charBuffer ) { if ( radix < 2 || radix > 36 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ']' ) ; } if ( ulongValue == 0 ) { return "0" ; } else { final String result ; if ( ulongValue > 0 ) { result = Long ... | Convert unsigned long value into string representation with defined radix base . |
21,460 | public static String ensureMinTextLength ( final String text , final int neededLen , final char ch , final int mode ) { final int number = neededLen - text . length ( ) ; if ( number <= 0 ) { return text ; } final StringBuilder result = new StringBuilder ( neededLen ) ; switch ( mode ) { case 0 : { for ( int i = 0 ; i ... | Extend text by chars to needed length . |
21,461 | public static String removeLeadingZeros ( final String str ) { String result = str ; if ( str != null && str . length ( ) != 0 ) { int startIndex = 0 ; while ( startIndex < str . length ( ) - 1 ) { final char ch = str . charAt ( startIndex ) ; if ( ch != '0' ) { break ; } startIndex ++ ; } if ( startIndex > 0 ) { resul... | Remove leading zeros from string . |
21,462 | public static String removeTrailingZeros ( final String str ) { String result = str ; if ( str != null && str . length ( ) != 0 ) { int endIndex = str . length ( ) ; while ( endIndex > 1 ) { final char ch = str . charAt ( endIndex - 1 ) ; if ( ch != '0' ) { break ; } endIndex -- ; } if ( endIndex < str . length ( ) ) {... | Remove trailing zeros from string . |
21,463 | public static boolean arrayStartsWith ( final byte [ ] array , final byte [ ] str ) { boolean result = false ; if ( array . length >= str . length ) { result = true ; int index = str . length ; while ( -- index >= 0 ) { if ( array [ index ] != str [ index ] ) { result = false ; break ; } } } return result ; } | Check that a byte array starts with some byte values . |
21,464 | public static boolean arrayEndsWith ( final byte [ ] array , final byte [ ] str ) { boolean result = false ; if ( array . length >= str . length ) { result = true ; int index = str . length ; int arrindex = array . length ; while ( -- index >= 0 ) { if ( array [ -- arrindex ] != str [ index ] ) { result = false ; break... | Check that a byte array ends with some byte values . |
21,465 | private JBBPTokenizerException checkFieldName ( final String name , final int position ) { if ( name != null ) { final String normalized = JBBPUtils . normalizeFieldNameOrPath ( name ) ; if ( normalized . indexOf ( '.' ) >= 0 ) { return new JBBPTokenizerException ( "Field name must not contain '.' char" , position ) ; ... | Check a field name |
21,466 | public static int findIndexForFieldPath ( final String fieldPath , final List < JBBPNamedFieldInfo > namedFields ) { final String normalized = JBBPUtils . normalizeFieldNameOrPath ( fieldPath ) ; int result = - 1 ; for ( int i = namedFields . size ( ) - 1 ; i >= 0 ; i -- ) { final JBBPNamedFieldInfo f = namedFields . g... | Find a named field info index in a list for its path . |
21,467 | public static void assertFieldIsNotArrayOrInArray ( final JBBPNamedFieldInfo fieldToCheck , final List < JBBPNamedFieldInfo > namedFieldList , final byte [ ] compiledScript ) { if ( ( compiledScript [ fieldToCheck . getFieldOffsetInCompiledBlock ( ) ] & FLAG_ARRAY ) != 0 ) { throw new JBBPCompilationException ( "An Arr... | Check a field in a compiled list defined by its named field info that the field is not an array and it is not inside a structure array . |
21,468 | private static int codeToUnary ( final int code ) { final int result ; switch ( code ) { case CODE_MINUS : result = CODE_UNARYMINUS ; break ; case CODE_ADD : result = CODE_UNARYPLUS ; break ; default : result = code ; break ; } return result ; } | Encode code of an operator to code of similar unary operator . |
21,469 | public static boolean hasExpressionOperators ( final String str ) { boolean result = false ; for ( final char chr : OPERATOR_FIRST_CHARS ) { if ( str . indexOf ( chr ) >= 0 ) { result = true ; break ; } } return result ; } | Check that a string has a char of operators . |
21,470 | private void assertUnaryOperator ( final String operator ) { if ( ! ( "+" . equals ( operator ) || "-" . equals ( operator ) || "~" . equals ( operator ) ) ) { throw new JBBPCompilationException ( "Wrong unary operator '" + operator + "' [" + this . expressionSource + ']' ) ; } } | Check that a string represents a unary operator . |
21,471 | public JavaSrcTextBuffer printf ( final String text , final Object ... args ) { this . buffer . append ( String . format ( text , args ) ) ; return this ; } | Formatted print . |
21,472 | public JavaSrcTextBuffer printLinesWithIndent ( final String text ) { final String [ ] splitted = text . split ( "\n" , - 1 ) ; for ( final String aSplitted : splitted ) { this . indent ( ) . println ( aSplitted ) ; } return this ; } | Parse string to lines and print each line with current indent |
21,473 | public Integer getArraySizeAsInt ( ) { if ( this . arraySize == null ) { throw new NullPointerException ( "Array size is not defined" ) ; } try { return Integer . valueOf ( this . arraySize . trim ( ) ) ; } catch ( NumberFormatException ex ) { return null ; } } | Get numeric representation of the array size . |
21,474 | public Object extractFieldValue ( final Object instance , final Field field ) { JBBPUtils . assertNotNull ( field , "Field must not be null" ) ; try { return ReflectUtils . makeAccessible ( field ) . get ( instance ) ; } catch ( Exception ex ) { throw new JBBPException ( "Can't extract value from field for exception" ,... | Auxiliary method to extract field value . |
21,475 | public JBBPClassInstantiator make ( final JBBPClassInstantiatorType type ) { JBBPUtils . assertNotNull ( type , "Type must not be null" ) ; String className = "com.igormaznitsa.jbbp.mapper.instantiators.JBBPSafeInstantiator" ; switch ( type ) { case AUTO : { final String customClassName = JBBPSystemProperty . PROPERTY_... | Make an instantiator for defined type . |
21,476 | public void writeShort ( final int value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . write ( value >>> 8 ) ; this . write ( value ) ; } else { this . write ( value ) ; this . write ( value >>> 8 ) ; } } | Write a signed short value into the output stream . |
21,477 | public void writeInt ( final int value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeShort ( value >>> 16 , byteOrder ) ; this . writeShort ( value , byteOrder ) ; } else { this . writeShort ( value , byteOrder ) ; this . writeShort ( value >>> 16 , ... | Write an integer value into the output stream . |
21,478 | public void writeFloat ( final float value , final JBBPByteOrder byteOrder ) throws IOException { final int intValue = Float . floatToIntBits ( value ) ; if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeShort ( intValue >>> 16 , byteOrder ) ; this . writeShort ( intValue , byteOrder ) ; } else { this . writ... | Write an float value into the output stream . |
21,479 | public void writeLong ( final long value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeInt ( ( int ) ( value >>> 32 ) , byteOrder ) ; this . writeInt ( ( int ) value , byteOrder ) ; } else { this . writeInt ( ( int ) value , byteOrder ) ; this . writ... | Write a long value into the output stream . |
21,480 | public void writeDouble ( final double value , final JBBPByteOrder byteOrder ) throws IOException { final long longValue = Double . doubleToLongBits ( value ) ; if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeInt ( ( int ) ( longValue >>> 32 ) , byteOrder ) ; this . writeInt ( ( int ) longValue , byteOrder... | Write a double value into the output stream . |
21,481 | public void writeBits ( final int value , final JBBPBitNumber bitNumber ) throws IOException { if ( this . bitBufferCount == 0 && bitNumber == JBBPBitNumber . BITS_8 ) { write ( value ) ; } else { final int initialMask ; int mask ; initialMask = 1 ; mask = initialMask << this . bitBufferCount ; int accum = value ; int ... | Write bits into the output stream . |
21,482 | public void align ( final long alignByteNumber ) throws IOException { if ( this . bitBufferCount > 0 ) { this . writeBits ( 0 , JBBPBitNumber . decode ( 8 - this . bitBufferCount ) ) ; } if ( alignByteNumber > 0 ) { long padding = ( alignByteNumber - ( this . byteCounter % alignByteNumber ) ) % alignByteNumber ; while ... | Write padding bytes to align the stream counter for the border . |
21,483 | private void writeByte ( int value ) throws IOException { if ( this . msb0 ) { value = JBBPUtils . reverseBitsInByte ( ( byte ) value ) & 0xFF ; } this . out . write ( value ) ; this . byteCounter ++ ; } | Inside method to write a byte into wrapped stream . |
21,484 | public void writeBytes ( final byte [ ] array , final int length , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { int i = length < 0 ? array . length - 1 : length - 1 ; while ( i >= 0 ) { this . write ( array [ i -- ] ) ; } } else { this . write ( array , 0 , le... | Write number of items from byte array into stream |
21,485 | public Object mapTo ( final Object objectToMap , final JBBPMapperCustomFieldProcessor customFieldProcessor ) { return JBBPMapper . map ( this , objectToMap , customFieldProcessor ) ; } | Map the structure fields to object fields . |
21,486 | public String getExtraDataExpression ( ) { String result = null ; if ( hasExpressionAsExtraData ( ) ) { result = this . extraData . substring ( 1 , this . extraData . length ( ) - 1 ) ; } return result ; } | Extract expression for extra data . |
21,487 | public void putField ( final JBBPNumericField field ) { JBBPUtils . assertNotNull ( field , "Field must not be null" ) ; final JBBPNamedFieldInfo fieldName = field . getNameInfo ( ) ; JBBPUtils . assertNotNull ( fieldName , "Field name info must not be null" ) ; this . fieldMap . put ( fieldName , field ) ; } | Put a numeric field into map . |
21,488 | public JBBPNumericField remove ( final JBBPNamedFieldInfo nameInfo ) { JBBPUtils . assertNotNull ( nameInfo , "Name info must not be null" ) ; return this . fieldMap . remove ( nameInfo ) ; } | Remove a field for its field name info descriptor . |
21,489 | public JBBPNumericField findForFieldOffset ( final int offset ) { JBBPNumericField result = null ; for ( final Map . Entry < JBBPNamedFieldInfo , JBBPNumericField > f : fieldMap . entrySet ( ) ) { if ( f . getKey ( ) . getFieldOffsetInCompiledBlock ( ) == offset ) { result = f . getValue ( ) ; break ; } } return result... | Find a registered field for its field offset in compiled script . |
21,490 | public int getExternalFieldValue ( final String externalFieldName , final JBBPCompiledBlock compiledBlock , final JBBPIntegerValueEvaluator evaluator ) { final String normalizedName = JBBPUtils . normalizeFieldNameOrPath ( externalFieldName ) ; if ( this . externalValueProvider == null ) { throw new JBBPEvalException (... | Ask the registered external value provider for a field value . |
21,491 | private static Object readFieldValue ( final Object obj , final Field field ) { try { return field . get ( obj ) ; } catch ( Exception ex ) { throw new JBBPException ( "Can't get value from field [" + field + ']' , ex ) ; } } | Inside auxiliary method to read object field value . |
21,492 | protected void onFieldCustom ( final Object obj , final Field field , final Bin annotation , final Object customFieldProcessor , final Object value ) { } | Notification about custom field . |
21,493 | protected void onFieldBits ( final Object obj , final Field field , final Bin annotation , final JBBPBitNumber bitNumber , final int value ) { } | Notification about bit field . |
21,494 | public void resetInsideClassCache ( ) { final Map < Class < ? > , Field [ ] > fieldz = cachedClasses ; if ( fieldz != null ) { synchronized ( fieldz ) { fieldz . clear ( ) ; } } } | Inside JBBPOut . Bin command creates cached list of fields of a saved class the method allows to reset the inside cache . |
21,495 | public static JBBPTextWriter makeStrWriter ( ) { final String lineSeparator = System . setProperty ( "line.separator" , "\n" ) ; return new JBBPTextWriter ( new StringWriter ( ) , JBBPByteOrder . BIG_ENDIAN , lineSeparator , 16 , "0x" , "." , ";" , "~" , "," ) ; } | Auxiliary method allows to build writer over StringWriter with system - depended next line and hex radix . The Method allows fast instance create . |
21,496 | private void ensureValueMode ( ) throws IOException { switch ( this . mode ) { case MODE_START_LINE : { changeMode ( MODE_VALUES ) ; for ( final Extra e : extras ) { e . onBeforeFirstValue ( this ) ; } writeIndent ( ) ; this . write ( this . prefixFirtValueAtLine ) ; } break ; case MODE_COMMENTS : { this . BR ( ) ; wri... | Ensure the value mode . |
21,497 | private void ensureCommentMode ( ) throws IOException { switch ( this . mode ) { case MODE_START_LINE : writeIndent ( ) ; this . prevLineCommentsStartPosition = this . linePosition ; this . write ( this . prefixComment ) ; changeMode ( MODE_COMMENTS ) ; break ; case MODE_VALUES : { this . prevLineCommentsStartPosition ... | Ensure the comment mode . |
21,498 | private void printValueString ( final String value ) throws IOException { if ( this . valuesLineCounter > 0 && this . valueSeparator . length ( ) > 0 ) { this . write ( this . valueSeparator ) ; } if ( this . prefixValue . length ( ) > 0 ) { this . write ( this . prefixValue ) ; } this . write ( value ) ; if ( this . p... | Print a value represented by its string . |
21,499 | public JBBPTextWriter Str ( final String ... str ) throws IOException { JBBPUtils . assertNotNull ( str , "String must not be null" ) ; final String oldPrefix = this . prefixValue ; final String oldPostfix = this . postfixValue ; this . prefixValue = "" ; this . postfixValue = "" ; for ( final String s : str ) { ensure... | Print string values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.