idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
11,900 | @ SuppressWarnings ( { "unchecked" } ) public static Component findByComponentType ( String id , String containerId , String componentType , int index , boolean required ) { java . awt . Container container = null ; if ( isBlank ( containerId ) ) { container = ( java . awt . Container ) currentWindow ( ) . getComponent ( ) . getSource ( ) ; } else { ComponentOperator op = componentMap . getComponent ( containerId ) ; if ( op != null && op . getSource ( ) instanceof java . awt . Container ) { container = ( java . awt . Container ) op . getSource ( ) ; } else { container = ( java . awt . Container ) findComponent ( containerId , currentWindow ( ) . getComponent ( ) . getSource ( ) ) ; if ( container == null ) { container = ( java . awt . Container ) currentWindow ( ) . getComponent ( ) . getSource ( ) ; } } } List < java . awt . Component > list = findComponents ( container , translateFindType ( componentType ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "findComponents returned list :" ) ; for ( java . awt . Component c : list ) { logger . debug ( " " + c . getName ( ) ) ; } logger . debug ( " index = " + index ) ; } if ( index < 0 || index >= list . size ( ) ) { if ( required ) { throw new JemmyDSLException ( "Component " + id + " not found" ) ; } else { componentMap . putComponent ( id , null ) ; logger . debug ( "findByComponentType returned null" ) ; return null ; } } java . awt . Component component = list . get ( index ) ; if ( component == null ) { if ( ! required ) { componentMap . putComponent ( id , null ) ; logger . debug ( "findByComponentType returned null" ) ; return null ; } else { throw new JemmyDSLException ( "Component " + id + " not found" ) ; } } JComponentOperator operator = convertFind ( component ) ; componentMap . putComponent ( id , operator ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "findByComponentType returned " + component ) ; } return convertFind ( operator ) ; } | Finds the first component with the given component type and stores it under the given id . The component can later be used on other commands using the locator id = ID_ASSIGNED . This method searches both VISIBLE and INVISIBLE components . |
11,901 | public void addlistener ( final ChangeListener listener ) { synchronized ( LISTENER_LOCK ) { if ( listeners . contains ( listener ) ) { LOGGER . warn ( "Skip listener registration. listener[" + listener + "] is already registered!" ) ; return ; } listeners . add ( listener ) ; } } | Registers the given listener to get informed about changes . |
11,902 | boolean hasNext ( ) throws DataSourceReadException { if ( ! hasNextComputed ) { boolean stayInLoop ; do { stayInLoop = false ; if ( i == 0 ) { this . currentMin = null ; for ( DataStreamingEvent < E > elt : this . currentElt ) { currentMin = min ( elt ) ; } } if ( currentMin == null ) { this . hasNext = false ; } else { int n = this . currentElt . size ( ) ; for ( ; i < n ; i ++ ) { DataStreamingEvent < E > elt = this . currentElt . get ( i ) ; if ( elt != null && elt . getKeyId ( ) . equals ( this . currentMin != null ? this . currentMin . getKeyId ( ) : null ) ) { this . result = elt ; this . nextKeyId = elt . getKeyId ( ) ; advance ( i ) ; i ++ ; break ; } } if ( this . i == n && this . result == null ) { this . i = 0 ; stayInLoop = true ; } } } while ( this . hasNext && stayInLoop ) ; this . hasNextComputed = true ; } return hasNext ; } | We loop through the iterators passed into the constructor and return whether the the next item in at least one iterator is for the right keyId . |
11,903 | public OkVolley init ( Context context ) { this . mContext = context ; InstanceRequestQueue = newRequestQueue ( context ) ; mUserAgent = generateUserAgent ( context ) ; mRequestHeaders = new HashMap < > ( ) ; mRequestHeaders . put ( OkRequest . HEADER_USER_AGENT , mUserAgent ) ; mRequestHeaders . put ( OkRequest . HEADER_ACCEPT_CHARSET , OkRequest . CHARSET_UTF8 ) ; return this ; } | init method please call this method in Application |
11,904 | public static String generateUserAgent ( Context context ) { StringBuilder ua = new StringBuilder ( "api-client/" ) ; ua . append ( VERSION ) ; String packageName = context . getApplicationContext ( ) . getPackageName ( ) ; ua . append ( " " ) ; ua . append ( packageName ) ; PackageInfo pi = null ; try { pi = context . getPackageManager ( ) . getPackageInfo ( packageName , 0 ) ; } catch ( PackageManager . NameNotFoundException e ) { e . printStackTrace ( ) ; } if ( pi != null ) { ua . append ( "/" ) ; ua . append ( pi . versionName ) ; ua . append ( "(" ) ; ua . append ( pi . versionCode ) ; ua . append ( ")" ) ; } ua . append ( " Android/" ) ; ua . append ( Build . VERSION . SDK_INT ) ; try { ua . append ( " " ) ; ua . append ( Build . PRODUCT ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } try { ua . append ( " " ) ; ua . append ( Build . MANUFACTURER ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } try { ua . append ( " " ) ; ua . append ( Build . MODEL ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return ua . toString ( ) ; } | build the default User - Agent |
11,905 | public static RequestQueue getRequestQueue ( Context context ) { if ( InstanceRequestQueue == null ) { InstanceRequestQueue = newRequestQueue ( context ) ; } return InstanceRequestQueue ; } | getRquest queue static |
11,906 | public void visit ( LowLevelAbstractionDefinition lowLevelAbstractionDefinition ) throws NoSuchAlgorithmException , AlgorithmSourceReadException { String algorithmId = lowLevelAbstractionDefinition . getAlgorithmId ( ) ; Algorithm algorithm = this . algorithmSource . readAlgorithm ( algorithmId ) ; if ( algorithm == null && algorithmId != null ) { throw new NoSuchAlgorithmException ( "Low level abstraction definition " + lowLevelAbstractionDefinition . getId ( ) + " wants the algorithm " + algorithmId + ", but no such algorithm is available." ) ; } this . algorithms . put ( lowLevelAbstractionDefinition , algorithm ) ; } | Throws an exception if no algorithm was found for the given low level abstraction definition . |
11,907 | public void objectRetracted ( ObjectRetractedEvent ore ) { String name = ore . getPropagationContext ( ) . getRuleOrigin ( ) . getName ( ) ; if ( name . equals ( "DELETE_PROPOSITION" ) ) { Proposition prop = ( Proposition ) ore . getOldObject ( ) ; LOGGER . log ( Level . FINEST , "Deleted proposition {0}" , prop ) ; prop . accept ( this . setDeleteDatePropVisitor ) ; this . propsToDelete . add ( this . setDeleteDatePropVisitor . getDeleted ( ) ) ; } } | Listens for retracted propositions that were retracted as a result of another proposition coming from a data source backend with a non - null delete date . Adds them to a list that will be passed to the query results handler along with propositions that remain in working memory . |
11,908 | static boolean getConsistent ( DirectedGraph g ) { Object [ ] vertexOrdering = new Object [ g . size ( ) ] ; int voa = 0 ; for ( Iterator < ? > itr = g . iterator ( ) ; itr . hasNext ( ) ; voa ++ ) { vertexOrdering [ voa ] = itr . next ( ) ; } int vol = vertexOrdering . length ; Weight [ ] [ ] updatedEdges = new Weight [ vol ] [ vol ] ; for ( int k = vol - 1 ; k > 1 ; k -- ) { Object vk = vertexOrdering [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { Object vi = vertexOrdering [ i ] ; Weight wik = getWeight ( i , k , vi , vk , g , updatedEdges ) ; if ( wik != null ) { Weight wki = getWeight ( k , i , vk , vi , g , updatedEdges ) ; for ( int j = i + 1 ; j < k ; j ++ ) { Object vj = vertexOrdering [ j ] ; Weight wjk = getWeight ( j , k , vj , vk , g , updatedEdges ) ; if ( wjk != null ) { Weight wkj = getWeight ( k , j , vk , vj , g , updatedEdges ) ; Weight wikj = wik . add ( wkj ) ; Weight wjki = wjk . add ( wki ) ; Weight wij = getWeight ( i , j , vi , vj , g , updatedEdges ) ; Weight wji = getWeight ( j , i , vj , vi , g , updatedEdges ) ; Weight iwjki = wjki . invertSign ( ) ; Weight iwji = null ; if ( wji != null ) { iwji = wji . invertSign ( ) ; } if ( wij != null ) { Weight intersectionMin = Weight . max ( iwji , iwjki ) ; Weight intersectionMax = Weight . min ( wij , wikj ) ; if ( intersectionMin . compareTo ( intersectionMax ) > 0 ) { return false ; } updatedEdges [ i ] [ j ] = intersectionMax ; updatedEdges [ j ] [ i ] = intersectionMin . invertSign ( ) ; } else { updatedEdges [ i ] [ j ] = wikj ; updatedEdges [ j ] [ i ] = wjki ; } } } } } } return true ; } | Returns whether a directed graph is consistent . |
11,909 | public static TrustManager [ ] initializeTrustManagers ( File _trustStoreFile , String _trustStorePassword ) throws IOException { if ( _trustStoreFile == null ) { return null ; } String storeType = getStoreTypeByFileName ( _trustStoreFile ) ; boolean derEncoded = storeType == STORETYPE_DER_ENCODED ; if ( derEncoded ) { storeType = STORETYPE_JKS ; } String trustStorePwd = StringUtil . defaultIfBlank ( _trustStorePassword , System . getProperty ( "javax.net.ssl.trustStorePassword" ) ) ; LOGGER . debug ( "Creating trust store of type '" + storeType + "' from " + ( derEncoded ? "DER-encoded" : "" ) + " file '" + _trustStoreFile + "'" ) ; try { TrustManagerFactory trustMgrFactory = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; KeyStore trustStore = KeyStore . getInstance ( storeType ) ; if ( derEncoded ) { FileInputStream fis = new FileInputStream ( _trustStoreFile ) ; X509Certificate certificate = ( X509Certificate ) CertificateFactory . getInstance ( "X.509" ) . generateCertificate ( fis ) ; trustStore . load ( null , null ) ; trustStore . setCertificateEntry ( "[der_cert_alias]" , certificate ) ; } else { trustStore . load ( new FileInputStream ( _trustStoreFile ) , trustStorePwd != null ? trustStorePwd . toCharArray ( ) : null ) ; } trustMgrFactory . init ( trustStore ) ; return trustMgrFactory . getTrustManagers ( ) ; } catch ( GeneralSecurityException _ex ) { throw new IOException ( "Error while setting up trustStore" , _ex ) ; } } | Initialization of trustStoreManager used to provide access to the configured trustStore . |
11,910 | public static KeyManager [ ] initializeKeyManagers ( File _keyStoreFile , String _keyStorePassword , String _keyPassword ) throws IOException { if ( _keyStoreFile == null ) { return null ; } String keyStorePwd = StringUtil . defaultIfBlank ( _keyStorePassword , System . getProperty ( "javax.net.ssl.keyStorePassword" ) ) ; if ( StringUtil . isBlank ( keyStorePwd ) ) { keyStorePwd = "changeit" ; } String keyPwd = StringUtil . defaultIfBlank ( _keyPassword , System . getProperty ( "javax.net.ssl.keyStorePassword" ) ) ; if ( StringUtil . isBlank ( keyPwd ) ) { keyPwd = "changeit" ; } String storeType = getStoreTypeByFileName ( _keyStoreFile ) ; LOGGER . debug ( "Creating key store of type '" + storeType + "' from file '" + _keyStoreFile + "'" ) ; try { KeyManagerFactory keyMgrFactory = KeyManagerFactory . getInstance ( KeyManagerFactory . getDefaultAlgorithm ( ) ) ; KeyStore keyStore = KeyStore . getInstance ( storeType ) ; try ( FileInputStream fis = new FileInputStream ( _keyStoreFile ) ) { keyStore . load ( fis , keyStorePwd . toCharArray ( ) ) ; } keyMgrFactory . init ( keyStore , keyPwd . toCharArray ( ) ) ; return keyMgrFactory . getKeyManagers ( ) ; } catch ( Exception _ex ) { throw new IOException ( "Error while setting up keyStore" , _ex ) ; } } | Initialization of keyStoreManager used to provide access to the configured keyStore . |
11,911 | protected Object findObjectSymbol ( String name , ExecutionContext context ) { CommandSymbol s = context . findSymbol ( name ) ; if ( s == null ) throw new CommandExecutionException ( "Symbol cannot be null" ) ; if ( ! ( s instanceof VarCommand ) ) throw new CommandExecutionException ( "Symbol must be a variable" ) ; Value value = ( ( VarCommand ) s ) . getValue ( null ) ; if ( value == null ) throw new CommandExecutionException ( "Symbol cannot be null" ) ; if ( value . getType ( ) != Type . OBJECT ) throw new CommandExecutionException ( "Symbol must refer to a Java object" ) ; Object obj = value . get ( ) ; if ( obj instanceof JComponentOperator ) { obj = ( ( JComponentOperator ) obj ) . getSource ( ) ; } return obj ; } | Finds a symbol which should wrap a Java object . |
11,912 | protected PlacementConfig verifyAndUpdatePlacement ( final String alias , final PlacementConfig placementConfig ) throws CouldNotPerformException , EntryModification { try { if ( alias == null || alias . isEmpty ( ) ) { throw new NotAvailableException ( "label" ) ; } if ( placementConfig == null ) { throw new NotAvailableException ( "placementconfig" ) ; } String frameId = generateFrameId ( alias , placementConfig ) ; if ( placementConfig . getTransformationFrameId ( ) . equals ( frameId ) ) { return null ; } return placementConfig . toBuilder ( ) . setTransformationFrameId ( frameId ) . build ( ) ; } catch ( CouldNotPerformException ex ) { throw new CouldNotPerformException ( "Could not verify and update placement!" , ex ) ; } } | Methods verifies and updates the transformation frame id for the given placement configuration . If the given placement configuration is up to date this the method returns null . |
11,913 | public void setProperties ( Map < String , Value > properties ) { if ( properties != null ) { this . properties = new HashMap < > ( properties ) ; } else { this . properties = null ; } } | Overrides the properties for copies made with this visitor . |
11,914 | public void setReferences ( Map < String , List < UniqueId > > references ) { if ( references != null ) { this . references = new HashMap < > ( references ) ; } else { this . references = null ; } } | Overrides the references for copies made with this visitor . |
11,915 | public List < T > filter ( final List < T > list ) throws CouldNotPerformException { beforeFilter ( ) ; return ListFilter . super . filter ( list ) ; } | Filter object from the list for which the verification fails . |
11,916 | public void log ( int level , String msg , String extra ) { if ( logLevel >= level ) { messageListener . debug ( msg + extra ) ; } } | Log some debug output . |
11,917 | private byte [ ] enhancement ( ClassLoader classLoader , byte [ ] classfileBuffer ) { ClassReader cr = new ClassReader ( classfileBuffer ) ; CLAwareClassWriter cw = new CLAwareClassWriter ( FLAGS , classLoader ) ; TypeQueryClassAdapter ca = new TypeQueryClassAdapter ( cw , enhanceContext ) ; try { cr . accept ( ca , ClassReader . EXPAND_FRAMES ) ; if ( ca . isLog ( 9 ) ) { ca . log ( "... completed" ) ; } return cw . toByteArray ( ) ; } catch ( AlreadyEnhancedException e ) { if ( ca . isLog ( 1 ) ) { ca . log ( "already enhanced" ) ; } return null ; } catch ( NoEnhancementRequiredException e ) { if ( ca . isLog ( 9 ) ) { ca . log ( "... skipping, no enhancement required" ) ; } return null ; } } | Perform enhancement . |
11,918 | public static boolean contains ( final Label label , final String labelString ) { final String withoutWhite = StringProcessor . removeWhiteSpaces ( labelString ) ; for ( final Label . MapFieldEntry entry : label . getEntryList ( ) ) { for ( final String value : entry . getValueList ( ) ) { if ( StringProcessor . removeWhiteSpaces ( value ) . equalsIgnoreCase ( withoutWhite ) ) { return true ; } } } return false ; } | Test if a label contains a label string . This test iterates over all languages and all label strings for the language and check if one equals the label string . The test is done ignoring the case of the label string and ignoring white spaces . |
11,919 | public static boolean isEmpty ( final Label label ) { for ( Label . MapFieldEntry entry : label . getEntryList ( ) ) { for ( String value : entry . getValueList ( ) ) { if ( ! value . isEmpty ( ) ) { return false ; } } } return true ; } | Test if the label is empty . This means that every label list for every languageCode is empty or that it only contains empty string . |
11,920 | public static Label . Builder addLabel ( final Label . Builder labelBuilder , final String languageCode , final String label ) { for ( int i = 0 ; i < labelBuilder . getEntryCount ( ) ; i ++ ) { if ( labelBuilder . getEntry ( i ) . getKey ( ) . equals ( languageCode ) ) { for ( String value : labelBuilder . getEntryBuilder ( i ) . getValueList ( ) ) { if ( value . equalsIgnoreCase ( label ) ) { return labelBuilder ; } } labelBuilder . getEntryBuilder ( i ) . addValue ( label ) ; return labelBuilder ; } } labelBuilder . addEntryBuilder ( ) . setKey ( languageCode ) . addValue ( label ) ; return labelBuilder ; } | Add a label to a labelBuilder by languageCode . If the label is already contained for the language code nothing will be done . If the languageCode already exists and the label is not contained it will be added to the end of the label list by this language code . If no entry for the languageCode exists a new entry will be added and the label added as its first value . |
11,921 | public static String getFirstLabel ( final LabelOrBuilder label ) throws NotAvailableException { for ( Label . MapFieldEntry entry : label . getEntryList ( ) ) { for ( String value : entry . getValueList ( ) ) { return value ; } } throw new NotAvailableException ( "Label" ) ; } | Get the first label found in the label type . This is independent of the language of the label . |
11,922 | public static List < String > getLabelListByLanguage ( final String languageCode , final LabelOrBuilder label ) throws NotAvailableException { for ( Label . MapFieldEntry entry : label . getEntryList ( ) ) { if ( entry . getKey ( ) . equalsIgnoreCase ( languageCode ) ) { return entry . getValueList ( ) ; } } throw new NotAvailableException ( "LabelList of Language[" + languageCode + "] in labelType[" + label + "]" ) ; } | Get a list of all labels for a languageCode in a label type . This is done by iterating over all entries in the label type and checking if the key matches the languageCode . If it matches the value list is returned . Thus the returned list can be empty depending on the label . |
11,923 | public static Label . Builder replace ( final Label . Builder label , final String oldLabel , final String newLabel ) { for ( final MapFieldEntry . Builder entryBuilder : label . getEntryBuilderList ( ) ) { final List < String > valueList = new ArrayList < > ( entryBuilder . getValueList ( ) ) ; entryBuilder . clearValue ( ) ; for ( String value : valueList ) { if ( StringProcessor . removeWhiteSpaces ( value ) . equalsIgnoreCase ( StringProcessor . removeWhiteSpaces ( oldLabel ) ) ) { entryBuilder . addValue ( newLabel ) ; } else { entryBuilder . addValue ( value ) ; } } } return label ; } | Replace all instances of a label string in a label builder . The check for the label string which should be replaced is done ignoring the case . |
11,924 | public static Label . Builder format ( final Label . Builder label ) { for ( final MapFieldEntry . Builder entryBuilder : label . getEntryBuilderList ( ) ) { final List < String > valueList = new ArrayList < > ( entryBuilder . getValueList ( ) ) ; entryBuilder . clearValue ( ) ; for ( String value : valueList ) { entryBuilder . addValue ( format ( value ) ) ; } } return label ; } | Format the given label by removing duplicated white spaces underscores and camel cases in all entries . |
11,925 | public static String format ( String label ) { if ( label . isEmpty ( ) ) { return label ; } if ( Character . isDigit ( label . charAt ( label . length ( ) - 1 ) ) ) { for ( int i = label . length ( ) ; i > 0 ; i -- ) { if ( ! Character . isDigit ( label . charAt ( i - 1 ) ) ) { if ( ! Character . isLowerCase ( label . charAt ( i - 1 ) ) ) { break ; } label = label . substring ( 0 , i ) + " " + label . substring ( i ) ; break ; } } } return StringProcessor . formatHumanReadable ( label ) ; } | Format the given label by removing duplicated white spaces underscores and camel cases . |
11,926 | void addIterator ( final DataStreamingEventIterator < E > iterator ) { checkLocked ( ) ; if ( iterator == null ) { throw new NullPointerException ( "Iterator must not be null" ) ; } iteratorChain . add ( iterator ) ; } | Add an Iterator to the end of the chain |
11,927 | protected void updateCurrentIterator ( ) throws DataSourceReadException { if ( currentIterator == null ) { if ( iteratorChain . isEmpty ( ) ) { currentIterator = new EmptyDataStreamingEventIterator ( ) ; } else { currentIterator = iteratorChain . remove ( ) ; } lastUsedIterator = currentIterator ; } while ( currentIterator . hasNext ( ) == false && ! iteratorChain . isEmpty ( ) ) { currentIterator . close ( ) ; currentIterator = iteratorChain . remove ( ) ; } } | Updates the current iterator field to ensure that the current Iterator is not exhausted |
11,928 | public DataStreamingEvent < E > next ( ) throws DataSourceReadException { lockChain ( ) ; updateCurrentIterator ( ) ; lastUsedIterator = currentIterator ; return currentIterator . next ( ) ; } | Returns the next Object of the current Iterator |
11,929 | public void declaration ( Writer out , char quotationMark ) throws IllegalArgumentException , NullPointerException , IOException { if ( quotationMark == '"' ) { out . write ( _declarationDoubleQuotes ) ; } else if ( quotationMark == '\'' ) { out . write ( _declarationSingleQuotes ) ; } } | Writes an XML declaration with double quotes . |
11,930 | public void whitespace ( Writer out , String s ) throws NullPointerException , InvalidXMLException , IOException { char [ ] ch = s . toCharArray ( ) ; int length = ch . length ; whitespace ( out , ch , 0 , length ) ; } | Writes the specified whitespace string . |
11,931 | public void whitespace ( Writer out , char [ ] ch , int start , int length ) throws NullPointerException , IndexOutOfBoundsException , InvalidXMLException , IOException { XMLChecker . checkS ( ch , start , length ) ; out . write ( ch , start , length ) ; } | Writes whitespace from the specified character array . |
11,932 | public void attribute ( Writer out , String name , String value , char quotationMark , boolean escapeAmpersands ) throws NullPointerException , IOException { char [ ] ch = value . toCharArray ( ) ; int length = ch . length ; int start = 0 ; int end = start + length ; int lastEscaped = 0 ; boolean useQuote ; if ( quotationMark == '"' ) { useQuote = true ; } else if ( quotationMark == '\'' ) { useQuote = false ; } else { String error = "Character 0x" + Integer . toHexString ( quotationMark ) + " ('" + quotationMark + "') is not a valid quotation mark." ; throw new IllegalArgumentException ( error ) ; } out . write ( ' ' ) ; out . write ( name ) ; if ( useQuote ) { out . write ( EQUALS_QUOTE , 0 , 2 ) ; } else { out . write ( EQUALS_APOSTROPHE , 0 , 2 ) ; } for ( int i = start ; i < end ; i ++ ) { int c = ch [ i ] ; if ( c >= 63 && c <= 127 || c >= 40 && c <= 59 || c >= 32 && c <= 37 && c != 34 || c == 38 && ! escapeAmpersands || c > 127 && ! _sevenBitEncoding || ! useQuote && c == 34 || useQuote && c == 39 || c == 10 || c == 13 || c == 61 || c == 9 ) { continue ; } else { out . write ( ch , lastEscaped , i - lastEscaped ) ; if ( c == 60 ) { out . write ( ESC_LESS_THAN , 0 , 4 ) ; } else if ( c == 62 ) { out . write ( ESC_GREATER_THAN , 0 , 4 ) ; } else if ( c == 34 ) { out . write ( ESC_QUOTE , 0 , 6 ) ; } else if ( c == 39 ) { out . write ( ESC_APOSTROPHE , 0 , 6 ) ; } else if ( c == 38 ) { out . write ( ESC_AMPERSAND , 0 , 5 ) ; } else if ( c > 127 ) { out . write ( AMPERSAND_HASH , 0 , 2 ) ; out . write ( Integer . toString ( c ) ) ; out . write ( ';' ) ; } else { throw new InvalidXMLException ( "The character 0x" + Integer . toHexString ( c ) + " is not valid." ) ; } lastEscaped = i + 1 ; } } out . write ( ch , lastEscaped , length - lastEscaped ) ; out . write ( quotationMark ) ; } | Writes an attribute assignment . |
11,933 | public boolean setRelation ( TemporalExtendedPropositionDefinition lhsDef , TemporalExtendedPropositionDefinition rhsDef , Relation relation ) { if ( lhsDef == null || rhsDef == null || relation == null ) { return false ; } if ( ! defs . contains ( lhsDef ) || ! defs . contains ( rhsDef ) ) { return false ; } List < TemporalExtendedPropositionDefinition > rulePair = Arrays . asList ( lhsDef , rhsDef ) ; defPairsMap . put ( rulePair , relation ) ; return true ; } | Sets the relation between the two temporal extended proposition definitions . |
11,934 | public boolean removeRelation ( TemporalExtendedPropositionDefinition lhsRule , TemporalExtendedPropositionDefinition rhsRule ) { List < TemporalExtendedPropositionDefinition > key = Arrays . asList ( lhsRule , rhsRule ) ; if ( defPairsMap . remove ( key ) != null ) { return true ; } else { return false ; } } | Removes a relation between two temporal extended proposition definitions . |
11,935 | public boolean add ( ExtendedPropositionDefinition def ) { if ( def != null && this . defs . add ( def ) ) { this . defsAsListOutdated = true ; recalculateChildren ( ) ; return true ; } else { return false ; } } | Adds an extended proposition definition . |
11,936 | public Relation getRelation ( TemporalExtendedPropositionDefinition lhsDef , TemporalExtendedPropositionDefinition rhsDef ) { return this . defPairsMap . get ( Arrays . asList ( lhsDef , rhsDef ) ) ; } | Gets the relation between two temporal extended proposition definitions . |
11,937 | public boolean removeAllRelations ( TemporalExtendedPropositionDefinition def ) { for ( Iterator < List < TemporalExtendedPropositionDefinition > > itr = this . defPairsMap . keySet ( ) . iterator ( ) ; itr . hasNext ( ) ; ) { List < TemporalExtendedPropositionDefinition > pair = itr . next ( ) ; if ( pair . get ( 0 ) == def || pair . get ( 1 ) == def ) { itr . remove ( ) ; } } return true ; } | Removes all relations involving a temporal extended proposition definition . |
11,938 | public boolean remove ( ExtendedPropositionDefinition def ) { if ( def instanceof TemporalExtendedPropositionDefinition ) { if ( removeAllRelations ( ( TemporalExtendedPropositionDefinition ) def ) ) { return true ; } else { return false ; } } boolean result = defs . remove ( def ) ; if ( result ) { recalculateChildren ( ) ; this . defsAsListOutdated = true ; } return result ; } | Removes an extended proposition definition and all relations involving it . |
11,939 | public void readWriteElement ( String tagName ) throws WLFormatException { try { while ( xmlEventReader . hasNext ( ) ) { XMLEvent event = xmlEventReader . nextEvent ( ) ; switch ( event . getEventType ( ) ) { case XMLStreamConstants . END_ELEMENT : add ( event ) ; if ( event . asEndElement ( ) . getName ( ) . getLocalPart ( ) . equals ( tagName ) ) { return ; } break ; default : add ( event ) ; break ; } } } catch ( XMLStreamException e ) { throw new WLFormatException ( e . getMessage ( ) , e ) ; } catch ( NoSuchElementException e ) { throw new WLFormatException ( e . getMessage ( ) , e ) ; } } | postcondition read pointer is just after the end of the tag with the local name tagName |
11,940 | public void readWriteUpToStartElement ( String startTag ) throws XMLStreamException { boolean startTagIsNext = false ; while ( xmlEventReader . hasNext ( ) && ! startTagIsNext ) { XMLEvent peekedEvent = xmlEventReader . peek ( ) ; switch ( peekedEvent . getEventType ( ) ) { case XMLStreamConstants . START_ELEMENT : String elementName = peekedEvent . asStartElement ( ) . getName ( ) . getLocalPart ( ) ; if ( elementName . equals ( startTag ) ) { startTagIsNext = true ; } else { XMLEvent readEvent = xmlEventReader . nextEvent ( ) ; add ( readEvent ) ; } break ; default : XMLEvent readEvent = xmlEventReader . nextEvent ( ) ; add ( readEvent ) ; break ; } } } | postcondition read pointer is just before the start of the tag with the local name startTag |
11,941 | public void init ( final Class < ? extends State > stateClass ) throws InitializationException { try { currentState = getState ( stateClass ) ; change . firePropertyChange ( STATE_CHANGE , null , currentState . getClass ( ) ) ; } catch ( NotAvailableException ex ) { throw new InitializationException ( this , ex ) ; } } | Defines the initial state of the state machine . |
11,942 | public synchronized void run ( ) { LOGGER . info ( "run " + currentState . getClass ( ) . getSimpleName ( ) + "..." ) ; if ( currentState == null ) { throw new IllegalStateException ( "No initial state defined." ) ; } while ( currentState != null ) { LOGGER . debug ( "execute " + currentState ) ; final Class < ? extends State > nextStateClass ; try { nextStateClass = currentState . call ( ) ; } catch ( CouldNotPerformException ex ) { ExceptionPrinter . printHistory ( "Something went wrong during state execution!" , ex , LOGGER ) ; if ( Thread . currentThread ( ) . isInterrupted ( ) ) { return ; } continue ; } catch ( Throwable t ) { ExceptionPrinter . printHistory ( "State failed: " , t , LOGGER ) ; change . firePropertyChange ( STATE_ERROR , currentState . getClass ( ) , t . getMessage ( ) ) ; return ; } change . firePropertyChange ( STATE_CHANGE , currentState . getClass ( ) , nextStateClass ) ; if ( nextStateClass != null ) { LOGGER . info ( "StateChange: " + currentState . getClass ( ) . getSimpleName ( ) + " -> " + nextStateClass . getSimpleName ( ) ) ; try { currentState = getState ( nextStateClass ) ; } catch ( NotAvailableException ex ) { ExceptionPrinter . printHistory ( "State change failed!" , ex , LOGGER ) ; } } } LOGGER . info ( "finished execution." ) ; } | Method starts the state machine . Because this class is implementing the runnable interface its not recommended to call this method manually . Start the state machine via the global executor service . |
11,943 | private State getState ( final Class < ? extends State > stateClass ) throws NotAvailableException { if ( ! stateMap . containsKey ( stateClass ) ) { try { final State state ; try { state = stateClass . getConstructor ( ) . newInstance ( ) ; } catch ( IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex ) { throw new CouldNotPerformException ( "Could not create instance of " + stateClass . getName ( ) , ex ) ; } stateMap . put ( stateClass , state ) ; return state ; } catch ( CouldNotPerformException ex ) { throw new NotAvailableException ( stateClass , ex ) ; } } return stateMap . get ( stateClass ) ; } | Method loads the state referred by the state class . |
11,944 | public ValueComparator compare ( Value d2 ) { if ( d2 == null ) { return ValueComparator . NOT_EQUAL_TO ; } switch ( d2 . getType ( ) ) { case NUMBERVALUE : NumberValue otherVal = ( NumberValue ) d2 ; int valComp = val . compareTo ( otherVal ) ; switch ( this . comp ) { case EQUAL_TO : return valComp > 0 ? ValueComparator . GREATER_THAN : ( valComp < 0 ? ValueComparator . LESS_THAN : ValueComparator . EQUAL_TO ) ; case LESS_THAN : return valComp <= 0 ? ValueComparator . LESS_THAN : ValueComparator . UNKNOWN ; default : return valComp >= 0 ? ValueComparator . GREATER_THAN : ValueComparator . UNKNOWN ; } case INEQUALITYNUMBERVALUE : InequalityNumberValue other = ( InequalityNumberValue ) d2 ; ValueComparator d2Comp = other . comp ; int valComp2 = this . val . compareTo ( other . val ) ; if ( this . comp == d2Comp ) { if ( this . comp == ValueComparator . EQUAL_TO ) { return valComp2 > 0 ? ValueComparator . GREATER_THAN : ( valComp2 < 0 ? ValueComparator . LESS_THAN : ValueComparator . EQUAL_TO ) ; } else { return ValueComparator . UNKNOWN ; } } else if ( this . comp == ValueComparator . GREATER_THAN && d2Comp == ValueComparator . LESS_THAN ) { if ( valComp2 >= 0 ) { return ValueComparator . GREATER_THAN ; } else { return ValueComparator . UNKNOWN ; } } else { if ( valComp2 <= 0 ) { return ValueComparator . LESS_THAN ; } else { return ValueComparator . UNKNOWN ; } } case VALUELIST : ValueList < ? > vl = ( ValueList < ? > ) d2 ; return vl . contains ( this ) ? ValueComparator . IN : ValueComparator . NOT_IN ; default : return ValueComparator . NOT_EQUAL_TO ; } } | Compares this value and another numerically or checks this value for membership in a value list . |
11,945 | public void clear ( ) { vertices . clear ( ) ; vertexModCount ++ ; Arrays . matrixFill ( edges , null ) ; edgeCount = 0 ; edgesArr = null ; edgeModCount ++ ; freeList . clear ( ) ; for ( int row = capacity - 1 ; row >= 0 ; row -- ) { freeList . add ( row ) ; } } | Remove all vertices and edges . |
11,946 | public void add ( Object vertex ) { if ( vertex == null || vertices . containsKey ( vertex ) ) { return ; } checkGraphSize ( ) ; vertices . put ( vertex , new VertexMetadata ( freeList . removeFirst ( ) ) ) ; vertexModCount ++ ; } | Adds a vertex . |
11,947 | public Object remove ( Object vertex ) { VertexMetadata vm = ( VertexMetadata ) vertices . get ( vertex ) ; if ( vm == null ) { return null ; } vertices . remove ( vertex ) ; vertexModCount ++ ; int index = vm . index ; for ( int row = 0 ; row < capacity ; row ++ ) { edges [ row ] [ index ] = null ; edges [ index ] [ row ] = null ; edgeModCount ++ ; } edgesArr = null ; freeList . add ( index ) ; return vertex ; } | Remove a vertex and all edges between the vertex and other vertices . |
11,948 | public static boolean isEmpty ( final MultiLanguageText multiLanguageText ) { for ( MultiLanguageText . MapFieldEntry entry : multiLanguageText . getEntryList ( ) ) { if ( ! entry . getValue ( ) . isEmpty ( ) ) { return false ; } } return true ; } | Test if the multiLanguageText is empty . This means that every multiLanguageText list for every languageCode is empty or that it only contains empty string . |
11,949 | public static MultiLanguageText . Builder addMultiLanguageText ( final MultiLanguageText . Builder multiLanguageTextBuilder , final String languageCode , final String multiLanguageText ) { for ( int i = 0 ; i < multiLanguageTextBuilder . getEntryCount ( ) ; i ++ ) { if ( multiLanguageTextBuilder . getEntry ( i ) . getKey ( ) . equals ( languageCode ) ) { if ( multiLanguageTextBuilder . getEntryBuilder ( i ) . getValue ( ) . equalsIgnoreCase ( multiLanguageText ) ) { return multiLanguageTextBuilder ; } multiLanguageTextBuilder . getEntryBuilder ( i ) . setValue ( multiLanguageText ) ; return multiLanguageTextBuilder ; } } multiLanguageTextBuilder . addEntryBuilder ( ) . setKey ( languageCode ) . setValue ( multiLanguageText ) ; return multiLanguageTextBuilder ; } | Add a multiLanguageText to a multiLanguageTextBuilder by languageCode . If the multiLanguageText is already contained for the language code nothing will be done . If the languageCode already exists and the multiLanguageText is not contained it will be added to the end of the multiLanguageText list by this language code . If no entry for the languageCode exists a new entry will be added and the multiLanguageText added as its first value . |
11,950 | public static String getFirstMultiLanguageText ( final MultiLanguageTextOrBuilder multiLanguageText ) throws NotAvailableException { for ( MultiLanguageText . MapFieldEntry entry : multiLanguageText . getEntryList ( ) ) { return entry . getValue ( ) ; } throw new NotAvailableException ( "MultiLanguageText" ) ; } | Get the first multiLanguageText found in the multiLanguageText type . This is independent of the language of the multiLanguageText . |
11,951 | public static String getMultiLanguageTextByLanguage ( final String languageCode , final MultiLanguageTextOrBuilder multiLanguageText ) throws NotAvailableException { for ( MultiLanguageText . MapFieldEntry entry : multiLanguageText . getEntryList ( ) ) { if ( entry . getKey ( ) . equalsIgnoreCase ( languageCode ) ) { return entry . getValue ( ) ; } } throw new NotAvailableException ( "MultiLanguageTextList of Language[" + languageCode + "] in multiLanguageTextType[" + multiLanguageText + "]" ) ; } | Get the multiLanguageText for a languageCode in a multiLanguageText type . This is done by checking if the key matches the languageCode . If it matches the value list is returned . Thus the returned list can be empty depending on the multiLanguageText . |
11,952 | public static MultiLanguageText . Builder format ( final MultiLanguageText . Builder multiLanguageText ) { for ( final MapFieldEntry . Builder entryBuilder : multiLanguageText . getEntryBuilderList ( ) ) { final String value = entryBuilder . getValue ( ) ; entryBuilder . clearValue ( ) ; entryBuilder . setValue ( format ( value ) ) ; } return multiLanguageText ; } | Format the given multiLanguageText by removing duplicated white spaces underscores and camel cases in all entries . |
11,953 | public static String format ( String multiLanguageText ) { if ( multiLanguageText . isEmpty ( ) ) { return multiLanguageText ; } if ( Character . isDigit ( multiLanguageText . charAt ( multiLanguageText . length ( ) - 1 ) ) ) { for ( int i = multiLanguageText . length ( ) ; i > 0 ; i -- ) { if ( ! Character . isDigit ( multiLanguageText . charAt ( i - 1 ) ) ) { if ( ! Character . isLowerCase ( multiLanguageText . charAt ( i - 1 ) ) ) { break ; } multiLanguageText = multiLanguageText . substring ( 0 , i ) + " " + multiLanguageText . substring ( i ) ; break ; } } } return StringProcessor . formatHumanReadable ( multiLanguageText ) ; } | Format the given multiLanguageText by removing duplicated white spaces underscores and camel cases . |
11,954 | public void setSubContexts ( String [ ] subContextOf ) { if ( subContextOf == null ) { this . subContexts = StringUtils . EMPTY_STRING_ARRAY ; } else { ProtempaUtil . checkArrayForNullElement ( subContextOf , "subContextOf" ) ; ProtempaUtil . checkArrayForDuplicates ( subContextOf , "subContextOf" ) ; this . subContexts = subContextOf . clone ( ) ; } } | Sets the ids of other context definitions that together with this one have a specific meaning when their intervals intersect . |
11,955 | String decrypt ( String str ) throws DecryptException { if ( str == null ) { return null ; } try { initCiphers ( ) ; byte [ ] ciphertext = Base64 . decodeBase64 ( str ) ; byte [ ] cleartext = this . decryptCipher . doFinal ( ciphertext ) ; return new String ( cleartext ) ; } catch ( NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException ex ) { throw new DecryptException ( ex ) ; } catch ( InvalidKeyException ex ) { throw new AssertionError ( ex ) ; } } | Decrypts the provided hex string . This method converts a hex string to a byte array and passes the array to a decryption cipher . If an exception is thrown this instance may no longer be usable . |
11,956 | public Interval getInstance ( Long start , Granularity startGran , Long finish , Granularity finishGran ) { List < Object > key = Arrays . asList ( new Object [ ] { start , startGran , finish , finishGran } ) ; Interval result ; synchronized ( cache ) { result = cache . get ( key ) ; if ( result == null ) { if ( start == null || finish == null ) { result = new DefaultInterval ( start , startGran , finish , finishGran ) ; } else { result = new SimpleInterval ( start , startGran , finish , finishGran ) ; } cache . put ( key , result ) ; } } return result ; } | Returns at interval specified by the given start and finish and granularities . |
11,957 | static boolean find ( Map < List < TemporalExtendedPropositionDefinition > , Relation > epdToRelation , List < List < TemporalExtendedPropositionDefinition > > epdPairs , Map < TemporalExtendedPropositionDefinition , TemporalProposition > potentialInstance ) { for ( List < TemporalExtendedPropositionDefinition > tepd : epdPairs ) { if ( ! hasRelation ( epdToRelation , potentialInstance , tepd ) ) { return false ; } } return true ; } | Determines if a list of abstract parameters satisfies a complex abstraction definition . |
11,958 | public void setRoles ( List < RoleEntity > inRoles ) { if ( inRoles == null ) { this . roles = new ArrayList < > ( ) ; } else { this . roles = new ArrayList < > ( inRoles ) ; } this . roles = inRoles ; } | Set the roles assigned to the current user . |
11,959 | private void publish2Subscribers ( String topic , AbstractMessage . QOSType qos , ByteBuffer origMessage , boolean retain , Integer messageID ) { Log . trace ( "publish2Subscribers republishing to existing subscribers that matches the topic {}" , topic ) ; if ( Log . DEBUG ) { Log . trace ( "content <{}>" , DebugUtils . payload2Str ( origMessage ) ) ; Log . trace ( "subscription tree {}" , subscriptions . dumpTree ( ) ) ; } for ( final Subscription sub : subscriptions . matches ( topic ) ) { if ( m_clientIDs . get ( sub . getClientId ( ) ) == null ) { subscriptions . removeSubscription ( topic , sub . getClientId ( ) ) ; continue ; } if ( qos . ordinal ( ) > sub . getRequestedQos ( ) . ordinal ( ) ) { qos = sub . getRequestedQos ( ) ; } ByteBuffer message = origMessage . duplicate ( ) ; if ( qos == AbstractMessage . QOSType . MOST_ONE && sub . isActive ( ) ) { sendPublish ( sub . getClientId ( ) , topic , qos , message , false ) ; } else { if ( ! sub . isCleanSession ( ) && ! sub . isActive ( ) ) { PublishEvent newPublishEvt = new PublishEvent ( topic , qos , message , retain , sub . getClientId ( ) , messageID ) ; m_storageService . storePublishForFuture ( newPublishEvt ) ; } else { if ( qos == AbstractMessage . QOSType . EXACTLY_ONCE ) { String publishKey = String . format ( "%s%d" , sub . getClientId ( ) , messageID ) ; PublishEvent newPublishEvt = new PublishEvent ( topic , qos , message , retain , sub . getClientId ( ) , messageID ) ; m_storageService . addInFlight ( newPublishEvt , publishKey ) ; } if ( sub . isActive ( ) ) { sendPublish ( sub . getClientId ( ) , topic , qos , message , false ) ; } } } } } | Flood the subscribers with the message to notify . MessageID is optional and should only used for QoS 1 and 2 |
11,960 | void processPubRel ( String clientID , int messageID ) { Log . trace ( "PUB --PUBREL , clientID , messageID ) ; String publishKey = String . format ( "%s%d" , clientID , messageID ) ; PublishEvent evt = m_storageService . retrieveQoS2Message ( publishKey ) ; final String topic = evt . getTopic ( ) ; final AbstractMessage . QOSType qos = evt . getQos ( ) ; publish2Subscribers ( topic , qos , evt . getMessage ( ) , evt . isRetain ( ) , evt . getMessageID ( ) ) ; m_storageService . removeQoS2Message ( publishKey ) ; if ( evt . isRetain ( ) ) { m_storageService . storeRetained ( topic , evt . getMessage ( ) , qos ) ; } sendPubComp ( clientID , messageID ) ; } | Second phase of a publish QoS2 protocol sent by publisher to the broker . Search the stored message and publish to all interested subscribers . |
11,961 | void processUnsubscribe ( ServerChannel session , String clientID , List < String > topics , int messageID ) { Log . trace ( "processUnsubscribe invoked, removing subscription on topics {}, for clientID <{}>" , topics , clientID ) ; for ( String topic : topics ) { subscriptions . removeSubscription ( topic , clientID ) ; } UnsubAckMessage ackMessage = new UnsubAckMessage ( ) ; ackMessage . setMessageID ( messageID ) ; Log . trace ( "replying with UnsubAck to MSG ID {}" , messageID ) ; session . write ( ackMessage ) ; } | Remove the clientID from topic subscription if not previously subscribed doesn t reply any error |
11,962 | public List < InetAddress > getSystemDNSServers ( ) { List < InetAddress > dnsServers = new ArrayList < InetAddress > ( ) ; ResolverConfig resolverConfig = new ResolverConfig ( ) ; try { for ( String dnsHostIp : resolverConfig . servers ( ) ) { if ( dnsHostIp . equals ( "" ) ) continue ; dnsServers . add ( InetAddress . getByName ( dnsHostIp ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } return dnsServers ; } | Get System DNS Servers |
11,963 | public final static void main ( String [ ] args ) throws IOException { Writer writer = new OutputStreamWriter ( System . out , "utf-8" ) ; XMLOutputter outputter = new XMLOutputter ( writer , "iso-8859-1" ) ; writeXML ( outputter ) ; System . out . println ( ) ; System . out . println ( ) ; outputter . reset ( writer , "utf-8" ) ; writeXML ( outputter ) ; } | Main function . |
11,964 | protected void fireBackendUpdated ( E e ) { for ( int i = 0 , n = this . listenerList . size ( ) ; i < n ; i ++ ) { this . listenerList . get ( i ) . backendUpdated ( e ) ; } } | Notifies all registered listeners when the backend has been updated . |
11,965 | protected void fireUnrecoverableError ( UnrecoverableBackendErrorEvent e ) { for ( int i = 0 , n = this . listenerList . size ( ) ; i < n ; i ++ ) { this . listenerList . get ( i ) . unrecoverableErrorOccurred ( e ) ; } } | Notifies all registered listeners when an unrecoverable error has occurred in a backend . |
11,966 | public final void register ( ) { synchronized ( lock ) { if ( serviceRegistration == null ) { BundleClassResolver resolver = new BundleClassResolver ( ) ; serviceRegistration = bundleContext . registerService ( SERVICE_NAMES , resolver , serviceProperties ) ; } } } | Register class resolver . |
11,967 | @ SuppressWarnings ( "unchecked" ) protected Project initProject ( ) { Collection errors = new ArrayList ( ) ; String projectFilePathOrURI = getProjectIdentifier ( ) ; return new Project ( projectFilePathOrURI , errors ) ; } | Opens the project specified by the file path or URI given in the constructor . |
11,968 | public static void printAllStackTraces ( final String filter , final Logger logger , final LogLevel logLevel ) { for ( Map . Entry < Thread , StackTraceElement [ ] > entry : Thread . getAllStackTraces ( ) . entrySet ( ) ) { if ( filter == null || entry . getKey ( ) . getName ( ) . contains ( filter ) ) { StackTracePrinter . printStackTrace ( "Thread[" + entry . getKey ( ) . getName ( ) + "] state[" + entry . getKey ( ) . getState ( ) . name ( ) + "]" , entry . getValue ( ) , logger , logLevel ) ; } } } | Method prints the stack traces of all running java threads via the given logger . |
11,969 | public void initialize ( BackendInstanceSpec config ) throws BackendInitializationException { super . initialize ( config ) ; if ( this . mappingsFactory == null ) { setMappingsFactory ( null ) ; } this . relationalDatabaseSpecBuilder = createRelationalDatabaseSpecBuilder ( ) ; } | Collects the database connection information specified in this backend s configuration and uses it to try and get a SQL generator with which to generate database queries . |
11,970 | public GranularityFactory getGranularityFactory ( ) throws DataSourceReadException { initializeIfNeeded ( ) ; GranularityFactory result = null ; DataSourceBackend b = null ; for ( DataSourceBackend backend : getBackends ( ) ) { result = backend . getGranularityFactory ( ) ; b = backend ; break ; } assert result != null : "no granularity factory returned from " + b . getClass ( ) + "!" ; return result ; } | Returns an object for accessing the granularity of returned data from the schema adaptor for this data source . |
11,971 | public UnitFactory getUnitFactory ( ) throws DataSourceReadException { initializeIfNeeded ( ) ; UnitFactory result = null ; DataSourceBackend b = null ; for ( DataSourceBackend backend : getBackends ( ) ) { result = backend . getUnitFactory ( ) ; b = backend ; break ; } assert result != null : "no unit factory returned from " + b . getClass ( ) + "!" ; return result ; } | Returns the length units of returned data from this data source . |
11,972 | boolean getMatches ( Proposition proposition , Collection < String > propIds ) throws KnowledgeSourceReadException { if ( proposition == null ) { return false ; } else { String pId = proposition . getId ( ) ; if ( this . propositionId != null && ! propIds . contains ( pId ) ) { return false ; } for ( PropertyConstraint pc : this . propertyConstraints ) { if ( ! pc . isSatisfiedBy ( proposition ) ) { return false ; } } return true ; } } | Returns whether a proposition has the same id and value and consistent duration as specified by this extended parameter definition . |
11,973 | public Response transform ( ClassLoader loader , String className , Class < ? > classBeingRedefined , ProtectionDomain protectionDomain , byte [ ] origBytes ) throws IllegalClassFormatException { byte [ ] transformed = first . transform ( loader , className , classBeingRedefined , protectionDomain , origBytes ) ; boolean firstEnhanced = ( transformed != null ) ; byte [ ] nextBytes = ( transformed != null ) ? transformed : origBytes ; byte [ ] finalTransformed = second . transform ( loader , className , classBeingRedefined , protectionDomain , nextBytes ) ; if ( finalTransformed != null ) { return new Response ( finalTransformed , firstEnhanced , true ) ; } else if ( transformed != null ) { return new Response ( transformed , firstEnhanced , false ) ; } return Response . NOT_TRANSFORMED ; } | Perform the combined enhancement . |
11,974 | public boolean cancel ( boolean mayInterruptIfRunning ) { boolean success = true ; for ( Future < FUTURE_TYPE > future : futureList ) { success &= future . cancel ( true ) ; } return success ; } | Cancels all internal futures . |
11,975 | public boolean isCancelled ( ) { boolean canceled = false ; for ( Future < FUTURE_TYPE > future : futureList ) { if ( ! future . isDone ( ) ) { return false ; } canceled |= future . isCancelled ( ) ; } return canceled ; } | Method returns true if at least one subfutures was canceled . In case there are still processing futures remaining than false is returned in any case . False is returned as well when all futures are done but none was canceled . |
11,976 | public boolean isDone ( ) { for ( Future < FUTURE_TYPE > future : futureList ) { if ( ! future . isDone ( ) ) { return false ; } } return true ; } | Method checks if the subfutures are done . |
11,977 | public static Coordinate [ ] deepCopyCoordinates ( Coordinate [ ] coordinatesOriginal ) { if ( coordinatesOriginal != null ) { Coordinate [ ] copy = new Coordinate [ coordinatesOriginal . length ] ; for ( int i = 0 ; i < coordinatesOriginal . length ; i ++ ) { copy [ i ] = deepCopyCoordinate ( coordinatesOriginal [ i ] ) ; } return copy ; } return null ; } | Copy values of array of coordinates to new array . |
11,978 | public ServiceException setException ( Throwable innerException ) { ByteArrayOutputStream messageOutputStream = new ByteArrayOutputStream ( ) ; innerException . printStackTrace ( new PrintStream ( messageOutputStream ) ) ; String exceptionMessage = messageOutputStream . toString ( ) ; this . fault . setException ( exceptionMessage ) ; return this ; } | Sets the exception which caused this service exception . It s important to set this exception to understand and reproduce the error! |
11,979 | private Object specializeInstance ( ClassDescriptor specializedClass , Object t ) { try ( Logger l = new Logger ( "specializeInstance(" + specializedClass . getSpecializedClass ( ) . getSimpleName ( ) + " , " + t + ")" ) ) { if ( ! specializedClass . isSpecialized ( ) ) { l . log ( "value unchanged" ) ; return t ; } l . log ( "Creating new instance" ) ; Object newInstance = specializedClass . getSpecializedClass ( ) . newInstance ( ) ; l . log ( "setting field values:" ) ; Class < ? > c = t . getClass ( ) ; l . log ( "from class " + c . getSimpleName ( ) + " to class " + specializedClass . getSpecializedClass ( ) . getSimpleName ( ) ) ; while ( c != null && specializedClass != null ) { for ( Field field : c . getDeclaredFields ( ) ) { field . setAccessible ( true ) ; Object value = field . get ( t ) ; FieldDescriptor fieldDescriptor = specializedClass . getFields ( ) . get ( field . getName ( ) ) ; if ( fieldDescriptor != null && fieldDescriptor . getSpecializedClass ( ) . isSpecialized ( ) ) { value = specializeInstance ( fieldDescriptor . getSpecializedClass ( ) , value ) ; l . log ( "- specialized " + newInstance . getClass ( ) . getSimpleName ( ) + "." + field . getName ( ) + " = " + value ) ; } else { l . log ( "- copied " + newInstance . getClass ( ) . getSimpleName ( ) + "." + field . getName ( ) + " = " + value ) ; } Field newField = newInstance . getClass ( ) . getField ( field . getName ( ) ) ; newField . set ( newInstance , value ) ; } c = c . getSuperclass ( ) ; specializedClass = specializedClass . getParent ( ) ; } return newInstance ; } catch ( InstantiationException | IllegalAccessException | NoSuchFieldException | SecurityException e ) { throw new SpecializationException ( "Could not create instance of the specialized class " + specializedClass . specializedClass . getSimpleName ( ) , e ) ; } } | creates a specialized copy of the given instance |
11,980 | public List < RemoteRepository > getRemoteRepositories ( SettingsDecrypter decrypter , ExtensionList < RemoteRepositoryDecorator > decorators ) { List < RemoteRepository > repositories = new ArrayList < RemoteRepository > ( ) ; MavenDependencyResolverSettings resolverSettings = new MavenDependencyResolverSettings ( ) ; resolverSettings . setUseMavenCentral ( true ) ; List < RemoteRepository > repos = resolverSettings . getRemoteRepositories ( ) ; for ( RemoteRepository remoteRepository : repos ) { Server server = resolverSettings . getSettings ( ) . getServer ( remoteRepository . getId ( ) ) ; if ( server != null ) { server = decrypter . decrypt ( new DefaultSettingsDecryptionRequest ( server ) ) . getServer ( ) ; remoteRepository . setAuthentication ( new Authentication ( server . getUsername ( ) , server . getPassword ( ) , server . getPrivateKey ( ) , server . getPassphrase ( ) ) ) ; } repositories . add ( decorate ( remoteRepository , decorators ) ) ; } RemoteRepository r = new RemoteRepository ( "cloudbees-public-release" , "default" , "https://repository-cloudbees.forge.cloudbees.com/public-release/" ) ; repositories . add ( decorate ( r , decorators ) ) ; return repositories ; } | List of remote repositories to resolve artifacts from . |
11,981 | public FoxHttpClientBuilder activteGZipResponseInterceptor ( int weight ) throws FoxHttpException { foxHttpClient . register ( FoxHttpInterceptorType . RESPONSE , new GZipResponseInterceptor ( weight ) ) ; return this ; } | Automatic gzip response parser . |
11,982 | public FoxHttpClientBuilder addFoxHttpAuthorization ( FoxHttpAuthorizationScope foxHttpAuthorizationScope , FoxHttpAuthorization foxHttpAuthorization ) { foxHttpClient . getFoxHttpAuthorizationStrategy ( ) . addAuthorization ( foxHttpAuthorizationScope , foxHttpAuthorization ) ; return this ; } | Add a Authorization to the AuthorizationStrategy |
11,983 | static void forceWritingEnumValue ( VerboseXmlEncoder encoder , Object object ) { Field valueToExpressionField = null ; Field refsField = null ; try { Class < ? > encoderClass = encoder . getClass ( ) . getSuperclass ( ) ; valueToExpressionField = encoderClass . getDeclaredField ( "valueToExpression" ) ; valueToExpressionField . setAccessible ( true ) ; Object valueToExpressionObject = valueToExpressionField . get ( encoder ) ; Map < ? , ? > valueToExpression = ( Map < ? , ? > ) valueToExpressionObject ; Object valueData = valueToExpression . get ( object ) ; if ( valueData != null ) { Class < ? > valueDataClass = valueData . getClass ( ) ; refsField = valueDataClass . getDeclaredField ( "refs" ) ; refsField . setAccessible ( true ) ; refsField . setInt ( valueData , 0 ) ; } } catch ( NoSuchFieldException e ) { logger . warning ( e . toString ( ) ) ; } catch ( SecurityException e ) { logger . warning ( e . toString ( ) ) ; } catch ( IllegalArgumentException e ) { logger . warning ( e . toString ( ) ) ; } catch ( IllegalAccessException e ) { logger . warning ( e . toString ( ) ) ; } finally { if ( valueToExpressionField != null ) { valueToExpressionField . setAccessible ( false ) ; } if ( refsField != null ) { refsField . setAccessible ( false ) ; } } } | Use a nasty reflection hack to make sure that the given object is always written explicitly without using idref in the given VerboseXmlEncoder |
11,984 | private int readSBits ( int numBits ) throws IOException { long uBits = readUBits ( numBits ) ; if ( ( uBits & ( 1L << ( numBits - 1 ) ) ) != 0 ) { uBits |= - 1L << numBits ; } return ( int ) uBits ; } | Read a signed integer value from input . |
11,985 | ConstructorParamExpressionBuilder param ( ) { return new ConstructorParamExpressionBuilder ( new ExpressionHandler < ConstructorCallBuilder > ( ) { public ConstructorCallBuilder handleExpression ( Expression e ) { return new ConstructorCallBuilder ( factory , expressionHandler , parameters . append ( e ) ) ; } } ) ; } | pass a parameter to the constructor |
11,986 | public static < B extends ProcessBuilder > QueueBuilder < B > newQueueBuilder ( Class < B > process_builder_class ) { return new QueueBuilder < B > ( ROOT_QUEUE , process_builder_class ) ; } | Retrieve a new QueueBuilder using the ROOT_QUEUE as a parent . |
11,987 | static < B extends ProcessBuilder > QueueBuilder < B > newQueueBuilder ( Queue parent_queue , Class < B > process_builder_class ) { return new QueueBuilder < B > ( parent_queue , process_builder_class ) ; } | Retrieve a new QueueBuilder using the specified queue as a parent . |
11,988 | public List < T > handle ( List < QueryParameters > outputList ) throws MjdbcException { return this . outputProcessor . toBeanList ( outputList , this . type ) ; } | Converts query output into list of beans |
11,989 | @ SuppressWarnings ( "unchecked" ) public Constraint getConstraint ( String ... typeInfo ) { if ( typeInfo == null || typeInfo . length < 1 ) { return getConstraints ( ) . iterator ( ) . next ( ) ; } else if ( typeInfo . length == 1 ) { Constraint c = getConstraint ( new String [ 0 ] ) ; DataType < ? > attr = c . getType ( ) ; Boolean b ; b = ( Boolean ) attr . getValue ( typeInfo [ 0 ] ) ; if ( b == null || ! b ) { return constraints . get ( 1 ) ; } else { return constraints . get ( 2 ) ; } } else { return super . getConstraint ( typeInfo ) ; } } | Overrides the default method to allow conditional checking . Only for non - longtext strings do we allow for a list of choices . |
11,990 | private MjdbcSQLException translateSQLStatePrefix ( String reason , String SQLState , int vendorCode , SQLException cause ) { MjdbcSQLException result = null ; String sqlState = getSqlState ( cause ) ; String sqlStatePrefix = null ; if ( sqlState != null && sqlState . length ( ) >= 2 ) { sqlStatePrefix = sqlState . substring ( 0 , 2 ) ; if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_BAD_SQL_GRAMMAR . contains ( sqlStatePrefix ) == true ) { result = new BadSqlGrammarException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_DATA_INTEGRITY_VIOLATION . contains ( sqlStatePrefix ) == true ) { result = new DataIntegrityViolationException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_DATA_ACCESS_RESOURCE_FAILURE . contains ( sqlStatePrefix ) == true ) { result = new DataAccessResourceFailureException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_TRANSIENT_DATA_ACCESS_RESOURCE_EXCEPTION . contains ( sqlStatePrefix ) == true ) { result = new TransientDataAccessResourceException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_CONCURRENCY_FAILURE . contains ( sqlStatePrefix ) == true ) { result = new ConcurrencyFailureException ( reason , SQLState , vendorCode ) ; } } return result ; } | Checks SQL state and tries to convert it into Spring SQL Exception . This implementation is vendor free . |
11,991 | private String getSqlState ( SQLException ex ) { String result = ex . getSQLState ( ) ; SQLException nestedEx = null ; if ( result == null ) { nestedEx = ex . getNextException ( ) ; if ( nestedEx != null ) { result = nestedEx . getSQLState ( ) ; } } return result ; } | Reads SQLException hierarchy and returns SQL state . |
11,992 | private String getErrorCode ( SQLException ex ) { String result = null ; SQLException nestedEx = null ; if ( ex . getErrorCode ( ) != 0 ) { result = Integer . toString ( ex . getErrorCode ( ) ) ; } if ( result == null ) { nestedEx = ex . getNextException ( ) ; if ( nestedEx != null ) { result = Integer . toString ( nestedEx . getErrorCode ( ) ) ; } } return result ; } | Reads SQLException hierarchy and returns error code |
11,993 | public static void setVariableWithSingleQuotationMarks ( final String variablename , final Object object , final Map < String , Object > variables ) { if ( object != null ) { variables . put ( variablename , "'" + object + "'" ) ; } else { variables . put ( variablename , "null" ) ; } } | Sets the variable with singe quotation marks . |
11,994 | public SimpleHTMLTag addSubTag ( SimpleHTMLTag tag ) { if ( tag == this ) { throw new IllegalArgumentException ( "The tag cannot be its own parent" ) ; } if ( subTags == null ) { subTags = new ArrayList < > ( ) ; } subTags . add ( tag ) ; return this ; } | Adds a subtag to this tag . If the tag has a text content any subtag will be ignored . |
11,995 | public SimpleHTMLTag setProperty ( String key , String value ) { key = UniformUtils . checkPropertyNameAndLowerCase ( key ) ; if ( properties == null ) { properties = new HashMap < > ( ) ; } properties . put ( key , value ) ; return this ; } | Sets a property of the tag by key . |
11,996 | public SimpleHTMLTag removeProperty ( String key ) { key = UniformUtils . checkPropertyNameAndLowerCase ( key ) ; if ( properties != null ) { properties . remove ( key ) ; } return this ; } | Removes a property of the tag by key . |
11,997 | public SimpleHTMLTag setProperties ( Map < String , String > properties ) { if ( properties == null || properties . isEmpty ( ) ) { this . properties = null ; } else { this . properties = new HashMap < > ( ) ; for ( Entry < String , String > entry : properties . entrySet ( ) ) { String key = entry . getKey ( ) ; key = UniformUtils . checkPropertyNameAndLowerCase ( key ) ; this . properties . put ( key , entry . getValue ( ) ) ; } } return this ; } | Replaces all properties of the tag with a map of properties indexed by key . |
11,998 | public String getProperty ( String key ) { key = UniformUtils . checkPropertyNameAndLowerCase ( key ) ; if ( properties == null ) { return null ; } return properties . get ( key ) ; } | Returns a property of this tag by key if present . |
11,999 | public static ImageInfo read ( InputStream in ) throws IOException { ImageInfo imageInfo = new ImageInfo ( ) ; imageInfo . setInput ( in ) ; if ( ! imageInfo . check ( ) ) { throw new IOException ( "ImageInfo.check() failed; data stream is " + "broken or does not contain data in a supported image format" ) ; } return imageInfo ; } | Reads image info from a stream . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.