idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
32,700 | public long add ( long instant , int years ) { if ( years == 0 ) { return instant ; } return set ( instant , get ( instant ) + years ) ; } | Add the specified years to the specified time instant . |
32,701 | public long set ( long instant , int year ) { FieldUtils . verifyValueBounds ( this , Math . abs ( year ) , iChronology . getMinYear ( ) , iChronology . getMaxYear ( ) ) ; int thisWeekyear = get ( instant ) ; if ( thisWeekyear == year ) { return instant ; } int thisDow = iChronology . getDayOfWeek ( instant ) ; int weeksInFromYear = iChronology . getWeeksInYear ( thisWeekyear ) ; int weeksInToYear = iChronology . getWeeksInYear ( year ) ; int maxOutWeeks = ( weeksInToYear < weeksInFromYear ) ? weeksInToYear : weeksInFromYear ; int setToWeek = iChronology . getWeekOfWeekyear ( instant ) ; if ( setToWeek > maxOutWeeks ) { setToWeek = maxOutWeeks ; } long workInstant = instant ; workInstant = iChronology . setYear ( workInstant , year ) ; int workWoyYear = get ( workInstant ) ; if ( workWoyYear < year ) { workInstant += DateTimeConstants . MILLIS_PER_WEEK ; } else if ( workWoyYear > year ) { workInstant -= DateTimeConstants . MILLIS_PER_WEEK ; } int currentWoyWeek = iChronology . getWeekOfWeekyear ( workInstant ) ; workInstant = workInstant + ( setToWeek - currentWoyWeek ) * ( long ) DateTimeConstants . MILLIS_PER_WEEK ; workInstant = iChronology . dayOfWeek ( ) . set ( workInstant , thisDow ) ; return workInstant ; } | Set the Year of a week based year component of the specified time instant . |
32,702 | public void setInto ( ReadWritablePeriod writablePeriod , Object object , Chronology chrono ) { ReadableInterval interval = ( ReadableInterval ) object ; chrono = ( chrono != null ? chrono : DateTimeUtils . getIntervalChronology ( interval ) ) ; long start = interval . getStartMillis ( ) ; long end = interval . getEndMillis ( ) ; int [ ] values = chrono . get ( writablePeriod , start , end ) ; for ( int i = 0 ; i < values . length ; i ++ ) { writablePeriod . setValue ( i , values [ i ] ) ; } } | Sets the values of the mutable duration from the specified interval . |
32,703 | public long getInstantMillis ( Object object , Chronology chrono ) { String str = ( String ) object ; DateTimeFormatter p = ISODateTimeFormat . dateTimeParser ( ) ; return p . withChronology ( chrono ) . parseMillis ( str ) ; } | Gets the millis which is the ISO parsed string value . |
32,704 | public int [ ] getPartialValues ( ReadablePartial fieldSource , Object object , Chronology chrono , DateTimeFormatter parser ) { if ( parser . getZone ( ) != null ) { chrono = chrono . withZone ( parser . getZone ( ) ) ; } long millis = parser . withChronology ( chrono ) . parseMillis ( ( String ) object ) ; return chrono . get ( fieldSource , millis ) ; } | Extracts the values of the partial from an object of this converter s type . This method checks if the parser has a zone and uses it if present . This is most useful for parsing local times with UTC . |
32,705 | public void setInto ( ReadWritableInterval writableInterval , Object object , Chronology chrono ) { String str = ( String ) object ; int separator = str . indexOf ( '/' ) ; if ( separator < 0 ) { throw new IllegalArgumentException ( "Format requires a '/' separator: " + str ) ; } String leftStr = str . substring ( 0 , separator ) ; if ( leftStr . length ( ) <= 0 ) { throw new IllegalArgumentException ( "Format invalid: " + str ) ; } String rightStr = str . substring ( separator + 1 ) ; if ( rightStr . length ( ) <= 0 ) { throw new IllegalArgumentException ( "Format invalid: " + str ) ; } DateTimeFormatter dateTimeParser = ISODateTimeFormat . dateTimeParser ( ) ; dateTimeParser = dateTimeParser . withChronology ( chrono ) ; PeriodFormatter periodParser = ISOPeriodFormat . standard ( ) ; long startInstant = 0 , endInstant = 0 ; Period period = null ; Chronology parsedChrono = null ; char c = leftStr . charAt ( 0 ) ; if ( c == 'P' || c == 'p' ) { period = periodParser . withParseType ( getPeriodType ( leftStr ) ) . parsePeriod ( leftStr ) ; } else { DateTime start = dateTimeParser . parseDateTime ( leftStr ) ; startInstant = start . getMillis ( ) ; parsedChrono = start . getChronology ( ) ; } c = rightStr . charAt ( 0 ) ; if ( c == 'P' || c == 'p' ) { if ( period != null ) { throw new IllegalArgumentException ( "Interval composed of two durations: " + str ) ; } period = periodParser . withParseType ( getPeriodType ( rightStr ) ) . parsePeriod ( rightStr ) ; chrono = ( chrono != null ? chrono : parsedChrono ) ; endInstant = chrono . add ( period , startInstant , 1 ) ; } else { DateTime end = dateTimeParser . parseDateTime ( rightStr ) ; endInstant = end . getMillis ( ) ; parsedChrono = ( parsedChrono != null ? parsedChrono : end . getChronology ( ) ) ; chrono = ( chrono != null ? chrono : parsedChrono ) ; if ( period != null ) { startInstant = chrono . add ( period , endInstant , - 1 ) ; } } writableInterval . setInterval ( startInstant , endInstant ) ; writableInterval . setChronology ( chrono ) ; } | Sets the value of the mutable interval from the string . |
32,706 | public static PeriodType years ( ) { PeriodType type = cYears ; if ( type == null ) { type = new PeriodType ( "Years" , new DurationFieldType [ ] { DurationFieldType . years ( ) } , new int [ ] { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , } ) ; cYears = type ; } return type ; } | Gets a type that defines just the years field . |
32,707 | public static PeriodType months ( ) { PeriodType type = cMonths ; if ( type == null ) { type = new PeriodType ( "Months" , new DurationFieldType [ ] { DurationFieldType . months ( ) } , new int [ ] { - 1 , 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , } ) ; cMonths = type ; } return type ; } | Gets a type that defines just the months field . |
32,708 | public static PeriodType weeks ( ) { PeriodType type = cWeeks ; if ( type == null ) { type = new PeriodType ( "Weeks" , new DurationFieldType [ ] { DurationFieldType . weeks ( ) } , new int [ ] { - 1 , - 1 , 0 , - 1 , - 1 , - 1 , - 1 , - 1 , } ) ; cWeeks = type ; } return type ; } | Gets a type that defines just the weeks field . |
32,709 | public static PeriodType days ( ) { PeriodType type = cDays ; if ( type == null ) { type = new PeriodType ( "Days" , new DurationFieldType [ ] { DurationFieldType . days ( ) } , new int [ ] { - 1 , - 1 , - 1 , 0 , - 1 , - 1 , - 1 , - 1 , } ) ; cDays = type ; } return type ; } | Gets a type that defines just the days field . |
32,710 | public static PeriodType hours ( ) { PeriodType type = cHours ; if ( type == null ) { type = new PeriodType ( "Hours" , new DurationFieldType [ ] { DurationFieldType . hours ( ) } , new int [ ] { - 1 , - 1 , - 1 , - 1 , 0 , - 1 , - 1 , - 1 , } ) ; cHours = type ; } return type ; } | Gets a type that defines just the hours field . |
32,711 | public static PeriodType minutes ( ) { PeriodType type = cMinutes ; if ( type == null ) { type = new PeriodType ( "Minutes" , new DurationFieldType [ ] { DurationFieldType . minutes ( ) } , new int [ ] { - 1 , - 1 , - 1 , - 1 , - 1 , 0 , - 1 , - 1 , } ) ; cMinutes = type ; } return type ; } | Gets a type that defines just the minutes field . |
32,712 | public static PeriodType seconds ( ) { PeriodType type = cSeconds ; if ( type == null ) { type = new PeriodType ( "Seconds" , new DurationFieldType [ ] { DurationFieldType . seconds ( ) } , new int [ ] { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 0 , - 1 , } ) ; cSeconds = type ; } return type ; } | Gets a type that defines just the seconds field . |
32,713 | public static PeriodType millis ( ) { PeriodType type = cMillis ; if ( type == null ) { type = new PeriodType ( "Millis" , new DurationFieldType [ ] { DurationFieldType . millis ( ) } , new int [ ] { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 0 , } ) ; cMillis = type ; } return type ; } | Gets a type that defines just the millis field . |
32,714 | public int indexOf ( DurationFieldType type ) { for ( int i = 0 , isize = size ( ) ; i < isize ; i ++ ) { if ( iTypes [ i ] == type ) { return i ; } } return - 1 ; } | Gets the index of the field in this period . |
32,715 | int getIndexedField ( ReadablePeriod period , int index ) { int realIndex = iIndices [ index ] ; return ( realIndex == - 1 ? 0 : period . getValue ( realIndex ) ) ; } | Gets the indexed field part of the period . |
32,716 | boolean setIndexedField ( ReadablePeriod period , int index , int [ ] values , int newValue ) { int realIndex = iIndices [ index ] ; if ( realIndex == - 1 ) { throw new UnsupportedOperationException ( "Field is not supported" ) ; } values [ realIndex ] = newValue ; return true ; } | Sets the indexed field part of the period . |
32,717 | boolean addIndexedField ( ReadablePeriod period , int index , int [ ] values , int valueToAdd ) { if ( valueToAdd == 0 ) { return false ; } int realIndex = iIndices [ index ] ; if ( realIndex == - 1 ) { throw new UnsupportedOperationException ( "Field is not supported" ) ; } values [ realIndex ] = FieldUtils . safeAdd ( values [ realIndex ] , valueToAdd ) ; return true ; } | Adds to the indexed field part of the period . |
32,718 | private PeriodType withFieldRemoved ( int indicesIndex , String name ) { int fieldIndex = iIndices [ indicesIndex ] ; if ( fieldIndex == - 1 ) { return this ; } DurationFieldType [ ] types = new DurationFieldType [ size ( ) - 1 ] ; for ( int i = 0 ; i < iTypes . length ; i ++ ) { if ( i < fieldIndex ) { types [ i ] = iTypes [ i ] ; } else if ( i > fieldIndex ) { types [ i - 1 ] = iTypes [ i ] ; } } int [ ] indices = new int [ 8 ] ; for ( int i = 0 ; i < indices . length ; i ++ ) { if ( i < indicesIndex ) { indices [ i ] = iIndices [ i ] ; } else if ( i > indicesIndex ) { indices [ i ] = ( iIndices [ i ] == - 1 ? - 1 : iIndices [ i ] - 1 ) ; } else { indices [ i ] = - 1 ; } } return new PeriodType ( getName ( ) + name , types , indices ) ; } | Removes the field specified by indices index . |
32,719 | public static void main ( String [ ] args ) { if ( args . length < 1 ) { System . err . println ( "File name is required!" ) ; usage ( ) ; System . exit ( 1 ) ; } new DateTimeBrowser ( ) . go ( args ) ; } | This is the main swing application method . It sets up and displays the initial GUI and controls execution thereafter . Everything else in this class is private please read the code . |
32,720 | public static synchronized UnsupportedDurationField getInstance ( DurationFieldType type ) { UnsupportedDurationField field ; if ( cCache == null ) { cCache = new HashMap < DurationFieldType , UnsupportedDurationField > ( 7 ) ; field = null ; } else { field = cCache . get ( type ) ; } if ( field == null ) { field = new UnsupportedDurationField ( type ) ; cCache . put ( type , field ) ; } return field ; } | Gets an instance of UnsupportedDurationField for a specific named field . The returned instance is cached . |
32,721 | private DateTimeZone loadZoneData ( String id ) { InputStream in = null ; try { in = openResource ( id ) ; DateTimeZone tz = DateTimeZoneBuilder . readFrom ( in , id ) ; iZoneInfoMap . put ( id , new SoftReference < DateTimeZone > ( tz ) ) ; return tz ; } catch ( IOException ex ) { uncaughtException ( ex ) ; iZoneInfoMap . remove ( id ) ; return null ; } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( IOException ex ) { } } } | Loads the time zone data for one id . |
32,722 | private static Map < String , Object > loadZoneInfoMap ( InputStream in ) throws IOException { Map < String , Object > map = new ConcurrentHashMap < String , Object > ( ) ; DataInputStream din = new DataInputStream ( in ) ; try { readZoneInfoMap ( din , map ) ; } finally { try { din . close ( ) ; } catch ( IOException ex ) { } } map . put ( "UTC" , new SoftReference < DateTimeZone > ( DateTimeZone . UTC ) ) ; return map ; } | Loads the zone info map . |
32,723 | private static void readZoneInfoMap ( DataInputStream din , Map < String , Object > zimap ) throws IOException { int size = din . readUnsignedShort ( ) ; String [ ] pool = new String [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { pool [ i ] = din . readUTF ( ) . intern ( ) ; } size = din . readUnsignedShort ( ) ; for ( int i = 0 ; i < size ; i ++ ) { try { zimap . put ( pool [ din . readUnsignedShort ( ) ] , pool [ din . readUnsignedShort ( ) ] ) ; } catch ( ArrayIndexOutOfBoundsException ex ) { throw new IOException ( "Corrupt zone info map" ) ; } } } | Reads the zone info map from file . |
32,724 | public long addWrapField ( long instant , int amount ) { return set ( instant , FieldUtils . getWrappedValue ( get ( instant ) , amount , 0 , iDivisor - 1 ) ) ; } | Add the specified amount to the specified time instant wrapping around within the remainder range if necessary . The amount added may be negative . |
32,725 | public long set ( long instant , int value ) { FieldUtils . verifyValueBounds ( this , value , 0 , iDivisor - 1 ) ; int divided = getDivided ( getWrappedField ( ) . get ( instant ) ) ; return getWrappedField ( ) . set ( instant , divided * iDivisor + value ) ; } | Set the specified amount of remainder units to the specified time instant . |
32,726 | public Period multipliedBy ( int scalar ) { if ( this == ZERO || scalar == 1 ) { return this ; } int [ ] values = getValues ( ) ; for ( int i = 0 ; i < values . length ; i ++ ) { values [ i ] = FieldUtils . safeMultiply ( values [ i ] , scalar ) ; } return new Period ( values , getPeriodType ( ) ) ; } | Returns a new instance with each element in this period multiplied by the specified scalar . |
32,727 | public int get ( long instant ) { int value = getWrappedField ( ) . get ( instant ) ; if ( value >= 0 ) { return value / iDivisor ; } else { return ( ( value + 1 ) / iDivisor ) - 1 ; } } | Get the amount of scaled units from the specified time instant . |
32,728 | public long addWrapField ( long instant , int amount ) { return set ( instant , FieldUtils . getWrappedValue ( get ( instant ) , amount , iMin , iMax ) ) ; } | Add to the scaled component of the specified time instant wrapping around within that component if necessary . |
32,729 | public long set ( long instant , int value ) { FieldUtils . verifyValueBounds ( this , value , iMin , iMax ) ; int remainder = getRemainder ( getWrappedField ( ) . get ( instant ) ) ; return getWrappedField ( ) . set ( instant , value * iDivisor + remainder ) ; } | Set the specified amount of scaled units to the specified time instant . |
32,730 | public Chronology getChronology ( Object object , DateTimeZone zone ) { Chronology chrono = ( ( ReadableInstant ) object ) . getChronology ( ) ; if ( chrono == null ) { return ISOChronology . getInstance ( zone ) ; } DateTimeZone chronoZone = chrono . getZone ( ) ; if ( chronoZone != zone ) { chrono = chrono . withZone ( zone ) ; if ( chrono == null ) { return ISOChronology . getInstance ( zone ) ; } } return chrono ; } | Gets the chronology which is taken from the ReadableInstant . If the chronology on the instant is null the ISOChronology in the specified time zone is used . If the chronology on the instant is not in the specified zone it is adapted . |
32,731 | public void setInto ( ReadWritablePeriod duration , Object object , Chronology chrono ) { duration . setPeriod ( ( ReadablePeriod ) object ) ; } | Extracts duration values from an object of this converter s type and sets them into the given ReadWritablePeriod . |
32,732 | public PeriodType getPeriodType ( Object object ) { ReadablePeriod period = ( ReadablePeriod ) object ; return period . getPeriodType ( ) ; } | Selects a suitable period type for the given object . |
32,733 | public long add ( long instant , int amount ) { instant = super . add ( instant , amount ) ; FieldUtils . verifyValueBounds ( this , get ( instant ) , iMin , iMax ) ; return instant ; } | Add the specified amount of offset units to the specified time instant . The amount added may be negative . |
32,734 | public long set ( long instant , int value ) { FieldUtils . verifyValueBounds ( this , value , iMin , iMax ) ; return super . set ( instant , value - iOffset ) ; } | Set the specified amount of offset units to the specified time instant . |
32,735 | public static synchronized UnsupportedDateTimeField getInstance ( DateTimeFieldType type , DurationField durationField ) { UnsupportedDateTimeField field ; if ( cCache == null ) { cCache = new HashMap < DateTimeFieldType , UnsupportedDateTimeField > ( 7 ) ; field = null ; } else { field = cCache . get ( type ) ; if ( field != null && field . getDurationField ( ) != durationField ) { field = null ; } } if ( field == null ) { field = new UnsupportedDateTimeField ( type , durationField ) ; cCache . put ( type , field ) ; } return field ; } | Gets an instance of UnsupportedDateTimeField for a specific named field . Names should be of standard format such as monthOfYear or hourOfDay . The returned instance is cached . |
32,736 | public int [ ] set ( ReadablePartial instant , int fieldIndex , int [ ] values , String text , Locale locale ) { throw unsupported ( ) ; } | Always throws UnsupportedOperationException |
32,737 | public Interval withChronology ( Chronology chronology ) { if ( getChronology ( ) == chronology ) { return this ; } return new Interval ( getStartMillis ( ) , getEndMillis ( ) , chronology ) ; } | Creates a new interval with the same start and end but a different chronology . |
32,738 | public Interval withStart ( ReadableInstant start ) { long startMillis = DateTimeUtils . getInstantMillis ( start ) ; return withStartMillis ( startMillis ) ; } | Creates a new interval with the specified start instant . |
32,739 | public Interval withEnd ( ReadableInstant end ) { long endMillis = DateTimeUtils . getInstantMillis ( end ) ; return withEndMillis ( endMillis ) ; } | Creates a new interval with the specified end instant . |
32,740 | public Interval withDurationAfterStart ( ReadableDuration duration ) { long durationMillis = DateTimeUtils . getDurationMillis ( duration ) ; if ( durationMillis == toDurationMillis ( ) ) { return this ; } Chronology chrono = getChronology ( ) ; long startMillis = getStartMillis ( ) ; long endMillis = chrono . add ( startMillis , durationMillis , 1 ) ; return new Interval ( startMillis , endMillis , chrono ) ; } | Creates a new interval with the specified duration after the start instant . |
32,741 | public Interval withDurationBeforeEnd ( ReadableDuration duration ) { long durationMillis = DateTimeUtils . getDurationMillis ( duration ) ; if ( durationMillis == toDurationMillis ( ) ) { return this ; } Chronology chrono = getChronology ( ) ; long endMillis = getEndMillis ( ) ; long startMillis = chrono . add ( endMillis , durationMillis , - 1 ) ; return new Interval ( startMillis , endMillis , chrono ) ; } | Creates a new interval with the specified duration before the end instant . |
32,742 | public Interval withPeriodAfterStart ( ReadablePeriod period ) { if ( period == null ) { return withDurationAfterStart ( null ) ; } Chronology chrono = getChronology ( ) ; long startMillis = getStartMillis ( ) ; long endMillis = chrono . add ( period , startMillis , 1 ) ; return new Interval ( startMillis , endMillis , chrono ) ; } | Creates a new interval with the specified period after the start instant . |
32,743 | public Interval withPeriodBeforeEnd ( ReadablePeriod period ) { if ( period == null ) { return withDurationBeforeEnd ( null ) ; } Chronology chrono = getChronology ( ) ; long endMillis = getEndMillis ( ) ; long startMillis = chrono . add ( period , endMillis , - 1 ) ; return new Interval ( startMillis , endMillis , chrono ) ; } | Creates a new interval with the specified period before the end instant . |
32,744 | public long addWrapField ( long instant , int months ) { return set ( instant , FieldUtils . getWrappedValue ( get ( instant ) , months , MIN , iMax ) ) ; } | Add to the Month component of the specified time instant wrapping around within that component if necessary . |
32,745 | public long set ( long instant , int value ) { long localInstant = iBase . getZone ( ) . convertUTCToLocal ( instant ) ; long difference = FieldUtils . safeSubtract ( value , get ( instant ) ) ; localInstant = getType ( ) . getField ( iBase . withUTC ( ) ) . add ( localInstant , difference ) ; return iBase . getZone ( ) . convertLocalToUTC ( localInstant , false , instant ) ; } | Set values which may be out of bounds by adding the difference between the new value and the current value . |
32,746 | public String getShortName ( Locale locale , String id , String nameKey , boolean standardTime ) { String [ ] nameSet = getNameSet ( locale , id , nameKey , standardTime ) ; return nameSet == null ? null : nameSet [ 0 ] ; } | handles changes to the nameKey better |
32,747 | public JobIntentService . GenericWorkItem dequeueWork ( ) { JobWorkItem work = null ; synchronized ( mLock ) { if ( mParams == null ) { return null ; } try { work = mParams . dequeueWork ( ) ; } catch ( SecurityException se ) { se . printStackTrace ( ) ; } } if ( work != null ) { work . getIntent ( ) . setExtrasClassLoader ( mService . getClassLoader ( ) ) ; return new WrapperWorkItem ( work ) ; } else { return null ; } } | Dequeue some work . |
32,748 | public static < T extends CharSequence > T checkNotEmpty ( final T reference ) { if ( TextUtils . isEmpty ( reference ) ) { throw new IllegalArgumentException ( ) ; } return reference ; } | Ensures that a CharSequence passed as a parameter to the calling method is not null and not empty . |
32,749 | public static void checkFlagsArgument ( final int requestedFlags , final int allowedFlags ) { if ( ( requestedFlags & allowedFlags ) != requestedFlags ) { throw new IllegalArgumentException ( "Requested flags 0x" + Integer . toHexString ( requestedFlags ) + ", but only 0x" + Integer . toHexString ( allowedFlags ) + " are allowed" ) ; } } | Check the requested flags throwing if any requested flags are outside the allowed set . |
32,750 | public static float checkArgumentFinite ( final float value , final String valueName ) { if ( Float . isNaN ( value ) ) { throw new IllegalArgumentException ( valueName + " must not be NaN" ) ; } else if ( Float . isInfinite ( value ) ) { throw new IllegalArgumentException ( valueName + " must not be infinite" ) ; } return value ; } | Ensures that the argument floating point value is a finite number . |
32,751 | public static float checkArgumentInRange ( float value , float lower , float upper , String valueName ) { if ( Float . isNaN ( value ) ) { throw new IllegalArgumentException ( valueName + " must not be NaN" ) ; } else if ( value < lower ) { throw new IllegalArgumentException ( String . format ( Locale . US , "%s is out of range of [%f, %f] (too low)" , valueName , lower , upper ) ) ; } else if ( value > upper ) { throw new IllegalArgumentException ( String . format ( Locale . US , "%s is out of range of [%f, %f] (too high)" , valueName , lower , upper ) ) ; } return value ; } | Ensures that the argument floating point value is within the inclusive range . |
32,752 | public void scheduleAsync ( final JobScheduledCallback callback ) { JobPreconditions . checkNotNull ( callback ) ; JobConfig . getExecutorService ( ) . execute ( new Runnable ( ) { public void run ( ) { try { int jobId = schedule ( ) ; callback . onJobScheduled ( jobId , getTag ( ) , null ) ; } catch ( Exception e ) { callback . onJobScheduled ( JobScheduledCallback . JOB_ID_ERROR , getTag ( ) , e ) ; } } } ) ; } | Helper method to schedule a request on a background thread . This is helpful to avoid IO operations on the main thread . The callback notifies you about the job ID or a possible failure . |
32,753 | public Builder cancelAndEdit ( ) { long scheduledAt = mScheduledAt ; JobManager . instance ( ) . cancel ( getJobId ( ) ) ; Builder builder = new Builder ( this . mBuilder ) ; mStarted = false ; if ( ! isPeriodic ( ) ) { long offset = JobConfig . getClock ( ) . currentTimeMillis ( ) - scheduledAt ; long minValue = 1L ; builder . setExecutionWindow ( Math . max ( minValue , getStartMs ( ) - offset ) , Math . max ( minValue , getEndMs ( ) - offset ) ) ; } return builder ; } | Cancel this request if it has been scheduled . Note that if the job isn t periodic then the time passed since the job has been scheduled is subtracted from the time frame . For example a job should run between 4 and 6 seconds from now . You cancel the scheduled job after 2 seconds then the job will run between 2 and 4 seconds after it s been scheduled again . |
32,754 | public static void setAllowSmallerIntervalsForMarshmallow ( boolean allowSmallerIntervals ) { if ( allowSmallerIntervals && Build . VERSION . SDK_INT >= Build . VERSION_CODES . N ) { throw new IllegalStateException ( "This method is only allowed to call on Android M or earlier" ) ; } JobConfig . allowSmallerIntervals = allowSmallerIntervals ; } | Option to override the minimum period and minimum flex for periodic jobs . This is useful for testing purposes . This method only works for Android M and earlier . Later versions throw an exception . |
32,755 | public static void setJobIdOffset ( int jobIdOffset ) { JobPreconditions . checkArgumentNonnegative ( jobIdOffset , "offset can't be negative" ) ; if ( jobIdOffset > JobIdsInternal . RESERVED_JOB_ID_RANGE_START - 500 ) { throw new IllegalArgumentException ( "offset is too close to Integer.MAX_VALUE" ) ; } JobConfig . jobIdOffset = jobIdOffset ; } | Adds an offset to the job IDs . Job IDs are generated and usually start with 1 . This offset shifts the very first job ID . |
32,756 | public static void reset ( ) { for ( JobApi api : JobApi . values ( ) ) { ENABLED_APIS . put ( api , Boolean . TRUE ) ; } allowSmallerIntervals = false ; forceAllowApi14 = false ; jobReschedulePause = DEFAULT_JOB_RESCHEDULE_PAUSE ; skipJobReschedule = false ; jobIdOffset = 0 ; forceRtc = false ; clock = Clock . DEFAULT ; executorService = DEFAULT_EXECUTOR_SERVICE ; closeDatabase = false ; JobCat . setLogcatEnabled ( true ) ; JobCat . clearLogger ( ) ; } | Resets all adjustments in the config . |
32,757 | public K ignoreUnavailable ( boolean ignore ) { setParameter ( Parameters . IGNORE_UNAVAILABLE , String . valueOf ( ignore ) ) ; return ( K ) this ; } | Ignore unavailable indices this includes indices that not exists or closed indices . |
32,758 | public K allowNoIndices ( boolean allow ) { setParameter ( Parameters . ALLOW_NO_INDICES , String . valueOf ( allow ) ) ; return ( K ) this ; } | Fail of wildcard indices expressions results into no concrete indices . |
32,759 | public K addRouting ( String routing ) { this . indexRouting . add ( routing ) ; this . searchRouting . add ( routing ) ; return ( K ) this ; } | This method will add the given routing as both search & index routing . |
32,760 | public K addRouting ( List < String > routings ) { this . indexRouting . addAll ( routings ) ; this . searchRouting . addAll ( routings ) ; return ( K ) this ; } | This method will add the given routings as both search & index routing . |
32,761 | public String getParamType ( ) { int firstColon = myValue . indexOf ( ':' ) ; if ( firstColon == - 1 || firstColon == myValue . length ( ) - 1 ) { return null ; } return myValue . substring ( 0 , firstColon ) ; } | Returns the portion of the value before the first colon |
32,762 | public String getParamName ( ) { int firstColon = myValue . indexOf ( ':' ) ; if ( firstColon == - 1 || firstColon == myValue . length ( ) - 1 ) { return null ; } int secondColon = myValue . indexOf ( ':' , firstColon + 1 ) ; if ( secondColon != - 1 ) { return myValue . substring ( firstColon + 1 , secondColon ) ; } return myValue . substring ( firstColon + 1 ) ; } | Returns the portion of the value after the first colon but before the second colon |
32,763 | public void unregisterFhirServer ( FhirServer server , Map < String , Object > props ) throws FhirConfigurationException { if ( server != null ) { String serverName = ( String ) props . get ( FhirServer . SVCPROP_SERVICE_NAME ) ; if ( serverName != null ) { FhirServer service = registeredServers . get ( serverName ) ; if ( service != null ) { log . trace ( "Unregistering FHIR Server [" + serverName + "]" ) ; service . unregisterOsgiProviders ( ) ; registeredServers . remove ( serverName ) ; log . trace ( "Dequeue any FHIR providers waiting for this server" ) ; pendingProviders . remove ( serverName ) ; if ( registeredServers . size ( ) == 0 ) { log . trace ( "Dequeue any FHIR providers waiting for the first/only server" ) ; pendingProviders . remove ( FIRST_SERVER ) ; } Collection < Collection < Object > > providers = serverProviders . get ( serverName ) ; if ( providers != null ) { serverProviders . remove ( serverName ) ; registeredProviders . removeAll ( providers ) ; } } } else { throw new FhirConfigurationException ( "FHIR Server registered in OSGi is missing the required [" + FhirServer . SVCPROP_SERVICE_NAME + "] service-property" ) ; } } } | This method will be called when a FHIR Server OSGi service is being removed from the container . This normally will only occur when its bundle is stopped because it is being removed or updated . |
32,764 | public void registerFhirProviders ( FhirProviderBundle bundle , Map < String , Object > props ) throws FhirConfigurationException { if ( bundle != null ) { Collection < Object > providers = bundle . getProviders ( ) ; if ( providers != null && ! providers . isEmpty ( ) ) { try { String serverName = ( String ) props . get ( FhirServer . SVCPROP_SERVICE_NAME ) ; String ourServerName = getServerName ( serverName ) ; String bundleName = ( String ) props . get ( "name" ) ; if ( null == bundleName ) { bundleName = "<default>" ; } log . trace ( "Register FHIR Provider Bundle [" + bundleName + "] on FHIR Server [" + ourServerName + "]" ) ; FhirServer server = registeredServers . get ( ourServerName ) ; if ( server != null ) { registerProviders ( providers , server , serverName ) ; } else { log . trace ( "Queue the Provider Bundle waiting for FHIR Server to be registered" ) ; Collection < Collection < Object > > pending ; synchronized ( pendingProviders ) { pending = pendingProviders . get ( serverName ) ; if ( null == pending ) { pending = Collections . synchronizedCollection ( new ArrayList < Collection < Object > > ( ) ) ; pendingProviders . put ( serverName , pending ) ; } } pending . add ( providers ) ; } } catch ( BadServerException e ) { throw new FhirConfigurationException ( "Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the [" + FhirServer . SVCPROP_SERVICE_NAME + "] service-property" ) ; } } } } | Register a new FHIR Provider - Bundle OSGi service . |
32,765 | public void unregisterFhirProviders ( FhirProviderBundle bundle , Map < String , Object > props ) throws FhirConfigurationException { if ( bundle != null ) { Collection < Object > providers = bundle . getProviders ( ) ; if ( providers != null && ! providers . isEmpty ( ) ) { try { registeredProviders . remove ( providers ) ; String serverName = ( String ) props . get ( FhirServer . SVCPROP_SERVICE_NAME ) ; String ourServerName = getServerName ( serverName ) ; FhirServer server = registeredServers . get ( ourServerName ) ; if ( server != null ) { server . unregisterOsgiProviders ( providers ) ; Collection < Collection < Object > > active = serverProviders . get ( serverName ) ; if ( active != null ) { active . remove ( providers ) ; } } } catch ( BadServerException e ) { throw new FhirConfigurationException ( "Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the [" + FhirServer . SVCPROP_SERVICE_NAME + "] service-property" ) ; } } } } | This method will be called when a FHIR Provider OSGi service is being removed from the container . This normally will only occur when its bundle is stopped because it is being removed or updated . |
32,766 | public void setPrecision ( TemporalPrecisionEnum thePrecision ) throws DataFormatException { if ( thePrecision == null ) { throw new NullPointerException ( "Precision may not be null" ) ; } myPrecision = thePrecision ; updateStringValue ( ) ; } | Sets the precision for this datatype |
32,767 | public void setValue ( Date theValue , TemporalPrecisionEnum thePrecision ) throws DataFormatException { if ( getTimeZone ( ) == null ) { setTimeZone ( TimeZone . getDefault ( ) ) ; } myPrecision = thePrecision ; myFractionalSeconds = "" ; if ( theValue != null ) { long millis = theValue . getTime ( ) % 1000 ; if ( millis < 0 ) { millis = 1000 + millis ; } String fractionalSeconds = Integer . toString ( ( int ) millis ) ; myFractionalSeconds = StringUtils . leftPad ( fractionalSeconds , 3 , '0' ) ; } super . setValue ( theValue ) ; } | Sets the value for this type using the given Java Date object as the time and using the specified precision as well as the local timezone as determined by the local operating system . Both of these properties may be modified in subsequent calls if neccesary . |
32,768 | public Writer getResponseWriter ( int theStatusCode , String theStatusMessage , String theContentType , String theCharset , boolean theRespondGzip ) throws UnsupportedEncodingException , IOException { return new StringWriter ( ) ; } | The response writer is a simple String Writer . All output is configured by the server . |
32,769 | public boolean isPrimitive ( String code ) { StructureDefinition sd = context . fetchResource ( StructureDefinition . class , "http://hl7.org/fhir/StructureDefinition/" + code ) ; return sd != null && sd . getKind ( ) == StructureDefinitionKind . PRIMITIVETYPE ; } | Is the given type a primitive |
32,770 | protected void initialize ( ) throws ServletException { List < IResourceProvider > resourceProviders = new ArrayList < IResourceProvider > ( ) ; resourceProviders . add ( new RestfulPatientResourceProvider ( ) ) ; resourceProviders . add ( new RestfulObservationResourceProvider ( ) ) ; setResourceProviders ( resourceProviders ) ; } | The initialize method is automatically called when the servlet is starting up so it can be used to configure the servlet to define resource providers or set up configuration interceptors etc . |
32,771 | public void round ( int thePrecision ) { if ( getValue ( ) != null ) { BigDecimal newValue = getValue ( ) . round ( new MathContext ( thePrecision ) ) ; setValue ( newValue ) ; } } | Rounds the value to the given prevision |
32,772 | public static Extension makeIssueSource ( Source source ) { Extension ex = new Extension ( ) ; ex . setUrl ( ToolingExtensions . EXT_ISSUE_SOURCE ) ; CodeType c = new CodeType ( ) ; c . setValue ( source . toString ( ) ) ; ex . setValue ( c ) ; return ex ; } | specific extension helpers |
32,773 | public void copyAdditionalPropertiesFrom ( BaseResourceMessage theMsg ) { if ( theMsg . myAttributes != null ) { if ( myAttributes == null ) { myAttributes = new HashMap < > ( ) ; } myAttributes . putAll ( theMsg . myAttributes ) ; } } | Copies any attributes from the given message into this messsage . |
32,774 | public static String encode ( List < XMLEvent > theEvents ) { try { StringWriter w = new StringWriter ( ) ; XMLEventWriter ew = XmlUtil . createXmlFragmentWriter ( w ) ; for ( XMLEvent next : theEvents ) { if ( next . isCharacters ( ) ) { ew . add ( next ) ; } else { ew . add ( next ) ; } } ew . close ( ) ; return w . toString ( ) ; } catch ( XMLStreamException e ) { throw new DataFormatException ( "Problem with the contained XML events" , e ) ; } catch ( FactoryConfigurationError e ) { throw new ConfigurationException ( e ) ; } } | Encode a set of StAX events into a String |
32,775 | public static List < XMLEvent > parse ( String theValue ) { if ( isBlank ( theValue ) ) { return Collections . emptyList ( ) ; } String val = theValue . trim ( ) ; if ( ! val . startsWith ( "<" ) ) { val = XhtmlDt . DIV_OPEN_FIRST + val + "</div>" ; } boolean hasProcessingInstruction = val . startsWith ( "<?" ) ; if ( hasProcessingInstruction && val . endsWith ( "?>" ) ) { return null ; } try { ArrayList < XMLEvent > value = new ArrayList < > ( ) ; StringReader reader = new StringReader ( val ) ; XMLEventReader er = XmlUtil . createXmlReader ( reader ) ; boolean first = true ; while ( er . hasNext ( ) ) { XMLEvent next = er . nextEvent ( ) ; if ( first ) { first = false ; continue ; } if ( er . hasNext ( ) ) { value . add ( next ) ; } } return value ; } catch ( XMLStreamException e ) { throw new DataFormatException ( "String does not appear to be valid XML/XHTML (error is \"" + e . getMessage ( ) + "\"): " + theValue , e ) ; } catch ( FactoryConfigurationError e ) { throw new ConfigurationException ( e ) ; } } | Parses an XML string into a set of StAX events |
32,776 | public void setOffsetMinutes ( int theZoneOffsetMinutes ) { int offsetAbs = Math . abs ( theZoneOffsetMinutes ) ; int mins = offsetAbs % 60 ; int hours = offsetAbs / 60 ; if ( theZoneOffsetMinutes < 0 ) { setTimeZone ( TimeZone . getTimeZone ( "GMT-" + hours + ":" + mins ) ) ; } else { setTimeZone ( TimeZone . getTimeZone ( "GMT+" + hours + ":" + mins ) ) ; } } | Sets the TimeZone offset in minutes relative to GMT |
32,777 | public void add ( int theField , int theValue ) { switch ( theField ) { case Calendar . YEAR : setValue ( DateUtils . addYears ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . MONTH : setValue ( DateUtils . addMonths ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . DATE : setValue ( DateUtils . addDays ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . HOUR : setValue ( DateUtils . addHours ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . MINUTE : setValue ( DateUtils . addMinutes ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . SECOND : setValue ( DateUtils . addSeconds ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; case Calendar . MILLISECOND : setValue ( DateUtils . addMilliseconds ( getValue ( ) , theValue ) , getPrecision ( ) ) ; break ; default : throw new IllegalArgumentException ( "Unknown field constant: " + theField ) ; } } | Adds the given amount to the field specified by theField |
32,778 | public IBundleProvider search ( @ RequiredParam ( name = Patient . SP_FAMILY ) StringParam theFamily ) { final InstantDt searchTime = InstantDt . withCurrentTime ( ) ; final List < Long > matchingResourceIds = null ; return new IBundleProvider ( ) { public Integer size ( ) { return matchingResourceIds . size ( ) ; } public List < IBaseResource > getResources ( int theFromIndex , int theToIndex ) { int end = Math . max ( theToIndex , matchingResourceIds . size ( ) - 1 ) ; List < Long > idsToReturn = matchingResourceIds . subList ( theFromIndex , end ) ; return loadResourcesByIds ( idsToReturn ) ; } public InstantDt getPublished ( ) { return searchTime ; } public Integer preferredPageSize ( ) { return null ; } public String getUuid ( ) { return null ; } } ; } | Search for Patient resources matching a given family name |
32,779 | protected ForcedId createForcedIdIfNeeded ( ResourceTable theEntity , IIdType theId , boolean theCreateForPureNumericIds ) { if ( theId . isEmpty ( ) == false && theId . hasIdPart ( ) && theEntity . getForcedId ( ) == null ) { if ( ! theCreateForPureNumericIds && IdHelperService . isValidPid ( theId ) ) { return null ; } ForcedId fid = new ForcedId ( ) ; fid . setResourceType ( theEntity . getResourceType ( ) ) ; fid . setForcedId ( theId . getIdPart ( ) ) ; fid . setResource ( theEntity ) ; theEntity . setForcedId ( fid ) ; return fid ; } return null ; } | Returns the newly created forced ID . If the entity already had a forced ID or if none was created returns null . |
32,780 | protected void validateResourceForStorage ( T theResource , ResourceTable theEntityToSave ) { Object tag = null ; int totalMetaCount = 0 ; if ( theResource instanceof IResource ) { IResource res = ( IResource ) theResource ; TagList tagList = ResourceMetadataKeyEnum . TAG_LIST . get ( res ) ; if ( tagList != null ) { tag = tagList . getTag ( Constants . TAG_SUBSETTED_SYSTEM_DSTU3 , Constants . TAG_SUBSETTED_CODE ) ; totalMetaCount += tagList . size ( ) ; } List < IdDt > profileList = ResourceMetadataKeyEnum . PROFILES . get ( res ) ; if ( profileList != null ) { totalMetaCount += profileList . size ( ) ; } } else { IAnyResource res = ( IAnyResource ) theResource ; tag = res . getMeta ( ) . getTag ( Constants . TAG_SUBSETTED_SYSTEM_DSTU3 , Constants . TAG_SUBSETTED_CODE ) ; totalMetaCount += res . getMeta ( ) . getTag ( ) . size ( ) ; totalMetaCount += res . getMeta ( ) . getProfile ( ) . size ( ) ; totalMetaCount += res . getMeta ( ) . getSecurity ( ) . size ( ) ; } if ( tag != null ) { throw new UnprocessableEntityException ( "Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data" ) ; } String resName = getContext ( ) . getResourceDefinition ( theResource ) . getName ( ) ; validateChildReferences ( theResource , resName ) ; validateMetaCount ( totalMetaCount ) ; } | This method is invoked immediately before storing a new resource or an update to an existing resource to allow the DAO to ensure that it is valid for persistence . By default checks for the subsetted tag and rejects resources which have it . Subclasses should call the superclass implementation to preserve this check . |
32,781 | public static void setExtension ( Element element , boolean modifier , String uri , Type value ) throws FHIRException { if ( value == null ) { if ( element instanceof BackboneElement ) for ( Extension e : ( ( BackboneElement ) element ) . getModifierExtension ( ) ) { if ( uri . equals ( e . getUrl ( ) ) ) ( ( BackboneElement ) element ) . getModifierExtension ( ) . remove ( e ) ; } for ( Extension e : element . getExtension ( ) ) { if ( uri . equals ( e . getUrl ( ) ) ) element . getExtension ( ) . remove ( e ) ; } } else { boolean found = false ; if ( element instanceof BackboneElement ) for ( Extension e : ( ( BackboneElement ) element ) . getModifierExtension ( ) ) { if ( uri . equals ( e . getUrl ( ) ) ) { if ( ! modifier ) throw new FHIRException ( "Error adding extension \"" + uri + "\": found an existing modifier extension, and the extension is not marked as a modifier" ) ; e . setValue ( value ) ; found = true ; } } for ( Extension e : element . getExtension ( ) ) { if ( uri . equals ( e . getUrl ( ) ) ) { if ( modifier ) throw new FHIRException ( "Error adding extension \"" + uri + "\": found an existing extension, and the extension is marked as a modifier" ) ; e . setValue ( value ) ; found = true ; } } if ( ! found ) { Extension ex = new Extension ( ) . setUrl ( uri ) . setValue ( value ) ; if ( modifier ) { if ( ! ( element instanceof BackboneElement ) ) throw new FHIRException ( "Error adding extension \"" + uri + "\": extension is marked as a modifier, but element is not a backbone element" ) ; ( ( BackboneElement ) element ) . getModifierExtension ( ) . add ( ex ) ; } else { element . getExtension ( ) . add ( ex ) ; } } } } | set the value of an extension on the element . if value == null make sure it doesn t exist |
32,782 | public String getBaseForServer ( ) { final String url = getUriInfo ( ) . getBaseUri ( ) . toASCIIString ( ) ; return StringUtils . isNotBlank ( url ) && url . endsWith ( "/" ) ? url . substring ( 0 , url . length ( ) - 1 ) : url ; } | This method returns the server base independent of the request or resource . |
32,783 | public Map < String , String [ ] > getParameters ( ) { final MultivaluedMap < String , String > queryParameters = getUriInfo ( ) . getQueryParameters ( ) ; final HashMap < String , String [ ] > params = new HashMap < String , String [ ] > ( ) ; for ( final Entry < String , List < String > > paramEntry : queryParameters . entrySet ( ) ) { params . put ( paramEntry . getKey ( ) , paramEntry . getValue ( ) . toArray ( new String [ paramEntry . getValue ( ) . size ( ) ] ) ) ; } return params ; } | This method returns the query parameters |
32,784 | public Response handleException ( final JaxRsRequest theRequest , final Throwable theException ) throws IOException { if ( theException instanceof JaxRsResponseException ) { return new JaxRsExceptionInterceptor ( ) . convertExceptionIntoResponse ( theRequest , ( JaxRsResponseException ) theException ) ; } else { return new JaxRsExceptionInterceptor ( ) . convertExceptionIntoResponse ( theRequest , new JaxRsExceptionInterceptor ( ) . convertException ( this , theException ) ) ; } } | Convert an exception to a response |
32,785 | @ SuppressWarnings ( "unused" ) @ Scheduled ( fixedDelay = DateUtils . MILLIS_PER_MINUTE ) public void syncSubscriptions ( ) { if ( ! mySyncSubscriptionsSemaphore . tryAcquire ( ) ) { return ; } try { doSyncSubscriptionsWithRetry ( ) ; } finally { mySyncSubscriptionsSemaphore . release ( ) ; } } | Read the existing subscriptions from the database |
32,786 | @ SuppressWarnings ( "UseBulkOperation" ) public List < Query > getCapturedQueries ( ) { ArrayList < Query > retVal = new ArrayList < > ( CAPACITY ) ; myQueries . forEach ( retVal :: add ) ; return Collections . unmodifiableList ( retVal ) ; } | Index 0 is oldest |
32,787 | public void logUpdateQueriesForCurrentThread ( ) { List < String > queries = getUpdateQueriesForCurrentThread ( ) . stream ( ) . map ( CircularQueueCaptureQueriesListener :: formatQueryAsSql ) . collect ( Collectors . toList ( ) ) ; ourLog . info ( "Select Queries:\n{}" , String . join ( "\n" , queries ) ) ; } | Log all captured UPDATE queries |
32,788 | public void logFirstSelectQueryForCurrentThread ( ) { String firstSelectQuery = getSelectQueriesForCurrentThread ( ) . stream ( ) . findFirst ( ) . map ( CircularQueueCaptureQueriesListener :: formatQueryAsSql ) . orElse ( "NONE FOUND" ) ; ourLog . info ( "First select Query:\n{}" , firstSelectQuery ) ; } | Log first captured SELECT query |
32,789 | public IServerInterceptor loggingInterceptor ( ) { LoggingInterceptor retVal = new LoggingInterceptor ( ) ; retVal . setLoggerName ( "fhirtest.access" ) ; retVal . setMessageFormat ( "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]" ) ; retVal . setLogExceptions ( true ) ; retVal . setErrorMessageFormat ( "ERROR - ${requestVerb} ${requestUrl}" ) ; return retVal ; } | Do some fancy logging to create a nice access log that has details about each incoming request . |
32,790 | @ Bean ( autowire = Autowire . BY_TYPE ) public IServerInterceptor responseHighlighterInterceptor ( ) { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor ( ) ; return retVal ; } | This interceptor adds some pretty syntax highlighting in responses when a browser is detected |
32,791 | public boolean asBoolean ( Object value ) { if ( value == null ) { return false ; } if ( value instanceof Boolean ) { return ( Boolean ) value ; } return true ; } | Convert value to a boolean . Note that only nil and false are false all other values are true . |
32,792 | public Number asNumber ( Object value ) throws NumberFormatException { if ( value instanceof Number ) { return ( Number ) value ; } String str = String . valueOf ( value ) ; return str . matches ( "\\d+" ) ? Long . valueOf ( str ) : Double . valueOf ( str ) ; } | Returns value as a Number . Strings will be coerced into either a Long or Double . |
32,793 | public String asString ( Object value ) { if ( value == null ) { return "" ; } if ( ! this . isArray ( value ) ) { return String . valueOf ( value ) ; } Object [ ] array = this . asArray ( value ) ; StringBuilder builder = new StringBuilder ( ) ; for ( Object obj : array ) { builder . append ( this . asString ( obj ) ) ; } return builder . toString ( ) ; } | Returns value as a String . |
32,794 | public boolean isArray ( Object value ) { return value != null && ( value . getClass ( ) . isArray ( ) || value instanceof List ) ; } | Returns true iff value is an array or a java . util . List . |
32,795 | public boolean isNumber ( Object value ) { if ( value == null ) { return false ; } if ( value instanceof Number ) { return true ; } if ( String . valueOf ( value ) . matches ( "\\d+" ) ) { return true ; } try { Double . parseDouble ( String . valueOf ( value ) ) ; } catch ( Exception e ) { return false ; } return true ; } | Returns true iff value is a Number . |
32,796 | private void storePatient ( final Patient patient ) { try { patients . put ( patient . getIdentifierFirstRep ( ) . getValue ( ) , patient ) ; final String bundleToString = currentPatientsAsJsonString ( ) ; broadcaster . broadcast ( new OutboundEvent . Builder ( ) . name ( "patients" ) . data ( String . class , bundleToString ) . build ( ) ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } } | Conceptual wrapper for storing in a db |
32,797 | public void load ( String filename ) throws FileNotFoundException , SAXException , IOException , ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; loadMessages ( builder . parse ( new CSFileInputStream ( filename ) ) ) ; } | Load from the XML translations file maintained by the FHIR project |
32,798 | public String getMessage ( String id , String defaultMsg ) { return getMessage ( id , lang , defaultMsg ) ; } | use configured language |
32,799 | public IBase cloneInto ( IBase theSource , IBase theTarget , boolean theIgnoreMissingFields ) { Validate . notNull ( theSource , "theSource must not be null" ) ; Validate . notNull ( theTarget , "theTarget must not be null" ) ; if ( theSource instanceof IPrimitiveType < ? > ) { if ( theTarget instanceof IPrimitiveType < ? > ) { ( ( IPrimitiveType < ? > ) theTarget ) . setValueAsString ( ( ( IPrimitiveType < ? > ) theSource ) . getValueAsString ( ) ) ; return theSource ; } if ( theIgnoreMissingFields ) { return theSource ; } throw new DataFormatException ( "Can not copy value from primitive of type " + theSource . getClass ( ) . getName ( ) + " into type " + theTarget . getClass ( ) . getName ( ) ) ; } BaseRuntimeElementCompositeDefinition < ? > sourceDef = ( BaseRuntimeElementCompositeDefinition < ? > ) myContext . getElementDefinition ( theSource . getClass ( ) ) ; BaseRuntimeElementCompositeDefinition < ? > targetDef = ( BaseRuntimeElementCompositeDefinition < ? > ) myContext . getElementDefinition ( theTarget . getClass ( ) ) ; List < BaseRuntimeChildDefinition > children = sourceDef . getChildren ( ) ; if ( sourceDef instanceof RuntimeExtensionDtDefinition ) { children = ( ( RuntimeExtensionDtDefinition ) sourceDef ) . getChildrenIncludingUrl ( ) ; } for ( BaseRuntimeChildDefinition nextChild : children ) for ( IBase nextValue : nextChild . getAccessor ( ) . getValues ( theSource ) ) { String elementName = nextChild . getChildNameByDatatype ( nextValue . getClass ( ) ) ; BaseRuntimeChildDefinition targetChild = targetDef . getChildByName ( elementName ) ; if ( targetChild == null ) { if ( theIgnoreMissingFields ) { continue ; } throw new DataFormatException ( "Type " + theTarget . getClass ( ) . getName ( ) + " does not have a child with name " + elementName ) ; } BaseRuntimeElementDefinition < ? > element = myContext . getElementDefinition ( nextValue . getClass ( ) ) ; IBase target = element . newInstance ( ) ; targetChild . getMutator ( ) . addValue ( theTarget , target ) ; cloneInto ( nextValue , target , theIgnoreMissingFields ) ; } return theTarget ; } | Clones all values from a source object into the equivalent fields in a target object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.