idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
32,900
public static String constructAbsoluteUrl ( String theBase , String theEndpoint ) { if ( theEndpoint == null ) { return null ; } if ( isAbsolute ( theEndpoint ) ) { return theEndpoint ; } if ( theBase == null ) { return theEndpoint ; } try { return new URL ( new URL ( theBase ) , theEndpoint ) . toString ( ) ; } catch ( MalformedURLException e ) { ourLog . warn ( "Failed to resolve relative URL[" + theEndpoint + "] against absolute base[" + theBase + "]" , e ) ; return theEndpoint ; } }
Resolve a relative URL - THIS METHOD WILL NOT FAIL but will log a warning and return theEndpoint if the input is invalid .
32,901
public static String sanitizeUrlPart ( String theString ) { if ( theString == null ) { return null ; } boolean needsSanitization = isNeedsSanitization ( theString ) ; if ( needsSanitization ) { StringBuilder buffer = new StringBuilder ( theString . length ( ) + 10 ) ; for ( int j = 0 ; j < theString . length ( ) ; j ++ ) { char nextChar = theString . charAt ( j ) ; switch ( nextChar ) { case '"' : buffer . append ( "&quot;" ) ; break ; case '<' : buffer . append ( "&lt;" ) ; break ; default : buffer . append ( nextChar ) ; break ; } } return buffer . toString ( ) ; } return theString ; }
This method specifically HTML - encodes the &quot ; and &lt ; characters in order to prevent injection attacks
32,902
public TokenOrListParam add ( String theSystem , String theValue ) { add ( new TokenParam ( theSystem , theValue ) ) ; return this ; }
Add a new token to this list
32,903
private static boolean isAvailable ( int thePort ) { ourLog . info ( "Testing a bind on thePort {}" , thePort ) ; try ( ServerSocket ss = new ServerSocket ( ) ) { ss . setReuseAddress ( true ) ; ss . bind ( new InetSocketAddress ( "0.0.0.0" , thePort ) ) ; try ( DatagramSocket ds = new DatagramSocket ( ) ) { ds . setReuseAddress ( true ) ; ds . connect ( new InetSocketAddress ( "127.0.0.1" , thePort ) ) ; ourLog . info ( "Successfully bound thePort {}" , thePort ) ; } catch ( IOException e ) { ourLog . info ( "Failed to bind thePort {}: {}" , thePort , e . toString ( ) ) ; return false ; } } catch ( IOException e ) { ourLog . info ( "Failed to bind thePort {}: {}" , thePort , e . toString ( ) ) ; return false ; } try ( ServerSocket ss = new ServerSocket ( ) ) { ss . setReuseAddress ( true ) ; ss . bind ( new InetSocketAddress ( "localhost" , thePort ) ) ; } catch ( IOException e ) { ourLog . info ( "Failed to bind thePort {}: {}" , thePort , e . toString ( ) ) ; return false ; } return true ; }
This method checks if we are able to bind a given port to both 0 . 0 . 0 . 0 and localhost in order to be sure it s truly available .
32,904
public List < RuntimeSearchParam > getSearchParamsForCompartmentName ( String theCompartmentName ) { validateSealed ( ) ; List < RuntimeSearchParam > retVal = myCompartmentNameToSearchParams . get ( theCompartmentName ) ; if ( retVal == null ) { return Collections . emptyList ( ) ; } return retVal ; }
Will not return null
32,905
public Resource parse ( InputStream input ) throws IOException , FHIRFormatError { try { XmlPullParser xpp = loadXml ( input ) ; return parse ( xpp ) ; } catch ( XmlPullParserException e ) { throw new FHIRFormatError ( e . getMessage ( ) , e ) ; } }
Parse content that is known to be a resource
32,906
public Resource parse ( XmlPullParser xpp ) throws IOException , FHIRFormatError , XmlPullParserException { if ( xpp . getNamespace ( ) == null ) throw new FHIRFormatError ( "This does not appear to be a FHIR resource (no namespace '" + xpp . getNamespace ( ) + "') (@ /) " + Integer . toString ( xpp . getEventType ( ) ) ) ; if ( ! xpp . getNamespace ( ) . equals ( FHIR_NS ) ) throw new FHIRFormatError ( "This does not appear to be a FHIR resource (wrong namespace '" + xpp . getNamespace ( ) + "') (@ /)" ) ; return parseResource ( xpp ) ; }
parse xml that is known to be a resource and that is already being read by an XML Pull Parser This is if a resource is in a bigger piece of XML .
32,907
private List < Element > findQuestionAnswers ( Element questionnaireResponse , String question ) { List < Element > retVal = new ArrayList < > ( ) ; List < Element > items = questionnaireResponse . getChildren ( ITEM_ELEMENT ) ; for ( Element next : items ) { if ( hasLinkId ( next , question ) ) { List < Element > answers = extractAnswer ( next ) ; retVal . addAll ( answers ) ; } retVal . addAll ( findQuestionAnswers ( next , question ) ) ; } return retVal ; }
Recursively look for answers to questions with the given link id
32,908
protected void sendNotification ( ResourceDeliveryMessage theMsg ) { Map < String , List < String > > params = new HashMap < > ( ) ; List < Header > headers = new ArrayList < > ( ) ; if ( theMsg . getSubscription ( ) . getHeaders ( ) != null ) { theMsg . getSubscription ( ) . getHeaders ( ) . stream ( ) . filter ( Objects :: nonNull ) . forEach ( h -> { final int sep = h . indexOf ( ':' ) ; if ( sep > 0 ) { final String name = h . substring ( 0 , sep ) ; final String value = h . substring ( sep + 1 ) ; if ( StringUtils . isNotBlank ( name ) ) { headers . add ( new Header ( name . trim ( ) , value . trim ( ) ) ) ; } } } ) ; } StringBuilder url = new StringBuilder ( theMsg . getSubscription ( ) . getEndpointUrl ( ) ) ; IHttpClient client = myFhirContext . getRestfulClientFactory ( ) . getHttpClient ( url , params , "" , RequestTypeEnum . POST , headers ) ; IHttpRequest request = client . createParamRequest ( myFhirContext , params , null ) ; try { IHttpResponse response = request . execute ( ) ; response . close ( ) ; } catch ( IOException e ) { ourLog . error ( "Error trying to reach " + theMsg . getSubscription ( ) . getEndpointUrl ( ) ) ; e . printStackTrace ( ) ; throw new ResourceNotFoundException ( e . getMessage ( ) ) ; } }
Sends a POST notification without a payload
32,909
private List < BaseInvoker > getInvokersForPointcut ( Pointcut thePointcut ) { List < BaseInvoker > invokers ; synchronized ( myRegistryMutex ) { List < BaseInvoker > globalInvokers = myGlobalInvokers . get ( thePointcut ) ; List < BaseInvoker > anonymousInvokers = myAnonymousInvokers . get ( thePointcut ) ; List < BaseInvoker > threadLocalInvokers = null ; if ( myThreadlocalInvokersEnabled ) { ListMultimap < Pointcut , BaseInvoker > pointcutToInvokers = myThreadlocalInvokers . get ( ) ; if ( pointcutToInvokers != null ) { threadLocalInvokers = pointcutToInvokers . get ( thePointcut ) ; } } invokers = union ( globalInvokers , anonymousInvokers , threadLocalInvokers ) ; } return invokers ; }
Returns an ordered list of invokers for the given pointcut . Note that a new and stable list is returned to .. do whatever you want with it .
32,910
private final List < BaseInvoker > union ( List < BaseInvoker > ... theInvokersLists ) { List < BaseInvoker > haveOne = null ; boolean haveMultiple = false ; for ( List < BaseInvoker > nextInvokerList : theInvokersLists ) { if ( nextInvokerList == null || nextInvokerList . isEmpty ( ) ) { continue ; } if ( haveOne == null ) { haveOne = nextInvokerList ; } else { haveMultiple = true ; } } if ( haveOne == null ) { return Collections . emptyList ( ) ; } List < BaseInvoker > retVal ; if ( haveMultiple == false ) { if ( haveOne == theInvokersLists [ 0 ] ) { retVal = haveOne ; } else { retVal = new ArrayList < > ( haveOne ) ; retVal . sort ( Comparator . naturalOrder ( ) ) ; } } else { retVal = Arrays . stream ( theInvokersLists ) . filter ( t -> t != null ) . flatMap ( t -> t . stream ( ) ) . sorted ( ) . collect ( Collectors . toList ( ) ) ; } return retVal ; }
First argument must be the global invoker list!!
32,911
boolean haveAppropriateParams ( Pointcut thePointcut , HookParams theParams ) { Validate . isTrue ( theParams . getParamsForType ( ) . values ( ) . size ( ) == thePointcut . getParameterTypes ( ) . size ( ) , "Wrong number of params for pointcut %s - Wanted %s but found %s" , thePointcut . name ( ) , toErrorString ( thePointcut . getParameterTypes ( ) ) , theParams . getParamsForType ( ) . values ( ) . stream ( ) . map ( t -> t != null ? t . getClass ( ) . getSimpleName ( ) : "null" ) . sorted ( ) . collect ( Collectors . toList ( ) ) ) ; List < String > wantedTypes = new ArrayList < > ( thePointcut . getParameterTypes ( ) ) ; ListMultimap < Class < ? > , Object > givenTypes = theParams . getParamsForType ( ) ; for ( Class < ? > nextTypeClass : givenTypes . keySet ( ) ) { String nextTypeName = nextTypeClass . getName ( ) ; for ( Object nextParamValue : givenTypes . get ( nextTypeClass ) ) { Validate . isTrue ( nextParamValue == null || nextTypeClass . isAssignableFrom ( nextParamValue . getClass ( ) ) , "Invalid params for pointcut %s - %s is not of type %s" , thePointcut . name ( ) , nextParamValue != null ? nextParamValue . getClass ( ) : "null" , nextTypeClass ) ; Validate . isTrue ( wantedTypes . remove ( nextTypeName ) , "Invalid params for pointcut %s - Wanted %s but found %s" , thePointcut . name ( ) , toErrorString ( thePointcut . getParameterTypes ( ) ) , nextTypeName ) ; } } return true ; }
Only call this when assertions are enabled it s expensive
32,912
public String getEstimatedTimeRemaining ( double theCompleteToDate , double theTotal ) { double millis = getMillis ( ) ; long millisRemaining = ( long ) ( ( ( theTotal / theCompleteToDate ) * millis ) - ( millis ) ) ; return formatMillis ( millisRemaining ) ; }
Given an amount of something completed so far and a total amount calculates how long it will take for something to complete
32,913
static private void append ( StringBuilder tgt , String pfx , int dgt , long val ) { tgt . append ( pfx ) ; if ( dgt > 1 ) { int pad = ( dgt - 1 ) ; for ( long xa = val ; xa > 9 && pad > 0 ; xa /= 10 ) { pad -- ; } for ( int xa = 0 ; xa < pad ; xa ++ ) { tgt . append ( '0' ) ; } } tgt . append ( val ) ; }
Append a right - aligned and zero - padded numeric value to a StringBuilder .
32,914
public static String cleanWhitespace ( String theResult ) { StringBuilder b = new StringBuilder ( ) ; boolean inWhitespace = false ; boolean betweenTags = false ; boolean lastNonWhitespaceCharWasTagEnd = false ; boolean inPre = false ; for ( int i = 0 ; i < theResult . length ( ) ; i ++ ) { char nextChar = theResult . charAt ( i ) ; if ( inPre ) { b . append ( nextChar ) ; continue ; } else if ( nextChar == '>' ) { b . append ( nextChar ) ; betweenTags = true ; lastNonWhitespaceCharWasTagEnd = true ; continue ; } else if ( nextChar == '\n' || nextChar == '\r' ) { continue ; } if ( betweenTags ) { if ( Character . isWhitespace ( nextChar ) ) { inWhitespace = true ; } else if ( nextChar == '<' ) { if ( inWhitespace && ! lastNonWhitespaceCharWasTagEnd ) { b . append ( ' ' ) ; } b . append ( nextChar ) ; inWhitespace = false ; betweenTags = false ; lastNonWhitespaceCharWasTagEnd = false ; if ( i + 3 < theResult . length ( ) ) { char char1 = Character . toLowerCase ( theResult . charAt ( i + 1 ) ) ; char char2 = Character . toLowerCase ( theResult . charAt ( i + 2 ) ) ; char char3 = Character . toLowerCase ( theResult . charAt ( i + 3 ) ) ; char char4 = Character . toLowerCase ( ( i + 4 < theResult . length ( ) ) ? theResult . charAt ( i + 4 ) : ' ' ) ; if ( char1 == 'p' && char2 == 'r' && char3 == 'e' ) { inPre = true ; } else if ( char1 == '/' && char2 == 'p' && char3 == 'r' && char4 == 'e' ) { inPre = false ; } } } else { lastNonWhitespaceCharWasTagEnd = false ; if ( inWhitespace ) { b . append ( ' ' ) ; inWhitespace = false ; } b . append ( nextChar ) ; } } else { b . append ( nextChar ) ; } } return b . toString ( ) ; }
Trims the superfluous whitespace out of an HTML block
32,915
@ Path ( "/metadata" ) public Response conformance ( ) throws IOException { setUpPostConstruct ( ) ; Builder request = getRequest ( RequestTypeEnum . OPTIONS , RestOperationTypeEnum . METADATA ) ; IRestfulResponse response = request . build ( ) . getResponse ( ) ; response . addHeader ( Constants . HEADER_CORS_ALLOW_ORIGIN , "*" ) ; IBaseResource conformance ; FhirVersionEnum fhirContextVersion = super . getFhirContext ( ) . getVersion ( ) . getVersion ( ) ; switch ( fhirContextVersion ) { case R4 : conformance = myR4CapabilityStatement ; break ; case DSTU3 : conformance = myDstu3CapabilityStatement ; break ; case DSTU2_1 : conformance = myDstu2_1Conformance ; break ; case DSTU2_HL7ORG : conformance = myDstu2Hl7OrgConformance ; break ; case DSTU2 : conformance = myDstu2Conformance ; break ; default : throw new ConfigurationException ( "Unsupported Fhir version: " + fhirContextVersion ) ; } if ( conformance != null ) { Set < SummaryEnum > summaryMode = Collections . emptySet ( ) ; return ( Response ) response . streamResponseAsResource ( conformance , false , summaryMode , Constants . STATUS_HTTP_200_OK , null , true , false ) ; } return ( Response ) response . returnResponse ( null , Constants . STATUS_HTTP_500_INTERNAL_ERROR , true , null , getResourceType ( ) . getSimpleName ( ) ) ; }
This method will retrieve the conformance using the http GET method
32,916
protected boolean shouldEncodePath ( IResource theResource , String thePath ) { if ( myDontEncodeElements != null ) { String resourceName = myContext . getResourceDefinition ( theResource ) . getName ( ) ; if ( myDontEncodeElements . stream ( ) . anyMatch ( t -> t . equalsPath ( resourceName + "." + thePath ) ) ) { return false ; } else if ( myDontEncodeElements . stream ( ) . anyMatch ( t -> t . equalsPath ( "*." + thePath ) ) ) { return false ; } } return true ; }
Used for DSTU2 only
32,917
protected AllergyIntoleranceReactionComponent processAdverseReactionObservation ( Element reaction ) throws Exception { checkNoNegationOrNullFlavor ( reaction , "Adverse Reaction Observation" ) ; checkNoSubject ( reaction , "Adverse Reaction Observation" ) ; AllergyIntoleranceReactionComponent ar = new AllergyIntoleranceReactionComponent ( ) ; for ( Element e : cda . getChildren ( reaction , "id" ) ) ToolingExtensions . addIdentifier ( ar , convert . makeIdentifierFromII ( e ) ) ; ar . setOnsetElement ( convert . makeDateTimeFromIVL ( cda . getChild ( reaction , "effectiveTime" ) ) ) ; ar . getManifestation ( ) . add ( convert . makeCodeableConceptFromCD ( cda . getChild ( reaction , "value" ) ) ) ; ar . setSeverity ( readSeverity ( cda . getSeverity ( reaction ) ) ) ; return ar ; }
this is going to be a contained resource so we aren t going to generate any narrative
32,918
protected IHttpRequest createHttpRequest ( String theUrl , EncodingEnum theEncoding , RequestTypeEnum theRequestType ) { IHttpClient httpClient = getRestfulClientFactory ( ) . getHttpClient ( new StringBuilder ( theUrl ) , null , null , theRequestType , myHeaders ) ; return httpClient . createGetRequest ( getContext ( ) , theEncoding ) ; }
Create an HTTP request for the given url encoding and request - type
32,919
private void addNewVersion ( Patient thePatient , Long theId ) { InstantDt publishedDate ; if ( ! myIdToPatientVersions . containsKey ( theId ) ) { myIdToPatientVersions . put ( theId , new LinkedList < Patient > ( ) ) ; publishedDate = InstantDt . withCurrentTime ( ) ; } else { Patient currentPatitne = myIdToPatientVersions . get ( theId ) . getLast ( ) ; Map < ResourceMetadataKeyEnum < ? > , Object > resourceMetadata = currentPatitne . getResourceMetadata ( ) ; publishedDate = ( InstantDt ) resourceMetadata . get ( ResourceMetadataKeyEnum . PUBLISHED ) ; } thePatient . getResourceMetadata ( ) . put ( ResourceMetadataKeyEnum . PUBLISHED , publishedDate ) ; thePatient . getResourceMetadata ( ) . put ( ResourceMetadataKeyEnum . UPDATED , InstantDt . withCurrentTime ( ) ) ; Deque < Patient > existingVersions = myIdToPatientVersions . get ( theId ) ; String newVersion = Integer . toString ( existingVersions . size ( ) ) ; IdDt newId = new IdDt ( "Patient" , Long . toString ( theId ) , newVersion ) ; thePatient . setId ( newId ) ; existingVersions . add ( thePatient ) ; }
Stores a new version of the patient in memory so that it can be retrieved later .
32,920
private void validateResource ( Patient thePatient ) { if ( thePatient . getNameFirstRep ( ) . getFamilyFirstRep ( ) . isEmpty ( ) ) { OperationOutcome outcome = new OperationOutcome ( ) ; outcome . addIssue ( ) . setSeverity ( IssueSeverityEnum . FATAL ) . setDetails ( "No family name provided, Patient resources must have at least one family name." ) ; throw new UnprocessableEntityException ( outcome ) ; } }
This method just provides simple business validation for resources we are storing .
32,921
public static void main ( String [ ] args ) throws IOException { FhirContext ctx = FhirContext . forDstu2 ( ) ; String serverBase = "http://fhir.healthintersections.com.au/open" ; ClientInterface client = ctx . newRestfulClient ( ClientInterface . class , serverBase ) ; List < Patient > patients = client . findPatientsForMrn ( new IdentifierDt ( "urn:oid:1.2.36.146.595.217.0.1" , "12345" ) ) ; System . out . println ( "Found " + patients . size ( ) + " patients" ) ; Patient patient = patients . get ( 0 ) ; System . out . println ( "Patient Last Name: " + patient . getName ( ) . get ( 0 ) . getFamily ( ) . get ( 0 ) . getValue ( ) ) ; ResourceReferenceDt managingRef = patient . getManagingOrganization ( ) ; Organization org = ( Organization ) managingRef . loadResource ( client ) ; System . out . println ( org . getName ( ) ) ; }
The main method here will directly call an open FHIR server and retrieve a list of resources matching a given criteria then load a linked resource .
32,922
public static void addIssue ( FhirContext theCtx , IBaseOperationOutcome theOperationOutcome , String theSeverity , String theDetails , String theLocation , String theCode ) { IBase issue = createIssue ( theCtx , theOperationOutcome ) ; populateDetails ( theCtx , issue , theSeverity , theDetails , theLocation , theCode ) ; }
Add an issue to an OperationOutcome
32,923
public static boolean hasIssues ( FhirContext theCtx , IBaseOperationOutcome theOutcome ) { if ( theOutcome == null ) { return false ; } RuntimeResourceDefinition ooDef = theCtx . getResourceDefinition ( theOutcome ) ; BaseRuntimeChildDefinition issueChild = ooDef . getChildByName ( "issue" ) ; return issueChild . getAccessor ( ) . getValues ( theOutcome ) . size ( ) > 0 ; }
Returns true if the given OperationOutcome has 1 or more Operation . issue repetitions
32,924
public void setDivAsString ( String theString ) { XhtmlNode div ; if ( StringUtils . isNotBlank ( theString ) ) { div = new XhtmlNode ( ) ; div . setValueAsString ( theString ) ; } else { div = null ; } setDiv ( div ) ; }
Sets the value of
32,925
public String getStringProperty ( String pstrSection , String pstrProp ) { String strRet = null ; INIProperty objProp = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { objProp = objSec . getProperty ( pstrProp ) ; if ( objProp != null ) { strRet = objProp . getPropValue ( ) ; objProp = null ; } objSec = null ; } return strRet ; }
Returns the specified string property from the specified section .
32,926
public Integer getIntegerProperty ( String pstrSection , String pstrProp ) { Integer intRet = null ; String strVal = null ; INIProperty objProp = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { objProp = objSec . getProperty ( pstrProp ) ; try { if ( objProp != null ) { strVal = objProp . getPropValue ( ) ; if ( strVal != null ) intRet = new Integer ( strVal ) ; } } catch ( NumberFormatException NFExIgnore ) { } finally { if ( objProp != null ) objProp = null ; } objSec = null ; } return intRet ; }
Returns the specified integer property from the specified section .
32,927
public Long getLongProperty ( String pstrSection , String pstrProp ) { Long lngRet = null ; String strVal = null ; INIProperty objProp = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { objProp = objSec . getProperty ( pstrProp ) ; try { if ( objProp != null ) { strVal = objProp . getPropValue ( ) ; if ( strVal != null ) lngRet = new Long ( strVal ) ; } } catch ( NumberFormatException NFExIgnore ) { } finally { if ( objProp != null ) objProp = null ; } objSec = null ; } return lngRet ; }
Returns the specified long property from the specified section .
32,928
public Double getDoubleProperty ( String pstrSection , String pstrProp ) { Double dblRet = null ; String strVal = null ; INIProperty objProp = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { objProp = objSec . getProperty ( pstrProp ) ; try { if ( objProp != null ) { strVal = objProp . getPropValue ( ) ; if ( strVal != null ) dblRet = new Double ( strVal ) ; } } catch ( NumberFormatException NFExIgnore ) { } finally { if ( objProp != null ) objProp = null ; } objSec = null ; } return dblRet ; }
Returns the specified double property from the specified section .
32,929
public void addSection ( String pstrSection , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setSecComments ( delRemChars ( pstrComments ) ) ; objSec = null ; }
Sets the comments associated with a section .
32,930
public void setStringProperty ( String pstrSection , String pstrProp , String pstrVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , pstrVal , pstrComments ) ; }
Sets the specified string property .
32,931
public void setBooleanProperty ( String pstrSection , String pstrProp , boolean pblnVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } if ( pblnVal ) objSec . setProperty ( pstrProp , "TRUE" , pstrComments ) ; else objSec . setProperty ( pstrProp , "FALSE" , pstrComments ) ; }
Sets the specified boolean property .
32,932
public void setIntegerProperty ( String pstrSection , String pstrProp , int pintVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , Integer . toString ( pintVal ) , pstrComments ) ; }
Sets the specified integer property .
32,933
public void setLongProperty ( String pstrSection , String pstrProp , long plngVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , Long . toString ( plngVal ) , pstrComments ) ; }
Sets the specified long property .
32,934
public void setDoubleProperty ( String pstrSection , String pstrProp , double pdblVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , Double . toString ( pdblVal ) , pstrComments ) ; }
Sets the specified double property .
32,935
public void setDateProperty ( String pstrSection , String pstrProp , Date pdtVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , utilDateToStr ( pdtVal , this . mstrDateFmt ) , pstrComments ) ; }
Sets the specified java . util . Date property .
32,936
public void setTimestampProperty ( String pstrSection , String pstrProp , Timestamp ptsVal , String pstrComments ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec == null ) { objSec = new INISection ( pstrSection ) ; this . mhmapSections . put ( pstrSection , objSec ) ; } objSec . setProperty ( pstrProp , timeToStr ( ptsVal , this . mstrTimeStampFmt ) , pstrComments ) ; }
Sets the specified java . sql . Timestamp property .
32,937
public String [ ] getAllSectionNames ( ) { int iCntr = 0 ; Iterator < String > iter = null ; String [ ] arrRet = null ; try { if ( this . mhmapSections . size ( ) > 0 ) { arrRet = new String [ this . mhmapSections . size ( ) ] ; for ( iter = this . mhmapSections . keySet ( ) . iterator ( ) ; ; iter . hasNext ( ) ) { arrRet [ iCntr ] = ( String ) iter . next ( ) ; iCntr ++ ; } } } catch ( NoSuchElementException NSEExIgnore ) { } finally { if ( iter != null ) iter = null ; } return arrRet ; }
Returns a string array containing names of all sections in INI file .
32,938
public String [ ] getPropertyNames ( String pstrSection ) { String [ ] arrRet = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { arrRet = objSec . getPropNames ( ) ; objSec = null ; } return arrRet ; }
Returns a string array containing names of all the properties under specified section .
32,939
public Map < String , INIProperty > getProperties ( String pstrSection ) { Map < String , INIProperty > hmRet = null ; INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { hmRet = objSec . getProperties ( ) ; objSec = null ; } return hmRet ; }
Returns a map containing all the properties under specified section .
32,940
public void removeProperty ( String pstrSection , String pstrProp ) { INISection objSec = null ; objSec = ( INISection ) this . mhmapSections . get ( pstrSection ) ; if ( objSec != null ) { objSec . removeProperty ( pstrProp ) ; objSec = null ; } }
Removed specified property from the specified section . If the specified section or the property does not exist does nothing .
32,941
public boolean save ( ) { boolean blnRet = false ; File objFile = null ; String strName = null ; String strTemp = null ; Iterator < String > itrSec = null ; INISection objSec = null ; FileWriter objWriter = null ; try { if ( this . mhmapSections . size ( ) == 0 ) return false ; objFile = new CSFile ( this . mstrFile ) ; if ( objFile . exists ( ) ) objFile . delete ( ) ; objWriter = new FileWriter ( objFile ) ; itrSec = this . mhmapSections . keySet ( ) . iterator ( ) ; while ( itrSec . hasNext ( ) ) { strName = ( String ) itrSec . next ( ) ; objSec = ( INISection ) this . mhmapSections . get ( strName ) ; strTemp = objSec . toString ( ) ; objWriter . write ( strTemp ) ; objWriter . write ( "\r\n" ) ; objSec = null ; } blnRet = true ; } catch ( IOException IOExIgnore ) { } finally { if ( objWriter != null ) { closeWriter ( objWriter ) ; objWriter = null ; } if ( objFile != null ) objFile = null ; if ( itrSec != null ) itrSec = null ; } return blnRet ; }
Flush changes back to the disk file . If the disk file does not exists then creates the new one .
32,942
private boolean checkDateTimeFormat ( String pstrDtFmt ) { boolean blnRet = false ; DateFormat objFmt = null ; try { objFmt = new SimpleDateFormat ( pstrDtFmt ) ; blnRet = true ; } catch ( NullPointerException NPExIgnore ) { } catch ( IllegalArgumentException IAExIgnore ) { } finally { if ( objFmt != null ) objFmt = null ; } return blnRet ; }
Helper function to check the date time formats .
32,943
private void loadStream ( InputStream stream ) { int iPos = - 1 ; String strLine = null ; String strSection = null ; String strRemarks = null ; BufferedReader objBRdr = null ; InputStreamReader objFRdr = null ; INISection objSec = null ; try { objFRdr = new InputStreamReader ( stream ) ; if ( objFRdr != null ) { objBRdr = new BufferedReader ( objFRdr ) ; if ( objBRdr != null ) { while ( objBRdr . ready ( ) ) { iPos = - 1 ; strLine = null ; strLine = objBRdr . readLine ( ) . trim ( ) ; if ( strLine == null ) { } else if ( strLine . length ( ) == 0 ) { } else if ( strLine . substring ( 0 , 1 ) . equals ( ";" ) ) { if ( strRemarks == null ) strRemarks = strLine . substring ( 1 ) ; else if ( strRemarks . length ( ) == 0 ) strRemarks = strLine . substring ( 1 ) ; else strRemarks = strRemarks + "\r\n" + strLine . substring ( 1 ) ; } else if ( strLine . startsWith ( "[" ) && strLine . endsWith ( "]" ) ) { if ( objSec != null ) this . mhmapSections . put ( strSection . trim ( ) , objSec ) ; objSec = null ; strSection = strLine . substring ( 1 , strLine . length ( ) - 1 ) ; objSec = new INISection ( strSection . trim ( ) , strRemarks ) ; strRemarks = null ; } else if ( ( iPos = strLine . indexOf ( "=" ) ) > 0 && objSec != null ) { objSec . setProperty ( strLine . substring ( 0 , iPos ) . trim ( ) , strLine . substring ( iPos + 1 ) . trim ( ) , strRemarks ) ; strRemarks = null ; } else { objSec . setProperty ( strLine , "" , strRemarks ) ; } } if ( objSec != null ) this . mhmapSections . put ( strSection . trim ( ) , objSec ) ; this . mblnLoaded = true ; } } } catch ( FileNotFoundException FNFExIgnore ) { this . mhmapSections . clear ( ) ; } catch ( IOException IOExIgnore ) { this . mhmapSections . clear ( ) ; } catch ( NullPointerException NPExIgnore ) { this . mhmapSections . clear ( ) ; } finally { if ( objBRdr != null ) { closeReader ( objBRdr ) ; objBRdr = null ; } if ( objFRdr != null ) { closeReader ( objFRdr ) ; objFRdr = null ; } if ( objSec != null ) objSec = null ; } }
Reads the INI file and load its contentens into a section collection after parsing the file line by line .
32,944
private boolean checkFile ( String pstrFile ) { boolean blnRet = false ; File objFile = null ; try { objFile = new CSFile ( pstrFile ) ; blnRet = ( objFile . exists ( ) && objFile . isFile ( ) ) ; } catch ( Exception e ) { blnRet = false ; } finally { if ( objFile != null ) objFile = null ; } return blnRet ; }
Helper method to check the existance of a file .
32,945
private String utilDateToStr ( Date pdt , String pstrFmt ) { String strRet = null ; SimpleDateFormat dtFmt = null ; try { dtFmt = new SimpleDateFormat ( pstrFmt ) ; strRet = dtFmt . format ( pdt ) ; } catch ( Exception e ) { strRet = null ; } finally { if ( dtFmt != null ) dtFmt = null ; } return strRet ; }
Converts a java . util . date into String
32,946
private String timeToStr ( Timestamp pobjTS , String pstrFmt ) { String strRet = null ; SimpleDateFormat dtFmt = null ; try { dtFmt = new SimpleDateFormat ( pstrFmt ) ; strRet = dtFmt . format ( pobjTS ) ; } catch ( IllegalArgumentException iae ) { strRet = "" ; } catch ( NullPointerException npe ) { strRet = "" ; } finally { if ( dtFmt != null ) dtFmt = null ; } return strRet ; }
Converts the given sql timestamp object to a string representation . The format to be used is to be obtained from the configuration file .
32,947
private String delRemChars ( String pstrSrc ) { int intPos = 0 ; if ( pstrSrc == null ) return null ; while ( ( intPos = pstrSrc . indexOf ( ";" ) ) >= 0 ) { if ( intPos == 0 ) pstrSrc = pstrSrc . substring ( intPos + 1 ) ; else if ( intPos > 0 ) pstrSrc = pstrSrc . substring ( 0 , intPos ) + pstrSrc . substring ( intPos + 1 ) ; } return pstrSrc ; }
This function deletes the remark characters ; from source string
32,948
private String addRemChars ( String pstrSrc ) { int intLen = 2 ; int intPos = 0 ; int intPrev = 0 ; String strLeft = null ; String strRight = null ; if ( pstrSrc == null ) return null ; while ( intPos >= 0 ) { intLen = 2 ; intPos = pstrSrc . indexOf ( "\r\n" , intPrev ) ; if ( intPos < 0 ) { intLen = 1 ; intPos = pstrSrc . indexOf ( "\n" , intPrev ) ; if ( intPos < 0 ) intPos = pstrSrc . indexOf ( "\r" , intPrev ) ; } if ( intPos == 0 ) { pstrSrc = ";\r\n" + pstrSrc . substring ( intPos + intLen ) ; intPrev = intPos + intLen + 1 ; } else if ( intPos > 0 ) { strLeft = pstrSrc . substring ( 0 , intPos ) ; strRight = pstrSrc . substring ( intPos + intLen ) ; if ( strRight == null ) pstrSrc = strLeft ; else if ( strRight . length ( ) == 0 ) pstrSrc = strLeft ; else pstrSrc = strLeft + "\r\n;" + strRight ; intPrev = intPos + intLen + 1 ; } } if ( ! pstrSrc . substring ( 0 , 1 ) . equals ( ";" ) ) pstrSrc = ";" + pstrSrc ; pstrSrc = pstrSrc + "\r\n" ; return pstrSrc ; }
This function adds a remark character ; in source string .
32,949
public static void main ( String [ ] pstrArgs ) { IniFile objINI = null ; String strFile = null ; if ( pstrArgs . length == 0 ) return ; strFile = pstrArgs [ 0 ] ; objINI = new IniFile ( strFile ) ; objINI . setStringProperty ( "Folders" , "folder1" , "G:\\Temp" , null ) ; objINI . setStringProperty ( "Folders" , "folder2" , "G:\\Temp\\Backup" , null ) ; objINI . save ( ) ; objINI = null ; }
The main entry point for testing .
32,950
public boolean hasTypeChildren ( TypeRefComponent type ) throws DefinitionException { if ( typeChildren == null || typeOfChildren != type ) { loadTypedChildren ( type ) ; } return ! typeChildren . isEmpty ( ) ; }
if you have a typed element the tree might end at that point . And you may or may not want to walk into the tree of that type It depends what you are doing . So this is a choice . You can ask for the children and then if you get no children you can see if there are children defined for the type and then get them
32,951
public Tag addTag ( String theScheme , String theTerm ) { Tag retVal = new Tag ( theScheme , theTerm ) ; add ( retVal ) ; myOrderedTags = null ; return retVal ; }
Add a new tag instance
32,952
public synchronized < T extends IRestfulClient > T newClient ( Class < T > theClientType , String theServerBase ) { validateConfigured ( ) ; if ( ! theClientType . isInterface ( ) ) { throw new ConfigurationException ( theClientType . getCanonicalName ( ) + " is not an interface" ) ; } ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers . get ( theClientType ) ; if ( invocationHandler == null ) { IHttpClient httpClient = getHttpClient ( theServerBase ) ; invocationHandler = new ClientInvocationHandlerFactory ( httpClient , myContext , theServerBase , theClientType ) ; for ( Method nextMethod : theClientType . getMethods ( ) ) { BaseMethodBinding < ? > binding = BaseMethodBinding . bindMethod ( nextMethod , myContext , null ) ; invocationHandler . addBinding ( nextMethod , binding ) ; } myInvocationHandlers . put ( theClientType , invocationHandler ) ; } return instantiateProxy ( theClientType , invocationHandler . newInvocationHandler ( this ) ) ; }
Instantiates a new client instance
32,953
public void setFhirContext ( FhirContext theContext ) { if ( myContext != null && myContext != theContext ) { throw new IllegalStateException ( "RestfulClientFactory instance is already associated with one FhirContext. RestfulClientFactory instances can not be shared." ) ; } myContext = theContext ; }
Sets the context associated with this client factory . Must not be called more than once .
32,954
public < T extends IElement > List < T > getAllPopulatedChildElementsOfType ( Class < T > theType ) { return Collections . emptyList ( ) ; }
NOP implementation of this method .
32,955
public Meta addTag ( String theSystem , String theCode , String theDisplay ) { addTag ( ) . setSystem ( theSystem ) . setCode ( theCode ) . setDisplay ( theDisplay ) ; return this ; }
Convenience method which adds a tag
32,956
public static < T extends IElement > List < T > allPopulatedChildElements ( Class < T > theType , Object ... theElements ) { ArrayList < T > retVal = new ArrayList < T > ( ) ; for ( Object next : theElements ) { if ( next == null ) { continue ; } else if ( next instanceof IElement ) { addElement ( retVal , ( IElement ) next , theType ) ; } else if ( next instanceof List ) { for ( Object nextElement : ( ( List < ? > ) next ) ) { if ( ! ( nextElement instanceof IBase ) ) { throw new IllegalArgumentException ( "Found element of " + nextElement . getClass ( ) ) ; } addElement ( retVal , ( IElement ) nextElement , theType ) ; } } else { throw new IllegalArgumentException ( "Found element of " + next . getClass ( ) ) ; } } return retVal ; }
Note that this method does not work on HL7 . org structures
32,957
public String [ ] parseLine ( ) throws IOException , FHIRException { List < String > res = new ArrayList < String > ( ) ; StringBuilder b = new StringBuilder ( ) ; boolean inQuote = false ; while ( inQuote || ( peek ( ) != '\r' && peek ( ) != '\n' ) ) { char c = peek ( ) ; next ( ) ; if ( c == '"' ) inQuote = ! inQuote ; else if ( ! inQuote && c == ',' ) { res . add ( b . toString ( ) . trim ( ) ) ; b = new StringBuilder ( ) ; } else b . append ( c ) ; } res . add ( b . toString ( ) . trim ( ) ) ; while ( ready ( ) && ( peek ( ) == '\r' || peek ( ) == '\n' ) ) { next ( ) ; } String [ ] r = new String [ ] { } ; r = res . toArray ( r ) ; return r ; }
Split one line in a CSV file into its rows . Comma s appearing in double quoted strings will not be seen as a separator .
32,958
@ SuppressWarnings ( "unchecked" ) protected < T extends Resource > T unmarshalReference ( HttpResponse response , String format ) { T resource = null ; OperationOutcome error = null ; byte [ ] cnt = log ( response ) ; if ( cnt != null ) { try { resource = ( T ) getParser ( format ) . parse ( cnt ) ; if ( resource instanceof OperationOutcome && hasError ( ( OperationOutcome ) resource ) ) { error = ( OperationOutcome ) resource ; } } catch ( IOException ioe ) { throw new EFhirClientException ( "Error reading Http Response: " + ioe . getMessage ( ) , ioe ) ; } catch ( Exception e ) { throw new EFhirClientException ( "Error parsing response message: " + e . getMessage ( ) , e ) ; } } if ( error != null ) { throw new EFhirClientException ( "Error from server: " + ResourceUtilities . getErrorDescription ( error ) , error ) ; } return resource ; }
Unmarshals a resource from the response stream .
32,959
protected Bundle unmarshalFeed ( HttpResponse response , String format ) { Bundle feed = null ; byte [ ] cnt = log ( response ) ; String contentType = response . getHeaders ( "Content-Type" ) [ 0 ] . getValue ( ) ; OperationOutcome error = null ; try { if ( cnt != null ) { if ( contentType . contains ( ResourceFormat . RESOURCE_XML . getHeader ( ) ) || contentType . contains ( "text/xml+fhir" ) ) { Resource rf = getParser ( format ) . parse ( cnt ) ; if ( rf instanceof Bundle ) feed = ( Bundle ) rf ; else if ( rf instanceof OperationOutcome && hasError ( ( OperationOutcome ) rf ) ) { error = ( OperationOutcome ) rf ; } else { throw new EFhirClientException ( "Error reading server response: a resource was returned instead" ) ; } } } } catch ( IOException ioe ) { throw new EFhirClientException ( "Error reading Http Response" , ioe ) ; } catch ( Exception e ) { throw new EFhirClientException ( "Error parsing response message" , e ) ; } if ( error != null ) { throw new EFhirClientException ( "Error from server: " + ResourceUtilities . getErrorDescription ( error ) , error ) ; } return feed ; }
Unmarshals Bundle from response stream .
32,960
protected String writeInputStreamAsString ( InputStream instream ) { String value = null ; try { value = IOUtils . toString ( instream , "UTF-8" ) ; System . out . println ( value ) ; } catch ( IOException ioe ) { } return value ; }
Used for debugging
32,961
public static ResponseEncoding determineResponseEncodingNoDefault ( RequestDetails theReq , EncodingEnum thePrefer ) { return determineResponseEncodingNoDefault ( theReq , thePrefer , null ) ; }
Returns null if the request doesn t express that it wants FHIR . If it expresses that it wants XML and JSON equally returns thePrefer .
32,962
public List < String > list ( String folder ) throws IOException { List < String > res = new ArrayList < String > ( ) ; if ( path != null ) { File f = new File ( Utilities . path ( path , folder ) ) ; if ( f . exists ( ) && f . isDirectory ( ) ) for ( String s : f . list ( ) ) res . add ( s ) ; } else { for ( String s : content . keySet ( ) ) { if ( s . startsWith ( folder + "/" ) && ! s . substring ( folder . length ( ) + 2 ) . contains ( "/" ) ) res . add ( s . substring ( folder . length ( ) + 1 ) ) ; } } return res ; }
Accessing the contents of the package - get a list of files in a subfolder of the package
32,963
public InputStream load ( String folder , String file ) throws IOException { if ( content . containsKey ( folder + "/" + file ) ) return new ByteArrayInputStream ( content . get ( folder + "/" + file ) ) ; else { File f = new File ( Utilities . path ( path , folder , file ) ) ; if ( f . exists ( ) ) return new FileInputStream ( f ) ; throw new IOException ( "Unable to find the file " + folder + "/" + file + " in the package " + name ( ) ) ; } }
get a stream that contains the contents of one of the files in a folder
32,964
public String fhirVersion ( ) { if ( "hl7.fhir.core" . equals ( npm . get ( "name" ) . getAsString ( ) ) ) return npm . get ( "version" ) . getAsString ( ) ; else return npm . getAsJsonObject ( "dependencies" ) . get ( "hl7.fhir.core" ) . getAsString ( ) ; }
convenience method for getting the package fhir version
32,965
static long hash ( String ... theValues ) { Hasher hasher = HASH_FUNCTION . newHasher ( ) ; for ( String next : theValues ) { if ( next == null ) { hasher . putByte ( ( byte ) 0 ) ; } else { next = UrlUtil . escapeUrlParam ( next ) ; byte [ ] bytes = next . getBytes ( Charsets . UTF_8 ) ; hasher . putBytes ( bytes ) ; } hasher . putBytes ( DELIMITER_BYTES ) ; } HashCode hashCode = hasher . hash ( ) ; return hashCode . asLong ( ) ; }
Applies a fast and consistent hashing algorithm to a set of strings
32,966
public TranslationRequest addCode ( String theSystem , String theCode ) { Validate . notBlank ( theSystem , "theSystem must not be null" ) ; Validate . notBlank ( theCode , "theCode must not be null" ) ; if ( getCodeableConcept ( ) == null ) { setCodeableConcept ( new CodeableConcept ( ) ) ; } getCodeableConcept ( ) . addCoding ( new Coding ( ) . setSystem ( theSystem ) . setCode ( theCode ) ) ; return this ; }
This is just a convenience method that creates a codeableconcept if one doesn t already exist and adds a coding to it
32,967
public Set < String > getResourceNames ( ) { Set < String > resourceNames = new HashSet < > ( ) ; if ( myNameToResourceDefinition . isEmpty ( ) ) { Properties props = new Properties ( ) ; try { props . load ( myVersion . getFhirVersionPropertiesFile ( ) ) ; } catch ( IOException theE ) { throw new ConfigurationException ( "Failed to load version properties file" ) ; } Enumeration < ? > propNames = props . propertyNames ( ) ; while ( propNames . hasMoreElements ( ) ) { String next = ( String ) propNames . nextElement ( ) ; if ( next . startsWith ( "resource." ) ) { resourceNames . add ( next . substring ( "resource." . length ( ) ) . trim ( ) ) ; } } } for ( RuntimeResourceDefinition next : myNameToResourceDefinition . values ( ) ) { resourceNames . add ( next . getName ( ) ) ; } return Collections . unmodifiableSet ( resourceNames ) ; }
Returns an unmodifiable set containing all resource names known to this context
32,968
public IRestfulClientFactory getRestfulClientFactory ( ) { if ( myRestfulClientFactory == null ) { try { myRestfulClientFactory = ( IRestfulClientFactory ) ReflectionUtil . newInstance ( Class . forName ( "ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory" ) , FhirContext . class , this ) ; } catch ( ClassNotFoundException e ) { throw new ConfigurationException ( "hapi-fhir-client does not appear to be on the classpath" ) ; } } return myRestfulClientFactory ; }
Get the restful client factory . If no factory has been set this will be initialized with a new ApacheRestfulClientFactory .
32,969
public ListMultimap < Class < ? > , Object > getParamsForType ( ) { ArrayListMultimap < Class < ? > , Object > retVal = ArrayListMultimap . create ( ) ; myParams . entries ( ) . forEach ( entry -> retVal . put ( entry . getKey ( ) , unwrapValue ( entry . getValue ( ) ) ) ) ; return Multimaps . unmodifiableListMultimap ( retVal ) ; }
Returns an unmodifiable multimap of the params where the key is the param type and the value is the actual instance
32,970
public boolean incomingServerRequestMatchesMethod ( RequestDetails theRequest ) { if ( ! Constants . PARAM_HISTORY . equals ( theRequest . getOperation ( ) ) ) { return false ; } if ( theRequest . getResourceName ( ) == null ) { return myResourceOperationType == RestOperationTypeEnum . HISTORY_SYSTEM ; } if ( ! StringUtils . equals ( theRequest . getResourceName ( ) , myResourceName ) ) { return false ; } boolean haveIdParam = theRequest . getId ( ) != null && ! theRequest . getId ( ) . isEmpty ( ) ; boolean wantIdParam = myIdParamIndex != null ; if ( haveIdParam != wantIdParam ) { return false ; } if ( theRequest . getId ( ) == null ) { return myResourceOperationType == RestOperationTypeEnum . HISTORY_TYPE ; } else if ( theRequest . getId ( ) . hasVersionIdPart ( ) ) { return false ; } return true ; }
ObjectUtils . equals is replaced by a JDK7 method ..
32,971
public BaseServerResponseException addResponseHeader ( String theName , String theValue ) { Validate . notBlank ( theName , "theName must not be null or empty" ) ; Validate . notBlank ( theValue , "theValue must not be null or empty" ) ; if ( getResponseHeaders ( ) . containsKey ( theName ) == false ) { getResponseHeaders ( ) . put ( theName , new ArrayList < > ( ) ) ; } getResponseHeaders ( ) . get ( theName ) . add ( theValue ) ; return this ; }
Add a header which will be added to any responses
32,972
public Response create ( final String resource ) throws IOException { return execute ( getRequest ( RequestTypeEnum . POST , RestOperationTypeEnum . TRANSACTION ) . resource ( resource ) ) ; }
Create all resources in one transaction
32,973
public void setMaxSubmitPerPass ( Integer theMaxSubmitPerPass ) { Integer maxSubmitPerPass = theMaxSubmitPerPass ; if ( maxSubmitPerPass == null ) { maxSubmitPerPass = DEFAULT_MAX_SUBMIT ; } Validate . isTrue ( maxSubmitPerPass > 0 , "theMaxSubmitPerPass must be > 0" ) ; myMaxSubmitPerPass = maxSubmitPerPass ; }
Sets the maximum number of resources that will be submitted in a single pass
32,974
public final void checkParams ( Object [ ] params , int expected ) { if ( params == null || params . length != expected ) { throw new RuntimeException ( "Liquid error: wrong number of arguments (" + ( params == null ? 0 : params . length + 1 ) + " for " + ( expected + 1 ) + ")" ) ; } }
Check the number of parameters and throws an exception if needed .
32,975
protected Object get ( int index , Object ... params ) { if ( index >= params . length ) { throw new RuntimeException ( "error in filter '" + name + "': cannot get param index: " + index + " from: " + Arrays . toString ( params ) ) ; } return params [ index ] ; }
Returns a value at a specific index from an array of parameters . If no such index exists a RuntimeException is thrown .
32,976
public void extractInlineReferences ( IBaseResource theResource ) { if ( ! myDaoConfig . isAllowInlineMatchUrlReferences ( ) ) { return ; } FhirTerser terser = myContext . newTerser ( ) ; List < IBaseReference > allRefs = terser . getAllPopulatedChildElementsOfType ( theResource , IBaseReference . class ) ; for ( IBaseReference nextRef : allRefs ) { IIdType nextId = nextRef . getReferenceElement ( ) ; String nextIdText = nextId . getValue ( ) ; if ( nextIdText == null ) { continue ; } int qmIndex = nextIdText . indexOf ( '?' ) ; if ( qmIndex != - 1 ) { for ( int i = qmIndex - 1 ; i >= 0 ; i -- ) { if ( nextIdText . charAt ( i ) == '/' ) { if ( i < nextIdText . length ( ) - 1 && nextIdText . charAt ( i + 1 ) == '?' ) { continue ; } nextIdText = nextIdText . substring ( i + 1 ) ; break ; } } String resourceTypeString = nextIdText . substring ( 0 , nextIdText . indexOf ( '?' ) ) . replace ( "/" , "" ) ; RuntimeResourceDefinition matchResourceDef = myContext . getResourceDefinition ( resourceTypeString ) ; if ( matchResourceDef == null ) { String msg = myContext . getLocalizer ( ) . getMessage ( BaseHapiFhirDao . class , "invalidMatchUrlInvalidResourceType" , nextId . getValue ( ) , resourceTypeString ) ; throw new InvalidRequestException ( msg ) ; } Class < ? extends IBaseResource > matchResourceType = matchResourceDef . getImplementingClass ( ) ; Set < Long > matches = myMatchResourceUrlService . processMatchUrl ( nextIdText , matchResourceType ) ; if ( matches . isEmpty ( ) ) { String msg = myContext . getLocalizer ( ) . getMessage ( BaseHapiFhirDao . class , "invalidMatchUrlNoMatches" , nextId . getValue ( ) ) ; throw new ResourceNotFoundException ( msg ) ; } if ( matches . size ( ) > 1 ) { String msg = myContext . getLocalizer ( ) . getMessage ( BaseHapiFhirDao . class , "invalidMatchUrlMultipleMatches" , nextId . getValue ( ) ) ; throw new PreconditionFailedException ( msg ) ; } Long next = matches . iterator ( ) . next ( ) ; String newId = myIdHelperService . translatePidIdToForcedId ( resourceTypeString , next ) ; ourLog . debug ( "Replacing inline match URL[{}] with ID[{}}" , nextId . getValue ( ) , newId ) ; nextRef . setReference ( newId ) ; } } }
Handle references within the resource that are match URLs for example references like Patient?identifier = foo . These match URLs are resolved and replaced with the ID of the matching resource .
32,977
public Future < OAuth2AccessToken > getAccessTokenClientCredentialsGrant ( OAuthAsyncRequestCallback < OAuth2AccessToken > callback ) { final OAuthRequest request = createAccessTokenClientCredentialsGrantRequest ( null ) ; return sendAccessTokenRequestAsync ( request , callback ) ; }
Start the request to retrieve the access token using client - credentials grant . The optionally provided callback will be called with the Token when it is available .
32,978
public void addOAuthParameter ( String key , String value ) { oauthParameters . put ( checkKey ( key ) , value ) ; }
Adds an OAuth parameter .
32,979
public String getSanitizedUrl ( ) { if ( url . startsWith ( "http://" ) && ( url . endsWith ( ":80" ) || url . contains ( ":80/" ) ) ) { return url . replaceAll ( "\\?.*" , "" ) . replaceAll ( ":80" , "" ) ; } else if ( url . startsWith ( "https://" ) && ( url . endsWith ( ":443" ) || url . contains ( ":443/" ) ) ) { return url . replaceAll ( "\\?.*" , "" ) . replaceAll ( ":443" , "" ) ; } else { return url . replaceAll ( "\\?.*" , "" ) ; } }
Returns the URL without the port and the query string part .
32,980
public static String getStreamContents ( InputStream is ) throws IOException { Preconditions . checkNotNull ( is , "Cannot get String from a null object" ) ; final char [ ] buffer = new char [ 0x10000 ] ; final StringBuilder out = new StringBuilder ( ) ; try ( Reader in = new InputStreamReader ( is , "UTF-8" ) ) { int read ; do { read = in . read ( buffer , 0 , buffer . length ) ; if ( read > 0 ) { out . append ( buffer , 0 , read ) ; } } while ( read >= 0 ) ; } return out . toString ( ) ; }
Returns the stream contents as an UTF - 8 encoded string
32,981
public static String getGzipStreamContents ( InputStream is ) throws IOException { Preconditions . checkNotNull ( is , "Cannot get String from a null object" ) ; final GZIPInputStream gis = new GZIPInputStream ( is ) ; return getStreamContents ( gis ) ; }
Return String content from a gzip stream
32,982
public static void pushImageTag ( DockerClient docker , String imageName , List < String > imageTags , Log log , boolean skipPush ) throws MojoExecutionException , DockerException , IOException , InterruptedException { if ( skipPush ) { log . info ( "Skipping docker push" ) ; return ; } if ( imageTags . isEmpty ( ) ) { throw new MojoExecutionException ( "You have used option \"pushImageTag\" but have" + " not specified an \"imageTag\" in your" + " docker-maven-client's plugin configuration" ) ; } final CompositeImageName compositeImageName = CompositeImageName . create ( imageName , imageTags ) ; for ( final String imageTag : compositeImageName . getImageTags ( ) ) { final String imageNameWithTag = compositeImageName . getName ( ) + ":" + imageTag ; log . info ( "Pushing " + imageNameWithTag ) ; docker . push ( imageNameWithTag , new AnsiProgressHandler ( ) ) ; } }
push just the tags listed in the pom rather than all images using imageName
32,983
protected RegistryAuth registryAuth ( ) throws MojoExecutionException { if ( settings != null && serverId != null ) { final Server server = settings . getServer ( serverId ) ; if ( server != null ) { final RegistryAuth . Builder registryAuthBuilder = RegistryAuth . builder ( ) ; final String username = server . getUsername ( ) ; String password = server . getPassword ( ) ; if ( secDispatcher != null ) { try { password = secDispatcher . decrypt ( password ) ; } catch ( SecDispatcherException ex ) { throw new MojoExecutionException ( "Cannot decrypt password from settings" , ex ) ; } } final String email = getEmail ( server ) ; if ( ! isNullOrEmpty ( username ) ) { registryAuthBuilder . username ( username ) ; } if ( ! isNullOrEmpty ( email ) ) { registryAuthBuilder . email ( email ) ; } if ( ! isNullOrEmpty ( password ) ) { registryAuthBuilder . password ( password ) ; } if ( ! isNullOrEmpty ( registryUrl ) ) { registryAuthBuilder . serverAddress ( registryUrl ) ; } return registryAuthBuilder . build ( ) ; } else { getLog ( ) . warn ( "No entry found in settings.xml for serverId=" + serverId + ", cannot configure authentication for that registry" ) ; } } return null ; }
Builds the registryAuth object from server details .
32,984
public static boolean setOnce ( AtomicReference < Disposable > upstream , Disposable next , Class < ? > observer ) { AutoDisposeUtil . checkNotNull ( next , "next is null" ) ; if ( ! upstream . compareAndSet ( null , next ) ) { next . dispose ( ) ; if ( upstream . get ( ) != AutoDisposableHelper . DISPOSED ) { reportDoubleSubscription ( observer ) ; } return false ; } return true ; }
Atomically updates the target upstream AtomicReference from null to the non - null next Disposable otherwise disposes next and reports a ProtocolViolationException if the AtomicReference doesn t contain the shared disposed indicator .
32,985
public static boolean setOnce ( AtomicReference < Subscription > upstream , Subscription next , Class < ? > subscriber ) { AutoDisposeUtil . checkNotNull ( next , "next is null" ) ; if ( ! upstream . compareAndSet ( null , next ) ) { next . cancel ( ) ; if ( upstream . get ( ) != AutoSubscriptionHelper . CANCELLED ) { reportDoubleSubscription ( subscriber ) ; } return false ; } return true ; }
Atomically updates the target upstream AtomicReference from null to the non - null next Subscription otherwise cancels next and reports a ProtocolViolationException if the AtomicReference doesn t contain the shared cancelled indicator .
32,986
public static < E > CompletableSource resolveScopeFromLifecycle ( final LifecycleScopeProvider < E > provider ) throws OutsideScopeException { return resolveScopeFromLifecycle ( provider , true ) ; }
Overload for resolving lifecycle providers that defaults to checking start and end boundaries of lifecycles . That is they will ensure that the lifecycle has both started and not ended .
32,987
private Description describe ( MethodInvocationTree methodInvocationTree , VisitorState state ) { ExpressionTree identifierExpr = ASTHelpers . getRootAssignable ( methodInvocationTree ) ; String identifierStr = null ; Type identifierType = null ; if ( identifierExpr != null ) { identifierStr = state . getSourceForNode ( identifierExpr ) ; if ( identifierExpr instanceof JCIdent ) { identifierType = ( ( JCIdent ) identifierExpr ) . sym . type ; } else if ( identifierExpr instanceof JCFieldAccess ) { identifierType = ( ( JCFieldAccess ) identifierExpr ) . sym . type ; } else { throw new IllegalStateException ( "Expected a JCIdent or a JCFieldAccess" ) ; } } Type returnType = getReturnType ( ( ( JCMethodInvocation ) methodInvocationTree ) . getMethodSelect ( ) ) ; Fix fix ; if ( identifierStr != null && ! "this" . equals ( identifierStr ) && returnType != null && state . getTypes ( ) . isAssignable ( returnType , identifierType ) ) { fix = SuggestedFix . prefixWith ( methodInvocationTree , identifierStr + " = " ) ; } else { Tree parent = state . getPath ( ) . getParentPath ( ) . getLeaf ( ) ; fix = SuggestedFix . delete ( parent ) ; } return describeMatch ( methodInvocationTree , fix ) ; }
Fixes the error by assigning the result of the call to the receiver reference or deleting the method call .
32,988
public static < T > boolean onNext ( Subscriber < ? super T > subscriber , T value , AtomicInteger wip , AtomicThrowable error ) { if ( wip . get ( ) == 0 && wip . compareAndSet ( 0 , 1 ) ) { subscriber . onNext ( value ) ; if ( wip . decrementAndGet ( ) != 0 ) { Throwable ex = error . terminate ( ) ; if ( ex != null ) { subscriber . onError ( ex ) ; } else { subscriber . onComplete ( ) ; } return true ; } } return false ; }
Emits the given value if possible and terminates if there was an onComplete or onError while emitting drops the value otherwise .
32,989
public boolean containsDirectoryOfType ( Class < ? extends Directory > type ) { for ( Directory dir : _directories ) { if ( type . isAssignableFrom ( dir . getClass ( ) ) ) return true ; } return false ; }
Indicates whether an instance of the given directory type exists in this Metadata instance .
32,990
public void processTiff ( final RandomAccessReader reader , final TiffHandler handler , final int tiffHeaderOffset ) throws TiffProcessingException , IOException { short byteOrderIdentifier = reader . getInt16 ( tiffHeaderOffset ) ; if ( byteOrderIdentifier == 0x4d4d ) { reader . setMotorolaByteOrder ( true ) ; } else if ( byteOrderIdentifier == 0x4949 ) { reader . setMotorolaByteOrder ( false ) ; } else { throw new TiffProcessingException ( "Unclear distinction between Motorola/Intel byte ordering: " + byteOrderIdentifier ) ; } final int tiffMarker = reader . getUInt16 ( 2 + tiffHeaderOffset ) ; handler . setTiffMarker ( tiffMarker ) ; int firstIfdOffset = reader . getInt32 ( 4 + tiffHeaderOffset ) + tiffHeaderOffset ; if ( firstIfdOffset >= reader . getLength ( ) - 1 ) { handler . warn ( "First IFD offset is beyond the end of the TIFF data segment -- trying default offset" ) ; firstIfdOffset = tiffHeaderOffset + 2 + 2 + 4 ; } Set < Integer > processedIfdOffsets = new HashSet < Integer > ( ) ; processIfd ( handler , reader , processedIfdOffsets , firstIfdOffset , tiffHeaderOffset ) ; }
Processes a TIFF data sequence .
32,991
public void addPath ( T value , byte [ ] ... parts ) { int depth = 0 ; ByteTrieNode < T > node = _root ; for ( byte [ ] part : parts ) { for ( byte b : part ) { ByteTrieNode < T > child = node . _children . get ( b ) ; if ( child == null ) { child = new ByteTrieNode < T > ( ) ; node . _children . put ( b , child ) ; } node = child ; depth ++ ; } } if ( depth == 0 ) throw new IllegalArgumentException ( "Parts must contain at least one byte." ) ; node . setValue ( value ) ; _maxDepth = Math . max ( _maxDepth , depth ) ; }
Store the given value at the specified path .
32,992
private static void print ( Metadata metadata , String method ) { System . out . println ( ) ; System . out . println ( "-------------------------------------------------" ) ; System . out . print ( ' ' ) ; System . out . print ( method ) ; System . out . println ( "-------------------------------------------------" ) ; System . out . println ( ) ; for ( Directory directory : metadata . getDirectories ( ) ) { for ( Tag tag : directory . getTags ( ) ) { System . out . println ( tag ) ; } for ( String error : directory . getErrors ( ) ) { System . err . println ( "ERROR: " + error ) ; } } }
Write all extracted values to stdout .
32,993
@ java . lang . SuppressWarnings ( { "UnnecessaryBoxing" } ) public boolean containsTag ( int tagType ) { return _tagMap . containsKey ( Integer . valueOf ( tagType ) ) ; }
Indicates whether the specified tag type has been set .
32,994
public void processRiff ( final SequentialReader reader , final RiffHandler handler ) throws RiffProcessingException , IOException { reader . setMotorolaByteOrder ( false ) ; final String fileFourCC = reader . getString ( 4 ) ; if ( ! fileFourCC . equals ( "RIFF" ) ) throw new RiffProcessingException ( "Invalid RIFF header: " + fileFourCC ) ; final int fileSize = reader . getInt32 ( ) ; int sizeLeft = fileSize ; final String identifier = reader . getString ( 4 ) ; sizeLeft -= 4 ; if ( ! handler . shouldAcceptRiffIdentifier ( identifier ) ) return ; processChunks ( reader , sizeLeft , handler ) ; }
Processes a RIFF data sequence .
32,995
public Iterable < JpegSegmentType > getSegmentTypes ( ) { Set < JpegSegmentType > segmentTypes = new HashSet < JpegSegmentType > ( ) ; for ( Byte segmentTypeByte : _segmentDataMap . keySet ( ) ) { JpegSegmentType segmentType = JpegSegmentType . fromByte ( segmentTypeByte ) ; if ( segmentType == null ) { throw new IllegalStateException ( "Should not have a segmentTypeByte that is not in the enum: " + Integer . toHexString ( segmentTypeByte ) ) ; } segmentTypes . add ( segmentType ) ; } return segmentTypes ; }
Gets the set of JPEG segment type identifiers .
32,996
public Iterable < byte [ ] > getSegments ( byte segmentType ) { final List < byte [ ] > segmentList = getSegmentList ( segmentType ) ; return segmentList == null ? new ArrayList < byte [ ] > ( ) : segmentList ; }
Returns all instances of a given JPEG segment . If no instances exist an empty sequence is returned .
32,997
public int getSegmentCount ( byte segmentType ) { final List < byte [ ] > segmentList = getSegmentList ( segmentType ) ; return segmentList == null ? 0 : segmentList . size ( ) ; }
Returns the count of segment data byte arrays stored for a given segment type .
32,998
private static String getReaderString ( final RandomAccessReader reader , final int makernoteOffset , final int bytesRequested ) throws IOException { try { return reader . getString ( makernoteOffset , bytesRequested , Charsets . UTF_8 ) ; } catch ( BufferBoundsException e ) { return "" ; } }
Read a given number of bytes from the stream
32,999
public static String convertISO2022CharsetToJavaCharset ( final byte [ ] bytes ) { if ( bytes . length > 2 && bytes [ 0 ] == ESC && bytes [ 1 ] == PERCENT_SIGN && bytes [ 2 ] == LATIN_CAPITAL_G ) return UTF_8 ; if ( bytes . length > 3 && bytes [ 0 ] == ESC && ( bytes [ 3 ] & 0xFF | ( ( bytes [ 2 ] & 0xFF ) << 8 ) | ( ( bytes [ 1 ] & 0xFF ) << 16 ) ) == DOT && bytes [ 4 ] == LATIN_CAPITAL_A ) return ISO_8859_1 ; return null ; }
Converts the given ISO2022 char set to a Java charset name .