idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
12,900
public boolean isEnabledFor ( E_MessageType type ) { if ( ! this . messageHandlers . containsKey ( type ) ) { return false ; } return this . messageHandlers . get ( type ) . isEnabled ( ) ; }
Returns is the report level is enabled or not .
12,901
public MessageMgr clear ( ) { for ( MessageTypeHandler handler : this . messageHandlers . values ( ) ) { handler . clear ( ) ; } this . messages . clear ( ) ; return this ; }
Resets the collected messages and all counters .
12,902
public ByteData decodeFrame ( Frame frame , ByteData pcmData ) { int byteSize = frame . header . blockSize * channels * ( ( streamInfo . getBitsPerSample ( ) + 7 ) / 2 ) ; if ( pcmData == null || pcmData . getData ( ) . length < byteSize ) { pcmData = new ByteData ( byteSize ) ; } else { pcmData . setLen ( 0 ) ; } if ( streamInfo . getBitsPerSample ( ) == 8 ) { for ( int i = 0 ; i < frame . header . blockSize ; i ++ ) { for ( int channel = 0 ; channel < channels ; channel ++ ) { pcmData . append ( ( byte ) ( channelData [ channel ] . getOutput ( ) [ i ] + 0x80 ) ) ; } } } else if ( streamInfo . getBitsPerSample ( ) == 16 ) { for ( int i = 0 ; i < frame . header . blockSize ; i ++ ) { for ( int channel = 0 ; channel < channels ; channel ++ ) { short val = ( short ) ( channelData [ channel ] . getOutput ( ) [ i ] ) ; pcmData . append ( ( byte ) ( val & 0xff ) ) ; pcmData . append ( ( byte ) ( ( val >> 8 ) & 0xff ) ) ; } } } else if ( streamInfo . getBitsPerSample ( ) == 24 ) { for ( int i = 0 ; i < frame . header . blockSize ; i ++ ) { for ( int channel = 0 ; channel < channels ; channel ++ ) { int val = ( channelData [ channel ] . getOutput ( ) [ i ] ) ; pcmData . append ( ( byte ) ( val & 0xff ) ) ; pcmData . append ( ( byte ) ( ( val >> 8 ) & 0xff ) ) ; pcmData . append ( ( byte ) ( ( val >> 16 ) & 0xff ) ) ; } } } return pcmData ; }
Fill the given ByteData object with PCM data from the frame .
12,903
public StreamInfo readStreamInfo ( ) throws IOException { readStreamSync ( ) ; Metadata metadata = readNextMetadata ( ) ; if ( ! ( metadata instanceof StreamInfo ) ) throw new IOException ( "StreamInfo metadata block missing" ) ; return ( StreamInfo ) metadata ; }
Read the FLAC stream info .
12,904
public void decode ( ) throws IOException { readMetadata ( ) ; try { while ( true ) { findFrameSync ( ) ; try { readFrame ( ) ; frameListeners . processFrame ( frame ) ; callPCMProcessors ( frame ) ; } catch ( FrameDecodeException e ) { badFrames ++ ; } } } catch ( EOFException e ) { eof = true ; } }
Decode the FLAC file .
12,905
public void decode ( SeekPoint from , SeekPoint to ) throws IOException { if ( ! ( inputStream instanceof RandomFileInputStream ) ) throw new IOException ( "Not a RandomFileInputStream: " + inputStream . getClass ( ) . getName ( ) ) ; ( ( RandomFileInputStream ) inputStream ) . seek ( from . getStreamOffset ( ) ) ; bitStream . reset ( ) ; samplesDecoded = from . getSampleNumber ( ) ; try { while ( true ) { findFrameSync ( ) ; try { readFrame ( ) ; frameListeners . processFrame ( frame ) ; callPCMProcessors ( frame ) ; } catch ( FrameDecodeException e ) { badFrames ++ ; } if ( to != null && samplesDecoded >= to . getSampleNumber ( ) ) return ; } } catch ( EOFException e ) { eof = true ; } }
Decode the data frames between two seek points .
12,906
private void readStreamSync ( ) throws IOException { int id = 0 ; for ( int i = 0 ; i < 4 ; ) { int x = bitStream . readRawUInt ( 8 ) ; if ( x == Constants . STREAM_SYNC_STRING [ i ] ) { i ++ ; id = 0 ; } else if ( x == ID3V2_TAG [ id ] ) { id ++ ; i = 0 ; if ( id == 3 ) { skipID3v2Tag ( ) ; id = 0 ; } } else { throw new IOException ( "Could not find Stream Sync" ) ; } } }
Read the stream sync string .
12,907
public Metadata readNextMetadata ( ) throws IOException { Metadata metadata = null ; boolean isLast = ( bitStream . readRawUInt ( Metadata . STREAM_METADATA_IS_LAST_LEN ) != 0 ) ; int type = bitStream . readRawUInt ( Metadata . STREAM_METADATA_TYPE_LEN ) ; int length = bitStream . readRawUInt ( Metadata . STREAM_METADATA_LENGTH_LEN ) ; if ( type == Metadata . METADATA_TYPE_STREAMINFO ) { metadata = streamInfo = new StreamInfo ( bitStream , length , isLast ) ; pcmProcessors . processStreamInfo ( ( StreamInfo ) metadata ) ; } else if ( type == Metadata . METADATA_TYPE_SEEKTABLE ) { metadata = seekTable = new SeekTable ( bitStream , length , isLast ) ; } else if ( type == Metadata . METADATA_TYPE_APPLICATION ) { metadata = new Application ( bitStream , length , isLast ) ; } else if ( type == Metadata . METADATA_TYPE_PADDING ) { metadata = new Padding ( bitStream , length , isLast ) ; } else if ( type == Metadata . METADATA_TYPE_VORBIS_COMMENT ) { metadata = vorbisComment = new VorbisComment ( bitStream , length , isLast ) ; } else if ( type == Metadata . METADATA_TYPE_CUESHEET ) { metadata = new CueSheet ( bitStream , length , isLast ) ; } else if ( type == Metadata . METADATA_TYPE_PICTURE ) { metadata = new Picture ( bitStream , length , isLast ) ; } else { metadata = new Unknown ( bitStream , length , isLast ) ; } frameListeners . processMetadata ( metadata ) ; return metadata ; }
Read a single metadata record .
12,908
public void seekTo ( long seekToSamples ) throws IOException { if ( seekTable != null ) { for ( int s = 0 ; s < seekTable . numberOfPoints ( ) ; s ++ ) { SeekPoint p = seekTable . getSeekPoint ( s ) ; samplesDecoded = p . getSampleNumber ( ) ; if ( samplesDecoded >= seekToSamples ) { if ( s > 0 ) p = seekTable . getSeekPoint ( s - 1 ) ; samplesDecoded = p . getSampleNumber ( ) ; bitStream . skip ( p . getStreamOffset ( ) ) ; break ; } } } while ( samplesDecoded < seekToSamples ) { try { findFrameSync ( ) ; readFrame ( ) ; if ( frame != null && frame . header != null ) { samplesDecoded = frame . header . sampleNumber ; if ( samplesDecoded + frame . header . blockSize >= seekToSamples ) break ; } } catch ( Throwable ex ) { } } }
This will do a forward seek - backwards is not possible yet because we would need to reset the inputstream
12,909
public float getBand ( int band ) { float eq = 0.0f ; if ( ( band >= 0 ) && ( band < BANDS ) ) { eq = settings [ band ] ; } return eq ; }
Retrieves the eq setting for a given band .
12,910
float [ ] getBandFactors ( ) { float [ ] factors = new float [ BANDS ] ; for ( int i = 0 , maxCount = BANDS ; i < maxCount ; i ++ ) { factors [ i ] = getBandFactor ( settings [ i ] ) ; } return factors ; }
Retrieves an array of floats whose values represent a scaling factor that can be applied to linear samples in each band to provide the equalization represented by this instance .
12,911
public Node < T > add ( T element ) { Node < T > node = new Node < > ( this , element ) ; nodes . add ( node ) ; return node ; }
Append a new node with the given element .
12,912
public boolean remove ( T element ) { for ( Iterator < Node < T > > it = nodes . iterator ( ) ; it . hasNext ( ) ; ) if ( ObjectUtil . equalsOrNull ( it . next ( ) . element , element ) ) { it . remove ( ) ; return true ; } return false ; }
Remove the first occurrence of the given element .
12,913
public Node < T > get ( T element ) { for ( Node < T > node : nodes ) if ( node . element . equals ( element ) ) return node ; return null ; }
Get the node containing the given element .
12,914
public static String tooltip ( Field field ) { final String tooltip = field . getTooltip ( ) ; if ( tooltip == null ) { return "" ; } return "<img class='tooltip' title='" + tooltip + "' alt='?' src='" + getContextPath ( ) + "/templates/" + getTemplate ( ) + "/img/tooltip.gif' />" ; }
This method show a tooltip if the key is defined
12,915
protected void print ( Object ... objects ) throws IOException { for ( Object object : objects ) { pageContext . getOut ( ) . print ( object ) ; } }
Prints the objects in the jsp writer of the page context
12,916
protected void println ( Object ... objects ) throws IOException { for ( Object object : objects ) { pageContext . getOut ( ) . println ( object ) ; } }
Prints the objects in the jsp writer of the page context with a new line
12,917
public Map < String , Integer > toMap ( ) { Map < String , Integer > ret = new HashMap < > ( ) ; ret . put ( "major" , this . major ) ; ret . put ( "minor" , this . minor ) ; ret . put ( "patch" , this . patch ) ; return ret ; }
Returns the string as a map using the key major for the major part the key minor for the minor part and the key patch for the patch part .
12,918
@ SuppressWarnings ( "unchecked" ) protected Class < T > determineBasicMessageClass ( ) { Class < ? > thisClazz = this . getClass ( ) ; Type superClazz = thisClazz . getGenericSuperclass ( ) ; while ( superClazz instanceof Class ) { superClazz = ( ( Class < ? > ) superClazz ) . getGenericSuperclass ( ) ; } ParameterizedType parameterizedType = ( ParameterizedType ) superClazz ; Type actualTypeArgument = parameterizedType . getActualTypeArguments ( ) [ 0 ] ; Class < T > clazz ; if ( actualTypeArgument instanceof Class < ? > ) { clazz = ( Class < T > ) actualTypeArgument ; } else { TypeVariable < ? > typeVar = ( TypeVariable < ? > ) actualTypeArgument ; clazz = ( Class < T > ) typeVar . getBounds ( ) [ 0 ] ; } return clazz ; }
In order to decode the JSON we need the class representation of the basic message type . This method uses reflection to try to get that type .
12,919
public static JCorsConfig load ( ) { log . info ( "Initializing JCors..." ) ; InputStream fileStream = findFileInClasspath ( CONFIG_FILE_NAME ) ; JCorsConfig config = new JCorsConfig ( ) ; if ( fileStream != null ) { config = loadFromFileStream ( fileStream ) ; Constraint . ensureNotNull ( config , "It was not possible to get a valid configuration instance" ) ; log . info ( String . format ( "Configuration loaded from classpath file '%s'" , CONFIG_FILE_NAME ) ) ; } else { log . info ( String . format ( "No file '%s' found in classpath. Using default configurations." , CONFIG_FILE_NAME ) ) ; } log . info ( config ) ; return config ; }
Loads a configuration from jcors . xml in classpath . If this file is not found uses a default configuration
12,920
private static InputStream findFileInClasspath ( String fileName ) { InputStream is = null ; try { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; is = classLoader . getResourceAsStream ( fileName ) ; return is ; } catch ( Exception ex ) { log . error ( String . format ( "Error while reading file '%s' from classpath" , fileName ) , ex ) ; return null ; } }
Finds a file by name in classpath
12,921
private static JCorsConfig loadFromFileStream ( InputStream fileStream ) { try { JAXBContext context = JAXBContext . newInstance ( ConfigBuilder . class ) ; Unmarshaller unmarshaller = context . createUnmarshaller ( ) ; unmarshaller . setSchema ( loadXmlSchema ( ) ) ; ConfigBuilder configBuilder = ( ConfigBuilder ) unmarshaller . unmarshal ( fileStream ) ; Constraint . ensureNotNull ( configBuilder , "It was not possible to get a valid configuration builder instance" ) ; return configBuilder . buildConfig ( ) ; } catch ( Exception e ) { log . error ( "Failed loading configuration file" , e ) ; return null ; } }
Builds a configuration class based on XML file
12,922
private static Schema loadXmlSchema ( ) throws SAXException { InputStream schemaFileStream = findFileInClasspath ( CONFIG_SCHEMA_FILE_NAME ) ; Constraint . ensureNotNull ( schemaFileStream , "JCors configuration schema not found" ) ; SchemaFactory schemaFactory = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; return schemaFactory . newSchema ( new StreamSource ( schemaFileStream ) ) ; }
Loads the XML validation schema from the classpath
12,923
private static boolean searchTree ( DependencyNode node , int level , ArtifactMatcher excludes , StringBuilder message ) throws InvalidVersionSpecificationException { List < DependencyNode > children = node . getChildren ( ) ; boolean hasTransitiveDependencies = level > 1 ; boolean excluded = false ; StringBuilder messageFromChildren = message == null ? null : new StringBuilder ( ) ; if ( excludes . match ( node . getArtifact ( ) ) ) { excluded = true ; hasTransitiveDependencies = false ; } else { for ( DependencyNode childNode : children ) { hasTransitiveDependencies = ( searchTree ( childNode , level + 1 , excludes , messageFromChildren ) || hasTransitiveDependencies ) ; } } if ( ( excluded || hasTransitiveDependencies ) && message != null ) { for ( int i = 0 ; i < level ; i ++ ) { message . append ( " " ) ; } message . append ( node . getArtifact ( ) ) ; if ( excluded ) { message . append ( " [excluded]\n" ) ; } if ( hasTransitiveDependencies ) { if ( level == 1 ) { message . append ( " has transitive dependencies:" ) ; } message . append ( "\n" ) . append ( messageFromChildren ) ; } } return hasTransitiveDependencies ; }
Searches dependency tree recursively for transitive dependencies that are not excluded while generating nice info message along the way .
12,924
public static int getGenre ( String str ) { for ( int i = 0 ; i < GENRES . length ; i ++ ) if ( GENRES [ i ] . equalsIgnoreCase ( str ) ) return i ; return - 1 ; }
Tries to find the string provided in the table and returns the corresponding int code if successful . Returns - 1 if the genres is not found in the table .
12,925
public static Element getChild ( Element parent , String childName ) { NodeList nodes = parent . getChildNodes ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; ++ i ) { Node node = nodes . item ( i ) ; if ( ( node instanceof Element ) && node . getNodeName ( ) . equals ( childName ) ) return ( Element ) node ; } return null ; }
Return the first child of the given name or null .
12,926
public static List < Element > getChildren ( Element parent , String childName ) { ArrayList < Element > children = new ArrayList < Element > ( ) ; NodeList nodes = parent . getChildNodes ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; ++ i ) { Node node = nodes . item ( i ) ; if ( ( node instanceof Element ) && node . getNodeName ( ) . equals ( childName ) ) children . add ( ( Element ) node ) ; } return children ; }
Return the children with the given name .
12,927
public static String getInnerText ( Node node ) { if ( node instanceof Element ) return ( ( Element ) node ) . getTextContent ( ) ; if ( node . getNodeType ( ) == Node . TEXT_NODE ) return node . getNodeValue ( ) ; if ( node instanceof Text ) return ( ( Text ) node ) . getData ( ) ; return null ; }
Return the inner text of a node .
12,928
public static String getChildText ( Element parent , String childName ) { Element child = getChild ( parent , childName ) ; if ( child == null ) return null ; return getInnerText ( child ) ; }
Return the inner text of the first child with the given name .
12,929
public static Message warn ( Entity entity , String key , String ... args ) { return message ( MessageType . WARN , entity , key , args ) ; }
Create an entity scoped warning message
12,930
public static Message error ( Entity entity , String key , String ... args ) { return message ( MessageType . ERROR , entity , key , args ) ; }
Create an entity scoped error message
12,931
public static Message info ( Entity entity , Field field , String key , String ... args ) { return message ( MessageType . INFO , entity , field , key , args ) ; }
Create a field scoped information message
12,932
public static void initEnvironment ( ) { if ( System . getProperty ( "org.apache.commons.logging.Log" ) == null ) System . setProperty ( "org.apache.commons.logging.Log" , "net.lecousin.framework.log.bridges.ApacheCommonsLogging" ) ; String protocols = System . getProperty ( "java.protocol.handler.pkgs" ) ; if ( protocols == null ) protocols = "" ; if ( ! protocols . contains ( "net.lecousin.framework.protocols" ) ) { if ( protocols . length ( ) > 0 ) protocols += "|" ; protocols += "net.lecousin.framework.protocols" ; System . setProperty ( "java.protocol.handler.pkgs" , protocols ) ; } }
Initialize properties .
12,933
public static MutableBoolean stop ( boolean forceJvmToStop ) { if ( stop != null ) { new Exception ( "LCCore already stopped" , stop ) . printStackTrace ( System . err ) ; return new MutableBoolean ( true ) ; } stop = new Exception ( "LCCore stop requested here" ) ; MutableBoolean stopped = new MutableBoolean ( false ) ; new Thread ( "Stopping LCCore" ) { public void run ( ) { synchronized ( toDoInMainThread ) { toDoInMainThread . notify ( ) ; } if ( instance != null ) instance . stop ( ) ; if ( forceJvmToStop ) { System . out . println ( "Stop JVM." ) ; System . exit ( 0 ) ; } synchronized ( stopped ) { stopped . set ( true ) ; stopped . notifyAll ( ) ; } } } . start ( ) ; return stopped ; }
Stop the environement .
12,934
public static void replaceMainThreadExecutor ( MainThreadExecutor executor ) { MainThreadExecutor previous ; synchronized ( LCCore . class ) { previous = mainThreadExecutor ; mainThreadExecutor = executor ; } do { Runnable toExecute = previous . pop ( ) ; if ( toExecute == null ) break ; executor . execute ( toExecute ) ; } while ( true ) ; }
Replace the main thread executor .
12,935
private Model readModel ( File pom ) throws IOException , XmlPullParserException { Reader reader = ReaderFactory . newXmlReader ( pom ) ; MavenXpp3Reader xpp3 = new MavenXpp3Reader ( ) ; Model model = null ; try { model = xpp3 . read ( reader ) ; } finally { reader . close ( ) ; reader = null ; } return model ; }
Gets the pom model for this file .
12,936
private Model getPomModel ( String groupId , String artifactId , String version , File pom ) throws ArtifactResolutionException , ArtifactNotFoundException , IOException , XmlPullParserException { Model model = null ; boolean found = false ; try { model = readModel ( pom ) ; found = checkIfModelMatches ( groupId , artifactId , version , model ) ; } catch ( IOException e ) { } catch ( XmlPullParserException e ) { } if ( ! found ) { Artifact pomArtifact = factory . createArtifact ( groupId , artifactId , version , null , "pom" ) ; resolver . resolve ( pomArtifact , remoteRepositories , local ) ; model = readModel ( pomArtifact . getFile ( ) ) ; } return model ; }
This method gets the model for the defined artifact . Looks first in the filesystem then tries to get it from the repo .
12,937
public List < Model > getModelsRecursively ( String groupId , String artifactId , String version , File pom ) throws ArtifactResolutionException , ArtifactNotFoundException , IOException , XmlPullParserException { List < Model > models = null ; Model model = getPomModel ( groupId , artifactId , version , pom ) ; Parent parent = model . getParent ( ) ; if ( parent != null ) { String relativePath = parent . getRelativePath ( ) ; if ( StringUtils . isEmpty ( relativePath ) ) { relativePath = "../pom.xml" ; } File parentPom = new File ( pom . getParent ( ) , relativePath ) ; if ( parentPom . isDirectory ( ) ) { parentPom = new File ( parentPom , "pom.xml" ) ; } models = getModelsRecursively ( parent . getGroupId ( ) , parent . getArtifactId ( ) , parent . getVersion ( ) , parentPom ) ; } else { models = new ArrayList < Model > ( ) ; } models . add ( model ) ; return models ; }
This method loops through all the parents getting each pom model and then its parent .
12,938
protected boolean checkIfModelMatches ( String groupId , String artifactId , String version , Model model ) { String modelGroup = model . getGroupId ( ) ; String modelArtifactId = model . getArtifactId ( ) ; String modelVersion = model . getVersion ( ) ; try { if ( StringUtils . isEmpty ( modelGroup ) ) { modelGroup = model . getParent ( ) . getGroupId ( ) ; } else { modelGroup = ( String ) helper . evaluate ( modelGroup ) ; } if ( StringUtils . isEmpty ( modelVersion ) ) { modelVersion = model . getParent ( ) . getVersion ( ) ; } else { modelVersion = ( String ) helper . evaluate ( modelVersion ) ; } modelArtifactId = ( String ) helper . evaluate ( modelArtifactId ) ; } catch ( NullPointerException e ) { } catch ( ExpressionEvaluationException e ) { } return ( StringUtils . equals ( groupId , modelGroup ) && StringUtils . equals ( version , modelVersion ) && StringUtils . equals ( artifactId , modelArtifactId ) ) ; }
Make sure the model is the one I m expecting .
12,939
public void execute ( EnforcerRuleHelper helper ) throws EnforcerRuleException { boolean callSuper ; MavenProject project = null ; if ( onlyWhenRelease ) { project = getProject ( helper ) ; callSuper = ! project . getArtifact ( ) . isSnapshot ( ) ; } else { callSuper = true ; } if ( callSuper ) { super . execute ( helper ) ; if ( failWhenParentIsSnapshot ) { if ( project == null ) { project = getProject ( helper ) ; } Artifact parentArtifact = project . getParentArtifact ( ) ; if ( parentArtifact != null && parentArtifact . isSnapshot ( ) ) { throw new EnforcerRuleException ( "Parent Cannot be a snapshot: " + parentArtifact . getId ( ) ) ; } } } }
Override parent to allow optional ignore of this rule .
12,940
public Object getNestedProperty ( Object obj , String propertyName ) { if ( obj != null && propertyName != null ) { return PresentationManager . getPm ( ) . get ( obj , propertyName ) ; } return null ; }
Getter for a nested property in the given object .
12,941
public String visualize ( Object obj ) throws ConverterException { Integer pad = 0 ; String padc = getConfig ( "pad-count" , "0" ) ; try { pad = Integer . parseInt ( padc ) ; } catch ( Exception e ) { } char padch = getConfig ( "pad-char" , " " ) . charAt ( 0 ) ; String padd = getConfig ( "pad-direction" , "left" ) ; String prefix = getConfig ( "prefix" ) ; String suffix = getConfig ( "suffix" ) ; String res = obj != null ? obj . toString ( ) : "" ; if ( padd . compareToIgnoreCase ( "left" ) == 0 ) { res = Utils . padleft ( res , pad , padch ) ; } else { res = Utils . padright ( res , pad , padch ) ; } if ( prefix != null ) { res = prefix + res ; } if ( suffix != null ) { res = res + suffix ; } return res ; }
Visualization with some standard properties .
12,942
public void addAllowedOrigin ( String origin ) { Constraint . ensureNotEmpty ( origin , String . format ( "Invalid origin '%s'" , origin ) ) ; allowedOrigins . add ( origin ) ; }
Add an origin allowed by the resource
12,943
public void addAllowedHeader ( String header ) { Constraint . ensureNotEmpty ( header , String . format ( "Invalid header '%s'" , header ) ) ; allowedHeaders . add ( header . toLowerCase ( ) ) ; }
Add a header allowed by the resource
12,944
public Collection < String > getAllowedHeaders ( Collection < String > requestHeaders ) { Constraint . ensureNotNull ( requestHeaders , "Null headers" ) ; Set < String > rtAllowedHeaders = new HashSet < String > ( allowedHeaders ) ; rtAllowedHeaders . addAll ( requestHeaders ) ; return rtAllowedHeaders ; }
Return all headers allowed by the resource including the preflight request headers
12,945
public boolean isMethodAllowed ( String method ) { return HttpMethod . isValidMethod ( method ) && ( allowedMethods . isEmpty ( ) || allowedMethods . contains ( method ) ) ; }
Check if the method is allowed by the resource This check is case - sensitive
12,946
public void addAllowedMethod ( String method ) { Constraint . ensureNotEmpty ( method , String . format ( "Invalid method '%s'" , method ) ) ; Constraint . ensureTrue ( HttpMethod . isValidMethod ( method ) , String . format ( "Invalid method '%s'" , method ) ) ; allowedMethods . add ( method . toUpperCase ( ) ) ; }
Add a method allowed by the resource
12,947
public Collection < String > getAllowedMethods ( String requestMethod ) { Constraint . ensureNotEmpty ( requestMethod , String . format ( "Invalid method '%s'" , requestMethod ) ) ; Set < String > rtAllowedMethods = new HashSet < String > ( allowedMethods ) ; rtAllowedMethods . add ( requestMethod . toUpperCase ( ) ) ; return rtAllowedMethods ; }
Return all methods allowed by the resource including the preflight request method
12,948
public boolean registerFileExtension ( String fileTypeName , String fileTypeExtension , String application ) throws OSException { throw new UnsupportedOperationException ( "Not supported yet." ) ; }
Registers a new file extension in the operating system .
12,949
int fetch_headers ( Info vi , Comment vc , int [ ] serialno , Page og_ptr ) { Page og = new Page ( ) ; Packet op = new Packet ( ) ; int ret ; if ( og_ptr == null ) { ret = get_next_page ( og , CHUNKSIZE ) ; if ( ret == OV_EREAD ) return OV_EREAD ; if ( ret < 0 ) return OV_ENOTVORBIS ; og_ptr = og ; } if ( serialno != null ) serialno [ 0 ] = og_ptr . serialno ( ) ; os . init ( og_ptr . serialno ( ) ) ; vi . init ( ) ; vc . init ( ) ; int i = 0 ; while ( i < 3 ) { os . pagein ( og_ptr ) ; while ( i < 3 ) { int result = os . packetout ( op ) ; if ( result == 0 ) break ; if ( result == - 1 ) { vi . clear ( ) ; vc . clear ( ) ; os . clear ( ) ; return - 1 ; } if ( vi . synthesis_headerin ( vc , op ) != 0 ) { vi . clear ( ) ; vc . clear ( ) ; os . clear ( ) ; return - 1 ; } i ++ ; } if ( i < 3 ) if ( get_next_page ( og_ptr , 1 ) < 0 ) { vi . clear ( ) ; vc . clear ( ) ; os . clear ( ) ; return - 1 ; } } return 0 ; }
non - streaming input sources
12,950
void prefetch_all_headers ( Info first_i , Comment first_c , int dataoffset ) throws JOrbisException { Page og = new Page ( ) ; int ret ; vi = new Info [ links ] ; vc = new Comment [ links ] ; dataoffsets = new long [ links ] ; pcmlengths = new long [ links ] ; serialnos = new int [ links ] ; for ( int i = 0 ; i < links ; i ++ ) { if ( first_i != null && first_c != null && i == 0 ) { vi [ i ] = first_i ; vc [ i ] = first_c ; dataoffsets [ i ] = dataoffset ; } else { seek_helper ( offsets [ i ] ) ; vi [ i ] = new Info ( ) ; vc [ i ] = new Comment ( ) ; if ( fetch_headers ( vi [ i ] , vc [ i ] , null , null ) == - 1 ) { dataoffsets [ i ] = - 1 ; } else { dataoffsets [ i ] = offset ; os . clear ( ) ; } } { long end = offsets [ i + 1 ] ; seek_helper ( end ) ; while ( true ) { ret = get_prev_page ( og ) ; if ( ret == - 1 ) { vi [ i ] . clear ( ) ; vc [ i ] . clear ( ) ; break ; } if ( og . granulepos ( ) != - 1 ) { serialnos [ i ] = og . serialno ( ) ; pcmlengths [ i ] = og . granulepos ( ) ; break ; } } } } }
attention to how that s done )
12,951
public Integer getInt ( String name , Integer def ) { final String s = getProperty ( name ) ; try { return Integer . parseInt ( s ) ; } catch ( Exception e ) { return def ; } }
Returns the property assuming its an int . If it isn t or if its not defined returns default value
12,952
public boolean getBool ( String name , boolean def ) { final String s = getProperty ( name ) ; if ( s == null ) { return def ; } try { return s != null && s . equalsIgnoreCase ( "true" ) ; } catch ( Exception e ) { return def ; } }
Returns the property assuming its a boolean . If it isn t or if its not defined returns default value .
12,953
public List < String > getAll ( String name ) { if ( properties == null ) { return null ; } final List < String > all = new ArrayList < String > ( ) ; for ( Property property : properties ) { if ( property . getName ( ) . equals ( name ) ) { all . add ( property . getValue ( ) ) ; } } return all ; }
Return all values for the given name
12,954
public void removeFromQueue ( T t ) { synchronized ( messages ) { for ( Map . Entry < Long , Message > messageEntry : messages . entrySet ( ) ) { if ( messageEntry . getValue ( ) . equals ( t ) ) { Message message = messages . remove ( messageEntry . getKey ( ) ) ; recycle ( message ) ; notifyQueueChanged ( ) ; return ; } } } }
Removing message from queue
12,955
public void scheduleOnce ( Envelope envelope , long time ) { if ( envelope . getMailbox ( ) != this ) { throw new RuntimeException ( "envelope.mailbox != this mailbox" ) ; } envelopes . putEnvelopeOnce ( envelope , time , comparator ) ; }
Send envelope once at time
12,956
protected boolean isEqualEnvelope ( Envelope a , Envelope b ) { return a . getMessage ( ) . getClass ( ) == b . getMessage ( ) . getClass ( ) ; }
Override this if you need to change filtering for scheduleOnce behaviour . By default it check equality only of class names .
12,957
public static < N extends TreeNode < N > > int countNodes ( N tree ) { int result = 0 ; if ( tree == null ) { return result ; } List < N > children = tree . getChildren ( ) ; for ( N node : children ) { result += countNodes ( node ) ; } return result + 1 ; }
This method counts all nodes within a tree .
12,958
public static < N extends TreeNode < N > > boolean equalsWithoutOrder ( N tree1 , N tree2 ) { if ( ! tree1 . getName ( ) . equals ( tree2 . getName ( ) ) ) { return false ; } List < N > children1 = tree1 . getChildren ( ) ; List < N > children2 = tree2 . getChildren ( ) ; if ( children1 . size ( ) != children2 . size ( ) ) { return false ; } for ( N child1 : children1 ) { for ( N child2 : children2 ) { if ( child1 . equals ( child2 ) ) { boolean equals = equalsWithoutOrder ( child1 , child2 ) ; if ( ! equals ) { return false ; } } } } return true ; }
This method checks to trees for equality . Equality is only checked on name basis and the order of the children is neglected .
12,959
public void closeFiles ( ) { filesAreOpened = false ; for ( HeaderIndexFile < Data > file : files ) { if ( file != null ) { file . close ( ) ; } } }
Closes all files
12,960
public static String format ( Object o , int precision ) { return String . format ( getFormat ( o , precision ) , o ) ; }
Returns a String representation of the given object using an appropriate format and the specified precision in case the object is a non - integer number .
12,961
public static String formatTrimmed ( Object o , int precision , int length ) { return String . format ( getTrimmedFormat ( getFormat ( o , precision ) , length ) , o ) ; }
Returns a String representation of the given object using an appropriate format and the specified precision in case the object is a non - integer number trimmed to the specified length .
12,962
public static String getIndexedFormat ( int index , String format ) { if ( index < 1 ) throw new IllegalArgumentException ( ) ; if ( format == null ) throw new NullPointerException ( ) ; if ( format . length ( ) == 0 ) throw new IllegalArgumentException ( ) ; return String . format ( INDEXED_FORMAT , index , format ) ; }
Returns an indexed format by placing the specified index before the given format .
12,963
public int getLength ( ) { int length = 0 ; Iterator < V > it = this . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { length += ( ( ID3v2Frame ) it . next ( ) ) . getFrameLength ( ) ; } return length ; }
Returns the length in bytes of all the frames contained in this object .
12,964
public byte [ ] getBytes ( ) { byte b [ ] = new byte [ getLength ( ) ] ; int bytesCopied = 0 ; Iterator < V > it = this . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { ID3v2Frame frame = ( ID3v2Frame ) it . next ( ) ; System . arraycopy ( frame . getFrameBytes ( ) , 0 , b , bytesCopied , frame . getFrameLength ( ) ) ; bytesCopied += frame . getFrameLength ( ) ; } return b ; }
Return an array bytes containing all frames contained in this object . This can be used to easily write the frames to a file .
12,965
void refreshCaptions ( ) { email . setCaption ( lp . l ( "user.email.caption" ) ) ; password . setCaption ( lp . l ( "user.password.caption" ) ) ; login . setCaption ( lp . l ( "loginform.button.caption" ) ) ; }
Since the language can be changed while this form is displayed we need a method to refresh the captions
12,966
private String checkOriginHeader ( HttpServletRequest request , JCorsConfig config ) { String originHeader = request . getHeader ( CorsHeaders . ORIGIN_HEADER ) ; Constraint . ensureNotEmpty ( originHeader , "Cross-Origin requests must specify an Origin Header" ) ; String [ ] origins = originHeader . split ( " " ) ; for ( String origin : origins ) { Constraint . ensureTrue ( config . isOriginAllowed ( origin ) , String . format ( "The specified origin is not allowed: '%s'" , origin ) ) ; } return originHeader ; }
Checks if the origin is allowed
12,967
public static < Data extends AbstractKVStorable > DRUMS < Data > openTable ( AccessMode accessMode , DRUMSParameterSet < Data > gp ) throws IOException { AbstractHashFunction hashFunction ; try { hashFunction = readHashFunction ( gp ) ; } catch ( ClassNotFoundException e ) { throw new IOException ( "Could not load HashFunction from " + gp . DATABASE_DIRECTORY , e ) ; } return new DRUMS < Data > ( hashFunction , accessMode , gp ) ; }
Opens an existing table .
12,968
public static < Data extends AbstractKVStorable > DRUMS < Data > createOrOpenTable ( AbstractHashFunction hashFunction , DRUMSParameterSet < Data > gp ) throws IOException { File databaseDirectoryFile = new File ( gp . DATABASE_DIRECTORY ) ; DRUMS < Data > drums = null ; if ( databaseDirectoryFile . exists ( ) ) { drums = openTable ( AccessMode . READ_WRITE , gp ) ; } else { drums = createTable ( hashFunction , gp ) ; } return drums ; }
Creates or opens the table . If the directory doesn t exists it will be created .
12,969
public boolean accept ( final File f ) { if ( f . isDirectory ( ) ) return true ; int len = extensions . size ( ) ; if ( len == 0 ) return true ; for ( int i = 0 ; i < len ; i ++ ) { String suffix = extensions . get ( i ) ; if ( suffix . equals ( "*" ) ) return true ; if ( f . getName ( ) . toLowerCase ( ) . endsWith ( '.' + suffix ) ) return true ; if ( f . getName ( ) . toLowerCase ( ) . startsWith ( suffix + '.' ) ) return true ; } return false ; }
Whether the given file is accepted by this filter .
12,970
protected int interpretInfo ( LineParser lp , MessageMgr mm ) { String fileName = this . getFileName ( lp ) ; String content = this . getContent ( fileName , mm ) ; if ( content == null ) { return 1 ; } String [ ] lines = StringUtils . split ( content , "\n" ) ; String info = null ; for ( String s : lines ) { if ( s . startsWith ( "//**" ) ) { info = StringUtils . substringAfter ( s , "//**" ) ; break ; } } if ( info != null ) { mm . report ( MessageMgr . createInfoMessage ( "script {} - info: {}" , new Object [ ] { fileName , info } ) ) ; } return 0 ; }
Interprets the actual info command
12,971
protected int interpretLs ( LineParser lp , MessageMgr mm ) { String directory = lp . getArgs ( ) ; IOFileFilter fileFilter = new WildcardFileFilter ( new String [ ] { "*.ssc" } ) ; DirectoryLoader dl = new CommonsDirectoryWalker ( directory , DirectoryFileFilter . INSTANCE , fileFilter ) ; if ( dl . getLoadErrors ( ) . hasErrors ( ) ) { mm . report ( dl . getLoadErrors ( ) ) ; return 1 ; } FileSourceList fsl = dl . load ( ) ; if ( dl . getLoadErrors ( ) . hasErrors ( ) ) { mm . report ( dl . getLoadErrors ( ) ) ; return 1 ; } for ( FileSource fs : fsl . getSource ( ) ) { mm . report ( MessageMgr . createInfoMessage ( "script file - dir <{}> file <{}>" , directory , fs . getBaseFileName ( ) ) ) ; } return 0 ; }
Interprets the actual ls command
12,972
protected int interpretRun ( LineParser lp , MessageMgr mm ) { String fileName = this . getFileName ( lp ) ; String content = this . getContent ( fileName , mm ) ; if ( content == null ) { return 1 ; } mm . report ( MessageMgr . createInfoMessage ( "" ) ) ; mm . report ( MessageMgr . createInfoMessage ( "running file {}" , fileName ) ) ; for ( String s : StringUtils . split ( content , '\n' ) ) { if ( this . printProgress == true && MessageConsole . PRINT_MESSAGES ) { System . out . print ( "." ) ; } this . skbShell . parseLine ( s ) ; } this . lastScript = fileName ; return 0 ; }
Interprets the actual run command
12,973
protected String getFileName ( LineParser lp ) { String fileName = lp . getArgs ( ) ; if ( fileName == null ) { fileName = this . lastScript ; } else if ( ! fileName . endsWith ( "." + SCRIPT_FILE_EXTENSION ) ) { fileName += "." + SCRIPT_FILE_EXTENSION ; } return fileName ; }
Returns a file name taken as argument from the line parser with fixed extension
12,974
protected String getContent ( String fileName , MessageMgr mm ) { StringFileLoader sfl = new StringFileLoader ( fileName ) ; if ( sfl . getLoadErrors ( ) . hasErrors ( ) ) { mm . report ( sfl . getLoadErrors ( ) ) ; return null ; } String content = sfl . load ( ) ; if ( sfl . getLoadErrors ( ) . hasErrors ( ) ) { mm . report ( sfl . getLoadErrors ( ) ) ; return null ; } if ( content == null ) { mm . report ( MessageMgr . createErrorMessage ( "run: unexpected problem with run script, content was null" ) ) ; return null ; } return content ; }
Returns the content of a string read from a file .
12,975
< T extends Entity < ? , ? > > Builder < BE , T > proceedTo ( Relationships . WellKnown over , Class < T > entityType ) { return new Builder < > ( this , hop ( ) , Query . filter ( ) , entityType ) . hop ( Related . by ( over ) , type ( entityType ) ) ; }
The new context will have the source path composed by appending current select candidates to the current source path and its select candidates will filter for entities related by the provided relationship to the new sources and will have the provided type .
12,976
< T extends Entity < ? , ? > , P extends Enum < P > & Parents > TraversalContext < BE , T > proceedWithParents ( Class < T > nextEntityType , Class < P > parentsType , P currentParent , P [ ] parents , BiConsumer < P , Query . SymmetricExtender > hopBuilder ) { EnumSet < P > ps = ParentsUtil . convert ( parentsType , currentParent , parents ) ; TraversalContext . Builder < BE , E > bld = proceed ( ) ; for ( P p : ps ) { Query . Builder qb = bld . rawQueryBuilder ( ) ; qb = qb . branch ( ) ; Query . SymmetricExtender extender = qb . symmetricExtender ( ) ; hopBuilder . accept ( p , extender ) ; qb . done ( ) ; } return bld . getting ( nextEntityType ) ; }
Proceeds the traversal to the next entities taking into account what parents the next entities should have .
12,977
Builder < BE , Relationship > proceedToRelationships ( Relationships . Direction direction ) { return new Builder < > ( this , hop ( ) , Query . filter ( ) , Relationship . class ) . hop ( new SwitchElementType ( direction , false ) ) ; }
The new context will have the source path composed by appending current select candidates to the current source path . The new context will have select candidates such that it will select the relationships in given direction stemming from the entities on the new source path .
12,978
TraversalContext < BE , E > replacePath ( Query path ) { return new TraversalContext < > ( inventory , path , Query . empty ( ) , backend , entityClass , configuration , observableContext , transactionRetries , this , null , transactionConstructor ) ; }
Constructs a new traversal context by replacing the source path with the provided query and clearing out the selected candidates .
12,979
public List < MonitorLine > getLinesFrom ( Object actual ) throws Exception { String line ; Integer currentLineNo = 0 ; final List < MonitorLine > result = new ArrayList < MonitorLine > ( ) ; BufferedReader in = null ; try { in = new BufferedReader ( new FileReader ( getFilename ( ) ) ) ; Integer startLine = ( actual == null ) ? 0 : ( Integer ) actual ; while ( currentLineNo < startLine + 1 ) { if ( in . readLine ( ) == null ) { throw new IOException ( "File too small" ) ; } currentLineNo ++ ; } line = in . readLine ( ) ; while ( line != null ) { result . add ( new MonitorLine ( currentLineNo , line ) ) ; currentLineNo ++ ; line = in . readLine ( ) ; } } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( IOException ignore ) { } } return result ; }
Get the file lines since the actual until the last .
12,980
public List < MonitorLine > getLastLine ( Integer count ) throws Exception { String line ; final List < MonitorLine > result = new ArrayList < MonitorLine > ( ) ; BufferedReader in = null ; try { in = new BufferedReader ( new FileReader ( getFilename ( ) ) ) ; int i = 0 ; line = in . readLine ( ) ; while ( line != null ) { result . add ( new MonitorLine ( i , line ) ) ; i ++ ; line = in . readLine ( ) ; } } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( IOException ignore ) { } } if ( result . size ( ) <= count ) { return result ; } else { return result . subList ( result . size ( ) - count , result . size ( ) ) ; } }
Return the last file line
12,981
@ SuppressWarnings ( "incomplete-switch" ) protected Icon getIcon ( JTable table , int column ) { SortKey sortKey = getSortKey ( table , column ) ; if ( sortKey != null && table . convertColumnIndexToView ( sortKey . getColumn ( ) ) == column ) { switch ( sortKey . getSortOrder ( ) ) { case ASCENDING : return UIManager . getIcon ( "Table.ascendingSortIcon" ) ; case DESCENDING : return UIManager . getIcon ( "Table.descendingSortIcon" ) ; } } return null ; }
Overloaded to return an icon suitable to the primary sorted column or null if the column is not the primary sort key .
12,982
public void run ( ) { while ( true ) { if ( countObservers ( ) == 0 ) { try { Thread . sleep ( Long . MAX_VALUE ) ; } catch ( InterruptedException e ) { } } else { startWatching ( ) ; while ( countObservers ( ) > 0 ) { getNewLines ( ) ; try { Thread . sleep ( getDelay ( ) ) ; } catch ( InterruptedException e ) { } } } } }
Implemented from runnable
12,983
public void startWatching ( ) { try { final List < MonitorLine > lines = getSource ( ) . getLastLine ( getInitialCount ( ) ) ; actual = null ; updateLines ( lines ) ; } catch ( Exception e ) { notifyObservers ( e ) ; } }
Start watching a monitor
12,984
public void getNewLines ( ) { try { List < MonitorLine > lines ; if ( getAll ( ) ) { lines = getSource ( ) . getLinesFrom ( null ) ; } else { lines = getSource ( ) . getLinesFrom ( actual ) ; } updateLines ( lines ) ; } catch ( Exception e ) { notifyObservers ( e ) ; } }
Looks for new lines
12,985
protected void createFile ( ) throws FileLockException , IOException { openChannel ( ) ; filledUpTo = 0 ; accessFile . setLength ( DEFAULT_SIZE ) ; size = DEFAULT_SIZE ; filledUpTo = HEADER_SIZE ; writeHeader ( ) ; }
this method will be called to init the database - file
12,986
public void unlock ( ) throws IOException { System . runFinalization ( ) ; if ( fileLock != null ) { try { fileLock . release ( ) ; } catch ( ClosedChannelException e ) { throw new IOException ( "Can't close Channel in " + osFile + "." ) ; } fileLock = null ; } }
tries to unlock the file
12,987
public void lock ( ) throws FileLockException , IOException { if ( mode == AccessMode . READ_ONLY ) { return ; } for ( int retries = 0 ; retries < max_retries_connect ; retries ++ ) { try { fileLock = channel . lock ( ) ; break ; } catch ( OverlappingFileLockException e ) { try { logger . debug ( "Can't open file '" + osFile . getAbsolutePath ( ) + "' because it's locked. Waiting {} ms and retry {}" , RETRY_CONNECT_WAITTIME , retries ) ; System . runFinalization ( ) ; Thread . sleep ( RETRY_CONNECT_WAITTIME ) ; } catch ( InterruptedException ex ) { } } } if ( fileLock == null ) { this . close ( ) ; throw new FileLockException ( "File " + osFile . getPath ( ) + " is locked by another process, maybe the database is in use by another process." ) ; } }
tries to lock the file
12,988
protected long checkRegions ( long offset , int length ) throws IOException { if ( offset + length > filledUpTo ) throw new IOException ( "Can't access memory outside the file size (" + filledUpTo + " bytes). You've requested portion " + offset + "-" + ( offset + length ) + " bytes. File: " + osFile . getAbsolutePath ( ) + "\n" + "actual Filesize: " + size + "\n" + "actual filledUpTo: " + filledUpTo ) ; return offset ; }
checks if the accessed region is accessible
12,989
public void close ( ) { logger . debug ( "Try to close accessFile and channel for file: " + osFile ) ; if ( headerBuffer != null ) { headerBuffer . force ( ) ; headerBuffer = null ; } try { unlock ( ) ; if ( channel != null && channel . isOpen ( ) ) { channel . close ( ) ; channel = null ; } if ( accessFile != null ) { accessFile . close ( ) ; accessFile = null ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } logger . debug ( "Closed accessFile and channel for file: " + osFile ) ; }
closes all open channels and the file
12,990
public void delete ( ) throws IOException { close ( ) ; if ( osFile != null ) { boolean deleted = osFile . delete ( ) ; while ( ! deleted ) { try { Thread . sleep ( 100 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; logger . error ( "{} not deleted." , osFile ) ; } System . gc ( ) ; deleted = osFile . delete ( ) ; } } }
tries to delete the file
12,991
protected boolean isInIgnoreParamList ( Parameter param ) { return "javax.servlet.http.HttpServletRequest" . equals ( param . type ( ) . qualifiedTypeName ( ) ) || "javax.servlet.http.HttpServletResponse" . equals ( param . type ( ) . qualifiedTypeName ( ) ) || "javax.servlet.http.HttpSession" . equals ( param . type ( ) . qualifiedTypeName ( ) ) || "org.springframework.web.context.request.WebRequest" . equals ( param . type ( ) . qualifiedTypeName ( ) ) || "java.io.OutputStream" . equals ( param . type ( ) . qualifiedTypeName ( ) ) || "org.springframework.http.HttpEntity<java.lang.String>" . equals ( param . type ( ) . qualifiedTypeName ( ) ) ; }
param which will not be displayed in doc .
12,992
public void write ( long offset , ByteBuffer sourceBuffer ) throws IOException { offset += contentStart ; sourceBuffer . position ( 0 ) ; long newFilePosition = offset + sourceBuffer . limit ( ) ; if ( newFilePosition > contentEnd ) { logger . debug ( "Filesize exceeded (contendEnd: {},size: {})" , contentEnd , size ) ; if ( AUTO_ENLARGE ) { this . enlargeFile ( newFilePosition - contentEnd ) ; } else { throw new IOException ( "Filesize exceeded (" + size + ") and automatic enlargement is disabled. You have to enlarge file manually." ) ; } } if ( offset + sourceBuffer . limit ( ) > filledUpTo ) { filledUpTo = offset + sourceBuffer . limit ( ) ; } channel . write ( sourceBuffer , offset ) ; writeHeader ( ) ; }
writes the bytes from the given ByteBuffer to the file beginning at offset . The size of the HEADER will be respected automatically .
12,993
public void enlargeFile ( long toEnlarge ) throws IOException { size += ( long ) Math . ceil ( ( double ) toEnlarge / incrementSize ) * incrementSize ; logger . debug ( "Enlarge filesize of {} to {}" , osFile , size ) ; contentEnd = size ; accessFile . setLength ( size ) ; if ( ( size - contentStart ) / chunkSize > indexSize ) { logger . error ( "File-Enlargement not possible. The index becomes too large." ) ; throw new IOException ( "File-Enlargement not possible. The index becomes too large." ) ; } calcIndexInformations ( ) ; }
Rounds up the given size to the next full chunk and enlarges the file by these amounts of bytes .
12,994
public boolean isConsistent ( ) throws IOException { byte [ ] b = new byte [ elementSize ] ; long offset = 0 ; byte [ ] oldKey = null ; int i = 0 ; while ( offset < this . getFilledUpFromContentStart ( ) ) { this . read ( offset , ByteBuffer . wrap ( b ) ) ; byte [ ] key = Arrays . copyOfRange ( b , 0 , keySize ) ; if ( oldKey != null && KeyUtils . compareKey ( key , oldKey ) != 1 ) { logger . error ( "File is not consistent at record {}. {} not larger than {}" , new Object [ ] { i , KeyUtils . toStringUnsignedInt ( key ) , KeyUtils . toStringUnsignedInt ( oldKey ) } ) ; return false ; } oldKey = Arrays . copyOf ( key , keySize ) ; offset += elementSize ; i ++ ; } return true ; }
This method checks if the keys of all inserted elements are incrementing continuously .
12,995
public boolean isConsitentWithIndex ( ) throws IOException { byte [ ] b = new byte [ keySize ] ; long offset = 0 ; int maxChunk = getChunkIndex ( getFilledUpFromContentStart ( ) ) ; boolean isConsistent = true ; for ( int i = 1 ; i <= maxChunk ; i ++ ) { offset = i * getChunkSize ( ) - elementSize ; read ( offset , ByteBuffer . wrap ( b ) ) ; if ( KeyUtils . compareKey ( getIndex ( ) . maxKeyPerChunk [ i - 1 ] , b ) != 0 ) { logger . error ( "Index is not consistent to data. Expected {}, but found {}." , Arrays . toString ( getIndex ( ) . maxKeyPerChunk [ i - 1 ] ) , Arrays . toString ( b ) ) ; isConsistent = false ; } } return isConsistent ; }
This method checks if the data is consistent with the index .
12,996
public List < Field > getFields ( Entity entity , String operationId , PMSecurityUser user ) { final String [ ] fs = getFields ( ) . split ( "[ ]" ) ; final List < Field > result = new ArrayList < Field > ( ) ; for ( String string : fs ) { final Field field = entity . getFieldById ( string ) ; if ( field != null ) { if ( operationId == null || field . shouldDisplay ( operationId , user ) ) { result . add ( field ) ; } } } return result ; }
Fields contained in this panel .
12,997
public List < Integer > getPageRange ( ) { List < Integer > r = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= getPages ( ) ; i ++ ) { r . add ( i ) ; } return r ; }
Returns a list with the existing pages index
12,998
public boolean registerFileExtension ( String fileTypeName , String fileTypeExtension , String application ) throws RegistryException , OSException { if ( ! isApplicable ( ) ) { return false ; } fileTypeExtension = sanitizeFileExtension ( fileTypeExtension ) ; String applicationPath = toWindowsPath ( new File ( application ) . getAbsolutePath ( ) ) ; WindowsRegistry . Hive hive = WindowsRegistry . Hive . HKEY_CURRENT_USER ; WindowsRegistry . createKey ( hive . getName ( ) + SOFTWARE_CLASSES_PATH + fileTypeName ) ; WindowsRegistry . createKey ( hive . getName ( ) + SOFTWARE_CLASSES_PATH + fileTypeName + SHELL_OPEN_COMMAND_PATH ) ; WindowsRegistry . writeValue ( hive . getName ( ) + SOFTWARE_CLASSES_PATH + fileTypeName + SHELL_OPEN_COMMAND_PATH , WindowsRegistry . DEFAULT_KEY_NAME , "\"" + applicationPath + "\" \"%1\"" ) ; WindowsRegistry . createKey ( hive . getName ( ) + SOFTWARE_CLASSES_PATH + fileTypeExtension ) ; WindowsRegistry . writeValue ( hive . getName ( ) + SOFTWARE_CLASSES_PATH + fileTypeExtension , WindowsRegistry . DEFAULT_KEY_NAME , fileTypeName ) ; return true ; }
Registers a new file extension in the Windows registry .
12,999
public static int cs_fkeep ( Scs A , Scs_ifkeep fkeep , Object other ) { int j , p , nz = 0 , n , Ap [ ] , Ai [ ] ; float Ax [ ] ; if ( ! Scs_util . CS_CSC ( A ) ) return ( - 1 ) ; n = A . n ; Ap = A . p ; Ai = A . i ; Ax = A . x ; for ( j = 0 ; j < n ; j ++ ) { p = Ap [ j ] ; Ap [ j ] = nz ; for ( ; p < Ap [ j + 1 ] ; p ++ ) { if ( fkeep . fkeep ( Ai [ p ] , j , Ax != null ? Ax [ p ] : 1 , other ) ) { if ( Ax != null ) Ax [ nz ] = Ax [ p ] ; Ai [ nz ++ ] = Ai [ p ] ; } } } Ap [ n ] = nz ; Scs_util . cs_sprealloc ( A , 0 ) ; return ( nz ) ; }
Srops entries from a sparse matrix ;