idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
34,400 | public static boolean isFinal ( Class < ? > expressionType ) { if ( expressionType . isArray ( ) ) { return isFinal ( expressionType . getComponentType ( ) ) ; } if ( expressionType . isPrimitive ( ) ) { return true ; } return expressionType . isEnum ( ) || Modifier . isFinal ( expressionType . getModifiers ( ) ) ; } | Replies if the given type is a final type . | 83 | 11 |
34,401 | public static boolean isInterface ( LightweightTypeReference type ) { return type . getType ( ) instanceof JvmGenericType && ( ( JvmGenericType ) type . getType ( ) ) . isInterface ( ) ; } | Replies if the given type is an interface . | 48 | 10 |
34,402 | @ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:booleanexpressioncomplexity" } ) public static boolean canCast ( LightweightTypeReference fromType , LightweightTypeReference toType , boolean enablePrimitiveWidening , boolean enableVoidMatchingNull , boolean allowSynonyms ) { if ( enableVoidMatchi... | Replies if it is allowed to cast between the given types . | 454 | 13 |
34,403 | public static LightweightTypeReference toLightweightTypeReference ( JvmType type , CommonTypeComputationServices services , boolean keepUnboundWildcardInformation ) { if ( type == null ) { return null ; } final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner ( services , type ) ; final LightweightType... | Convert a type to a lightweight type reference . | 109 | 10 |
34,404 | public static int compareVersions ( String v1 , String v2 ) { // Remove the SNAPSHOT version. //final String fixedv1 = v1.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$ //final String fixedv2 = v2.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$ //final Version vobject1 = Version.parseVersion(fi... | Compare the two strings as they are version numbers . | 183 | 10 |
34,405 | public static String getSarlCodeFor ( EObject object ) { final ICompositeNode node = NodeModelUtils . getNode ( object ) ; if ( node != null ) { String text = node . getText ( ) ; if ( text != null ) { text = text . trim ( ) ; text = text . replaceAll ( "[\n\r\f]+" , " " ) ; //$NON-NLS-1$//$NON-NLS-2$ } return Strings ... | Replies the original code for the given Ecore object . | 123 | 12 |
34,406 | public static boolean hasAbstractMember ( XtendTypeDeclaration declaration ) { if ( declaration != null ) { for ( final XtendMember member : declaration . getMembers ( ) ) { if ( member instanceof XtendFunction ) { if ( ( ( XtendFunction ) member ) . isAbstract ( ) ) { return true ; } } } } return false ; } | Replies if the given declaration has an abstract member . | 80 | 11 |
34,407 | public static boolean isCompatibleSARLLibraryOnClasspath ( TypeReferences typeReferences , Notifier context ) { final OutParameter < String > version = new OutParameter <> ( ) ; final SarlLibraryErrorCode code = getSARLLibraryVersionOnClasspath ( typeReferences , context , version ) ; if ( code == SarlLibraryErrorCode ... | Check if a compatible SARL library is available on the classpath . | 105 | 14 |
34,408 | public static boolean isCompatibleSARLLibraryVersion ( String version ) { if ( version != null ) { final Version currentVersion = Version . parseVersion ( SARLVersion . SPECIFICATION_RELEASE_VERSION_STRING ) ; final Version paramVersion = Version . parseVersion ( version ) ; return currentVersion . getMajor ( ) == para... | Check if a version is compatible with the expected SARL library . | 101 | 13 |
34,409 | public static boolean isCompatibleJREVersion ( String version ) { if ( version != null && ! version . isEmpty ( ) ) { final Version current = Version . parseVersion ( version ) ; if ( current != null ) { final Version minJdk = Version . parseVersion ( SARLVersion . MINIMAL_JDK_VERSION ) ; assert minJdk != null ; if ( c... | Check if a version of the JRE is compatible with the SARL library . | 147 | 16 |
34,410 | public static boolean isCompatibleXtextVersion ( String version ) { return version != null && ! version . isEmpty ( ) && compareVersions ( version , SARLVersion . MINIMAL_XTEXT_VERSION ) >= 0 ; } | Check if a version of Xtext is compatible with the SARL library . | 49 | 15 |
34,411 | public static boolean isCompatibleXtextVersion ( ) { final XtextVersion xtextVersion = XtextVersion . getCurrent ( ) ; if ( xtextVersion != null && ! Strings . isNullOrEmpty ( xtextVersion . getVersion ( ) ) ) { return isCompatibleXtextVersion ( xtextVersion . getVersion ( ) ) ; } return false ; } | Check if a version of the current Xtext is compatible with the SARL library . | 80 | 17 |
34,412 | public static boolean isSARLAnnotation ( Class < ? > type ) { return ( type != null && Annotation . class . isAssignableFrom ( type ) ) && isSARLAnnotation ( type . getPackage ( ) . getName ( ) ) ; } | Replies if the given annotation is an annotation from the SARL core library . | 59 | 16 |
34,413 | public static boolean isFunctionalInterface ( JvmGenericType type , IActionPrototypeProvider sarlSignatureProvider ) { if ( type != null && type . isInterface ( ) ) { final Map < ActionPrototype , JvmOperation > operations = new HashMap <> ( ) ; populateInterfaceElements ( type , operations , null , sarlSignatureProvid... | Replies if the given type is a functional interface . | 133 | 11 |
34,414 | @ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static String dump ( Object object , boolean includeStaticField ) { if ( object == null ) { return new String ( ) ; } final StringBuilder buffer = new StringBuilder ( ) ; final LinkedList < Class < ? > > types = new LinkedList <> ( ) ; types . add ( object . ge... | Dump the object . | 484 | 5 |
34,415 | public static JvmTypeReference cloneWithTypeParametersAndProxies ( JvmTypeReference type , Iterable < JvmTypeParameter > executableTypeParameters , Map < String , JvmTypeReference > superTypeParameterMapping , JvmTypeReferenceBuilder typeParameterBuilder , JvmTypesBuilder typeBuilder , TypeReferences typeReferences , T... | Clone the given type reference that for being link to the given operation . | 557 | 15 |
34,416 | public static void getSuperTypeParameterMap ( JvmDeclaredType type , Map < String , JvmTypeReference > mapping ) { for ( final JvmTypeReference superTypeReference : type . getSuperTypes ( ) ) { if ( superTypeReference instanceof JvmParameterizedTypeReference ) { final JvmParameterizedTypeReference parameterizedTypeRefe... | Extract the mapping between the type parameters declared within the super types and the type parameters arguments that are declared within the given type . | 201 | 26 |
34,417 | public static void setStructuralFeature ( EObject object , EStructuralFeature property , Object value ) { assert object != null ; assert property != null ; if ( value == null ) { object . eUnset ( property ) ; } else { object . eSet ( property , value ) ; } } | Set the given structure feature with the given value . | 63 | 10 |
34,418 | public static XAbstractFeatureCall getRootFeatureCall ( XAbstractFeatureCall featureCall ) { final EObject container = featureCall . eContainer ( ) ; final XAbstractFeatureCall rootFeatureCall ; if ( container instanceof XMemberFeatureCall || container instanceof XFeatureCall ) { rootFeatureCall = ( XAbstractFeatureCal... | Replies the root feature call into a sequence of feature calls . | 136 | 13 |
34,419 | public static XAbstractFeatureCall getRootFeatureCall ( XAbstractFeatureCall featureCall , XExpression container , List < JvmFormalParameter > containerParameters ) { if ( hasLocalParameters ( featureCall , container , containerParameters ) || ! ( featureCall instanceof XMemberFeatureCall || featureCall instanceof XFea... | Replies the root feature call into a sequence of feature calls that has not reference to elements declared within the container and that are not one of the container s parameters . | 185 | 33 |
34,420 | @ Override public final boolean isFieldNameSet ( ) { if ( _field_name_type != null ) { switch ( _field_name_type ) { case STRING : return _field_name != null ; case INT : return _field_name_sid >= 0 ; default : break ; } } return false ; } | not supported . | 70 | 3 |
34,421 | int putSymbol ( String symbolName ) { if ( isReadOnly ) { throw new ReadOnlyValueException ( SymbolTable . class ) ; } if ( mySymbolsCount == mySymbolNames . length ) { int newlen = mySymbolsCount * 2 ; if ( newlen < DEFAULT_CAPACITY ) { newlen = DEFAULT_CAPACITY ; } String [ ] temp = new String [ newlen ] ; System . a... | NOT SYNCHRONIZED! Call within constructor or from synch d method . | 211 | 18 |
34,422 | boolean symtabExtends ( SymbolTable other ) { // Throws ClassCastException if other isn't a local symtab LocalSymbolTable subset = ( LocalSymbolTable ) other ; // Gather snapshots of each LST's data, so we don't // Superset must have same/more known symbols than subset. if ( getMaxId ( ) < subset . getMaxId ( ) ) retur... | This method and the context from which it is called assumes that the symtabs are not being mutated by another thread . Therefore it doesn t use synchronization . | 394 | 31 |
34,423 | public static SymbolToken newSymbolToken ( SymbolTable symtab , String text ) { // TODO amzn/ion-java/issues/21 symtab should not be null text . getClass ( ) ; // quick null check SymbolToken tok = ( symtab == null ? null : symtab . find ( text ) ) ; if ( tok == null ) { tok = new SymbolTokenImpl ( text , UNKNOWN_SYMBO... | Checks symbol content . | 104 | 5 |
34,424 | public static SymbolToken [ ] newSymbolTokens ( SymbolTable symtab , String ... text ) { if ( text != null ) { int count = text . length ; if ( count != 0 ) { SymbolToken [ ] result = new SymbolToken [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { String s = text [ i ] ; result [ i ] = newSymbolToken ( symtab , s ) ... | Validates each text element . | 111 | 6 |
34,425 | public static String [ ] toStrings ( SymbolToken [ ] symbols , int count ) { if ( count == 0 ) return _Private_Utils . EMPTY_STRING_ARRAY ; String [ ] annotations = new String [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { SymbolToken tok = symbols [ i ] ; String text = tok . getText ( ) ; if ( text == null ) { thr... | Extracts the non - null text from a list of symbol tokens . | 125 | 15 |
34,426 | public static Iterator < IonValue > iterate ( ValueFactory valueFactory , IonReader input ) { return new IonIteratorImpl ( valueFactory , input ) ; } | Create a value iterator from a reader . Primarily a trampoline for access permission . | 34 | 18 |
34,427 | public static boolean isTrivialTable ( SymbolTable table ) { if ( table == null ) return true ; if ( table . isSystemTable ( ) ) return true ; if ( table . isLocalTable ( ) ) { // this is only true when there are no local // symbols defined // and there are no imports with any symbols if ( table . getMaxId ( ) == table... | Is the table null system or local without imported symbols? | 105 | 11 |
34,428 | public static SymbolTable copyLocalSymbolTable ( SymbolTable symtab ) throws SubstituteSymbolTableException { if ( ! symtab . isLocalTable ( ) ) { String message = "symtab should be a local symtab" ; throw new IllegalArgumentException ( message ) ; } SymbolTable [ ] imports = ( ( LocalSymbolTable ) symtab ) . getImport... | local symtab has substituted symtabs for imports . | 206 | 11 |
34,429 | public static SymbolTable initialSymtab ( _Private_LocalSymbolTableFactory lstFactory , SymbolTable defaultSystemSymtab , SymbolTable ... imports ) { if ( imports == null || imports . length == 0 ) { return defaultSystemSymtab ; } if ( imports . length == 1 && imports [ 0 ] . isSystemTable ( ) ) { return imports [ 0 ] ... | Returns a minimal symtab that either system or local depending on the given values that supports representation as an IonStruct . If the imports are empty the default system symtab is returned . | 99 | 36 |
34,430 | public static boolean isNonSymbolScalar ( IonType type ) { return ! IonType . isContainer ( type ) && ! type . equals ( IonType . SYMBOL ) ; } | Determines whether the passed - in data type is a scalar and not a symbol . | 41 | 19 |
34,431 | public static final int getSidForSymbolTableField ( String text ) { final int shortestFieldNameLength = 4 ; // 'name' if ( text != null && text . length ( ) >= shortestFieldNameLength ) { int c = text . charAt ( 0 ) ; switch ( c ) { case ' ' : if ( VERSION . equals ( text ) ) { return VERSION_SID ; } break ; case ' ' :... | Returns the symbol ID matching a system symbol text of a local or shared symtab field . | 210 | 18 |
34,432 | private Timestamp make_localtime ( ) { int offset = _offset != null ? _offset . intValue ( ) : 0 ; // We use a Copy-Constructor that expects the time parameters to be in // UTC, as that's what we're supposed to have. // As this Copy-Constructor doesn't apply local offset to the time // field values (it assumes that the... | Applies the local offset from UTC to each of the applicable time field values and returns the new Timestamp . In short this makes the Timestamp represent local time . | 195 | 33 |
34,433 | public int getYear ( ) { Timestamp adjusted = this ; if ( this . _offset != null ) { if ( this . _offset . intValue ( ) != 0 ) { adjusted = make_localtime ( ) ; } } return adjusted . _year ; } | Returns the year of this Timestamp in its local time . | 56 | 12 |
34,434 | public int getMonth ( ) { Timestamp adjusted = this ; if ( this . _offset != null ) { if ( this . _offset . intValue ( ) != 0 ) { adjusted = make_localtime ( ) ; } } return adjusted . _month ; } | Returns the month of this Timestamp in its local time . | 56 | 12 |
34,435 | public int getHour ( ) { Timestamp adjusted = this ; if ( this . _offset != null ) { if ( this . _offset . intValue ( ) != 0 ) { adjusted = make_localtime ( ) ; } } return adjusted . _hour ; } | Returns the hour of this Timestamp in its local time . | 56 | 12 |
34,436 | public int getMinute ( ) { Timestamp adjusted = this ; if ( this . _offset != null ) { if ( this . _offset . intValue ( ) != 0 ) { adjusted = make_localtime ( ) ; } } return adjusted . _minute ; } | Returns the minute of this Timestamp in its local time . | 57 | 12 |
34,437 | public Timestamp withLocalOffset ( Integer offset ) { Precision precision = getPrecision ( ) ; if ( precision . alwaysUnknownOffset ( ) || safeEquals ( offset , getLocalOffset ( ) ) ) { return this ; } Timestamp ts = createFromUtcFields ( precision , getZYear ( ) , getZMonth ( ) , getZDay ( ) , getZHour ( ) , getZMinut... | Returns a timestamp at the same point in time but with the given local offset . If this timestamp has precision coarser than minutes then it is returned unchanged since such timestamps always have an unknown offset . | 114 | 41 |
34,438 | private void clearUnusedPrecision ( ) { switch ( _precision ) { case YEAR : _month = 1 ; case MONTH : _day = 1 ; case DAY : _hour = 0 ; _minute = 0 ; case MINUTE : _second = 0 ; _fraction = null ; case SECOND : } } | Clears any fields more precise than this Timestamp s precision supports . | 68 | 14 |
34,439 | public final Timestamp addDay ( int amount ) { long delta = ( long ) amount * 24 * 60 * 60 * 1000 ; return addMillisForPrecision ( delta , Precision . DAY , false ) ; } | Returns a timestamp relative to this one by the given number of days . | 45 | 14 |
34,440 | public static void printStringCodePoint ( Appendable out , int codePoint ) throws IOException { printCodePoint ( out , codePoint , EscapeMode . ION_STRING ) ; } | Prints a single Unicode code point for use in an ASCII - safe Ion string . | 41 | 17 |
34,441 | public static void printSymbolCodePoint ( Appendable out , int codePoint ) throws IOException { printCodePoint ( out , codePoint , EscapeMode . ION_SYMBOL ) ; } | Prints a single Unicode code point for use in an ASCII - safe Ion symbol . | 43 | 17 |
34,442 | public static void printJsonCodePoint ( Appendable out , int codePoint ) throws IOException { // JSON only allows double-quote strings. printCodePoint ( out , codePoint , EscapeMode . JSON ) ; } | Prints a single Unicode code point for use in an ASCII - safe JSON string . | 47 | 17 |
34,443 | private static void printCodePoint ( Appendable out , int c , EscapeMode mode ) throws IOException { // JSON only allows uHHHH numeric escapes. switch ( c ) { case 0 : out . append ( mode == EscapeMode . JSON ? "\\u0000" : "\\0" ) ; return ; case ' ' : out . append ( "\\t" ) ; return ; case ' ' : if ( mode == EscapeMod... | Prints a single code point ASCII safe . | 690 | 9 |
34,444 | public static String printCodePointAsString ( int codePoint ) { StringBuilder builder = new StringBuilder ( 12 ) ; builder . append ( ' ' ) ; try { printStringCodePoint ( builder , codePoint ) ; } catch ( IOException e ) { // Shouldn't happen throw new Error ( e ) ; } builder . append ( ' ' ) ; return builder . toStrin... | Builds a String denoting an ASCII - encoded Ion string with double - quotes surrounding a single Unicode code point . | 84 | 23 |
34,445 | public void truncate ( final long position ) { final int index = index ( position ) ; final int offset = offset ( position ) ; final Block block = blocks . get ( index ) ; this . index = index ; block . limit = offset ; current = block ; } | Resets the write buffer to a particular point . | 56 | 10 |
34,446 | public int getUInt8At ( final long position ) { final int index = index ( position ) ; final int offset = offset ( position ) ; final Block block = blocks . get ( index ) ; return block . data [ offset ] & OCTET_MASK ; } | Returns the octet at the logical position given . | 57 | 10 |
34,447 | public void writeByte ( final byte octet ) { if ( remaining ( ) < 1 ) { if ( index == blocks . size ( ) - 1 ) { allocateNewBlock ( ) ; } index ++ ; current = blocks . get ( index ) ; } final Block block = current ; block . data [ block . limit ] = octet ; block . limit ++ ; } | Writes a single octet to the buffer expanding if necessary . | 77 | 13 |
34,448 | private void writeBytesSlow ( final byte [ ] bytes , int off , int len ) { while ( len > 0 ) { final Block block = current ; final int amount = Math . min ( len , block . remaining ( ) ) ; System . arraycopy ( bytes , off , block . data , block . limit , amount ) ; block . limit += amount ; off += amount ; len -= amoun... | slow in the sense that we do all kind of block boundary checking | 129 | 13 |
34,449 | public void writeBytes ( final byte [ ] bytes , final int off , final int len ) { if ( len > remaining ( ) ) { writeBytesSlow ( bytes , off , len ) ; return ; } final Block block = current ; System . arraycopy ( bytes , off , block . data , block . limit , len ) ; block . limit += len ; } | Writes an array of bytes to the buffer expanding if necessary . | 76 | 13 |
34,450 | private int writeUTF8Slow ( final CharSequence chars , int off , int len ) { int octets = 0 ; while ( len > 0 ) { final char ch = chars . charAt ( off ) ; if ( ch >= LOW_SURROGATE_FIRST && ch <= LOW_SURROGATE_LAST ) { throw new IllegalArgumentException ( "Unpaired low surrogate: " + ( int ) ch ) ; } if ( ( ch >= HIGH_S... | slow in the sense that we deal with any kind of UTF - 8 sequence and block boundaries | 777 | 18 |
34,451 | public void writeTo ( final OutputStream out ) throws IOException { for ( int i = 0 ; i <= index ; i ++ ) { Block block = blocks . get ( i ) ; out . write ( block . data , 0 , block . limit ) ; } } | Write the entire buffer to output stream . | 56 | 8 |
34,452 | public void writeTo ( final OutputStream out , long position , long length ) throws IOException { while ( length > 0 ) { final int index = index ( position ) ; final int offset = offset ( position ) ; final Block block = blocks . get ( index ) ; final int amount = ( int ) Math . min ( block . data . length - offset , l... | Write a specific segment of data from the buffer to a stream . | 101 | 13 |
34,453 | public static _Private_IonTextAppender forAppendable ( Appendable out ) { _Private_FastAppendable fast = new AppendableFastAppendable ( out ) ; boolean escapeNonAscii = false ; return new _Private_IonTextAppender ( fast , escapeNonAscii ) ; } | Doesn t escape non - ASCII characters . | 72 | 9 |
34,454 | public final void printString ( CharSequence text ) throws IOException { if ( text == null ) { appendAscii ( "null.string" ) ; } else { appendAscii ( ' ' ) ; printCodePoints ( text , STRING_ESCAPE_CODES ) ; appendAscii ( ' ' ) ; } } | Print an Ion String type | 75 | 5 |
34,455 | public final void printLongString ( CharSequence text ) throws IOException { if ( text == null ) { appendAscii ( "null.string" ) ; } else { appendAscii ( TRIPLE_QUOTES ) ; printCodePoints ( text , LONG_STRING_ESCAPE_CODES ) ; appendAscii ( TRIPLE_QUOTES ) ; } } | Print an Ion triple - quoted string | 88 | 7 |
34,456 | public final void printJsonString ( CharSequence text ) throws IOException { if ( text == null ) { appendAscii ( "null" ) ; } else { appendAscii ( ' ' ) ; printCodePoints ( text , JSON_ESCAPE_CODES ) ; appendAscii ( ' ' ) ; } } | Print a JSON string | 74 | 4 |
34,457 | public final void printSymbol ( CharSequence text ) throws IOException { if ( text == null ) { appendAscii ( "null.symbol" ) ; } else if ( symbolNeedsQuoting ( text , true ) ) { appendAscii ( ' ' ) ; printCodePoints ( text , SYMBOL_ESCAPE_CODES ) ; appendAscii ( ' ' ) ; } else { appendAscii ( text ) ; } } | Print an Ion Symbol type . This method will check if symbol needs quoting | 102 | 14 |
34,458 | public final void printQuotedSymbol ( CharSequence text ) throws IOException { if ( text == null ) { appendAscii ( "null.symbol" ) ; } else { appendAscii ( ' ' ) ; printCodePoints ( text , SYMBOL_ESCAPE_CODES ) ; appendAscii ( ' ' ) ; } } | Print single - quoted Ion Symbol type | 80 | 7 |
34,459 | @ Override public SymbolTable getSymbolTable ( ) { SymbolTable symtab = super . getSymbolTable ( ) ; if ( symtab == null ) { symtab = _system_symtab ; } return symtab ; } | Horrible temporary hack . | 50 | 5 |
34,460 | public _Private_IonManagedBinaryWriterBuilder withFlatImports ( final SymbolTable ... tables ) { if ( tables != null ) { return withFlatImports ( Arrays . asList ( tables ) ) ; } return this ; } | Adds imports flattening them to make lookup more efficient . This is particularly useful when a builder instance is long lived . | 54 | 23 |
34,461 | public void writeValue ( IonReader reader ) throws IOException { // TODO this should do symtab optimization as per writeValues() IonType type = reader . getType ( ) ; writeValueRecursively ( type , reader ) ; } | Overrides can optimize special cases . | 50 | 8 |
34,462 | boolean attemptClearSymbolIDValues ( ) { boolean sidsRemain = false ; if ( _fieldName != null ) { _fieldId = UNKNOWN_SYMBOL_ID ; } else if ( _fieldId > UNKNOWN_SYMBOL_ID ) { // retaining the field SID, as it couldn't be cleared due to loss of context // TODO - for SID handling consistency; this should attempt resolutio... | Sets this value s symbol table to null and erases any SIDs here and recursively . | 248 | 21 |
34,463 | final void setFieldNameSymbol ( SymbolToken name ) { assert _fieldId == UNKNOWN_SYMBOL_ID && _fieldName == null ; _fieldName = name . getText ( ) ; _fieldId = name . getSid ( ) ; // if a SID has been added by this operation to a previously SID-less node we have to mark upwards // towards the context root that a SID is ... | Sets the field name and ID based on a SymbolToken . Both parts of the SymbolToken are trusted! | 129 | 22 |
34,464 | final void detachFromContainer ( ) // throws IOException { checkForLock ( ) ; clearSymbolIDValues ( ) ; _context = ContainerlessContext . wrap ( getSystem ( ) ) ; _fieldName = null ; _fieldId = UNKNOWN_SYMBOL_ID ; _elementid ( 0 ) ; } | Removes this value from its container ensuring that all data stays available . Dirties this value and it s original container . | 68 | 24 |
34,465 | public final static int convertToUTF8Bytes ( int unicodeScalar , byte [ ] outputBytes , int offset , int maxLength ) { int dst = offset ; int end = offset + maxLength ; switch ( getUTF8ByteCount ( unicodeScalar ) ) { case 1 : if ( dst >= end ) throw new ArrayIndexOutOfBoundsException ( ) ; outputBytes [ dst ++ ] = ( by... | this helper converts the unicodeScalar to a sequence of utf8 bytes and copies those bytes into the supplied outputBytes array . If there is insufficient room in the array to hold the generated bytes it will throw an ArrayIndexOutOfBoundsException . It does not check for the validity of the passed in unicodeScalar thoro... | 366 | 98 |
34,466 | public byte [ ] getBytes ( ) { int length = _eob - _start ; byte [ ] copy = new byte [ length ] ; System . arraycopy ( _bytes , _start , copy , 0 , length ) ; return copy ; } | Makes a copy of the internal byte array . | 52 | 10 |
34,467 | private void prepareValue ( ) { if ( isInStruct ( ) && currentFieldSid == null ) { throw new IllegalStateException ( "IonWriter.setFieldName() must be called before writing a value into a struct." ) ; } if ( currentFieldSid != null ) { checkSid ( currentFieldSid ) ; writeVarUInt ( currentFieldSid ) ; // clear out field... | prepare to write values with field name and annotations . | 362 | 11 |
34,468 | private void finishValue ( ) { final ContainerInfo current = currentContainer ( ) ; if ( current != null && current . type == ContainerType . ANNOTATION ) { // close out and patch the length popContainer ( ) ; } hasWrittenValuesSinceFinished = true ; hasWrittenValuesSinceConstructed = true ; } | Closes out annotations . | 66 | 5 |
34,469 | public static SymbolToken symbol ( final String name , final int val ) { if ( name == null ) { throw new NullPointerException ( ) ; } if ( val <= 0 ) { throw new IllegalArgumentException ( "Symbol value must be positive: " + val ) ; } return new SymbolToken ( ) { public String getText ( ) { return name ; } public Strin... | Constructs a token with a non - null name and positive value . | 139 | 14 |
34,470 | public static Iterator < String > symbolNameIterator ( final Iterator < SymbolToken > tokenIter ) { return new Iterator < String > ( ) { public boolean hasNext ( ) { return tokenIter . hasNext ( ) ; } public String next ( ) { return tokenIter . next ( ) . getText ( ) ; } public void remove ( ) { throw new UnsupportedOp... | Lazy iterator over the symbol names of an iterator of symbol tokens . | 88 | 14 |
34,471 | public static SymbolToken systemSymbol ( final int sid ) { if ( sid < 1 || sid > ION_1_0_MAX_ID ) { throw new IllegalArgumentException ( "No such system SID: " + sid ) ; } return SYSTEM_TOKENS . get ( sid - 1 ) ; } | Returns a symbol token for a system SID . | 68 | 10 |
34,472 | public static SymbolTable unknownSharedSymbolTable ( final String name , final int version , final int maxId ) { return new AbstractSymbolTable ( name , version ) { public Iterator < String > iterateDeclaredSymbolNames ( ) { return new Iterator < String > ( ) { int id = 1 ; public boolean hasNext ( ) { return id <= max... | Returns a substitute shared symbol table where none of the symbols are known . | 334 | 14 |
34,473 | public static void main ( String [ ] args ) throws IOException { process_command_line ( args ) ; info = new JarInfo ( ) ; if ( printVersion ) { doPrintVersion ( ) ; } if ( printHelp ) { doPrintHelp ( ) ; } } | This main simply prints the version information to allow users to identify the build version of the Jar . | 58 | 19 |
34,474 | @ Deprecated public static IonSystem newSystem ( IonCatalog catalog ) { return IonSystemBuilder . standard ( ) . withCatalog ( catalog ) . build ( ) ; } | Constructs a new system instance with the given catalog . | 35 | 11 |
34,475 | protected void tokenValueIsFinished ( ) { _scanner . tokenIsFinished ( ) ; if ( IonType . BLOB . equals ( _value_type ) || IonType . CLOB . equals ( _value_type ) ) { int state_after_scalar = get_state_after_value ( ) ; set_state ( state_after_scalar ) ; } } | called by super classes to tell us that the current token has been consumed . | 86 | 15 |
34,476 | public boolean isInStruct ( ) { boolean in_struct = false ; IonType container = getContainerType ( ) ; if ( IonType . STRUCT . equals ( container ) ) { if ( getDepth ( ) > 0 ) { in_struct = true ; } else { assert ( IonType . STRUCT . equals ( _nesting_parent ) == true ) ; } } return in_struct ; } | we re not really in a struct we at the top level | 86 | 12 |
34,477 | private boolean is_in_struct_internal ( ) { boolean in_struct = false ; IonType container = getContainerType ( ) ; if ( IonType . STRUCT . equals ( container ) ) { in_struct = true ; } return in_struct ; } | have to ignore | 56 | 3 |
34,478 | public long getPosition ( ) { long file_pos = 0 ; UnifiedDataPageX page = _buffer . getCurrentPage ( ) ; if ( page != null ) { file_pos = page . getFilePosition ( _pos ) ; } return file_pos ; } | used to find the current position of this stream in the input source . | 57 | 14 |
34,479 | public final int read ( byte [ ] dst , int offset , int length ) throws IOException { if ( ! is_byte_data ( ) ) { throw new IOException ( "byte read is not support over character sources" ) ; } int remaining = length ; while ( remaining > 0 && ! isEOF ( ) ) { int ready = _limit - _pos ; if ( ready > remaining ) { ready... | It is unclear what the implication to the rest of the system to make it conform | 151 | 16 |
34,480 | protected int refill ( ) throws IOException { UnifiedDataPageX curr = _buffer . getCurrentPage ( ) ; SavePoint sp = _save_points . savePointActiveTop ( ) ; if ( ! can_fill_new_page ( ) ) { // aka: there can be only one! // (and it's used up) return refill_is_eof ( ) ; } if ( sp != null && sp . getEndIdx ( ) == _buffer ... | the refill method is the key override that is filled in by the various subclasses . It fills either the byte or char array with a block of data from the input source . As this is a virtual function the right version will get called for each source type . Since it is only called once per block and from then on the final... | 715 | 86 |
34,481 | private bbBlock init ( int initialSize , bbBlock initialBlock ) { this . _lastCapacity = BlockedBuffer . _defaultBlockSizeMin ; this . _blockSizeUpperLimit = BlockedBuffer . _defaultBlockSizeUpperLimit ; while ( this . _lastCapacity < initialSize && this . _lastCapacity < this . _blockSizeUpperLimit ) { this . nextBloc... | Initializes the various members such as the block arraylist the initial block and the various values like the block size upper limit . | 286 | 25 |
34,482 | private void clear ( Object caller , int version ) { assert mutation_in_progress ( caller , version ) ; _buf_limit = 0 ; for ( int ii = 0 ; ii < _blocks . size ( ) ; ii ++ ) { _blocks . get ( ii ) . clearBlock ( ) ; // _blocks.get(ii)._idx = -1; this is done in clearBlock() } bbBlock first = _blocks . get ( 0 ) ; first... | empties the entire contents of the buffer | 139 | 8 |
34,483 | bbBlock truncate ( Object caller , int version , int pos ) { assert mutation_in_progress ( caller , version ) ; if ( 0 > pos || pos > this . _buf_limit ) throw new IllegalArgumentException ( ) ; // clear out all the blocks in use from the last in use // to the block where the eof will be located bbBlock b = null ; for ... | treat the limit as the end of file | 256 | 9 |
34,484 | int insert ( Object caller , int version , bbBlock curr , int pos , int len ) { assert mutation_in_progress ( caller , version ) ; // DEBUG: int amountMoved = 0; // DEBUG: int before = this._buf_limit; // DEBUG: assert _validate(); // if there's room in the current block - just // move the "trailing" bytes down and we'... | dispatcher for the various forms of insert we encounter calls one of the four helpers depending on the case that is needed to inser here | 756 | 28 |
34,485 | private int insertInCurrOnly ( Object caller , int version , bbBlock curr , int pos , int len ) { assert mutation_in_progress ( caller , version ) ; // the space we need is available right in the block assert curr . unusedBlockCapacity ( ) >= len ; System . arraycopy ( curr . _buffer , curr . blockOffsetFromAbsolute ( ... | this handles insert when there s enough room in the current block | 156 | 12 |
34,486 | private int readVarInt ( int firstByte ) throws IOException { // VarInt uses the high-order bit of the last octet as a marker; some (but not all) 5-byte VarInts can fit // into a Java int. // To validate overflows we accumulate the VarInt in a long and then check if it can be represented by an int // // see http://amzn... | reads a varInt after the first byte was read . The first byte is used to specify the sign and - 0 has different representation on the protected API that was called | 541 | 33 |
34,487 | public Type next ( boolean is_in_expression ) throws IOException { inQuotedContent = false ; int c = this . readIgnoreWhitespace ( ) ; return next ( c , is_in_expression ) ; } | Java handles the tail optimization ) | 49 | 6 |
34,488 | private boolean twoMoreSingleQuotes ( ) throws IOException { int c = read ( ) ; if ( c == ' ' ) { int c2 = read ( ) ; if ( c2 == ' ' ) { return true ; } unread ( c2 ) ; } unread ( c ) ; return false ; } | If two single quotes are next on the input consume them and return true . Otherwise leave them on the input and return false . | 66 | 25 |
34,489 | public final static int typeNameKeyWordFromMask ( int possible_names , int length ) { int kw = KEYWORD_unrecognized ; if ( possible_names != IonTokenConstsX . KW_ALL_BITS ) { for ( int ii = 0 ; ii < typeNameBits . length ; ii ++ ) { int tb = typeNameBits [ ii ] ; if ( tb == possible_names ) { if ( typeNameNames [ ii ] ... | this can be faster but it s pretty unusual to be called . | 135 | 13 |
34,490 | public final IonTextWriterBuilder withIvmMinimizing ( IvmMinimizing minimizing ) { IonTextWriterBuilder b = mutable ( ) ; b . setIvmMinimizing ( minimizing ) ; return b ; } | Declares the strategy for reducing or eliminating non - initial Ion version markers returning a new mutable builder if this is immutable . When null IVMs are emitted as they are written . | 48 | 36 |
34,491 | public final IonTextWriterBuilder withLongStringThreshold ( int threshold ) { IonTextWriterBuilder b = mutable ( ) ; b . setLongStringThreshold ( threshold ) ; return b ; } | Declares the length beyond which string and clob content will be rendered as triple - quoted long strings . At present such content will only line - break on extant newlines . | 42 | 35 |
34,492 | private void startLocalSymbolTableIfNeeded ( final boolean writeIVM ) throws IOException { if ( symbolState == SymbolState . SYSTEM_SYMBOLS ) { if ( writeIVM ) { symbols . writeIonVersionMarker ( ) ; } symbols . addTypeAnnotationSymbol ( systemSymbol ( ION_SYMBOL_TABLE_SID ) ) ; symbols . stepIn ( STRUCT ) ; { if ( imp... | Symbol Table Management | 305 | 4 |
34,493 | public void setFieldName ( final String name ) { if ( ! isInStruct ( ) ) { throw new IllegalStateException ( "IonWriter.setFieldName() must be called before writing a value into a struct." ) ; } if ( name == null ) { throw new NullPointerException ( "Null field name is not allowed." ) ; } final SymbolToken token = inte... | Current Value Meta | 97 | 3 |
34,494 | public SymbolTable removeTable ( String name , int version ) { SymbolTable removed = null ; synchronized ( myTablesByName ) { TreeMap < Integer , SymbolTable > versions = myTablesByName . get ( name ) ; if ( versions != null ) { synchronized ( versions ) { removed = versions . remove ( version ) ; // Remove empty inter... | Removes a symbol table from this catalog . | 104 | 9 |
34,495 | public Iterator < SymbolTable > iterator ( ) { ArrayList < SymbolTable > tables ; synchronized ( myTablesByName ) { tables = new ArrayList < SymbolTable > ( myTablesByName . size ( ) ) ; // I don't think we can shorten the synchronization block // because HashMap.values() result is a live view (not a copy) and // thus ... | Constructs an iterator that enumerates all of the shared symbol tables in this catalog at the time of method invocation . The result represents a snapshot of the state of this catalog . | 157 | 35 |
34,496 | void validateNewChild ( IonValue child ) throws ContainedValueException , NullPointerException , IllegalArgumentException { if ( child . getContainer ( ) != null ) // Also checks for null. { throw new ContainedValueException ( ) ; } if ( child . isReadOnly ( ) ) throw new ReadOnlyValueException ( ) ; if ( child instanc... | Ensures that a potential new child is non - null has no container is not read - only and is not a datagram . | 171 | 27 |
34,497 | protected int add_child ( int idx , IonValueLite child ) { _isNullValue ( false ) ; // if we add children we're not null anymore child . setContext ( this . getContextForIndex ( child , idx ) ) ; if ( _children == null || _child_count >= _children . length ) { int old_len = ( _children == null ) ? 0 : _children . lengt... | Does not validate the child or check locks . | 283 | 9 |
34,498 | void remove_child ( int idx ) { assert ( idx >= 0 ) ; assert ( idx < get_child_count ( ) ) ; // this also asserts child count > 0 assert get_child ( idx ) != null : "No child at index " + idx ; _children [ idx ] . detachFromContainer ( ) ; int children_to_move = _child_count - idx - 1 ; if ( children_to_move > 0 ) { Sy... | Does not check locks . | 153 | 5 |
34,499 | public void put ( String fieldName , IonValue value ) { checkForLock ( ) ; validateFieldName ( fieldName ) ; if ( value != null ) validateNewChild ( value ) ; int lowestRemovedIndex = get_child_count ( ) ; boolean any_removed = false ; // first we remove the any existing fields // associated with fieldName (which may b... | put is make this value the one and only value associated with this fieldName . The side effect is that if there were multiple fields with this name when put is complete there will only be the one value in the collection . | 561 | 44 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.