idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
200
public void attachInfo ( Context context , ProviderInfo info ) { super . attachInfo ( context , info ) ; if ( info . exported ) { throw new SecurityException ( "Provider must not be exported" ) ; } if ( ! info . grantUriPermissions ) { throw new SecurityException ( "Provider must grant uri permissions" ) ; } mStrategy ...
After the FileProvider is instantiated this method is called to provide the system with information about the provider .
201
public static void cleanUp ( Context context ) { File path = getScreenshotFolder ( context ) ; if ( ! path . exists ( ) ) { return ; } delete ( path ) ; }
Delete the screenshot folder for this app . Be careful not to call this before any intents have finished using a screenshot reference .
202
private static void delete ( File file ) { if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File child : files ) { delete ( child ) ; } } } file . delete ( ) ; }
Recursive delete of a file or directory .
203
public static Drawable getCompatDrawable ( Context c , int drawableRes ) { Drawable d = null ; try { if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { d = c . getResources ( ) . getDrawable ( drawableRes ) ; } else { d = c . getResources ( ) . getDrawable ( drawableRes , c . getTheme ( ) ) ; } } cat...
helper method to get the drawable by its resource . specific to the correct android version
204
public static int getThemeAttributeDimensionSize ( Context context , int attr ) { TypedArray a = null ; try { a = context . getTheme ( ) . obtainStyledAttributes ( new int [ ] { attr } ) ; return a . getDimensionPixelSize ( 0 , 0 ) ; } finally { if ( a != null ) { a . recycle ( ) ; } } }
Returns the size in pixels of an attribute dimension
205
private boolean isMobileNetworkEnabled ( ConnectivityManager connectivityManager ) { final NetworkInfo info = connectivityManager . getNetworkInfo ( ConnectivityManager . TYPE_MOBILE ) ; return ( info != null && info . isConnected ( ) ) ; }
True if mobile network enabled
206
public void closeDrawer ( ) { if ( drawerLayout != null ) { if ( drawerGravity != 0 ) { drawerLayout . closeDrawer ( drawerGravity ) ; } else { drawerLayout . closeDrawer ( sliderLayout ) ; } } }
close the drawer
207
public void save ( OnSaveLogListener listener ) { File dir = getLogDir ( ) ; if ( dir == null ) { listener . onError ( "Can't save logs. External storage is not mounted. " + "Check android.permission.WRITE_EXTERNAL_STORAGE permission" ) ; return ; } FileWriter fileWriter = null ; try { File output = new File ( dir , ge...
Save the current logs to disk .
208
void unregisterReceiver ( ) { try { final Context context = contextRef . get ( ) ; if ( context != null ) { context . unregisterReceiver ( receiver ) ; } } catch ( IllegalArgumentException e ) { } }
Unregister network state broadcast receiver
209
void registerReceiver ( ) { if ( receiver == null ) { receiver = new NetworkReceiver ( new Listener ( ) { public void post ( NetworkChangeEvent event ) { if ( onNetworkChangedListener != null ) { onNetworkChangedListener . onChanged ( event ) ; } } } ) ; } final Context context = contextRef . get ( ) ; if ( context != ...
Register network state broadcast receiver
210
void setIsoEntry ( final Iso9660FileEntry entry ) { if ( null != this . entry ) { throw new RuntimeException ( "Cannot change the underlying entry once it has been set" ) ; } if ( null == entry ) { throw new IllegalArgumentException ( "'entry' cannot be null" ) ; } this . entry = entry ; this . type = ( entry . isDirec...
Sets the Iso9660FileEntry that backs this FileObject . This method is package - private because IsoFileSystem pre - creates some directory entries when building the file index and it needs to set the backing entry after the fact .
211
protected void doCloseCommunicationLink ( ) { if ( null != this . fileSystem && ! this . fileSystem . isClosed ( ) ) { try { this . fileSystem . close ( ) ; } catch ( IOException ex ) { VfsLog . warn ( getLogger ( ) , log , "vfs.provider.iso/close-iso-file.error :" + this . fileSystem , ex ) ; } } }
Closes the underlying . iso file .
212
public Iterator < ISO9660Directory > unsortedIterator ( ) { if ( unsortedIterator == null ) { unsortedIterator = new ISO9660DirectoryIterator ( this , false ) ; } unsortedIterator . reset ( ) ; return unsortedIterator ; }
Returns a directory iterator to traverse the directory hierarchy using a recursive method
213
protected final boolean readBlock ( final long block , final byte [ ] buffer ) throws IOException { final int bytesRead = readData ( block * this . blockSize , buffer , 0 , this . blockSize ) ; if ( bytesRead <= 0 ) { return false ; } if ( this . blockSize != bytesRead ) { throw new IOException ( "Could not deserialize...
Read the data for the specified block into the specified buffer .
214
protected final synchronized int readData ( final long startPos , final byte [ ] buffer , final int offset , final int len ) throws IOException { seek ( startPos ) ; return read ( buffer , offset , len ) ; }
Read file data starting at the specified position .
215
public void setVersion ( int version ) throws HandlerException { if ( version < 1 || version > ISO9660Constants . MAX_FILE_VERSION ) { throw new HandlerException ( "Invalid file version: " + version ) ; } this . version = version ; if ( parent != null ) { parent . forceSort ( ) ; } }
Set file version
216
public static long getUInt32 ( byte [ ] src , int offset ) { final long v0 = src [ offset ] & 0xFF ; final long v1 = src [ offset + 1 ] & 0xFF ; final long v2 = src [ offset + 2 ] & 0xFF ; final long v3 = src [ offset + 3 ] & 0xFF ; return ( ( v3 << 24 ) | ( v2 << 16 ) | ( v1 << 8 ) | v0 ) ; }
Gets a 32 - bit unsigned integer from the given byte array at the given offset .
217
public void addModeForPattern ( String pattern , Integer mode ) { System . out . println ( String . format ( "*** Recording pattern \"%s\" with mode %o" , pattern , mode ) ) ; patternToModeMap . put ( pattern , mode ) ; }
Add a new mode for a specific file pattern .
218
public static String getDChars ( byte [ ] block , int pos , int length ) { return new String ( block , pos - 1 , length ) . trim ( ) ; }
Gets a string of d - characters . See section 7 . 4 . 1 .
219
public void setMovedDirectoryStore ( ) { if ( movedDirectoriesStore == null ) { movedDirectoriesStore = new ISO9660Directory ( MOVED_DIRECTORIES_STORE_NAME ) ; addDirectory ( movedDirectoriesStore ) ; sortedIterator = null ; } }
Create and Add Moved Directories Store to Directory Hierarchy
220
public void setUCS2Level ( int level ) throws ConfigException { if ( level != 1 && level != 2 && level != 3 ) { throw new ConfigException ( this , "Invalid UCS-2 level: " + level ) ; } this . ucs2_level = level ; }
Set UCS - 2 Level
221
public void allowASCII ( boolean allow ) { this . allowASCII = allow ; ISO9660NamingConventions . FORCE_ISO9660_CHARSET = ! allow ; if ( allow ) { System . out . println ( "Warning: Allowing the full ASCII character set breaks ISO 9660 conformance." ) ; } }
Allow ASCII for filenames and other strings
222
private void deserializePrimary ( byte [ ] descriptor ) throws IOException { if ( this . hasPrimary ) { return ; } validateBlockSize ( descriptor ) ; if ( ! this . hasSupplementary ) { deserializeCommon ( descriptor ) ; } this . standardIdentifier = Util . getDChars ( descriptor , 2 , 5 ) ; this . volumeSetSize = Util ...
Read the fields of a primary volume descriptor .
223
private void deserializeSupplementary ( byte [ ] descriptor ) throws IOException { if ( this . hasSupplementary ) { return ; } validateBlockSize ( descriptor ) ; String escapeSequences = Util . getDChars ( descriptor , 89 , 32 ) ; String enc = getEncoding ( escapeSequences ) ; if ( null != enc ) { this . encoding = enc...
The supplementary descriptor sets the character encoding and may override the common descriptor information .
224
private void deserializeCommon ( byte [ ] descriptor ) throws IOException { this . systemIdentifier = Util . getAChars ( descriptor , 9 , 32 , this . encoding ) ; this . volumeIdentifier = Util . getDChars ( descriptor , 41 , 32 , this . encoding ) ; this . volumeSetIdentifier = Util . getDChars ( descriptor , 191 , 12...
Read the information common to primary and secondary volume descriptors .
225
private void validateBlockSize ( byte [ ] descriptor ) throws IOException { int blockSize = Util . getUInt16Both ( descriptor , 129 ) ; if ( blockSize != Constants . DEFAULT_BLOCK_SIZE ) { throw new LoopFileSystemException ( "Invalid block size: " + blockSize ) ; } }
Check that the block size is what we expect .
226
private String getEncoding ( String escapeSequences ) { String encoding = null ; if ( escapeSequences . equals ( "%/@" ) ) { encoding = "UTF-16BE" ; } else if ( escapeSequences . equals ( "%/C" ) ) { encoding = "UTF-16BE" ; } else if ( escapeSequences . equals ( "%/E" ) ) { encoding = "UTF-16BE" ; } return encoding ; }
Derive an encoding name from the given escape sequences .
227
public void finalizeDisc ( File isoPath ) { ISOImageFileHandler handler = null ; try { handler = new ISOImageFileHandler ( isoPath ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } try { CreateISO iso = new CreateISO ( handler , root ) ; try { iso . process ( iso9660config , rockConfig , jolietConfi...
Close out the disc .
228
public List < FileItemStream > items ( String fieldName ) { List < FileItemStream > filteredItems = new ArrayList < FileItemStream > ( ) ; for ( FileItemStream fis : _items ) { if ( fis . getFieldName ( ) . equals ( fieldName ) ) filteredItems . add ( fis ) ; } return filteredItems ; }
find items with given form field name
229
public static FsItemFilter createMimeFilter ( final String [ ] mimeFilters ) { if ( mimeFilters == null || mimeFilters . length == 0 ) return FILTER_ALL ; return new FsItemFilter ( ) { public boolean accepts ( FsItemEx item ) { String mimeType = item . getMimeType ( ) . toUpperCase ( ) ; for ( String mf : mimeFilters )...
returns a FsItemFilter according to given mimeFilters
230
protected CommandExecutorFactory createCommandExecutorFactory ( ServletConfig config ) { DefaultCommandExecutorFactory defaultCommandExecutorFactory = new DefaultCommandExecutorFactory ( ) ; defaultCommandExecutorFactory . setClassNamePattern ( "cn.bluejoe.elfinder.controller.executors.%sCommandExecutor" ) ; defaultCom...
create a command executor factory
231
protected ConnectorController createConnectorController ( ServletConfig config ) { ConnectorController connectorController = new ConnectorController ( ) ; connectorController . setCommandExecutorFactory ( createCommandExecutorFactory ( config ) ) ; connectorController . setFsServiceFactory ( createServiceFactory ( conf...
create a connector controller
232
protected StaticFsServiceFactory createServiceFactory ( ServletConfig config ) { StaticFsServiceFactory staticFsServiceFactory = new StaticFsServiceFactory ( ) ; DefaultFsService fsService = createFsService ( ) ; staticFsServiceFactory . setFsService ( fsService ) ; return staticFsServiceFactory ; }
create a service factory
233
private Collection < FsItemEx > findRecursively ( FsItemFilter filter , FsItem root ) { List < FsItemEx > results = new ArrayList < FsItemEx > ( ) ; FsVolume vol = root . getVolume ( ) ; for ( FsItem child : vol . listChildren ( root ) ) { if ( vol . isFolder ( child ) ) { results . addAll ( findRecursively ( filter , ...
find files recursively in specific folder
234
static void removeEntityGraphs ( Map < String , Object > queryHints ) { if ( queryHints == null ) { return ; } queryHints . remove ( EntityGraph . EntityGraphType . FETCH . getKey ( ) ) ; queryHints . remove ( EntityGraph . EntityGraphType . LOAD . getKey ( ) ) ; }
Remove all EntityGraph pre existing in the QueryHints
235
static EntityManager proxy ( EntityManager entityManager ) { ProxyFactory proxyFactory = new ProxyFactory ( entityManager ) ; proxyFactory . addAdvice ( new RepositoryEntityManagerEntityGraphInjector ( ) ) ; return ( EntityManager ) proxyFactory . getProxy ( ) ; }
Builds a proxy on entity manager which is aware of methods that can make use of query hints .
236
private void addEntityGraphToFindMethodQueryHints ( EntityGraphBean entityGraphCandidate , MethodInvocation invocation ) { LOG . trace ( "Trying to push the EntityGraph candidate to the query hints find method" ) ; Map < String , Object > queryProperties = null ; int index = 0 ; for ( Object argument : invocation . get...
Push the current entity graph to the find method query hints .
237
public void execute ( ) throws MojoExecutionException { super . execute ( ) ; try { lambdaFunctions . forEach ( context -> { try { deleteTriggers . andThen ( deleteFunction ) . apply ( context . withFunctionArn ( lambdaClient . getFunction ( new GetFunctionRequest ( ) . withFunctionName ( context . getFunctionName ( ) ...
The entry point into the AWS lambda function .
238
public void storeAs ( String queryName ) { QueryRecorder . queryCompleted ( this . query ) ; QueryMemento qm = this . createMemento ( ) ; IDBAccess dbAccess = ( ( IIntDomainAccess ) this . domainAccess ) . getInternalDomainAccess ( ) . getDBAccess ( ) ; String qLabel = ( ( IIntDomainAccess ) this . domainAccess ) . get...
Store the query with the domain model under the given name .
239
public QueryPersistor augment ( DomainObjectMatch < ? > domainObjectMatch , String as ) { if ( this . augmentations == null ) this . augmentations = new HashMap < DomainObjectMatch < ? > , String > ( ) ; this . augmentations . put ( domainObjectMatch , as ) ; return this ; }
Give a name to a DomainObjectMatch for better readability in a Java - DSL like string representation
240
@ SuppressWarnings ( "unchecked" ) public < T > DomainObjectMatch < T > createMatchFrom ( DomainObjectMatch < T > domainObjectMatch ) { DomainObjectMatch < T > ret ; FromPreviousQueryExpression pqe ; DomainObjectMatch < ? > match ; DomainObjectMatch < ? > delegate = APIAccess . getDelegate ( domainObjectMatch ) ; if ( ...
Create a match from a DomainObjectMatch specified in the context of another query
241
@ SuppressWarnings ( "unchecked" ) public < T > DomainObjectMatch < T > createMatchFor ( T domainObject ) { DomainObjectMatch < T > ret ; if ( domainObject . getClass ( ) . equals ( DomainObject . class ) ) { List < DomainObject > source = new ArrayList < DomainObject > ( ) ; source . add ( ( DomainObject ) domainObjec...
Create a match for a domain object which was retrieved by another query
242
public TerminalResult BR_OPEN ( ) { ConcatenateExpression ce = new ConcatenateExpression ( Concatenator . BR_OPEN ) ; this . astObjectsContainer . addAstObject ( ce ) ; TerminalResult ret = APIAccess . createTerminalResult ( ce ) ; QueryRecorder . recordInvocation ( this , "BR_OPEN" , ret ) ; return ret ; }
Open a block encapsulating predicate expressions
243
public Order ORDER ( DomainObjectMatch < ? > toOrder ) { DomainObjectMatch < ? > delegate = APIAccess . getDelegate ( toOrder ) ; DomainObjectMatch < ? > match = delegate != null ? delegate : toOrder ; OrderExpression oe = this . queryExecutor . getOrderFor ( match ) ; Order ret = APIAccess . createOrder ( oe ) ; Query...
Define an order on a set of domain objects which are specified by a DomainObjectMatch in the context of the domain query .
244
public Traverse TRAVERSE_FROM ( DomainObjectMatch < ? > start ) { DomainObjectMatch < ? > delegate = APIAccess . getDelegate ( start ) ; DomainObjectMatch < ? > match = delegate != null ? delegate : start ; TraversalExpression te = new TraversalExpression ( match , this . queryExecutor ) ; this . queryExecutor . addAst...
Start traversing the graph of domain objects .
245
public < T > Select < T > SELECT_FROM ( DomainObjectMatch < T > start ) { DomainObjectMatch < ? > delegate = APIAccess . getDelegate ( start ) ; DomainObjectMatch < ? > match = delegate != null ? delegate : start ; SelectExpression < T > se = new SelectExpression < T > ( APIAccess . getDomainObjectType ( start ) , matc...
Select domain objects out of a set of other domain objects .
246
public Collect COLLECT ( JcProperty attribute ) { CollectExpression ce = new CollectExpression ( attribute , this . getIntAccess ( ) ) ; Collect coll = APIAccess . createCollect ( ce ) ; this . queryExecutor . addAstObject ( ce ) ; QueryRecorder . recordInvocation ( this , "COLLECT" , coll , QueryRecorder . placeHolder...
Collect the specified attribute from all objects in a DomainObjectMatch
247
@ SuppressWarnings ( "unchecked" ) public < T > DomainObjectMatch < T > INTERSECTION ( DomainObjectMatch < T > ... set ) { DomainObjectMatch < T > ret = this . union_Intersection ( false , set ) ; Object [ ] placeHolders = new Object [ set . length ] ; DomainObjectMatch < ? > delegate ; DomainObjectMatch < ? > match ; ...
Build the intersection of the specified sets
248
public DomainQueryResult execute ( ) { DomainQueryResult ret = new DomainQueryResult ( this ) ; Object so = this . queryExecutor . getMappingInfo ( ) . getInternalDomainAccess ( ) . getSyncObject ( ) ; if ( so != null ) { synchronized ( so ) { this . queryExecutor . execute ( ) ; } } else this . queryExecutor . execute...
Execute the domain query
249
public CountQueryResult executeCount ( ) { CountQueryResult ret = new CountQueryResult ( this ) ; Object so = this . queryExecutor . getMappingInfo ( ) . getInternalDomainAccess ( ) . getSyncObject ( ) ; if ( so != null ) { synchronized ( so ) { this . queryExecutor . executeCount ( ) ; } } else this . queryExecutor . ...
Retrieve the count for every DomainObjectMatch of the query in order to support pagination
250
public String toJSON ( RecordedQuery query ) { StringWriter sw = new StringWriter ( ) ; JsonGenerator generator ; if ( this . prettyFormat != Format . NONE ) { JsonGeneratorFactory gf = JSONWriter . getPrettyGeneratorFactory ( ) ; generator = gf . createGenerator ( sw ) ; } else generator = Json . createGenerator ( sw ...
Answer a JSON representation of a recorded query
251
public RecordedQuery fromJSON ( String json ) { RecordedQuery ret = new RecordedQuery ( false ) ; StringReader sr = new StringReader ( json ) ; JsonReader reader = Json . createReader ( sr ) ; JsonObject jsonResult = reader . readObject ( ) ; ret . setGeneric ( jsonResult . getBoolean ( GENERIC ) ) ; JsonArray augmenta...
Build a recorded query from it s JSON representation
252
public GrProperty getProperty ( String propertyName ) { for ( GrProperty prop : getProperties ( ) ) { if ( prop . getName ( ) . equals ( propertyName ) ) return prop ; } return null ; }
return a property
253
public GrProperty addProperty ( String name , Object value ) { GrProperty prop = GrAccess . createProperty ( name ) ; prop . setValue ( value ) ; return getPropertiesContainer ( ) . addElement ( prop ) ; }
add a new property throw a RuntimeException if the property already exists
254
public long countOf ( DomainObjectMatch < ? > match ) { long ret ; Object so = InternalAccess . getQueryExecutor ( this . domainQuery ) . getMappingInfo ( ) . getInternalDomainAccess ( ) . getSyncObject ( ) ; if ( so != null ) { synchronized ( so ) { ret = intCountOf ( match ) ; } } else ret = intCountOf ( match ) ; re...
Answer the number of domain objects
255
public static String writePretty ( JsonObject jsonObject ) { JsonWriterFactory factory = createPrettyWriterFactory ( ) ; StringWriter sw = new StringWriter ( ) ; JsonWriter writer = factory . createWriter ( sw ) ; writer . writeObject ( jsonObject ) ; String ret = sw . toString ( ) ; writer . close ( ) ; return ret ; }
write a JsonObject formatted in a pretty way into a String
256
public static void printQuery ( JcQuery query , QueryToObserve toObserve , Format format ) { boolean titlePrinted = false ; ContentToObserve tob = QueriesPrintObserver . contentToObserve ( toObserve ) ; if ( tob == ContentToObserve . CYPHER || tob == ContentToObserve . CYPHER_JSON ) { titlePrinted = true ; QueriesPrint...
map to CYPHER statements and map to JSON print the mapping results to System . out
257
public static void printQueries ( List < JcQuery > queries , QueryToObserve toObserve , Format format ) { boolean titlePrinted = false ; ContentToObserve tob = QueriesPrintObserver . contentToObserve ( toObserve ) ; if ( tob == ContentToObserve . CYPHER || tob == ContentToObserve . CYPHER_JSON ) { titlePrinted = true ;...
map to CYPHER statements and map to JSON print the mapping results to the output streams configured in QueriesPrintObserver
258
public static List < String > availableDomains ( IDBAccess dbAccess ) { List < GrNode > resultList = loadAllDomainInfoNodes ( dbAccess ) ; List < String > domains = new ArrayList < String > ( ) ; for ( GrNode rNode : resultList ) { domains . add ( rNode . getProperty ( DomainInfoNameProperty ) . getValue ( ) . toString...
answer the names of available domains .
259
public List < DomainObjectType > getDomainObjectTypes ( ) { List < DomainObjectType > resultList = new ArrayList < DomainObjectType > ( ) ; GrNode infoNode = loadDomainInfoNode ( ) ; GrProperty prop = infoNode . getProperty ( DomainInfoLabel2ClassProperty ) ; if ( prop != null ) { @ SuppressWarnings ( "unchecked" ) Lis...
answer a list of DomainObjectTypes stored in the domain graph
260
public List < String > getDomainObjectTypeNames ( ) { List < DomainObjectType > types = getDomainObjectTypes ( ) ; List < String > typeNames = new ArrayList < String > ( types . size ( ) ) ; for ( DomainObjectType typ : types ) { typeNames . add ( typ . getTypeName ( ) ) ; } return typeNames ; }
answer a list of names of DomainObjectTypes stored in the domain graph
261
public T addElement ( T element ) { getElements ( ) ; if ( ! containsElement ( this . elements , element ) ) { this . elements . add ( element ) ; element . addChangeListener ( this . elementChangeListener ) ; element . notifyState ( ) ; return element ; } throw new RuntimeException ( element . toString ( ) + " already...
add a new element throw a RuntimeException if the element already exists
262
private SyncState checkForElementStates ( SyncState ... states ) { if ( this . elements != null ) { for ( T elem : this . elements ) { for ( SyncState state : states ) { if ( elem . getSyncState ( ) != state ) return elem . getSyncState ( ) ; } } } return null ; }
check all elements if their state is one of the given states
263
public void addListFieldValue ( String fieldName , Object value ) { Object val = value ; if ( value instanceof DomainObject ) val = ( ( DomainObject ) value ) . getRawObject ( ) ; Object lst = getFieldValue ( fieldName , true ) ; DOField fld = getDomainObjectType ( ) . getFieldByName ( fieldName ) ; String ctn = fld . ...
Add a value to a list or array field
264
public Object getListFieldValue ( String fieldName , int index ) { Object ret = null ; Object val = getFieldValue ( fieldName , true ) ; if ( val instanceof List < ? > ) { List < ? > list = ( List < ? > ) val ; Object cval = list . get ( index ) ; DomainObject gdo = getForRawObject ( cval ) ; if ( gdo != null ) ret = g...
if the field is a list or array answer the value at the given index .
265
public int getIndexOfValue ( String fieldName , Object value ) { int ret = - 1 ; Object val = value ; if ( value instanceof DomainObject ) val = ( ( DomainObject ) value ) . getRawObject ( ) ; Object lst = getFieldValue ( fieldName , true ) ; if ( lst instanceof List < ? > ) { List < ? > list = ( List < ? > ) lst ; for...
Returns the index of the first occurrence of the specified value in the list field or - 1 if the list field does not contain the value .
266
public void clearListField ( String fieldName ) { Object val = getFieldValue ( fieldName , true ) ; if ( val instanceof List < ? > ) ( ( List < ? > ) val ) . clear ( ) ; else if ( val != null && val . getClass ( ) . isArray ( ) ) { DOField fld = getDomainObjectType ( ) . getFieldByName ( fieldName ) ; String ctn = fld ...
Removes all of the elements from the list field .
267
public int getListFieldLength ( String fieldName ) { int ret = - 1 ; Object val = getFieldValue ( fieldName , true ) ; if ( val instanceof List < ? > ) ret = ( ( List < ? > ) val ) . size ( ) ; else if ( val != null && val . getClass ( ) . isArray ( ) ) { ret = Array . getLength ( val ) ; } else { if ( ! getDomainObjec...
Answer the length of a list field
268
@ SuppressWarnings ( "unchecked" ) public DomainObjectMatch < T > ELEMENTS ( TerminalResult ... where ) { DomainObjectMatch < T > ret ; SelectExpression < T > se = this . getSelectExpression ( ) ; DomainObjectMatch < ? > selDom = APIAccess . createDomainObjectMatch ( se . getStart ( ) . getDomainObjectType ( ) , se . g...
Specify one or more predicate expressions to constrain the set of domain objects
269
private JcError checkLockingError ( List < JcQueryResult > results , boolean hasCreateQuery , List < ElemId2Query > elemIds2Query ) { JcError error = null ; if ( this . lockingStrategy == Locking . OPTIMISTIC ) { JcNumber lockV = new JcNumber ( "lockV" ) ; JcNumber nSum = new JcNumber ( "sum" ) ; int to = hasCreateQuer...
in case of error return the element s id or if not available return - 2 in case of change or - 3 in case of delete in case of ok return - 1
270
Parameter getCreateParameter ( String name ) { if ( this . parameters == null ) this . parameters = new HashMap < String , Parameter > ( ) ; Parameter param = this . parameters . get ( name ) ; if ( param == null ) { param = new Parameter ( name ) ; this . parameters . put ( name , param ) ; } return param ; }
Get or create if not exists a query parameter .
271
public String getDomains ( ) { StringWriter sw = new StringWriter ( ) ; JsonGenerator generator ; if ( this . prettyFormat != Format . NONE ) { JsonGeneratorFactory gf = JSONWriter . getPrettyGeneratorFactory ( ) ; generator = gf . createGenerator ( sw ) ; } else generator = Json . createGenerator ( sw ) ; generator . ...
Answer a JSON representation of the available domains in the database
272
public List < Class < ? > > getTypes ( boolean noAbstractTypes ) { List < Class < ? > > typeList = new ArrayList < Class < ? > > ( ) ; this . addType ( typeList , noAbstractTypes ) ; return typeList ; }
Answer a list of types of this CompoundObjectType .
273
public LiteralMapList resultMapListOf ( JcPrimitive ... key ) { List < List < ? > > results = new ArrayList < List < ? > > ( ) ; LiteralMapList ret = new LiteralMapList ( ) ; int size = - 1 ; ResultHandler . includeNullValues . set ( Boolean . TRUE ) ; try { for ( JcPrimitive k : key ) { List < ? > r = this . resultOf ...
answer a list of literal maps containing result values for the given keys
274
protected Class < ? > getComponentType ( GrNode rNode ) { Class < ? > compType ; if ( this . getFieldType ( ) . isArray ( ) && ( compType = this . getFieldType ( ) . getComponentType ( ) ) . isPrimitive ( ) ) { return compType ; } return null ; }
only called when to check for a concrete simple component type
275
public GrLabel getLabel ( String labelName ) { for ( GrLabel lab : getLabels ( ) ) { if ( lab . getName ( ) . equals ( labelName ) ) return lab ; } return null ; }
return a label
276
public GrLabel addLabel ( String name ) { GrLabel lab = GrAccess . createLabel ( name ) ; return getLabelsContainer ( ) . addElement ( lab ) ; }
add a new label throw a RuntimeException if the label already exists
277
public TraversalStep FORTH ( String attributeName ) { TraversalExpression te = ( TraversalExpression ) this . astObject ; te . step ( attributeName , 0 ) ; TraversalStep ret = new TraversalStep ( te ) ; QueryRecorder . recordInvocation ( this , "FORTH" , ret , QueryRecorder . literal ( attributeName ) ) ; return ret ; ...
Traverse forward via an attribute
278
public < T > DomainObjectMatch < T > TO ( Class < T > domainObjectType ) { TraversalExpression te = ( TraversalExpression ) this . astObject ; DomainObjectMatch < T > ret = APIAccess . createDomainObjectMatch ( domainObjectType , te . getQueryExecutor ( ) . getDomainObjectMatches ( ) . size ( ) , te . getQueryExecutor ...
End the traversal of the domain object graph matching a specific type of domain objects
279
public void remove ( ) { SyncState oldState = this . syncState ; if ( this . syncState == SyncState . NEW || this . syncState == SyncState . NEW_REMOVED ) this . syncState = SyncState . NEW_REMOVED ; else this . syncState = SyncState . REMOVED ; if ( oldState != this . syncState ) fireChanged ( oldState , this . syncSt...
removes this item
280
public JcProperty atttribute ( String name ) { if ( this . delegate != null ) return this . delegate . atttribute ( name ) ; JcProperty ret = checkField_getJcVal ( name , JcProperty . class ) ; QueryRecorder . recordInvocationReplace ( this , ret , "atttribute" ) ; return ret ; }
Access an attribute don t rely on a specific attribute type
281
public JcString stringAtttribute ( String name ) { if ( this . delegate != null ) return this . delegate . stringAtttribute ( name ) ; JcString ret = checkField_getJcVal ( name , JcString . class ) ; QueryRecorder . recordInvocationReplace ( this , ret , "stringAtttribute" ) ; return ret ; }
Access a string attribute
282
public JcNumber numberAtttribute ( String name ) { if ( this . delegate != null ) return this . delegate . numberAtttribute ( name ) ; JcNumber ret = checkField_getJcVal ( name , JcNumber . class ) ; QueryRecorder . recordInvocationReplace ( this , ret , "numberAtttribute" ) ; return ret ; }
Access a number attribute
283
public JcBoolean booleanAtttribute ( String name ) { if ( this . delegate != null ) return this . delegate . booleanAtttribute ( name ) ; JcBoolean ret = checkField_getJcVal ( name , JcBoolean . class ) ; QueryRecorder . recordInvocationReplace ( this , ret , "booleanAtttribute" ) ; return ret ; }
Access a boolean attribute
284
public JcCollection collectionAtttribute ( String name ) { if ( this . delegate != null ) return this . delegate . collectionAtttribute ( name ) ; JcCollection ret = checkField_getJcVal ( name , JcCollection . class ) ; QueryRecorder . recordInvocationReplace ( this , ret , "collectionAtttribute" ) ; return ret ; }
Access a collection attribute
285
public static IDomainAccess createDomainAccess ( IDBAccess dbAccess , String domainName ) { return IDomainAccessFactory . INSTANCE . createDomainAccess ( dbAccess , domainName ) ; }
Create a domain accessor .
286
public static IGenericDomainAccess createGenericDomainAccess ( IDBAccess dbAccess , String domainName , DomainLabelUse domainLabelUse ) { return IDomainAccessFactory . INSTANCE . createGenericDomainAccess ( dbAccess , domainName , domainLabelUse ) ; }
Create a domain accessor which works with a generic domain model .
287
public OrderDirection BY ( String attributeName ) { OrderBy ob = this . orderExpression . getCreateOrderCriteriaFor ( attributeName ) ; OrderDirection ret = new OrderDirection ( ob ) ; QueryRecorder . recordInvocation ( this , "BY" , ret , QueryRecorder . literal ( attributeName ) ) ; return ret ; }
Specify the attribute to be used for sorting
288
public String getDomainName ( ) { DomainModel model = ( ( IIntDomainAccess ) this . domainAccess ) . getInternalDomainAccess ( ) . getDomainModel ( ) ; StringWriter sw = new StringWriter ( ) ; JsonGenerator generator ; if ( this . prettyFormat != Format . NONE ) { JsonGeneratorFactory gf = JSONWriter . getPrettyGenerat...
Answer a JSON object containing the domain name
289
public static Graph create ( IDBAccess dbAccess ) { ResultHandler rh = new ResultHandler ( dbAccess ) ; Graph ret = rh . getGraph ( ) ; ret . setSyncState ( SyncState . NEW ) ; return ret ; }
create an empty graph
290
public GrRelation createRelation ( String type , GrNode startNode , GrNode endNode ) { return this . resultHandler . getLocalElements ( ) . createRelation ( type , startNode , endNode ) ; }
create a relation in the graph
291
public DomainQuery replayQuery ( RecordedQuery recordedQuery , IDomainAccess domainAccess ) { Boolean br_old = null ; DomainQuery query ; try { if ( ! Settings . TEST_MODE ) { br_old = QueryRecorder . blockRecording . get ( ) ; if ( this . createNew ) QueryRecorder . blockRecording . set ( Boolean . FALSE ) ; else Quer...
Create a domain query from a recorded query .
292
public GDomainQuery replayGenericQuery ( RecordedQuery recordedQuery , IGenericDomainAccess domainAccess ) { Boolean br_old = null ; GDomainQuery query ; try { if ( ! Settings . TEST_MODE ) { br_old = QueryRecorder . blockRecording . get ( ) ; if ( this . createNew ) QueryRecorder . blockRecording . set ( Boolean . FAL...
Create a generic domain query from a recorded query .
293
public static JcPrimitive fromType ( Class < ? > type , String name ) { if ( type . equals ( String . class ) ) return new JcString ( name ) ; else if ( type . equals ( Number . class ) ) return new JcNumber ( name ) ; else if ( type . equals ( Boolean . class ) ) return new JcBoolean ( name ) ; return null ; }
Answer an appropriate instance of a JcPrimitive for the given simple - type and name . E . g . given a type java . lang . String a JcString instance will be returned .
294
public static Object [ ] getEnumValues ( Class < ? extends Enum < ? > > clazz ) { Object [ ] enums = clazz . getEnumConstants ( ) ; if ( enums == null ) { Method [ ] mthds = clazz . getDeclaredMethods ( ) ; Method mthd = null ; for ( Method mth : mthds ) { if ( mth . getName ( ) . equals ( "values" ) ) { mthd = mth ; b...
finds enum values in normal enum classes and in dynamically created ones .
295
public List < String > getDeclaredFieldNames ( ) { if ( this . declaredFieldNames == null ) { this . declaredFieldNames = new ArrayList < String > ( this . declaredFields . size ( ) ) ; for ( DOField f : this . declaredFields ) { this . declaredFieldNames . add ( f . getName ( ) ) ; } } return this . declaredFieldNames...
Answer a list of all field names declared by this type .
296
public List < String > getFieldNames ( ) { List < String > ret = new ArrayList < String > ( ) ; DOType typ = this ; while ( typ != null ) { ret . addAll ( typ . getDeclaredFieldNames ( ) ) ; typ = typ . getSuperType ( ) ; } return ret ; }
Answer a list of all field names declared by this type and all it s super types .
297
public Object getEnumValue ( String name ) { if ( this . kind != Kind . ENUM ) throw new RuntimeException ( "getEnumValue(..) can only be called on an enum" ) ; Object [ ] vals = getEnumValues ( ) ; if ( vals != null ) { for ( Object val : vals ) { if ( ( ( Enum < ? > ) val ) . name ( ) . equals ( name ) ) return val ;...
Answer an enum value with the given name .
298
@ SuppressWarnings ( "unchecked" ) public Object [ ] getEnumValues ( ) { if ( this . kind != Kind . ENUM ) throw new RuntimeException ( "getEnumValues() can only be called on an enum" ) ; try { return MappingUtil . getEnumValues ( ( Class < ? extends Enum < ? > > ) getRawType ( ) ) ; } catch ( ClassNotFoundException e ...
Answer the list of enum values of this enum .
299
public static InputStream findInputStreamForResource ( final ZipFile zipFile , final String resourcePath ) throws IOException { final ZipEntry entry = zipFile . getEntry ( resourcePath ) ; InputStream result = null ; if ( entry != null && ! entry . isDirectory ( ) ) { result = zipFile . getInputStream ( entry ) ; } ret...
Get input stream for resource in zip file .