idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
37,900
public TimezoneOffsetFrom setTimezoneOffsetFrom ( UtcOffset offset ) { TimezoneOffsetFrom prop = new TimezoneOffsetFrom ( offset ) ; setTimezoneOffsetFrom ( prop ) ; return prop ; }
Sets the UTC offset that the timezone observance transitions from .
37,901
public TimezoneName addTimezoneName ( String timezoneName ) { TimezoneName prop = new TimezoneName ( timezoneName ) ; addTimezoneName ( prop ) ; return prop ; }
Adds a traditional non - standard name for the timezone observance .
37,902
private static String getCidUriValue ( String uri ) { int colon = uri . indexOf ( ':' ) ; if ( colon == 3 ) { String scheme = uri . substring ( 0 , colon ) ; return "cid" . equalsIgnoreCase ( scheme ) ? uri . substring ( colon + 1 ) : null ; } if ( uri . length ( ) > 0 && uri . charAt ( 0 ) == '<' && uri . charAt ( uri...
Gets the value of the given cid URI .
37,903
public < T extends ICalProperty > T getProperty ( Class < T > clazz ) { return clazz . cast ( properties . first ( clazz ) ) ; }
Gets the first property of a given class .
37,904
public List < ICalProperty > setProperty ( ICalProperty property ) { return properties . replace ( property . getClass ( ) , property ) ; }
Replaces all existing properties of the given property instance s class with the given property instance .
37,905
public < T extends ICalProperty > List < T > setProperty ( Class < T > clazz , T property ) { List < ICalProperty > replaced = properties . replace ( clazz , property ) ; return castList ( replaced , clazz ) ; }
Replaces all existing properties of the given class with a single property instance . If the property instance is null then all instances of that property will be removed .
37,906
public < T extends ICalProperty > boolean removeProperty ( T property ) { return properties . remove ( property . getClass ( ) , property ) ; }
Removes a specific property instance from this component .
37,907
public < T extends ICalProperty > List < T > removeProperties ( Class < T > clazz ) { List < ICalProperty > removed = properties . removeAll ( clazz ) ; return castList ( removed , clazz ) ; }
Removes all properties of a given class from this component .
37,908
public < T extends ICalComponent > boolean removeComponent ( T component ) { return components . remove ( component . getClass ( ) , component ) ; }
Removes a specific sub - component instance from this component .
37,909
public < T extends ICalComponent > List < T > removeComponents ( Class < T > clazz ) { List < ICalComponent > removed = components . removeAll ( clazz ) ; return castList ( removed , clazz ) ; }
Removes all sub - components of the given class from this component .
37,910
public RawProperty getExperimentalProperty ( String name ) { for ( RawProperty raw : getExperimentalProperties ( ) ) { if ( raw . getName ( ) . equalsIgnoreCase ( name ) ) { return raw ; } } return null ; }
Gets the first experimental property with a given name .
37,911
public List < RawProperty > getExperimentalProperties ( String name ) { List < RawProperty > toReturn = new ArrayList < RawProperty > ( ) ; for ( RawProperty property : getExperimentalProperties ( ) ) { if ( property . getName ( ) . equalsIgnoreCase ( name ) ) { toReturn . add ( property ) ; } } return Collections . un...
Gets all experimental properties with a given name .
37,912
public List < RawProperty > removeExperimentalProperties ( String name ) { List < RawProperty > all = getExperimentalProperties ( ) ; List < RawProperty > toRemove = new ArrayList < RawProperty > ( ) ; for ( RawProperty property : all ) { if ( property . getName ( ) . equalsIgnoreCase ( name ) ) { toRemove . add ( prop...
Removes all experimental properties that have the given name .
37,913
public < T extends ICalComponent > T getComponent ( Class < T > clazz ) { return clazz . cast ( components . first ( clazz ) ) ; }
Gets the first sub - component of a given class .
37,914
public < T extends ICalComponent > List < T > getComponents ( Class < T > clazz ) { return new ICalComponentList < T > ( clazz ) ; }
Gets all sub - components of a given class . Changes to the returned list will update the parent component object and vice versa .
37,915
public List < ICalComponent > setComponent ( ICalComponent component ) { return components . replace ( component . getClass ( ) , component ) ; }
Replaces all sub - components of a given class with the given component .
37,916
public < T extends ICalComponent > List < T > setComponent ( Class < T > clazz , T component ) { List < ICalComponent > replaced = components . replace ( clazz , component ) ; return castList ( replaced , clazz ) ; }
Replaces all sub - components of a given class with the given component . If the component instance is null then all instances of that component will be removed .
37,917
public RawComponent getExperimentalComponent ( String name ) { for ( RawComponent component : getExperimentalComponents ( ) ) { if ( component . getName ( ) . equalsIgnoreCase ( name ) ) { return component ; } } return null ; }
Gets the first experimental sub - component with a given name .
37,918
public List < RawComponent > getExperimentalComponents ( String name ) { List < RawComponent > toReturn = new ArrayList < RawComponent > ( ) ; for ( RawComponent component : getExperimentalComponents ( ) ) { if ( component . getName ( ) . equalsIgnoreCase ( name ) ) { toReturn . add ( component ) ; } } return Collectio...
Gets all experimental sub - component with a given name .
37,919
public RawComponent addExperimentalComponent ( String name ) { RawComponent raw = new RawComponent ( name ) ; addComponent ( raw ) ; return raw ; }
Adds an experimental sub - component to this component .
37,920
public List < RawComponent > removeExperimentalComponents ( String name ) { List < RawComponent > all = getExperimentalComponents ( ) ; List < RawComponent > toRemove = new ArrayList < RawComponent > ( ) ; for ( RawComponent property : all ) { if ( property . getName ( ) . equalsIgnoreCase ( name ) ) { toRemove . add (...
Removes all experimental sub - components that have the given name .
37,921
protected void checkRequiredCardinality ( List < ValidationWarning > warnings , Class < ? extends ICalProperty > ... classes ) { for ( Class < ? extends ICalProperty > clazz : classes ) { List < ? extends ICalProperty > props = getProperties ( clazz ) ; if ( props . isEmpty ( ) ) { warnings . add ( new ValidationWarnin...
Utility method for validating that there is exactly one instance of each of the given properties .
37,922
private static < T > List < T > castList ( List < ? > list , Class < T > castTo ) { List < T > casted = new ArrayList < T > ( list . size ( ) ) ; for ( Object object : list ) { casted . add ( castTo . cast ( object ) ) ; } return Collections . unmodifiableList ( casted ) ; }
Casts all objects in the given list to the given class adding the casted objects to a new list .
37,923
public final T parseText ( String value , ICalDataType dataType , ICalParameters parameters , ParseContext context ) { T property = _parseText ( value , dataType , parameters , context ) ; property . setParameters ( parameters ) ; return property ; }
Unmarshals a property from a plain - text iCalendar data stream .
37,924
private static String jcalValueToString ( JCalValue value ) { List < JsonValue > values = value . getValues ( ) ; if ( values . size ( ) > 1 ) { List < String > multi = value . asMulti ( ) ; if ( ! multi . isEmpty ( ) ) { return VObjectPropertyValues . writeList ( multi ) ; } } if ( ! values . isEmpty ( ) && values . g...
Converts a jCal value to its plain - text format representation .
37,925
protected static DateWriter date ( Date date ) { return date ( ( date == null ) ? null : new ICalDate ( date ) ) ; }
Formats a date as a string .
37,926
protected static ICalParameters handleTzidParameter ( ICalProperty property , boolean hasTime , WriteContext context ) { ICalParameters parameters = property . getParameters ( ) ; if ( ! hasTime ) { return parameters ; } if ( context . getVersion ( ) == ICalVersion . V1_0 ) { return parameters ; } TimezoneInfo tzinfo =...
Adds a TZID parameter to a property s parameter list if necessary .
37,927
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( String componentName , ICalVersion version ) { componentName = componentName . toUpperCase ( ) ; ICalComponentScribe < ? extends ICalComponent > scribe = experimentalCompByName . get ( componentName ) ; if ( scribe == null ) { scribe = standard...
Gets a component scribe by name .
37,928
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( String propertyName , ICalVersion version ) { propertyName = propertyName . toUpperCase ( ) ; String key = propertyNameKey ( propertyName , version ) ; ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByName . get ( key ) ; i...
Gets a property scribe by name .
37,929
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( Class < ? extends ICalComponent > clazz ) { ICalComponentScribe < ? extends ICalComponent > scribe = experimentalCompByClass . get ( clazz ) ; if ( scribe != null ) { return scribe ; } return standardCompByClass . get ( clazz ) ; }
Gets a component scribe by class .
37,930
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( Class < ? extends ICalProperty > clazz ) { ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByClass . get ( clazz ) ; if ( scribe != null ) { return scribe ; } return standardPropByClass . get ( clazz ) ; }
Gets a property scribe by class .
37,931
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( ICalComponent component ) { if ( component instanceof RawComponent ) { RawComponent raw = ( RawComponent ) component ; return new RawComponentScribe ( raw . getName ( ) ) ; } return getComponentScribe ( component . getClass ( ) ) ; }
Gets the appropriate component scribe for a given component instance .
37,932
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( ICalProperty property ) { if ( property instanceof RawProperty ) { RawProperty raw = ( RawProperty ) property ; return new RawPropertyScribe ( raw . getName ( ) ) ; } return getPropertyScribe ( property . getClass ( ) ) ; }
Gets the appropriate property scribe for a given property instance .
37,933
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( QName qname ) { ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByQName . get ( qname ) ; if ( scribe == null ) { scribe = standardPropByQName . get ( qname ) ; } if ( scribe == null || ! scribe . getSupportedVersions ( ) . ...
Gets a property scribe by XML local name and namespace .
37,934
public void unregister ( ICalComponentScribe < ? extends ICalComponent > scribe ) { experimentalCompByName . remove ( scribe . getComponentName ( ) . toUpperCase ( ) ) ; experimentalCompByClass . remove ( scribe . getComponentClass ( ) ) ; }
Unregisters a component scribe .
37,935
public void unregister ( ICalPropertyScribe < ? extends ICalProperty > scribe ) { for ( ICalVersion version : ICalVersion . values ( ) ) { experimentalPropByName . remove ( propertyNameKey ( scribe , version ) ) ; } experimentalPropByClass . remove ( scribe . getPropertyClass ( ) ) ; experimentalPropByQName . remove ( ...
Unregisters a property scribe
37,936
private static Date determineStartDate ( VAlarm valarm , ICalComponent parent ) { Trigger trigger = valarm . getTrigger ( ) ; if ( trigger == null ) { return null ; } Date triggerStart = trigger . getDate ( ) ; if ( triggerStart != null ) { return triggerStart ; } Duration triggerDuration = trigger . getDuration ( ) ; ...
Determines what the alarm property s start date should be .
37,937
static int [ ] uniquify ( int [ ] ints ) { IntSet iset = new IntSet ( ) ; for ( int i : ints ) { iset . add ( i ) ; } return iset . toIntArray ( ) ; }
Returns a sorted copy of an integer array with duplicate values removed .
37,938
static int countInPeriod ( DayOfWeek dow , DayOfWeek dow0 , int nDays ) { if ( dow . getCalendarConstant ( ) >= dow0 . getCalendarConstant ( ) ) { return 1 + ( ( nDays - ( dow . getCalendarConstant ( ) - dow0 . getCalendarConstant ( ) ) - 1 ) / 7 ) ; } else { return 1 + ( ( nDays - ( 7 - ( dow0 . getCalendarConstant ( ...
Counts the number of occurrences of a weekday in a given period .
37,939
private DateValue generateInstance ( ) { try { do { if ( ! instanceGenerator . generate ( builder ) ) { return null ; } DateValue dUtc = dtStart instanceof TimeValue ? TimeUtils . toUtc ( builder . toDateTime ( ) , tzid ) : builder . toDate ( ) ; if ( dUtc . compareTo ( lastUtc_ ) > 0 ) { return dUtc ; } } while ( true...
Generates a date .
37,940
public void setTimezone ( ICalProperty property , TimezoneAssignment timezone ) { if ( timezone == null ) { TimezoneAssignment existing = propertyTimezones . remove ( property ) ; if ( existing != null && existing != defaultTimezone && ! propertyTimezones . values ( ) . contains ( existing ) ) { assignments . remove ( ...
Assigns a timezone to a specific property .
37,941
public boolean isFloating ( ICalProperty property ) { if ( containsIdentity ( floatingProperties , property ) ) { return true ; } if ( propertyTimezones . containsKey ( property ) ) { return false ; } return globalFloatingTime ; }
Determines if a property value should be formatted in floating time when written to an output stream .
37,942
private static < T > void removeIdentity ( List < T > list , T object ) { Iterator < T > it = list . iterator ( ) ; while ( it . hasNext ( ) ) { if ( object == it . next ( ) ) { it . remove ( ) ; } } }
Removes an object from a list using reference equality .
37,943
private static < T > boolean containsIdentity ( List < T > list , T object ) { for ( T item : list ) { if ( item == object ) { return true ; } } return false ; }
Searches for an item in a list using reference equality .
37,944
public ChainingXmlWriter register ( String parameterName , ICalDataType dataType ) { parameterDataTypes . put ( parameterName , dataType ) ; return this ; }
Registers the data type of a non - standard parameter . Non - standard parameters use the unknown data type by default .
37,945
public void setScribeIndex ( ScribeIndex index ) { this . index = index ; serializer . setScribeIndex ( index ) ; deserializer . setScribeIndex ( index ) ; }
Sets the scribe index for the serializer and deserializer to use .
37,946
public static JCalValue multi ( List < ? > values ) { List < JsonValue > multiValues = new ArrayList < JsonValue > ( values . size ( ) ) ; for ( Object value : values ) { multiValues . add ( new JsonValue ( value ) ) ; } return new JCalValue ( multiValues ) ; }
Creates a multi - valued value .
37,947
public static JCalValue structured ( List < List < ? > > values ) { List < JsonValue > array = new ArrayList < JsonValue > ( values . size ( ) ) ; for ( List < ? > list : values ) { if ( list . isEmpty ( ) ) { array . add ( new JsonValue ( "" ) ) ; continue ; } if ( list . size ( ) == 1 ) { Object value = list . get ( ...
Creates a structured value .
37,948
public static JCalValue object ( ListMultimap < String , Object > value ) { Map < String , JsonValue > object = new LinkedHashMap < String , JsonValue > ( ) ; for ( Map . Entry < String , List < Object > > entry : value ) { String key = entry . getKey ( ) ; List < Object > list = entry . getValue ( ) ; JsonValue v ; if...
Creates an object value .
37,949
public String asSingle ( ) { if ( values . isEmpty ( ) ) { return "" ; } JsonValue first = values . get ( 0 ) ; if ( first . isNull ( ) ) { return "" ; } Object obj = first . getValue ( ) ; if ( obj != null ) { return obj . toString ( ) ; } List < JsonValue > array = first . getArray ( ) ; if ( array != null && ! array...
Parses this jCal value as a single - valued property value .
37,950
public List < List < String > > asStructured ( ) { if ( values . isEmpty ( ) ) { return Collections . emptyList ( ) ; } JsonValue first = values . get ( 0 ) ; List < JsonValue > array = first . getArray ( ) ; if ( array != null ) { List < List < String > > components = new ArrayList < List < String > > ( array . size (...
Parses this jCal value as a structured property value .
37,951
public List < String > asMulti ( ) { if ( values . isEmpty ( ) ) { return Collections . emptyList ( ) ; } List < String > multi = new ArrayList < String > ( values . size ( ) ) ; for ( JsonValue value : values ) { if ( value . isNull ( ) ) { multi . add ( "" ) ; continue ; } Object obj = value . getValue ( ) ; if ( obj...
Parses this jCal value as a multi - valued property value .
37,952
public ListMultimap < String , String > asObject ( ) { if ( values . isEmpty ( ) ) { return new ListMultimap < String , String > ( 0 ) ; } Map < String , JsonValue > map = values . get ( 0 ) . getObject ( ) ; if ( map == null ) { return new ListMultimap < String , String > ( 0 ) ; } ListMultimap < String , String > val...
Parses this jCal value as an object property value .
37,953
public static DateTimeComponents parse ( String dateString , Boolean hasTime ) { Matcher m = regex . matcher ( dateString ) ; if ( ! m . find ( ) ) { throw Messages . INSTANCE . getIllegalArgumentException ( 19 , dateString ) ; } int i = 1 ; int year = Integer . parseInt ( m . group ( i ++ ) ) ; int month = Integer . p...
Parses the components out of a date - time string .
37,954
public static RecurrenceIterator createRecurrenceIterator ( Collection < ? extends DateValue > dates ) { DateValue [ ] datesArray = dates . toArray ( new DateValue [ 0 ] ) ; return new RDateIteratorImpl ( datesArray ) ; }
Creates a recurrence iterator from an RDATE or EXDATE list .
37,955
public static RecurrenceIterable createRecurrenceIterable ( final Recurrence rrule , final DateValue dtStart , final TimeZone tzid ) { return new RecurrenceIterable ( ) { public RecurrenceIterator iterator ( ) { return createRecurrenceIterator ( rrule , dtStart , tzid ) ; } } ; }
Creates a recurrence iterable from an RRULE .
37,956
public static RecurrenceIterator join ( RecurrenceIterator first , RecurrenceIterator ... rest ) { List < RecurrenceIterator > all = new ArrayList < RecurrenceIterator > ( ) ; all . add ( first ) ; all . addAll ( Arrays . asList ( rest ) ) ; return new CompoundIteratorImpl ( all , Collections . < RecurrenceIterator > e...
Generates a recurrence iterator that iterates over the union of the given recurrence iterators .
37,957
public static Duration parse ( String value ) { if ( value . length ( ) == 0 ) { throw parseError ( value ) ; } int index = 0 ; char first = value . charAt ( index ) ; boolean prior = ( first == '-' ) ; if ( first == '-' || first == '+' ) { index ++ ; } if ( value . charAt ( index ) != 'P' ) { throw parseError ( value ...
Parses a duration string .
37,958
public static Duration diff ( Date start , Date end ) { return fromMillis ( end . getTime ( ) - start . getTime ( ) ) ; }
Builds a duration based on the difference between two dates .
37,959
public static Duration fromMillis ( long milliseconds ) { Duration . Builder builder = builder ( ) ; if ( milliseconds < 0 ) { builder . prior ( true ) ; milliseconds *= - 1 ; } int seconds = ( int ) ( milliseconds / 1000 ) ; Integer weeks = seconds / ( 60 * 60 * 24 * 7 ) ; if ( weeks > 0 ) { builder . weeks ( weeks ) ...
Builds a duration from a number of milliseconds .
37,960
public long toMillis ( ) { long totalSeconds = 0 ; if ( weeks != null ) { totalSeconds += 60L * 60 * 24 * 7 * weeks ; } if ( days != null ) { totalSeconds += 60L * 60 * 24 * days ; } if ( hours != null ) { totalSeconds += 60L * 60 * hours ; } if ( minutes != null ) { totalSeconds += 60L * minutes ; } if ( seconds != nu...
Converts the duration value to milliseconds .
37,961
private static DateValue [ ] removeDuplicates ( DateValue [ ] dates ) { int k = 0 ; for ( int i = 1 ; i < dates . length ; ++ i ) { if ( ! dates [ i ] . equals ( dates [ k ] ) ) { dates [ ++ k ] = dates [ i ] ; } } if ( ++ k < dates . length ) { DateValue [ ] uniqueDates = new DateValue [ k ] ; System . arraycopy ( dat...
Removes duplicates from a list of date values .
37,962
public T emptyInstance ( ) { T component = _newInstance ( ) ; component . getProperties ( ) . clear ( ) ; component . getComponents ( ) . clear ( ) ; return component ; }
Creates a new instance of the component class that doesn t have any properties or sub - components .
37,963
public List < ICalComponent > getComponents ( T component ) { return new ArrayList < ICalComponent > ( component . getComponents ( ) . values ( ) ) ; }
Gets the sub - components to marshal . Child classes can override this for better control over which components are marshalled .
37,964
public List < ICalProperty > getProperties ( T component ) { return new ArrayList < ICalProperty > ( component . getProperties ( ) . values ( ) ) ; }
Gets the properties to marshal . Child classes can override this for better control over which properties are marshalled .
37,965
public void registerParameterDataType ( String parameterName , ICalDataType dataType ) { parameterName = parameterName . toLowerCase ( ) ; if ( dataType == null ) { parameterDataTypes . remove ( parameterName ) ; } else { parameterDataTypes . put ( parameterName , dataType ) ; } }
Registers the data type of an experimental parameter . Experimental parameters use the unknown data type by default .
37,966
public static void premain ( String agentArgs , Instrumentation inst ) { MarkerType markerType = MarkerType . NONE ; boolean debugMode = false ; boolean autoSerializable = true ; if ( agentArgs != null && ! agentArgs . isEmpty ( ) ) { String [ ] splitArgs = agentArgs . split ( "," ) ; for ( String splitArg : splitArgs ...
Java agent premain .
37,967
public static StorageSizes computeSizes ( Frame < BasicValue > frame , int offset , int length ) { Validate . notNull ( frame ) ; Validate . isTrue ( offset >= 0 ) ; Validate . isTrue ( length >= 0 ) ; Validate . isTrue ( offset < frame . getStackSize ( ) ) ; Validate . isTrue ( offset + length <= frame . getStackSize ...
Compute sizes required for the storage arrays that will contain the operand stack at this frame .
37,968
public static InsnList jumpTo ( LabelNode labelNode ) { Validate . notNull ( labelNode ) ; InsnList ret = new InsnList ( ) ; ret . add ( new JumpInsnNode ( Opcodes . GOTO , labelNode ) ) ; return ret ; }
Generates instructions for an unconditional jump to a label .
37,969
public static InsnList addLabel ( LabelNode labelNode ) { Validate . notNull ( labelNode ) ; InsnList ret = new InsnList ( ) ; ret . add ( labelNode ) ; return ret ; }
Generates instructions for a label .
37,970
public static InsnList lineNumber ( int num ) { Validate . isTrue ( num >= 0 ) ; InsnList ret = new InsnList ( ) ; LabelNode labelNode = new LabelNode ( ) ; ret . add ( labelNode ) ; ret . add ( new LineNumberNode ( num , labelNode ) ) ; return ret ; }
Generates instructions for line numbers . This is useful for debugging . For example you can put a line number of 99999 or some other special number to denote that the code being executed is instrumented code . Then if a stacktrace happens you ll know that if instrumented code was immediately involved .
37,971
public static InsnList pop ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . POP ) ) ; return ret ; }
Generates instructions to pop an item off the stack .
37,972
public static InsnList monitorEnter ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . MONITORENTER ) ) ; return ret ; }
Generates a MONITORENTER instruction which consumes an Object from the top of the stack .
37,973
public static InsnList monitorExit ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . MONITOREXIT ) ) ; return ret ; }
Generates a MONITOREXIT instruction which consumes an Object from the top of the stack .
37,974
public static InsnList loadIntConst ( int i ) { InsnList ret = new InsnList ( ) ; ret . add ( new LdcInsnNode ( i ) ) ; return ret ; }
Generates instructions to push an integer constant on to the stack .
37,975
public static InsnList loadStringConst ( String s ) { Validate . notNull ( s ) ; InsnList ret = new InsnList ( ) ; ret . add ( new LdcInsnNode ( s ) ) ; return ret ; }
Generates instruction to push a string constant on to the stack .
37,976
public static InsnList loadNull ( ) { InsnList ret = new InsnList ( ) ; ret . add ( new InsnNode ( Opcodes . ACONST_NULL ) ) ; return ret ; }
Generates instruction to push a null on to the stack .
37,977
public static InsnList loadVar ( Variable variable ) { Validate . notNull ( variable ) ; InsnList ret = new InsnList ( ) ; switch ( variable . getType ( ) . getSort ( ) ) { case Type . BOOLEAN : case Type . BYTE : case Type . CHAR : case Type . SHORT : case Type . INT : ret . add ( new VarInsnNode ( Opcodes . ILOAD , v...
Copies a local variable on to the stack .
37,978
public static InsnList saveVar ( Variable variable ) { Validate . notNull ( variable ) ; InsnList ret = new InsnList ( ) ; switch ( variable . getType ( ) . getSort ( ) ) { case Type . BOOLEAN : case Type . BYTE : case Type . CHAR : case Type . SHORT : case Type . INT : ret . add ( new VarInsnNode ( Opcodes . ISTORE , ...
Pops the stack in to the the local variable table . You may run in to problems if the item on top of the stack isn t of the same type as the variable it s being put in to .
37,979
public static InsnList createNewObjectArray ( InsnList size ) { Validate . notNull ( size ) ; InsnList ret = new InsnList ( ) ; ret . add ( size ) ; ret . add ( new TypeInsnNode ( Opcodes . ANEWARRAY , "java/lang/Object" ) ) ; return ret ; }
Creates a new object array on the stack .
37,980
public static InsnList loadArrayLength ( InsnList arrayRef ) { Validate . notNull ( arrayRef ) ; InsnList ret = new InsnList ( ) ; ret . add ( arrayRef ) ; ret . add ( new InsnNode ( Opcodes . ARRAYLENGTH ) ) ; return ret ; }
Gets the size of an array and puts it on to the stack .
37,981
public static InsnList addIntegers ( InsnList lhs , InsnList rhs ) { Validate . notNull ( lhs ) ; Validate . notNull ( rhs ) ; InsnList ret = new InsnList ( ) ; ret . add ( lhs ) ; ret . add ( rhs ) ; ret . add ( new InsnNode ( Opcodes . IADD ) ) ; return ret ; }
Adds two integers together and puts the result on to the stack .
37,982
public static InsnList ifIntegersEqual ( InsnList lhs , InsnList rhs , InsnList action ) { Validate . notNull ( lhs ) ; Validate . notNull ( rhs ) ; Validate . notNull ( action ) ; InsnList ret = new InsnList ( ) ; LabelNode notEqualLabelNode = new LabelNode ( ) ; ret . add ( lhs ) ; ret . add ( rhs ) ; ret . add ( new...
Compares two integers and performs some action if the integers are equal .
37,983
public static InsnList forEach ( Variable counterVar , Variable arrayLenVar , InsnList array , InsnList action ) { Validate . notNull ( counterVar ) ; Validate . notNull ( arrayLenVar ) ; Validate . notNull ( array ) ; Validate . notNull ( action ) ; Validate . isTrue ( counterVar . getType ( ) . equals ( Type . INT_TY...
For each element in an object array performs an action .
37,984
public static InsnList combineObjectArrays ( Variable destArrayVar , Variable firstArrayVar , Variable secondArrayVar ) { Validate . notNull ( destArrayVar ) ; Validate . notNull ( firstArrayVar ) ; Validate . notNull ( secondArrayVar ) ; Validate . isTrue ( destArrayVar . getType ( ) . equals ( Type . getType ( Object...
Concatenates two object arrays together .
37,985
public static InsnList tryCatchBlock ( TryCatchBlockNode tryCatchBlockNode , Type exceptionType , InsnList tryInsnList , InsnList catchInsnList ) { Validate . notNull ( tryInsnList ) ; Validate . notNull ( catchInsnList ) ; if ( exceptionType != null ) { Validate . isTrue ( exceptionType . getSort ( ) == Type . OBJECT ...
Generates instructions for a try - catch block .
37,986
public static InsnList returnValue ( Type returnType , InsnList returnValueInsnList ) { Validate . notNull ( returnType ) ; Validate . isTrue ( returnType . getSort ( ) != Type . METHOD ) ; InsnList ret = new InsnList ( ) ; ret . add ( returnValueInsnList ) ; switch ( returnType . getSort ( ) ) { case Type . VOID : ret...
Generates instructions that returns a value .
37,987
protected final void instrumentPath ( Log log , List < String > classpath , File path ) throws MojoExecutionException { try { Instrumenter instrumenter = getInstrumenter ( log , classpath ) ; InstrumentationSettings settings = new InstrumentationSettings ( markerType , debugMode , autoSerializable ) ; PluginHelper . in...
Instruments all classes in a path recursively .
37,988
private static byte [ ] dumpBytecode ( MethodNode methodNode ) { List < AbstractInsnNode > onlyInstructionsAndLabels = Arrays . stream ( methodNode . instructions . toArray ( ) ) . filter ( x -> x instanceof LabelNode || x . getOpcode ( ) != - 1 ) . collect ( Collectors . toList ( ) ) ; Map < Label , Integer > labelOff...
Takes into account the instructions and operands as well as the overall structure .
37,989
public static Type getReturnTypeOfInvocation ( AbstractInsnNode invokeNode ) { Validate . notNull ( invokeNode ) ; if ( invokeNode instanceof MethodInsnNode ) { MethodInsnNode methodInsnNode = ( MethodInsnNode ) invokeNode ; Type methodType = Type . getType ( methodInsnNode . desc ) ; return methodType . getReturnType ...
Get the return type of the method being invoked .
37,990
public void addIndividual ( String className , ClassInformation classInformation ) { Validate . notNull ( className ) ; Validate . notNull ( classInformation ) ; Validate . isTrue ( ! hierarchyMap . containsKey ( className ) ) ; hierarchyMap . put ( className , classInformation ) ; }
Add a custom class .
37,991
public void addClasspath ( List < File > classpath ) throws IOException { Validate . notNull ( classpath ) ; Validate . noNullElements ( classpath ) ; for ( File classpathElement : classpath ) { if ( classpathElement . isFile ( ) ) { addJar ( classpathElement ) ; } else if ( classpathElement . isDirectory ( ) ) { addDi...
Add classes contained within a list of JAR files and folders . Note that if a duplicate class is encountered the original is kept .
37,992
private static InsnList popMethodResult ( AbstractInsnNode invokeInsnNode ) { Validate . notNull ( invokeInsnNode ) ; Type returnType = getReturnTypeOfInvocation ( invokeInsnNode ) ; InsnList ret = new InsnList ( ) ; switch ( returnType . getSort ( ) ) { case Type . LONG : case Type . DOUBLE : ret . add ( new InsnNode ...
Generates instructions to pop the result of the method off the stack . This will only generate instructions if the method being invoked generates a return value .
37,993
public void detail ( MethodNode methodNode , MethodAttributes attrs , StringBuilder output ) { Validate . notNull ( methodNode ) ; Validate . notNull ( attrs ) ; Validate . notNull ( output ) ; int methodId = attrs . getSignature ( ) . getMethodId ( ) ; output . append ( "Class Name: " ) . append ( attrs . getSignature...
MUST BE CALLED PRIOR TO INSTRUMENTATION!!!!
37,994
protected String getCommonSuperClass ( final String type1 , final String type2 ) { Validate . notNull ( type1 ) ; Validate . notNull ( type2 ) ; infoRepo . getInformation ( type1 ) ; LinkedHashSet < String > type1Hierarchy = flattenHierarchy ( type1 ) ; LinkedHashSet < String > type2Hierarchy = flattenHierarchy ( type2...
Derives common super class from the super name mapping passed in to the constructor .
37,995
void validateState ( ) { if ( frames == null || coroutine == null ) { throw new IllegalStateException ( "Bad state" ) ; } for ( int i = 0 ; i < frames . length ; i ++ ) { if ( frames [ i ] == null ) { throw new IllegalStateException ( "Bad state" ) ; } frames [ i ] . validateState ( ) ; } }
method to do that .
37,996
public static InsnList debugMarker ( MarkerType markerType , String text ) { Validate . notNull ( markerType ) ; Validate . notNull ( text ) ; InsnList ret = new InsnList ( ) ; switch ( markerType ) { case NONE : break ; case CONSTANT : ret . add ( new LdcInsnNode ( text ) ) ; ret . add ( new InsnNode ( Opcodes . POP )...
Generates instructions for generating marker instructions . These marker instructions are meant to be is useful for debugging instrumented code . For example you can spot a specific portion of instrumented code by looking for specific markers in the assembly output .
37,997
public InstrumentationResult instrument ( byte [ ] input , InstrumentationSettings settings ) { Validate . notNull ( input ) ; Validate . notNull ( settings ) ; Validate . isTrue ( input . length > 0 ) ; ClassReader cr = new ClassReader ( input ) ; ClassNode classNode = new SimpleClassNode ( ) ; cr . accept ( classNode...
Instruments a class .
37,998
public static List < MethodNode > findMethodsWithName ( Collection < MethodNode > methodNodes , String name ) { Validate . notNull ( methodNodes ) ; Validate . notNull ( name ) ; Validate . noNullElements ( methodNodes ) ; List < MethodNode > ret = new ArrayList < > ( ) ; for ( MethodNode methodNode : methodNodes ) { i...
Find methods within a class with a specific name .
37,999
public static List < MethodNode > findStaticMethods ( Collection < MethodNode > methodNodes ) { Validate . notNull ( methodNodes ) ; Validate . noNullElements ( methodNodes ) ; List < MethodNode > ret = new ArrayList < > ( ) ; for ( MethodNode methodNode : methodNodes ) { if ( ( methodNode . access & Opcodes . ACC_STAT...
Find static methods within a class .