idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
8,600
public void clearGeometries ( ) throws GeometryMergeException { if ( ! busy ) { throw new GeometryMergeException ( "Can't clear geometry list if no merging process is active." ) ; } for ( Geometry geometry : geometries ) { eventBus . fireEvent ( new GeometryMergeRemovedEvent ( geometry ) ) ; } geometries . clear ( ) ; }
Clear the entire list of geometries for merging basically resetting the process .
8,601
public void stop ( final GeometryFunction callback ) throws GeometryMergeException { if ( ! busy ) { throw new GeometryMergeException ( "Can't stop the merging process since it is not activated." ) ; } if ( callback == null ) { cancel ( ) ; return ; } merge ( new GeometryFunction ( ) { public void execute ( Geometry geometry ) { callback . execute ( geometry ) ; try { clearGeometries ( ) ; } catch ( GeometryMergeException e ) { } busy = false ; eventBus . fireEvent ( new GeometryMergeStopEvent ( geometry ) ) ; } } ) ; }
End the merging process by effectively executing the merge operation and returning the result through a call - back .
8,602
protected Map < String , List < String > > getEffectiveAnnotationMap ( Map < String , List < String > > inheritedAnnotationMap , Map < String , List < String > > immediateAnnotationMap ) { Map < String , List < String > > effectiveAnnotationMap = new HashMap < String , List < String > > ( ) ; effectiveAnnotationMap . putAll ( inheritedAnnotationMap ) ; effectiveAnnotationMap . putAll ( immediateAnnotationMap ) ; return effectiveAnnotationMap ; }
Resolves the effective set of annotation by combining the inherited annotations with the immediate annotations associated with the statement or statement group . If an annotation existing in both the inherited map and the immediate map the immediate annotation overrides the inherited .
8,603
protected void writeAnnotations ( Map < String , List < String > > effectiveAnnotationMap , Map < String , List < String > > currentAnnotationMap , Writer writer ) throws IOException , BELRuntimeException { List < Map . Entry < String , List < String > > > entriesToSet = new ArrayList < Map . Entry < String , List < String > > > ( ) ; for ( Map . Entry < String , List < String > > effEntry : effectiveAnnotationMap . entrySet ( ) ) { if ( ! currentAnnotationMap . containsKey ( effEntry . getKey ( ) ) ) { entriesToSet . add ( effEntry ) ; } else { List < String > currentValues = currentAnnotationMap . get ( effEntry . getKey ( ) ) ; List < String > effectiveValues = effEntry . getValue ( ) ; if ( currentValues == null || effectiveValues == null ) { throw new BELRuntimeException ( "Invalid annotation value" , ExitCode . PARSE_ERROR ) ; } if ( ! currentValues . equals ( effectiveValues ) ) { entriesToSet . add ( effEntry ) ; } } } currentAnnotationMap . keySet ( ) . removeAll ( effectiveAnnotationMap . keySet ( ) ) ; if ( ! currentAnnotationMap . keySet ( ) . isEmpty ( ) || ! entriesToSet . isEmpty ( ) ) { writer . write ( "\n" ) ; for ( String name : currentAnnotationMap . keySet ( ) ) { unsetAnnotation ( name , writer ) ; } for ( Map . Entry < String , List < String > > entry : entriesToSet ) { setAnnotation ( entry . getKey ( ) , entry . getValue ( ) , writer ) ; } writer . write ( "\n" ) ; } currentAnnotationMap . clear ( ) ; currentAnnotationMap . putAll ( effectiveAnnotationMap ) ; }
Writes a series of BEL script control statements via the writer to match current annotations to the effective annotations . At the end of this function the content of currentAnnotationMap will be equivalent to the content of effectiveAnnotationMap .
8,604
public Span [ ] seqToSpans ( final String [ ] tokens ) { final Span [ ] origSpans = this . sequenceLabeler . tag ( tokens ) ; final Span [ ] seqSpans = SequenceLabelerME . dropOverlappingSpans ( origSpans ) ; return seqSpans ; }
Tag the current sentence .
8,605
public String [ ] lemmatize ( final String [ ] tokens ) { final Span [ ] origSpans = this . sequenceLabeler . tag ( tokens ) ; final Span [ ] seqSpans = SequenceLabelerME . dropOverlappingSpans ( origSpans ) ; final String [ ] decodedLemmas = StringUtils . decodeLemmas ( tokens , seqSpans ) ; return decodedLemmas ; }
Lemmatize the current sentence .
8,606
public void serialize ( final OutputStream out ) throws IOException { final Writer writer = new BufferedWriter ( new OutputStreamWriter ( out ) ) ; this . seqModel . serialize ( out ) ; writer . flush ( ) ; }
Serialize this model into the overall Sequence model .
8,607
public static void logWarn ( String message ) { GWT . log ( "WARNING: " + message ) ; LOG . warning ( message ) ; logServer ( LEVEL_WARN , message , null ) ; }
Log a warning .
8,608
public static void logError ( String message ) { GWT . log ( "ERROR: " + message ) ; LOG . severe ( message ) ; logServer ( LEVEL_ERROR , message , null ) ; }
Log an error .
8,609
public static void logDebug ( String message , Throwable t ) { logDebug ( message + SEP + getMessage ( t ) ) ; }
Debug logging with cause .
8,610
public static void logInfo ( String message , Throwable t ) { logInfo ( message + SEP + getMessage ( t ) ) ; }
Info logging with cause .
8,611
public static void logWarn ( String message , Throwable t ) { logWarn ( message + SEP + getMessage ( t ) ) ; }
Warning logging with cause .
8,612
public static void logError ( String message , Throwable t ) { logError ( message + SEP + getMessage ( t ) ) ; }
Error logging with cause .
8,613
public static void logServer ( int logLevel , String message , Throwable throwable ) { String logMessage = message ; if ( null == logMessage ) { logMessage = "" ; } if ( null != throwable ) { logMessage += "\n" + getMessage ( throwable ) ; } LogRequest logRequest = new LogRequest ( ) ; logRequest . setLevel ( logLevel ) ; logRequest . setStatement ( logMessage ) ; GwtCommand command = new GwtCommand ( LogRequest . COMMAND ) ; command . setCommandRequest ( logRequest ) ; Deferred deferred = new Deferred ( ) ; deferred . setLogCommunicationExceptions ( false ) ; GwtCommandDispatcher . getInstance ( ) . execute ( command , deferred ) ; }
Log a message in the server log .
8,614
public void onMapTouchStart ( TouchEvent < ? > event ) { onDown ( event ) ; event . stopPropagation ( ) ; event . preventDefault ( ) ; }
Forward as mouse down and stop the event .
8,615
public void onMapTouchMove ( TouchEvent < ? > event ) { onDrag ( event ) ; event . stopPropagation ( ) ; event . preventDefault ( ) ; }
Forward as mouse move and stop the event .
8,616
public String asString ( ) { try { return EntityUtils . toString ( entity , PcsUtils . UTF8 . name ( ) ) ; } catch ( IOException e ) { throw new CStorageException ( "Can't get string from HTTP entity" , e ) ; } }
Extracts string from input stream
8,617
public JSONObject asJSONObject ( ) { if ( entity == null ) { return null ; } String str = asString ( ) ; try { return new JSONObject ( str ) ; } catch ( JSONException ex ) { throw new CStorageException ( "Error parsing the JSON response: " + str , ex ) ; } }
Get the response as a json object
8,618
public JSONArray asJSONArray ( ) { if ( entity == null ) { return null ; } String str = asString ( ) ; try { return new JSONArray ( str ) ; } catch ( JSONException ex ) { throw new CStorageException ( "Error parsing the JSON response: " + str , ex ) ; } }
Get the response as a json array
8,619
public InputStream openStream ( ) { if ( entity == null ) { return null ; } try { return entity . getContent ( ) ; } catch ( IOException ex ) { throw new CStorageException ( "Can't open stream" , ex ) ; } }
Open a raw stream on the response body .
8,620
public void setStyles ( String styles ) { this . styles = styles ; if ( eventBus != null && parentLayer != null ) { eventBus . fireEvent ( new LayerStyleChangedEvent ( parentLayer ) ) ; } }
Set the styles parameter to be used in the GetMap requests .
8,621
protected AjaxEventBehavior newAjaxEventBehavior ( final String event ) { return new AjaxEventBehavior ( event ) { private static final long serialVersionUID = 1L ; protected void onEvent ( final AjaxRequestTarget target ) { final RadioGroup < T > radioGroup = getGroup ( ) ; radioGroup . processInput ( ) ; onClick ( target ) ; } protected void updateAjaxAttributes ( final AjaxRequestAttributes attributes ) { super . updateAjaxAttributes ( attributes ) ; AjaxRadio . this . updateAjaxAttributes ( attributes ) ; } } ; }
New ajax event behavior .
8,622
public static org . openbel . framework . common . model . Namespace convert ( final Namespace ws ) { return new org . openbel . framework . common . model . Namespace ( ws . getPrefix ( ) , ws . getResourceLocation ( ) ) ; }
Convert a WS namespace to a common namespace
8,623
private void afterLogin ( GwtCommand command , Deferred deferred ) { String token = notNull ( command . getUserToken ( ) ) ; if ( ! afterLoginCommands . containsKey ( token ) ) { afterLoginCommands . put ( token , new ArrayList < RetryCommand > ( ) ) ; } afterLoginCommands . get ( token ) . add ( new RetryCommand ( command , deferred ) ) ; }
Add a command and it s callbacks to the list of commands to retry after login .
8,624
public void setServiceEndPointUrl ( String url ) { ServiceDefTarget endpoint = ( ServiceDefTarget ) service ; endpoint . setServiceEntryPoint ( url ) ; }
Set the service end point URL to a different value . If pointing to a different context make sure the GeomajasController of that context supports this .
8,625
private void login ( final String oldToken ) { tokenRequestHandler . login ( new TokenChangedHandler ( ) { public void onTokenChanged ( TokenChangedEvent event ) { setToken ( event . getToken ( ) , event . getUserDetail ( ) , false ) ; List < RetryCommand > retryCommands = afterLoginCommands . remove ( oldToken ) ; if ( null != retryCommands ) { for ( RetryCommand retryCommand : retryCommands ) { execute ( retryCommand . getCommand ( ) , retryCommand . getDeferred ( ) ) ; } } } } ) ; }
Force request a new login the dangling commands for the previous token are retried when logged in .
8,626
private void setToken ( String userToken , UserDetail userDetail , boolean loginPending ) { boolean changed = ! isEqual ( this . userToken , userToken ) ; this . userToken = userToken ; if ( null == userDetail ) { userDetail = new UserDetail ( ) ; } this . userDetail = userDetail ; if ( changed ) { TokenChangedEvent event = new TokenChangedEvent ( userToken , userDetail , loginPending ) ; manager . fireEvent ( event ) ; } }
Set the user token so it can be sent in every command . This is the internal version used by the token changed handler .
8,627
public void setUseLazyLoading ( boolean useLazyLoading ) { if ( useLazyLoading != this . useLazyLoading ) { if ( useLazyLoading ) { lazyFeatureIncludesDefault = GeomajasConstant . FEATURE_INCLUDE_STYLE + GeomajasConstant . FEATURE_INCLUDE_LABEL ; lazyFeatureIncludesSelect = GeomajasConstant . FEATURE_INCLUDE_ALL ; lazyFeatureIncludesAll = GeomajasConstant . FEATURE_INCLUDE_ALL ; } else { lazyFeatureIncludesDefault = GeomajasConstant . FEATURE_INCLUDE_ALL ; lazyFeatureIncludesSelect = GeomajasConstant . FEATURE_INCLUDE_ALL ; lazyFeatureIncludesAll = GeomajasConstant . FEATURE_INCLUDE_ALL ; } } this . useLazyLoading = useLazyLoading ; }
Set lazy feature loading status .
8,628
private boolean isEqual ( Object o1 , Object o2 ) { return o1 == null ? o2 == null : o1 . equals ( o2 ) ; }
Checks whether 2 objects are equal . Null - safe 2 null objects are considered equal .
8,629
protected void onAfterRender ( final Component component ) { final Response response = component . getResponse ( ) ; response . write ( onWriteAfterRender ( ) ) ; }
Factory callback method to hook after render .
8,630
protected void onBeforeRender ( final Component component ) { final Response response = component . getResponse ( ) ; response . write ( onWriteBeforeRender ( ) ) ; }
Factory callback method to hook before render .
8,631
private String [ ] getSuffixes ( final String lex ) { final Integer start = Integer . parseInt ( this . attributes . get ( "sufBegin" ) ) ; final Integer end = Integer . parseInt ( this . attributes . get ( "sufEnd" ) ) ; final String [ ] suffs = new String [ end ] ; for ( int li = start , ll = end ; li < ll ; li ++ ) { suffs [ li ] = lex . substring ( Math . max ( lex . length ( ) - li - 1 , 0 ) ) ; } return suffs ; }
Obtain suffixes for each token .
8,632
public void rearrangeTriangles ( int [ ] indices ) { assert indices . length % 3 == 0 ; for ( int off = 0 ; off < indices . length ; off += 3 ) { if ( ( indices [ off + 1 ] < indices [ off ] ) && ( indices [ off + 1 ] < indices [ off + 2 ] ) ) { int tmp = indices [ off ] ; indices [ off ] = indices [ off + 1 ] ; indices [ off + 1 ] = indices [ off + 2 ] ; indices [ off + 2 ] = tmp ; } else if ( ( indices [ off + 2 ] < indices [ off ] ) && ( indices [ off + 2 ] < indices [ off + 1 ] ) ) { int tmp = indices [ off ] ; indices [ off ] = indices [ off + 2 ] ; indices [ off + 2 ] = indices [ off + 1 ] ; indices [ off + 1 ] = tmp ; } } Triangle [ ] tris = new Triangle [ indices . length / 3 ] ; for ( int i = 0 ; i < tris . length ; i ++ ) { int off = i * 3 ; tris [ i ] = new Triangle ( indices , off ) ; } Arrays . sort ( tris ) ; for ( int i = 0 ; i < tris . length ; i ++ ) { int off = i * 3 ; tris [ i ] . copyBack ( indices , off ) ; } }
Re - arrange all triangles for optimal compression .
8,633
public String getDisplayValue ( final ResourceBundleKey resourceBundleKey ) { return ResourceModelFactory . newResourceModel ( getPropertiesKey ( resourceBundleKey . getKey ( ) ) , resourceBundleKey . getParameters ( ) , component , resourceBundleKey . getDefaultValue ( ) ) . getObject ( ) ; }
Gets the display value .
8,634
private ResourceReference getResourceReference ( ) { final Map < String , Object > map = new HashMap < > ( ) ; map . put ( "url" , WicketUrlExtensions . getUrlAsString ( pageClass ) ) ; final ResourceReference resourceReference = new TextTemplateResourceReference ( pageClass , this . filename , "text/javascript" , Model . ofMap ( map ) ) ; return resourceReference ; }
Gets the resource reference .
8,635
public static void addCssFiles ( final IHeaderResponse response , final Class < ? > scope , final String ... cssFilenames ) { for ( final String cssFilename : cssFilenames ) { final HeaderItem item = CssHeaderItem . forReference ( new PackageResourceReference ( scope , cssFilename ) ) ; response . render ( item ) ; } }
Adds the given css files to the given response object in the given scope .
8,636
public static void addJsFiles ( final IHeaderResponse response , final Class < ? > scope , final String ... jsFilenames ) { for ( final String jsFilename : jsFilenames ) { final HeaderItem item = JavaScriptHeaderItem . forReference ( new PackageResourceReference ( scope , jsFilename ) ) ; response . render ( item ) ; } }
Adds the given javascript files to the given response object in the given scope .
8,637
private Set < PackageResourceReferenceWrapper > addFoundPackageResourceReferences ( Set < PackageResourceReferenceWrapper > packageResourceReferences , final Class < ? > iface ) { final Set < PackageResourceReferenceWrapper > prr = PackageResourceReferences . getInstance ( ) . getPackageResourceReferenceMap ( ) . get ( iface ) ; if ( ( packageResourceReferences != null ) && ! packageResourceReferences . isEmpty ( ) ) { if ( ( prr != null ) && ! prr . isEmpty ( ) ) { packageResourceReferences . addAll ( prr ) ; } else { } } else { if ( ( prr != null ) && ! prr . isEmpty ( ) ) { packageResourceReferences = prr ; } } return packageResourceReferences ; }
Adds the found package resource references .
8,638
private Set < PackageResourceReferenceWrapper > addPackageResourceReferenceFromInterfaces ( Set < PackageResourceReferenceWrapper > packageResourceReferences , final Class < ? > searchClass ) { final Class < ? > [ ] interfaces = searchClass . getInterfaces ( ) ; for ( final Class < ? > iface : interfaces ) { packageResourceReferences = addFoundPackageResourceReferences ( packageResourceReferences , iface ) ; } return packageResourceReferences ; }
Adds the package resource reference from interfaces .
8,639
public Set < PackageResourceReferenceWrapper > getPackageResourceReference ( final Class < ? > componentClass ) { Set < PackageResourceReferenceWrapper > packageResourceReference = PackageResourceReferences . getInstance ( ) . getPackageResourceReferenceMap ( ) . get ( componentClass ) ; packageResourceReference = addPackageResourceReferenceFromInterfaces ( packageResourceReference , componentClass ) ; return packageResourceReference ; }
Gets the package resource reference .
8,640
public void initializeResources ( final String packageName ) throws ClassNotFoundException , IOException , URISyntaxException { final Map < Class < ? > , ImportResource [ ] > resourcesMap = ImportResourcesExtensions . getImportResources ( packageName ) ; for ( final Entry < Class < ? > , ImportResource [ ] > entry : resourcesMap . entrySet ( ) ) { final Class < ? > key = entry . getKey ( ) ; final ImportResource [ ] value = entry . getValue ( ) ; final Set < PackageResourceReferenceWrapper > packageResourceReferences = new LinkedHashSet < > ( ) ; for ( final ImportResource importResource : value ) { if ( importResource . resourceType ( ) . equalsIgnoreCase ( "js" ) ) { final PackageResourceReference t = new PackageResourceReference ( key , importResource . resourceName ( ) ) ; packageResourceReferences . add ( new PackageResourceReferenceWrapper ( t , ResourceReferenceType . JS ) ) ; } else if ( importResource . resourceType ( ) . equalsIgnoreCase ( "css" ) ) { final PackageResourceReference t = new PackageResourceReference ( key , importResource . resourceName ( ) ) ; packageResourceReferences . add ( new PackageResourceReferenceWrapper ( t , ResourceReferenceType . CSS ) ) ; } } PackageResourceReferences . getInstance ( ) . getPackageResourceReferenceMap ( ) . put ( key , packageResourceReferences ) ; } }
Initialize resources from the given package .
8,641
private String doCompile ( String resourceLocation ) throws IndexingFailure , ResourceDownloadError { final ResolvedResource resolved = resourceCache . resolveResource ( NAMESPACES , resourceLocation ) ; final File resourceCopy = resolved . getCacheResourceCopy ( ) ; namespaceIndexerService . indexNamespace ( resourceLocation , resolved . getCacheResourceCopy ( ) ) ; final String indexPath = asPath ( resourceCopy . getParent ( ) , NAMESPACE_ROOT_DIRECTORY_NAME , NS_INDEX_FILE_NAME ) ; return indexPath ; }
Do compilation of the namespace resource .
8,642
private Set < String > doSearch ( String resourceLocation , Pattern pattern ) { JDBMNamespaceLookup il = openNamespaces . get ( resourceLocation ) ; Set < String > results = new HashSet < String > ( ) ; for ( String value : il . getKeySet ( ) ) { if ( pattern . matcher ( value ) . matches ( ) ) { results . add ( value ) ; } } return results ; }
Do a search on the values in namespace specified by the resource location
8,643
private void doVerify ( Parameter p ) throws NamespaceSyntaxWarning { if ( p . getValue ( ) == null ) { throw new InvalidArgument ( "parameter value is null" ) ; } Namespace ns = p . getNamespace ( ) ; String resourceLocation = ns . getResourceLocation ( ) ; if ( resourceLocation == null ) { throw new InvalidArgument ( "resourceLocation" , resourceLocation ) ; } JDBMNamespaceLookup il = openNamespaces . get ( ns . getResourceLocation ( ) ) ; if ( il == null ) { throw new IllegalStateException ( "namespace index is not open." ) ; } String encoding = il . lookup ( p . getValue ( ) ) ; if ( encoding == null ) { throw new NamespaceSyntaxWarning ( ns . getResourceLocation ( ) , ns . getPrefix ( ) , p . getValue ( ) ) ; } }
Do namespace value verification against a resource location . This implementation assumes the namespace has been open prior to execution .
8,644
public void copyProviderDataToBuilder ( TemplateBuilder builder , TemplateBuilderDataProvider templateBuilderDataProvider ) { PageSize size = templateBuilderDataProvider . getPageSize ( ) ; if ( templateBuilderDataProvider . isLandscape ( ) ) { builder . setPageHeight ( size . getWidth ( ) ) ; builder . setPageWidth ( size . getHeight ( ) ) ; } else { builder . setPageHeight ( size . getHeight ( ) ) ; builder . setPageWidth ( size . getWidth ( ) ) ; } builder . setTitleText ( templateBuilderDataProvider . getTitle ( ) ) ; builder . setWithArrow ( templateBuilderDataProvider . isWithArrow ( ) ) ; builder . setWithScaleBar ( templateBuilderDataProvider . isWithScaleBar ( ) ) ; builder . setRasterDpi ( templateBuilderDataProvider . getRasterDpi ( ) ) ; builder . setDpi ( templateBuilderDataProvider . getDpi ( ) ) ; }
Fill the builder with information from the data provider . UTIL method .
8,645
protected Label newEmailLabel ( final String id , final String forId , final String resourceKey , final String defaultValue , final Component component ) { return ComponentFactory . newLabel ( id , forId , ResourceModelFactory . newResourceModel ( resourceKey , component , defaultValue ) ) ; }
Factory method for creating the Label . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a Label .
8,646
protected Component newEmailTextField ( final String id , final IModel < PasswordForgottenModelBean > model ) { final IModel < String > labelModel = ResourceModelFactory . newResourceModel ( "password.forgotten.content.label" , this , "Give email in the Textfield" ) ; final IModel < String > placeholderModel = ResourceModelFactory . newResourceModel ( "global.enter.your.email.label" , this , "Enter your email here" ) ; final LabeledEmailTextFieldPanel < String , PasswordForgottenModelBean > emailTextField = new LabeledEmailTextFieldPanel < String , PasswordForgottenModelBean > ( id , model , labelModel ) { private static final long serialVersionUID = 1L ; protected EmailTextField newEmailTextField ( final String id , final IModel < PasswordForgottenModelBean > model ) { final EmailTextField emailTextField = new EmailTextField ( id , new PropertyModel < > ( model , "email" ) ) ; emailTextField . setOutputMarkupId ( true ) ; emailTextField . setRequired ( true ) ; if ( placeholderModel != null ) { emailTextField . add ( new AttributeAppender ( "placeholder" , placeholderModel ) ) ; } return emailTextField ; } } ; return emailTextField ; }
Factory method for creating the EmailTextField for the email . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a EmailTextField for the email .
8,647
private void addParseEvents ( final List < Event > parseEvents , Parse [ ] chunks ) { int ci = 0 ; while ( ci < chunks . length ) { final Parse c = chunks [ ci ] ; final Parse parent = c . getParent ( ) ; if ( parent != null ) { final String type = parent . getType ( ) ; String outcome ; if ( firstChild ( c , parent ) ) { outcome = type + "-" + BioCodec . START ; } else { outcome = type + "-" + BioCodec . CONTINUE ; } c . setLabel ( outcome ) ; if ( this . etype == ParserEventTypeEnum . BUILD ) { parseEvents . add ( new Event ( outcome , this . bcg . getContext ( chunks , ci ) ) ) ; } int start = ci - 1 ; while ( start >= 0 && chunks [ start ] . getParent ( ) == parent ) { start -- ; } if ( lastChild ( c , parent ) ) { if ( this . etype == ParserEventTypeEnum . CHECK ) { parseEvents . add ( new Event ( ShiftReduceParser . COMPLETE , this . kcg . getContext ( chunks , type , start + 1 , ci ) ) ) ; } int reduceStart = ci ; while ( reduceStart >= 0 && chunks [ reduceStart ] . getParent ( ) == parent ) { reduceStart -- ; } reduceStart ++ ; chunks = reduceChunks ( chunks , ci , parent ) ; ci = reduceStart - 1 ; } else { if ( this . etype == ParserEventTypeEnum . CHECK ) { parseEvents . add ( new Event ( ShiftReduceParser . INCOMPLETE , this . kcg . getContext ( chunks , type , start + 1 , ci ) ) ) ; } } } ci ++ ; } }
Adds events for parsing ( post tagging and chunking to the specified list of events for the specified parse chunks .
8,648
private void showDialog ( String msg , String stack ) { ExceptionDialog warning = new ExceptionDialog ( msg , stack ) ; warning . show ( ) ; }
Makes a dialog box to show exception message and stack trace .
8,649
private String rawCreateFolder ( CPath path , String parentId ) { JSONObject body = new JSONObject ( ) ; body . put ( "title" , path . getBaseName ( ) ) ; body . put ( "mimeType" , MIME_TYPE_DIRECTORY ) ; JSONArray ids = new JSONArray ( ) ; JSONObject idObj = new JSONObject ( ) ; idObj . put ( "id" , parentId ) ; ids . put ( idObj ) ; body . put ( "parents" , ids ) ; HttpPost request = new HttpPost ( FILES_ENDPOINT + "?fields=id" ) ; request . setEntity ( new JSONEntity ( body ) ) ; RequestInvoker < CResponse > ri = getApiRequestInvoker ( request , path ) ; JSONObject jresp = retryStrategy . invokeRetry ( ri ) . asJSONObject ( ) ; return jresp . getString ( "id" ) ; }
Create a folder without creating any higher level intermediate folders and returned id of created folder .
8,650
public static void renderHeaderResponse ( final IHeaderResponse response , final Class < ? > componentClass ) { final Set < PackageResourceReferenceWrapper > headerContributors = PackageResourceReferences . getInstance ( ) . getPackageResourceReference ( componentClass ) ; if ( ( null != headerContributors ) && ! headerContributors . isEmpty ( ) ) { for ( final PackageResourceReferenceWrapper packageResourceReference : headerContributors ) { if ( packageResourceReference . getType ( ) . equals ( ResourceReferenceType . JS ) ) { final JavaScriptResourceReference reference = new JavaScriptResourceReference ( componentClass , packageResourceReference . getPackageResourceReference ( ) . getName ( ) ) ; if ( ! response . wasRendered ( reference ) ) { final JavaScriptReferenceHeaderItem headerItem = JavaScriptHeaderItem . forReference ( reference ) ; response . render ( headerItem ) ; } } if ( packageResourceReference . getType ( ) . equals ( ResourceReferenceType . CSS ) ) { final CssResourceReference reference = new CssResourceReference ( componentClass , packageResourceReference . getPackageResourceReference ( ) . getName ( ) ) ; if ( ! response . wasRendered ( reference ) ) { final CssReferenceHeaderItem headerItem = CssHeaderItem . forReference ( reference ) ; response . render ( headerItem ) ; } } } } }
Render header response .
8,651
public static String getSignatureHexCode ( Context context , String targetPackageName ) { if ( TextUtils . isEmpty ( targetPackageName ) ) { return null ; } try { PackageInfo info = PackageManagerUtils . getSignaturePackageInfo ( context , targetPackageName ) ; if ( info . signatures . length != 1 ) { return null ; } Signature sig = info . signatures [ 0 ] ; byte [ ] sha256 = MessageDigestUtils . computeSha256 ( sig . toByteArray ( ) ) ; return StringUtils . byteToHex ( sha256 ) ; } catch ( NameNotFoundException e ) { Log . e ( TAG , "target package not found: " , e ) ; return null ; } }
Obtains the signature hex code .
8,652
@ SuppressLint ( "NewApi" ) public static Point getDisplaySize ( WindowManager manager ) { Display display = manager . getDefaultDisplay ( ) ; if ( Build . VERSION . SDK_INT > Build . VERSION_CODES . HONEYCOMB_MR2 ) { Point size = new Point ( ) ; display . getSize ( size ) ; return size ; } else { Point size = new Point ( ) ; size . x = getDisplayWidth ( manager ) ; size . y = getDisplayHeight ( manager ) ; return size ; } }
Get the display width and height .
8,653
@ SuppressLint ( "NewApi" ) @ SuppressWarnings ( "deprecation" ) public static int getDisplayWidth ( WindowManager manager ) { Display display = manager . getDefaultDisplay ( ) ; if ( Build . VERSION . SDK_INT > Build . VERSION_CODES . HONEYCOMB_MR2 ) { Point size = new Point ( ) ; display . getSize ( size ) ; return size . x ; } else { return display . getWidth ( ) ; } }
Get the display width .
8,654
void initialize ( ) { if ( initialized ) { throw new IllegalStateException ( "Dialect already initialized; re-initialization not allowed" ) ; } this . hashCode = new HashCodeBuilder ( ) . append ( geneNamespaces ) . append ( bpNamespaces ) . append ( chemNamespaces ) . append ( displayLongForm ) . append ( removeNamespacePrefix ) . toHashCode ( ) ; this . initialized = true ; }
Initialize the dialect . Must be invoked post - mutation .
8,655
protected Parameter convert ( Parameter orig ) { if ( orig . getNamespace ( ) == null ) { return orig ; } NamespaceDomain domain = nsDomains . get ( orig . getNamespace ( ) . getPrefix ( ) ) ; if ( domain == null ) { return orig ; } List < Namespace > coll ; switch ( domain ) { case BiologicalProcess : coll = bpNamespaces ; break ; case Chemical : coll = chemNamespaces ; break ; case Gene : coll = geneNamespaces ; break ; default : throw new UnsupportedOperationException ( "Unknown domain: " + domain ) ; } try { SkinnyUUID uuid = equivalencer . getUUID ( getNamespace ( orig . getNamespace ( ) ) , orig . getValue ( ) ) ; if ( uuid == null ) { return orig ; } for ( Namespace ns : coll ) { String v = equivalencer . equivalence ( uuid , ns ) ; if ( v != null ) { return removeNamespacePrefix ? new Parameter ( null , v ) : new Parameter ( ns , v ) ; } } } catch ( EquivalencerException e ) { return null ; } return orig ; }
Convert a parameter to the preferred namespaces .
8,656
public static int dipToPixel ( Resources resources , int dip ) { final float scale = resources . getDisplayMetrics ( ) . density ; return ( int ) ( dip * scale + 0.5f ) ; }
Convert the dips to pixels based on density scale .
8,657
public static float pixelToDip ( WindowManager windowManager , int pixel ) { DisplayMetrics metrics = new DisplayMetrics ( ) ; windowManager . getDefaultDisplay ( ) . getMetrics ( metrics ) ; return metrics . scaledDensity * pixel ; }
Convert the pixels to dips based on density scale
8,658
public static float sipToPixel ( Resources resources , float sip ) { float density = resources . getDisplayMetrics ( ) . scaledDensity ; return sip * density ; }
Convert the sip to pixels based on density scale .
8,659
public static float pixelToSip ( Context context , float pixels ) { DisplayMetrics metrics = new DisplayMetrics ( ) ; float scaledDensity = metrics . scaledDensity ; if ( pixels == 0 || scaledDensity == 0 ) { return 1 ; } return pixels / scaledDensity ; }
Convert the pixels to sips based on density scale .
8,660
@ SuppressWarnings ( "unchecked" ) public static < V extends View > V findViewById ( View view , int id ) { return ( V ) view . findViewById ( id ) ; }
Find the specific view from the view as traversal root . Returning value type is bound to your variable type .
8,661
public ByteSource getByteSource ( ) { ByteSource bs = byteSource ; if ( progressListener != null ) { bs = new ProgressByteSource ( bs , progressListener ) ; } return bs ; }
If no progress listener has been set return the byte source set in constructor otherwise decorate it for progress .
8,662
public void addChildComponent ( final WicketField < ? > parent ) { if ( ( parent . getChildren ( ) != null ) && ! parent . getChildren ( ) . isEmpty ( ) ) { for ( final SimpleTag iterable_element : parent . getChildren ( ) ) { final WicketField < ? > field = ( WicketField < ? > ) iterable_element ; final Component c = parent . getComponent ( ) ; if ( c instanceof MarkupContainer ) { final MarkupContainer mc = ( MarkupContainer ) c ; mc . add ( field . getComponent ( ) ) ; } addChildComponent ( field ) ; } } }
Adds recursive the child components .
8,663
public void start ( Geometry geometry ) { this . geometry = geometry ; splitLine = new Geometry ( Geometry . LINE_STRING , 0 , 0 ) ; service . start ( splitLine ) ; service . setEditingState ( GeometryEditState . INSERTING ) ; service . setInsertIndex ( service . getIndexService ( ) . create ( GeometryIndexType . TYPE_VERTEX , 0 ) ) ; started = true ; eventBus . fireEvent ( new GeometrySplitStartEvent ( geometry ) ) ; }
Start splitting the given geometry .
8,664
private void check ( String pathName ) { for ( char c : pathName . toCharArray ( ) ) { if ( c < 32 || FORBIDDEN_CHAR == c ) { throw new IllegalArgumentException ( "Pathname contains invalid char " + c + " : " + pathName ) ; } } for ( String comp : pathName . split ( "/" ) ) { if ( ! comp . trim ( ) . equals ( comp ) ) { throw new IllegalArgumentException ( "Pathname contains leading or trailing spaces : " + pathName ) ; } } }
Check pathname is valid
8,665
private void processOutputDirectory ( ) { final String outputPath = outputDirectory . getAbsolutePath ( ) ; final String [ ] args = getCommandLineArguments ( ) ; final PhaseThreeApplication p3App = new PhaseThreeApplication ( args ) ; String folder ; if ( p3App . isSkipped ( ) ) { folder = PhaseTwoApplication . DIR_ARTIFACT ; } else { folder = PhaseThreeApplication . DIR_ARTIFACT ; } final File pnPath = new File ( asPath ( outputPath , folder ) ) ; if ( ! pnPath . isDirectory ( ) ) { error ( NOT_A_DIRECTORY + ": " + pnPath ) ; failUsage ( ) ; } final File [ ] files = pnPath . listFiles ( new GlobalProtonetworkFilter ( ) ) ; if ( files . length == 0 || files . length > 1 ) { bail ( ExitCode . NO_GLOBAL_PROTO_NETWORK ) ; } processFiles ( files [ 0 ] ) ; }
Process output directory .
8,666
private void processFiles ( File protoNetwork ) { phaseOutput ( format ( "=== %s ===" , getApplicationName ( ) ) ) ; ProtoNetworkDescriptor pnd = new BinaryProtoNetworkDescriptor ( protoNetwork ) ; BinaryProtoNetworkExternalizer bpne = new BinaryProtoNetworkExternalizer ( ) ; ProtoNetwork gpn = null ; try { gpn = bpne . readProtoNetwork ( pnd ) ; } catch ( ProtoNetworkError e ) { error ( "Unable to read merged network." ) ; exit ( ExitCode . NO_GLOBAL_PROTO_NETWORK ) ; } stage1 ( gpn ) ; }
Starts phase four creation of KAM .
8,667
private void stage1 ( ProtoNetwork gpn ) { beginStage ( PHASE4_STAGE1_HDR , "1" , numPhases ) ; final StringBuilder bldr = new StringBuilder ( ) ; final String kamURL = sysconfig . getKamURL ( ) ; final String kamUser = sysconfig . getKamUser ( ) ; final String kamPass = sysconfig . getKamPassword ( ) ; DBConnection dbc = null ; try { dbc = p4 . stage1ConnectKAMStore ( kamURL , kamUser , kamPass ) ; } catch ( DBConnectionFailure e ) { e . printStackTrace ( ) ; stageError ( e . getUserFacingMessage ( ) ) ; exit ( ExitCode . KAM_CONNECTION_FAILURE ) ; } KamDbObject kamDb = new KamDbObject ( null , kamName , kamDescription , new Date ( ) , null ) ; String kamSchemaName = null ; try { kamSchemaName = p4 . stage2SaveToKAMCatalog ( kamDb ) ; } catch ( KAMCatalogFailure e ) { e . printStackTrace ( ) ; stageError ( e . getUserFacingMessage ( ) ) ; exit ( ExitCode . KAM_CONNECTION_FAILURE ) ; } try { p4 . stage3CreateKAMstore ( dbc , kamSchemaName ) ; } catch ( CreateKAMFailure e ) { e . printStackTrace ( ) ; stageError ( "Unable to build KAM store - " + e . getMessage ( ) ) ; exit ( ExitCode . KAM_CONNECTION_FAILURE ) ; } try { p4 . stage4LoadKAM ( dbc , gpn , kamSchemaName ) ; } catch ( DatabaseError e ) { stageError ( "Unable to load KAM." ) ; stageError ( e . getUserFacingMessage ( ) ) ; exit ( ExitCode . KAM_LOAD_FAILURE ) ; } catch ( CreateKAMFailure e ) { stageError ( "Unable to build KAM store - " + e . getMessage ( ) ) ; exit ( ExitCode . KAM_CONNECTION_FAILURE ) ; } markEndStage ( bldr ) ; }
Stage one connection to KAM store .
8,668
public static Cookie getCookie ( final String name ) { return ( ( WebRequest ) RequestCycle . get ( ) . getRequest ( ) ) . getCookie ( name ) ; }
Gets the cookie form the given name .
8,669
public static Cookie newCookie ( final String name , final String value , final String purpose , final String domain , final int maxAge , final String path , final boolean secure ) { final Cookie cookie = new Cookie ( name , value ) ; cookie . setComment ( purpose ) ; cookie . setDomain ( domain ) ; cookie . setMaxAge ( maxAge ) ; cookie . setPath ( path ) ; return cookie ; }
Creates a new cookie .
8,670
private SnapshotElement newSnapshotElement ( String name , Handle handle , QType type ) throws IOException { return new DefaultSnapshotElement ( name , m_store . getLocation ( handle ) , type , handle . getIdentification ( ) ) ; }
Create a new SnapshotElement instance of name handle and type . Helper method .
8,671
protected RequiredTextField < String > newRequiredTextField ( final String id , final IModel < CaptchaModelBean > model ) { final RequiredTextField < String > captchaInput = new RequiredTextField < String > ( "captchaInput" , new PropertyModel < > ( model , "captchaInput" ) ) { private static final long serialVersionUID = 1L ; protected final void onComponentTag ( final ComponentTag tag ) { super . onComponentTag ( tag ) ; tag . put ( "value" , "" ) ; } } ; captchaInput . setType ( String . class ) ; return captchaInput ; }
Factory method for creating a new RequiredTextField . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a RequiredTextField .
8,672
public final void detailEvaluate ( ) throws IOException { final List < EvaluationMonitor < SequenceLabelSample > > listeners = new LinkedList < EvaluationMonitor < SequenceLabelSample > > ( ) ; final SequenceLabelerDetailedFMeasureListener detailedFListener = new SequenceLabelerDetailedFMeasureListener ( ) ; listeners . add ( detailedFListener ) ; final SequenceLabelerEvaluator evaluator = new SequenceLabelerEvaluator ( this . corpusFormat , this . sequenceLabeler , listeners . toArray ( new SequenceLabelerEvaluationMonitor [ listeners . size ( ) ] ) ) ; evaluator . evaluate ( this . testSamples ) ; System . out . println ( detailedFListener . toString ( ) ) ; }
Evaluate and print the precision recall and F measure per sequence class .
8,673
public List < Annotation > getAllAnnotations ( ) { List < Annotation > ret = new ArrayList < Annotation > ( ) ; for ( StatementGroup sg : statementGroups ) { ret . addAll ( sg . getAllAnnotations ( ) ) ; } return ret ; }
Returns all annotations contained within the document .
8,674
public Set < Namespace > getAllNamespaces ( ) { if ( namespaceGroup == null ) { return emptySet ( ) ; } return new HashSet < Namespace > ( namespaceGroup . getAllNamespaces ( ) ) ; }
Returns the set of all namespaces contained within the document .
8,675
public Set < Term > getAllTerms ( ) { final Set < Term > ret = new HashSet < Term > ( ) ; for ( final StatementGroup sg : statementGroups ) { for ( final Statement stmt : sg . getAllStatements ( ) ) { ret . addAll ( stmt . getAllTerms ( ) ) ; } } return ret ; }
Returns the set of all terms contained within the document .
8,676
public Set < Parameter > getAllParameters ( ) { final Set < Parameter > ret = new HashSet < Parameter > ( ) ; for ( final Term term : getAllTerms ( ) ) { List < Parameter > params = term . getParameters ( ) ; if ( params == null ) { continue ; } ret . addAll ( params ) ; } return ret ; }
Returns the set of all parameters contained within the document .
8,677
public List < StatementGroup > getAllStatementGroups ( ) { final List < StatementGroup > ret = new ArrayList < StatementGroup > ( ) ; ret . addAll ( statementGroups ) ; for ( final StatementGroup sg : statementGroups ) { ret . addAll ( sg . getAllStatementGroups ( ) ) ; } return ret ; }
Returns a list of all statement groups contained within the document .
8,678
public List < Statement > getAllStatements ( ) { final List < Statement > ret = new LinkedList < Statement > ( ) ; for ( final StatementGroup sg : statementGroups ) { ret . addAll ( sg . getAllStatements ( ) ) ; } return ret ; }
Returns a list of all statements contained within the document .
8,679
public int getStatementCount ( ) { int ret = 0 ; for ( final StatementGroup sg : statementGroups ) { ret += sg . getAllStatements ( ) . size ( ) ; } return ret ; }
Returns the count of statements contained within the document .
8,680
public void resolveReferences ( ) { Map < String , AnnotationDefinition > defs = getDefinitionMap ( ) ; final List < Annotation > annos = new ArrayList < Annotation > ( ) ; for ( final StatementGroup sg : statementGroups ) { annos . addAll ( sg . getAllAnnotations ( ) ) ; } for ( final Annotation a : annos ) { AnnotationDefinition ad = a . getDefinition ( ) ; if ( ad == null ) { continue ; } final String id = ad . getId ( ) ; AnnotationDefinition documentDefinition = defs . get ( id ) ; assert documentDefinition != null ; a . setDefinition ( documentDefinition ) ; } Map < String , Namespace > nspcs = getNamespaceMap ( ) ; final List < Parameter > params = new ArrayList < Parameter > ( ) ; for ( final StatementGroup sg : statementGroups ) { params . addAll ( sg . getAllParameters ( ) ) ; } final Namespace defaultNS = nspcs . get ( DEFAULT_NAMESPACE_PREFIX ) ; for ( final Parameter av : params ) { Namespace ns = av . getNamespace ( ) ; if ( ns == null ) { if ( defaultNS != null ) { av . setNamespace ( defaultNS ) ; } continue ; } final String prefix = ns . getPrefix ( ) ; Namespace documentNamespace = nspcs . get ( prefix ) ; assert documentNamespace != null ; av . setNamespace ( documentNamespace ) ; } }
Resolves any property references in use within the document to their corresponding instances .
8,681
protected IModel < String > newDescription ( ) { return ResourceModelFactory . newResourceModel ( ResourceBundleKey . builder ( ) . key ( "page.meta.description" ) . defaultValue ( "" ) . build ( ) , this ) ; }
Factory method that can be overwritten for new meta tag content for description .
8,682
public static WebTask sleepFor ( int seconds ) { return new BaseWebTask ( ) { public WebPage run ( WebPage initialPage ) { try { Thread . sleep ( seconds * 1000 ) ; } catch ( InterruptedException e ) { logger . warn ( "sleep interrupted" ) ; } return initialPage ; } } ; }
Task that sleeps for the given number of seconds and finally returns the very initial page .
8,683
private String buildUrl ( String methodPath , CPath path ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( END_POINT ) . append ( '/' ) . append ( methodPath ) ; if ( path != null ) { sb . append ( '/' ) . append ( scope ) . append ( path . getUrlEncoded ( ) ) ; } return sb . toString ( ) ; }
Url encodes object path and concatenate to API endpoint and method to get full URL
8,684
private String buildContentUrl ( String methodPath , CPath path ) { return CONTENT_END_POINT + '/' + methodPath + '/' + scope + path . getUrlEncoded ( ) ; }
Url encodes blob path and concatenate to content endpoint to get full URL
8,685
private CFile parseCFile ( JSONObject jObj ) { CFile cfile ; if ( jObj . optBoolean ( "is_dir" , false ) ) { cfile = new CFolder ( new CPath ( jObj . getString ( "path" ) ) ) ; } else { cfile = new CBlob ( new CPath ( jObj . getString ( "path" ) ) , jObj . getLong ( "bytes" ) , jObj . getString ( "mime_type" ) ) ; String stringDate = jObj . getString ( "modified" ) ; try { SimpleDateFormat sdf = new SimpleDateFormat ( "EEE, dd MMM yyyy HH:mm:ss Z" , Locale . US ) ; Date modified = sdf . parse ( stringDate ) ; cfile . setModificationDate ( modified ) ; } catch ( ParseException ex ) { throw new CStorageException ( "Can't parse date modified: " + stringDate + " (" + ex . getMessage ( ) + ")" , ex ) ; } } return cfile ; }
Generates a CFile from its json representation
8,686
public static File resolveResource ( String resourceLocation , String localPath , String localFileName ) throws ResourceDownloadError { if ( nulls ( resourceLocation , localPath , localFileName ) ) { throw new InvalidArgument ( "null argument(s) provided" ) ; } createDirectories ( localPath ) ; StringBuilder builder = new StringBuilder ( ) ; builder . append ( localPath ) . append ( File . separator ) . append ( localFileName ) ; File resourceFile = resolver . resolveResource ( resourceLocation , builder . toString ( ) ) ; return resourceFile ; }
Resolves a resource location to a local path .
8,687
public void addUrl ( String url ) { if ( url != null && ! url . isEmpty ( ) ) { renderer . addUrl ( url ) ; } }
Add an URL to the tile service .
8,688
private Collection < RequestMapperBean > initializeRequestMappers ( final Request request ) { final Set < RequestMapperBean > mapperBeans = new TreeSet < > ( getComparator ( ) ) ; for ( final IRequestMapper requestMapper : this . requestMappers ) { mapperBeans . add ( new RequestMapperBean ( requestMapper , requestMapper . getCompatibilityScore ( request ) ) ) ; } return mapperBeans ; }
Initialize request mappers .
8,689
protected Comparator < RequestMapperBean > newComparator ( ) { return new Comparator < RequestMapperBean > ( ) { public int compare ( final RequestMapperBean o1 , final RequestMapperBean o2 ) { return o1 . getCompatibilityScore ( ) - o2 . getCompatibilityScore ( ) ; } } ; }
Factory method for creating a new Comparator for sort the compatibility score . This method is invoked in the method initializeRequestMappers and can be overridden so users can provide their own version of a Comparator .
8,690
public String buildMailtoContent ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( email ) ; if ( StringUtils . isNotEmpty ( subject ) ) { sb . append ( "?" ) . append ( "subject" ) . append ( "=" ) . append ( subject ) ; } if ( StringUtils . isNotEmpty ( body ) ) { sb . append ( StringUtils . isNotEmpty ( subject ) ? "&" : "?" ) . append ( "body" ) . append ( "=" ) . append ( body ) ; } return sb . toString ( ) . trim ( ) ; }
Builds the mailto content .
8,691
private Headers headOrNull ( CPath path ) { try { String url = getObjectUrl ( path ) ; HttpHead request = new HttpHead ( url ) ; RequestInvoker < CResponse > ri = getBasicRequestInvoker ( request , path ) ; CResponse response = retryStrategy . invokeRetry ( ri ) ; return response . getHeaders ( ) ; } catch ( CFileNotFoundException ex ) { return null ; } }
Perform a quick HEAD request on the given object to check existence and type .
8,692
private void rawCreateFolder ( CPath path ) throws CStorageException { CResponse response = null ; try { String url = getObjectUrl ( path ) ; HttpPut request = new HttpPut ( url ) ; request . addHeader ( "Content-Type" , CONTENT_TYPE_DIRECTORY ) ; RequestInvoker < CResponse > ri = getApiRequestInvoker ( request , path ) ; response = retryStrategy . invokeRetry ( ri ) ; } finally { PcsUtils . closeQuietly ( response ) ; } }
Create a folder without creating any higher level intermediate folders .
8,693
public CFile getFile ( CPath path ) { Headers headers = headOrNull ( path ) ; if ( headers == null ) { return null ; } if ( ! headers . contains ( "Content-Type" ) ) { LOGGER . warn ( "{} object has no content type ?!" , path ) ; return null ; } CFile file ; if ( ! CONTENT_TYPE_DIRECTORY . equals ( headers . getHeaderValue ( "Content-Type" ) ) ) { file = new CBlob ( path , Long . parseLong ( headers . getHeaderValue ( "Content-Length" ) ) , headers . getHeaderValue ( "Content-Type" ) , parseTimestamp ( headers ) , parseMetaHeaders ( headers ) ) ; } else { file = new CFolder ( path , parseTimestamp ( headers ) , parseMetaHeaders ( headers ) ) ; } return file ; }
Inquire details about object at given path .
8,694
public CFolderContent listFolder ( CPath path ) throws CStorageException { JSONArray array = listObjectsWithinFolder ( path , "/" ) ; CFile file ; if ( array == null || array . length ( ) == 0 ) { file = getFile ( path ) ; if ( file == null ) { return null ; } if ( file . isBlob ( ) ) { throw new CInvalidFileTypeException ( path , false ) ; } return new CFolderContent ( Collections . EMPTY_MAP ) ; } Map < CPath , CFile > ret = new HashMap < CPath , CFile > ( ) ; boolean detailed ; JSONObject obj ; for ( int i = 0 ; i < array . length ( ) ; i ++ ) { obj = array . getJSONObject ( i ) ; if ( obj . has ( "subdir" ) ) { file = new CFolder ( new CPath ( obj . getString ( "subdir" ) ) ) ; detailed = false ; } else { detailed = true ; if ( ! CONTENT_TYPE_DIRECTORY . equals ( obj . getString ( "content_type" ) ) ) { file = new CBlob ( new CPath ( obj . getString ( "name" ) ) , obj . getLong ( "bytes" ) , obj . getString ( "content_type" ) , parseLastModified ( obj ) , null ) ; } else { file = new CFolder ( new CPath ( obj . getString ( "name" ) ) , parseLastModified ( obj ) , null ) ; } } if ( detailed || ! ret . containsKey ( path ) ) { ret . put ( file . getPath ( ) , file ) ; } } return new CFolderContent ( ret ) ; }
Return map of CFile in given folder . Key is file CPath
8,695
private String getObjectUrl ( CPath path ) { String containerUrl = getCurrentContainerUrl ( ) ; return containerUrl + path . getUrlEncoded ( ) ; }
Url encode object path and concatenate to current container URL to get full URL
8,696
public StorageBuilder setAppInfoRepository ( AppInfoRepository appInfoRepo , String appName ) { this . appInfoRepo = appInfoRepo ; this . appName = appName ; return this ; }
Set the app informations repository . This setter must always be called during the build
8,697
public StorageBuilder setUserCredentialsRepository ( UserCredentialsRepository userCredentialsRepo , String userId ) { this . userCredentialsRepo = userCredentialsRepo ; this . userId = userId ; return this ; }
Set the user credentials repository . This setter must always be called during the build
8,698
public IStorageProvider build ( ) { if ( appInfoRepo == null ) { throw new IllegalStateException ( "Undefined application information repository" ) ; } if ( userCredentialsRepo == null ) { throw new IllegalStateException ( "Undefined user credentials repository" ) ; } try { Constructor providerConstructor = providerClass . getConstructor ( StorageBuilder . class ) ; StorageProvider providerInstance = ( StorageProvider ) providerConstructor . newInstance ( this ) ; return providerInstance ; } catch ( InvocationTargetException itex ) { Throwable cause = itex . getCause ( ) ; if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } throw new UnsupportedOperationException ( "Error instantiating the provider " + providerClass . getSimpleName ( ) , itex ) ; } catch ( Exception ex ) { throw new UnsupportedOperationException ( "Error instantiating the provider " + providerClass . getSimpleName ( ) , ex ) ; } }
Builds a provider - specific storage implementation by passing this builder in constructor . Each implementation gets its required information from builder .
8,699
@ SuppressWarnings ( "unchecked" ) protected List < ? extends Class < ? extends WebPage > > getAllPageClassesQuietly ( ) { final List < Class < ? extends WebPage > > pages = new ArrayList < > ( ) ; try { final Set < Class < ? > > set = AnnotationExtensions . getAllAnnotatedClasses ( getPackageName ( ) , MountPath . class ) ; for ( final Class < ? > class1 : set ) { pages . add ( ( Class < ? extends WebPage > ) class1 ) ; } } catch ( final ClassCastException e ) { LOGGER . error ( e . getClass ( ) . getName ( ) + " occured while scanning for MountPath annotations." , e ) ; } catch ( final ClassNotFoundException e ) { LOGGER . error ( e . getClass ( ) . getName ( ) + " occured while scanning for MountPath annotations." , e ) ; } catch ( final IOException e ) { LOGGER . error ( e . getClass ( ) . getName ( ) + " occured while scanning for MountPath annotations." , e ) ; } catch ( URISyntaxException e ) { LOGGER . error ( e . getClass ( ) . getName ( ) + " occured while scanning for MountPath annotations." , e ) ; } return pages ; }
Gets the all page classes quietly .