idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
13,700
protected void dispatchRequest ( int clientOid , int invCode , int methodId , Object [ ] args , Transport transport ) { ClientObject source = ( ClientObject ) _omgr . getObject ( clientOid ) ; if ( source == null ) { log . info ( "Client no longer around for invocation request" , "clientOid" , clientOid , "code" , invCode , "methId" , methodId , "args" , args ) ; return ; } Dispatcher disp = _dispatchers . get ( invCode ) ; if ( disp == null ) { log . info ( "Received invocation request but dispatcher registration was already cleared" , "code" , invCode , "methId" , methodId , "args" , args , "marsh" , _recentRegServices . get ( Integer . valueOf ( invCode ) ) ) ; return ; } ListenerMarshaller rlist = null ; int acount = args . length ; for ( int ii = 0 ; ii < acount ; ii ++ ) { Object arg = args [ ii ] ; if ( arg instanceof ListenerMarshaller ) { ListenerMarshaller list = ( ListenerMarshaller ) arg ; list . callerOid = clientOid ; list . omgr = _omgr ; list . transport = transport ; if ( rlist == null ) { rlist = list ; } } } log . debug ( "Dispatching invreq" , "caller" , source . who ( ) , "provider" , disp . getProvider ( ) , "methId" , methodId , "args" , args ) ; try { if ( rlist != null ) { rlist . setInvocationId ( StringUtil . shortClassName ( disp . getProvider ( ) ) + ", methodId=" + methodId ) ; } disp . dispatchRequest ( source , methodId , args ) ; } catch ( InvocationException ie ) { if ( rlist != null ) { rlist . requestFailed ( ie . getMessage ( ) ) ; } else { log . warning ( "Service request failed but we've got no listener to inform of " + "the failure" , "caller" , source . who ( ) , "code" , invCode , "provider" , disp . getProvider ( ) , "methodId" , methodId , "args" , args , "error" , ie ) ; } } catch ( Throwable t ) { log . warning ( "Dispatcher choked" , "provider" , disp . getProvider ( ) , "caller" , source . who ( ) , "methId" , methodId , "args" , args , t ) ; if ( rlist != null ) { rlist . setNoResponse ( ) ; } } }
Called when we receive an invocation request message . Dispatches the request to the appropriate invocation provider via the registered invocation dispatcher .
13,701
public void setClientInfo ( String msg , String ltype ) { message = msg ; localtype = ltype ; bundle = null ; timestamp = System . currentTimeMillis ( ) ; }
Once this message reaches the client the information contained within is changed around a bit .
13,702
protected int innerCompare ( Comparable < Object > co1 , Comparable < Object > co2 ) { return co1 . compareTo ( co2 ) ; }
Override this to customize the comparation itself . E . g . inversing it .
13,703
protected void processClass ( File source ) { CtClass clazz ; InputStream in = null ; try { clazz = _pool . makeClass ( in = new BufferedInputStream ( new FileInputStream ( source ) ) ) ; } catch ( IOException ioe ) { System . err . println ( "Failed to load " + source + ": " + ioe ) ; return ; } finally { StreamUtil . close ( in ) ; } try { if ( clazz . subtypeOf ( _streamable ) ) { processStreamable ( source , clazz ) ; } } catch ( NotFoundException nfe ) { System . err . println ( "Error processing class [class=" + clazz . getName ( ) + ", error=" + nfe + "]." ) ; } }
Processes a class file .
13,704
protected synchronized void createAgent ( int agentId ) { Subscriber < AgentObject > delegator = new Subscriber < AgentObject > ( ) { public void objectAvailable ( AgentObject agentObject ) { BureauDirector . this . objectAvailable ( agentObject ) ; } public void requestFailed ( int oid , ObjectAccessException cause ) { BureauDirector . this . requestFailed ( oid , cause ) ; } } ; log . info ( "Subscribing to object " + agentId ) ; SafeSubscriber < AgentObject > subscriber = new SafeSubscriber < AgentObject > ( agentId , delegator ) ; _subscribers . put ( agentId , subscriber ) ; subscriber . subscribe ( _ctx . getDObjectManager ( ) ) ; }
Creates a new agent when the server requests it .
13,705
protected synchronized void destroyAgent ( int agentId ) { Agent agent = null ; agent = _agents . remove ( agentId ) ; if ( agent == null ) { log . warning ( "Lost an agent, id " + agentId ) ; } else { try { agent . stop ( ) ; } catch ( Throwable t ) { log . warning ( "Stopping an agent caused an exception" , t ) ; } SafeSubscriber < AgentObject > subscriber = _subscribers . remove ( agentId ) ; if ( subscriber == null ) { log . warning ( "Lost a subscriber for agent " + agent ) ; } else { subscriber . unsubscribe ( _ctx . getDObjectManager ( ) ) ; } _bureauService . agentDestroyed ( agentId ) ; } }
Destroys an agent at the server s request .
13,706
protected synchronized void objectAvailable ( AgentObject agentObject ) { int oid = agentObject . getOid ( ) ; log . info ( "Object " + oid + " now available" ) ; Agent agent ; try { agent = createAgent ( agentObject ) ; agent . init ( agentObject ) ; agent . start ( ) ; } catch ( Throwable t ) { log . warning ( "Could not create agent" , "obj" , agentObject , t ) ; _bureauService . agentCreationFailed ( oid ) ; return ; } _agents . put ( oid , agent ) ; _bureauService . agentCreated ( oid ) ; }
Callback for when the a request to subscribe to an object finishes and the object is available .
13,707
public void handleSuccess ( ) { if ( _listener instanceof InvocationService . ConfirmListener ) { reportRequestProcessed ( ) ; } else if ( _listener instanceof InvocationService . ResultListener && _resultSet ) { reportRequestProcessed ( _result ) ; } }
Handles the success case which by default posts a response to a ConfirmListener . If you need something else or to repond to a ResultListener you ll need to override this .
13,708
public void handleFailure ( Exception error ) { if ( error instanceof InvocationException ) { _listener . requestFailed ( error . getMessage ( ) ) ; } else { if ( _args != null ) { log . warning ( getFailureMessage ( ) , ArrayUtil . append ( _args , error ) ) ; } else { log . warning ( getFailureMessage ( ) , error ) ; } _listener . requestFailed ( InvocationCodes . INTERNAL_ERROR ) ; } }
Handles the failure case by logging the error and reporting an internal error to the listener .
13,709
public void addConstraint ( Shutdowner lhs , Constraint constraint , Shutdowner rhs ) { switch ( constraint ) { case RUNS_BEFORE : _cycle . addShutdownConstraint ( lhs , Lifecycle . Constraint . RUNS_BEFORE , rhs ) ; break ; case RUNS_AFTER : _cycle . addShutdownConstraint ( lhs , Lifecycle . Constraint . RUNS_AFTER , rhs ) ; break ; } }
Adds a constraint that a certain shutdowner must be run before another .
13,710
public void handleDatagram ( InetSocketAddress source , DatagramChannel channel , ByteBuffer buf , long when ) { if ( _digest == null ) { try { _digest = MessageDigest . getInstance ( "MD5" ) ; } catch ( NoSuchAlgorithmException nsae ) { log . warning ( "Missing MD5 algorithm." ) ; return ; } _sequencer = _pcmgr . createDatagramSequencer ( ) ; } buf . position ( 12 ) ; _digest . update ( buf ) ; byte [ ] hash = _digest . digest ( _datagramSecret ) ; buf . position ( 4 ) ; for ( int ii = 0 ; ii < 8 ; ii ++ ) { if ( hash [ ii ] != buf . get ( ) ) { log . warning ( "Datagram failed hash check" , "id" , _connectionId , "source" , source ) ; return ; } } _datagramAddress = source ; _datagramChannel = channel ; try { Message msg = _sequencer . readDatagram ( ) ; if ( msg == null ) { return ; } msg . received = when ; _handler . handleMessage ( msg ) ; } catch ( ClassNotFoundException cnfe ) { log . warning ( "Error reading datagram" , "error" , cnfe ) ; } catch ( IOException ioe ) { log . warning ( "Error reading datagram" , "error" , ioe ) ; } }
Processes a datagram sent to this connection .
13,711
protected void inheritStreams ( PresentsConnection other ) { _fin = other . _fin ; _oin = other . _oin ; _oout = other . _oout ; if ( _loader != null ) { _oin . setClassLoader ( _loader ) ; } }
Instructs this connection to inherit its streams from the supplied connection object . This is called by the connection manager when the time comes to pass streams from the authing connection to the running connection .
13,712
public void setDefaultAccessController ( AccessController controller ) { AccessController oldDefault = _defaultController ; _defaultController = controller ; for ( DObject obj : _objects . values ( ) ) { if ( oldDefault == obj . getAccessController ( ) ) { obj . setAccessController ( controller ) ; } } }
Sets up an access controller that will be provided to any distributed objects created on the server . The controllers can subsequently be overridden if desired but a default controller is useful for implementing basic access control policies .
13,713
public void clearProxyObject ( int origObjectId , DObject object ) { if ( _proxies . remove ( object . getOid ( ) ) == null ) { log . warning ( "Missing proxy mapping for cleared proxy" , "ooid" , origObjectId ) ; } _objects . remove ( object . getOid ( ) ) ; }
Clears a proxy object reference from our local distributed object space . This merely removes it from our internal tables the caller is responsible for coordinating the deregistration of the object with the proxying client .
13,714
public Stats getStats ( boolean snapshot ) { if ( snapshot ) { _recent = _current ; _current = new Stats ( ) ; _current . maxQueueSize = _evqueue . size ( ) ; } return _recent ; }
Returns a recent snapshot of runtime statistics tracked by the distributed object manager .
13,715
public void run ( ) { log . info ( "DOMGR running." ) ; synchronized ( this ) { _dobjThread = Thread . currentThread ( ) ; } while ( isRunning ( ) ) { processUnit ( _evqueue . get ( ) ) ; } log . info ( "DOMGR exited." ) ; }
Runs the dobjmgr event loop until it is requested to exit . This should be called from the main application thread .
13,716
public void dumpUnitProfiles ( ) { for ( Map . Entry < String , UnitProfile > entry : _profiles . entrySet ( ) ) { log . info ( "P: " + entry . getKey ( ) + " => " + entry . getValue ( ) ) ; } }
Dumps collected profiling information to the system log .
13,717
protected void processUnit ( Object unit ) { long start = System . nanoTime ( ) ; int queueSize = _evqueue . size ( ) ; if ( queueSize > _current . maxQueueSize ) { _current . maxQueueSize = queueSize ; } try { if ( unit instanceof Runnable ) { ( ( Runnable ) unit ) . run ( ) ; } else { DEvent event = ( DEvent ) unit ; ProxyReference proxy = _proxies . get ( event . getTargetOid ( ) ) ; if ( proxy != null ) { event . setTargetOid ( proxy . origObjectId ) ; proxy . origManager . postEvent ( event ) ; } else if ( event instanceof CompoundEvent ) { processCompoundEvent ( ( CompoundEvent ) event ) ; } else { processEvent ( event ) ; } } } catch ( VirtualMachineError e ) { handleFatalError ( unit , e ) ; } catch ( Throwable t ) { log . warning ( "Execution unit failed" , "unit" , unit , t ) ; } long elapsed = ( System . nanoTime ( ) - start ) / 1000 ; if ( elapsed > 500000 && ! ( unit instanceof LongRunnable ) ) { log . warning ( "Long dobj unit " + StringUtil . shortClassName ( unit ) , "unit" , unit , "time" , ( elapsed / 1000 ) + "ms" ) ; } if ( UNIT_PROF_ENABLED && _eventCount % _unitProfInterval == 0 ) { String cname ; if ( unit instanceof Interval . RunBuddy ) { cname = StringUtil . shortClassName ( ( ( Interval . RunBuddy ) unit ) . getIntervalClassName ( ) ) ; } else if ( unit instanceof InvocationRequestEvent ) { InvocationRequestEvent ire = ( InvocationRequestEvent ) unit ; Class < ? > c = _invmgr . getDispatcherClass ( ire . getInvCode ( ) ) ; cname = ( c == null ) ? "dobj.InvocationRequestEvent:(no longer registered)" : StringUtil . shortClassName ( c ) + ":" + ire . getMethodId ( ) ; } else { cname = StringUtil . shortClassName ( unit ) ; } UnitProfile uprof = _profiles . get ( cname ) ; if ( uprof == null ) { _profiles . put ( cname , uprof = new UnitProfile ( ) ) ; } uprof . record ( elapsed ) ; } }
Processes a single unit from the queue .
13,718
protected void processCompoundEvent ( CompoundEvent event ) { List < DEvent > events = event . getEvents ( ) ; int ecount = events . size ( ) ; DObject target = _objects . get ( event . getTargetOid ( ) ) ; if ( target == null ) { log . debug ( "Compound event target no longer exists" , "event" , event ) ; return ; } for ( int ii = 0 ; ii < ecount ; ii ++ ) { DEvent sevent = events . get ( ii ) ; if ( ! target . checkPermissions ( sevent ) ) { log . warning ( "Event failed permissions check" , "event" , sevent , "target" , target ) ; return ; } } for ( int ii = 0 ; ii < ecount ; ii ++ ) { dispatchEvent ( events . get ( ii ) , target ) ; } target . notifyProxies ( event ) ; }
Performs the processing associated with a compound event notifying listeners and the like .
13,719
protected void processEvent ( DEvent event ) { DObject target = _objects . get ( event . getTargetOid ( ) ) ; if ( target == null ) { log . debug ( "Event target no longer exists" , "event" , event ) ; return ; } if ( ! target . checkPermissions ( event ) ) { log . warning ( "Event failed permissions check" , "event" , event , "target" , target ) ; return ; } if ( dispatchEvent ( event , target ) ) { target . notifyProxies ( event ) ; } }
Performs the processing associated with an event notifying listeners and the like .
13,720
protected void handleFatalError ( Object causer , Error error ) { if ( _fatalThrottle . throttleOp ( ) ) { throw error ; } log . warning ( "Fatal error caused by '" + causer + "': " + error , error ) ; }
Attempts to recover from fatal errors but rethrows if things are freaking out too frequently .
13,721
protected void registerEventHelpers ( ) { try { _helpers . put ( ObjectDestroyedEvent . class , new EventHelper ( ) { public boolean invoke ( DEvent event , DObject target ) { return objectDestroyed ( event , target ) ; } } ) ; _helpers . put ( ObjectAddedEvent . class , new EventHelper ( ) { public boolean invoke ( DEvent event , DObject target ) { return objectAdded ( event , target ) ; } } ) ; _helpers . put ( ObjectRemovedEvent . class , new EventHelper ( ) { public boolean invoke ( DEvent event , DObject target ) { return objectRemoved ( event , target ) ; } } ) ; } catch ( Exception e ) { log . warning ( "Unable to register event helpers" , "error" , e ) ; } }
Registers our event helper methods .
13,722
public void setHeader ( File header ) { try { _header = StreamUtil . toString ( new FileReader ( header ) ) ; } catch ( IOException ioe ) { System . err . println ( "Unabled to load header '" + header + ": " + ioe . getMessage ( ) ) ; } }
Configures us with a header file that we ll prepend to all generated source files .
13,723
protected boolean wouldProduceSameFile ( String generated , File existing ) throws IOException { Iterator < String > generatedLines = Splitter . on ( EOL ) . split ( generated ) . iterator ( ) ; for ( String prev : Files . readLines ( existing , UTF_8 ) ) { if ( ! generatedLines . hasNext ( ) ) { return false ; } String cur = generatedLines . next ( ) ; if ( ! prev . equals ( cur ) && ! ( prev . startsWith ( "// $Id" ) && cur . startsWith ( "// $Id" ) ) ) { return false ; } } if ( generatedLines . hasNext ( ) ) { return generatedLines . next ( ) . equals ( "" ) && ! generatedLines . hasNext ( ) ; } return true ; }
Returns true if the given string has the same content as the file sans svn prop lines .
13,724
protected String mergeTemplate ( String template , Object ... data ) throws IOException { return mergeTemplate ( template , createMap ( data ) ) ; }
Merges the specified template using the supplied mapping of keys to objects .
13,725
protected String mergeTemplate ( String template , Map < String , Object > data ) throws IOException { Reader reader = new InputStreamReader ( getClass ( ) . getClassLoader ( ) . getResourceAsStream ( template ) , UTF_8 ) ; return convertEols ( Mustache . compiler ( ) . escapeHTML ( false ) . compile ( reader ) . execute ( data ) ) ; }
Merges the specified template using the supplied mapping of string keys to objects .
13,726
public static String comicChars ( int length ) { char [ ] chars = new char [ length ] ; for ( int ii = 0 ; ii < length ; ii ++ ) { chars [ ii ] = RandomUtil . pickRandom ( COMIC_CHARS ) ; } return new String ( chars ) ; }
Return a comicy replacement of the specified length .
13,727
public String filter ( String msg , Name otherUser , boolean outgoing ) { _stopMatcher . reset ( msg ) ; if ( _stopMatcher . find ( ) ) { return null ; } Mode level = getFilterMode ( ) ; if ( level == Mode . UNFILTERED ) { return msg ; } StringBuffer inbuf = new StringBuffer ( msg ) ; StringBuffer outbuf = new StringBuffer ( msg . length ( ) ) ; for ( int ii = 0 , nn = _matchers . length ; ii < nn ; ii ++ ) { Matcher m = _matchers [ ii ] ; m . reset ( inbuf ) ; while ( m . find ( ) ) { switch ( level ) { case DROP : return null ; case COMIC : m . appendReplacement ( outbuf , _replacements [ ii ] . replace ( " " , comicChars ( _comicLength [ ii ] ) ) ) ; break ; case VERNACULAR : String vernacular = _vernacular [ ii ] ; if ( Character . isUpperCase ( m . group ( 2 ) . codePointAt ( 0 ) ) ) { int firstCharLen = Character . charCount ( vernacular . codePointAt ( 0 ) ) ; vernacular = vernacular . substring ( 0 , firstCharLen ) . toUpperCase ( ) + vernacular . substring ( firstCharLen ) ; } m . appendReplacement ( outbuf , _replacements [ ii ] . replace ( " " , vernacular ) ) ; break ; case UNFILTERED : log . warning ( "Omg? We're trying to filter chat even though we're unfiltered?" ) ; break ; } } if ( outbuf . length ( ) == 0 ) { continue ; } m . appendTail ( outbuf ) ; StringBuffer temp = inbuf ; inbuf = outbuf ; outbuf = temp ; outbuf . setLength ( 0 ) ; } return inbuf . toString ( ) ; }
from interface ChatFilter
13,728
protected void configureCurseWords ( String curseWords ) { StringTokenizer st = new StringTokenizer ( curseWords ) ; int numWords = st . countTokens ( ) ; _matchers = new Matcher [ numWords ] ; _replacements = new String [ numWords ] ; _vernacular = new String [ numWords ] ; _comicLength = new int [ numWords ] ; for ( int ii = 0 ; ii < numWords ; ii ++ ) { String mapping = st . nextToken ( ) ; StringTokenizer st2 = new StringTokenizer ( mapping , "=" ) ; if ( st2 . countTokens ( ) != 2 ) { log . warning ( "Something looks wrong in the x.cursewords properties (" + mapping + "), skipping." ) ; continue ; } String curse = st2 . nextToken ( ) ; String s = "" ; String p = "" ; if ( curse . startsWith ( "*" ) ) { curse = curse . substring ( 1 ) ; p += "([\\p{L}\\p{Digit}]*)" ; s += "$1" ; } else { p += "()" ; } s += " " ; p += " " ; if ( curse . endsWith ( "*" ) ) { curse = curse . substring ( 0 , curse . length ( ) - 1 ) ; p += "([\\p{L}\\p{Digit}]*)" ; s += "$3" ; } String pattern = "\\b" + p . replace ( " " , "(" + curse + ")" ) + "\\b" ; Pattern pat = Pattern . compile ( pattern , Pattern . CASE_INSENSITIVE | Pattern . UNICODE_CASE ) ; _matchers [ ii ] = pat . matcher ( "" ) ; _replacements [ ii ] = s ; _vernacular [ ii ] = st2 . nextToken ( ) . replace ( '_' , ' ' ) ; _comicLength [ ii ] = curse . codePointCount ( 0 , curse . length ( ) ) ; } }
Configure the curse word portion of our filtering .
13,729
protected void configureStopWords ( String stopWords ) { List < String > patterns = Lists . newArrayList ( ) ; for ( StringTokenizer st = new StringTokenizer ( stopWords ) ; st . hasMoreTokens ( ) ; ) { patterns . add ( getStopWordRegexp ( st . nextToken ( ) ) ) ; } String pattern = patterns . isEmpty ( ) ? ".\\A" : "(" + Joiner . on ( '|' ) . join ( patterns ) + ")" ; setStopPattern ( pattern ) ; }
Configure the words that will stop .
13,730
protected void setStopPattern ( String pattern ) { _stopMatcher = Pattern . compile ( pattern , Pattern . CASE_INSENSITIVE ) . matcher ( "" ) ; }
Sets our stop word matcher to one for the given regular expression .
13,731
public static < T > T queueAndWait ( RunQueue runq , final String name , final Callable < T > action ) throws ServiceException { final ServletWaiter < T > waiter = new ServletWaiter < T > ( name ) ; runq . postRunnable ( new Runnable ( ) { public void run ( ) { try { waiter . postSuccess ( action . call ( ) ) ; } catch ( final Exception e ) { waiter . postFailure ( e ) ; } } } ) ; return waiter . waitForResult ( ) ; }
Posts a result getter to be executed on the run queue thread and blocks waiting for the result .
13,732
public static < T extends TOP > int count ( final Class < T > type , final JCas aJCas ) { return JCasUtil . select ( aJCas , type ) . size ( ) ; }
Counts the number of features structures of the given type in the JCas
13,733
public static < T extends TOP > boolean hasAny ( final Class < T > type , final JCas aJCas ) { return count ( type , aJCas ) != 0 ; }
Returns whether there is any feature structure of the given type
13,734
public static < T extends TOP > boolean hasNo ( final Class < T > type , final JCas aJCas ) { return ! hasAny ( type , aJCas ) ; }
Returns whether there is no feature structure of the given type
13,735
public static < T extends TOP > List < T > selectAsList ( final JCas jCas , final Class < T > type ) { return new ArrayList < > ( JCasUtil . select ( jCas , type ) ) ; }
Convenience method that selects all feature structures of the given type and creates a list from them .
13,736
public static < T extends Annotation > boolean doOverlap ( final T anno1 , final T anno2 ) { return anno1 . getEnd ( ) > anno2 . getBegin ( ) && anno1 . getBegin ( ) < anno2 . getEnd ( ) ; }
Returns whether the given annotations have a non - empty overlap .
13,737
public static boolean haveSameSpan ( final Annotation anno1 , final Annotation anno2 ) { return anno1 . getBegin ( ) == anno2 . getBegin ( ) && anno1 . getEnd ( ) == anno2 . getEnd ( ) ; }
Returns whether two annotations share the same span
13,738
public static JCas getJCas ( final Annotation annotation ) { JCas result = null ; try { result = annotation . getCAS ( ) . getJCas ( ) ; } catch ( final CASException e ) { throw new IllegalArgumentException ( e ) ; } return result ; }
Returns the JCas of this annotation .
13,739
public static boolean isFirstCoveredToken ( final Token token , final Annotation annotation ) { final JCas jCas = getJCas ( annotation ) ; final List < Token > coveredTokens = JCasUtil . selectCovered ( jCas , Token . class , annotation ) ; if ( coveredTokens . isEmpty ( ) ) { return false ; } else { final Token firstCoveredToken = coveredTokens . get ( 0 ) ; return haveSameSpan ( token , firstCoveredToken ) ; } }
Returns whether the given token is the first token covered by the given annotation .
13,740
public static void updateEnd ( final Annotation annotation , final int end ) { annotation . removeFromIndexes ( ) ; annotation . setEnd ( end ) ; annotation . addToIndexes ( ) ; }
Sets the end value of the annotation updating indexes appropriately
13,741
public static void updateBegin ( final Annotation annotation , final int begin ) { annotation . removeFromIndexes ( ) ; annotation . setBegin ( begin ) ; annotation . addToIndexes ( ) ; }
Sets the begin value of the annotation updating indexes appropriately
13,742
public static Token findTokenByBeginPosition ( JCas jCas , int begin ) { for ( Token token : JCasUtil . select ( getInitialView ( jCas ) , Token . class ) ) { if ( token . getBegin ( ) == begin ) { return token ; } } return null ; }
Returns token at the given position
13,743
public static Token findTokenByEndPosition ( JCas jCas , int end ) { for ( Token token : JCasUtil . select ( getInitialView ( jCas ) , Token . class ) ) { if ( token . getEnd ( ) == end ) { return token ; } } return null ; }
Returns token ending at the given position
13,744
public static List < Token > getPrecedingTokens ( JCas jCas , Token token ) { List < Token > result = new ArrayList < Token > ( ) ; for ( Token t : JCasUtil . select ( getInitialView ( jCas ) , Token . class ) ) { if ( t . getBegin ( ) < token . getBegin ( ) ) { result . add ( t ) ; } } return result ; }
Returns a list of tokens preceding the given token
13,745
public static List < Sentence > getPrecedingSentences ( JCas jCas , Sentence annotation ) { List < Sentence > result = new ArrayList < Sentence > ( ) ; for ( Sentence sentence : JCasUtil . select ( getInitialView ( jCas ) , Sentence . class ) ) { if ( sentence . getBegin ( ) < annotation . getBegin ( ) ) { result . add ( sentence ) ; } } Collections . sort ( result , new Comparator < Sentence > ( ) { public int compare ( Sentence o1 , Sentence o2 ) { return o2 . getBegin ( ) - o1 . getBegin ( ) ; } } ) ; return result ; }
Returns a list of annotations of the same type preceding the given annotation
13,746
public byte [ ] getSecret ( PrivateKey key ) { if ( _secret == null ) { _secret = SecureUtil . decryptBytes ( key , _encodedSecret , _salt ) ; } return _secret ; }
Decodes the secret .
13,747
public void addTranslation ( String className , String streamedName ) { if ( _translations == null ) { _translations = Maps . newHashMap ( ) ; } _translations . put ( className , streamedName ) ; }
Configures this object output stream with a mapping from a classname to a streamed name .
13,748
public void writeIntern ( String value ) throws IOException { if ( value == null ) { writeShort ( 0 ) ; return ; } if ( _internmap == null ) { _internmap = Maps . newHashMap ( ) ; } Short code = _internmap . get ( value ) ; if ( code == null ) { if ( ObjectInputStream . STREAM_DEBUG ) { log . info ( hashCode ( ) + ": Creating intern mapping" , "code" , _nextInternCode , "value" , value ) ; } code = createInternMapping ( _nextInternCode ++ ) ; _internmap . put ( value . intern ( ) , code ) ; if ( _nextInternCode <= 0 ) { throw new RuntimeException ( "Too many unique interns written to ObjectOutputStream" ) ; } writeNewInternMapping ( code , value ) ; } else { writeExistingInternMapping ( code , value ) ; } }
Writes a pooled string value to the output stream .
13,749
protected ClassMapping writeClassMapping ( Class < ? > sclass ) throws IOException { if ( _classmap == null ) { _classmap = Maps . newHashMap ( ) ; } ClassMapping cmap = _classmap . get ( sclass ) ; if ( cmap == null ) { Class < ? > collClass = Streamer . getCollectionClass ( sclass ) ; if ( collClass != null && ! collClass . equals ( sclass ) ) { cmap = writeClassMapping ( collClass ) ; _classmap . put ( sclass , cmap ) ; return cmap ; } Streamer streamer = Streamer . getStreamer ( sclass ) ; if ( ObjectInputStream . STREAM_DEBUG ) { log . info ( hashCode ( ) + ": Creating class mapping" , "code" , _nextClassCode , "class" , sclass . getName ( ) ) ; } cmap = createClassMapping ( _nextClassCode ++ , sclass , streamer ) ; _classmap . put ( sclass , cmap ) ; if ( _nextClassCode <= 0 ) { throw new RuntimeException ( "Too many unique classes written to ObjectOutputStream" ) ; } writeNewClassMapping ( cmap ) ; } else { writeExistingClassMapping ( cmap ) ; } return cmap ; }
Retrieves or creates the class mapping for the supplied class writes it out to the stream and returns a reference to it .
13,750
protected void writeClassMapping ( int code , Class < ? > sclass ) throws IOException { writeShort ( code ) ; String cname = sclass . getName ( ) ; if ( _translations != null ) { String tname = _translations . get ( cname ) ; if ( tname != null ) { cname = tname ; } } writeUTF ( cname ) ; }
Writes out the mapping for a class .
13,751
public void getTimeOid ( String arg1 , TimeBaseService . GotTimeBaseListener arg2 ) { TimeBaseMarshaller . GotTimeBaseMarshaller listener2 = new TimeBaseMarshaller . GotTimeBaseMarshaller ( ) ; listener2 . listener = arg2 ; sendRequest ( GET_TIME_OID , new Object [ ] { arg1 , listener2 } ) ; }
from interface TimeBaseService
13,752
public synchronized void writeDatagram ( Message datagram ) throws IOException { _uout . writeInt ( ++ _lastNumber ) ; _uout . writeInt ( _lastReceived ) ; Set < Class < ? > > mappedClasses = _uout . getMappedClasses ( ) ; mappedClasses . clear ( ) ; Set < String > mappedInterns = _uout . getMappedInterns ( ) ; mappedInterns . clear ( ) ; _uout . writeObject ( datagram ) ; if ( mappedClasses . isEmpty ( ) ) { mappedClasses = null ; } else { _uout . setMappedClasses ( new HashSet < Class < ? > > ( ) ) ; } if ( mappedInterns . isEmpty ( ) ) { mappedInterns = null ; } else { _uout . setMappedInterns ( new HashSet < String > ( ) ) ; } _sendrecs . add ( new SendRecord ( _lastNumber , mappedClasses , mappedInterns ) ) ; }
Writes a datagram to the underlying stream .
13,753
public synchronized Message readDatagram ( ) throws IOException , ClassNotFoundException { int number = _uin . readInt ( ) ; if ( number <= _lastReceived ) { return null ; } _missedCount = number - _lastReceived - 1 ; _lastReceived = number ; int received = _uin . readInt ( ) ; int remove = 0 ; for ( int ii = 0 , nn = _sendrecs . size ( ) ; ii < nn ; ii ++ ) { SendRecord sendrec = _sendrecs . get ( ii ) ; if ( sendrec . number > received ) { break ; } remove ++ ; if ( sendrec . number == received ) { if ( sendrec . mappedClasses != null ) { _uout . noteClassMappingsReceived ( sendrec . mappedClasses ) ; } if ( sendrec . mappedInterns != null ) { _uout . noteInternMappingsReceived ( sendrec . mappedInterns ) ; } } } if ( remove > 0 ) { _sendrecs . subList ( 0 , remove ) . clear ( ) ; } Message datagram = ( Message ) _uin . readObject ( ) ; datagram . setTransport ( Transport . UNRELIABLE_ORDERED ) ; return datagram ; }
Reads a datagram from the underlying stream .
13,754
protected < T extends InvocationMarshaller < ? > > T addProvider ( InvocationProvider prov , Class < T > mclass ) { return _plmgr . addProvider ( prov , mclass ) ; }
Registers an invocation provider and notes the registration such that it will be automatically cleared when our parent manager shuts down .
13,755
protected < T extends InvocationMarshaller < ? > > T addDispatcher ( InvocationDispatcher < T > disp ) { return _plmgr . addDispatcher ( disp ) ; }
Registers an invocation dispatcher and notes the registration such that it will be automatically cleared when our parent manager shuts down .
13,756
public byte [ ] createSecret ( PublicKeyCredentials pkcred , PrivateKey key , int length ) { _data = new AuthResponseData ( ) ; byte [ ] clientSecret = pkcred . getSecret ( key ) ; if ( clientSecret == null ) { _data . code = FAILED_TO_SECURE ; return null ; } byte [ ] secret = SecureUtil . createRandomKey ( length ) ; _data . code = StringUtil . hexlate ( SecureUtil . xorBytes ( secret , clientSecret ) ) ; return secret ; }
Encodes the server secret in the response data or sets the failed state .
13,757
public byte [ ] getCodeBytes ( PublicKeyCredentials pkcreds ) { return pkcreds == null || _data . code == null || _data . code . equals ( FAILED_TO_SECURE ) ? null : SecureUtil . xorBytes ( StringUtil . unhexlate ( _data . code ) , pkcreds . getSecret ( ) ) ; }
Returns the code bytes or null for a failed state .
13,758
public void activatePeriodicReport ( RootDObjectManager omgr ) { omgr . newInterval ( new Runnable ( ) { public void run ( ) { logReport ( LOG_REPORT_HEADER + generateReport ( DEFAULT_TYPE , System . currentTimeMillis ( ) , true ) ) ; } } ) . schedule ( getReportInterval ( ) , true ) ; }
Starts up our periodic report generation task .
13,759
protected String generateReport ( String type , long now , boolean reset ) { long sinceLast = now - _lastReportStamp ; long uptime = now - _serverStartTime ; StringBuilder report = new StringBuilder ( ) ; if ( DEFAULT_TYPE . equals ( type ) ) { report . append ( "- Uptime: " ) ; report . append ( StringUtil . intervalToString ( uptime ) ) . append ( "\n" ) ; report . append ( "- Report period: " ) ; report . append ( StringUtil . intervalToString ( sinceLast ) ) . append ( "\n" ) ; Runtime rt = Runtime . getRuntime ( ) ; long total = rt . totalMemory ( ) , max = rt . maxMemory ( ) ; long used = ( total - rt . freeMemory ( ) ) ; report . append ( "- Memory: " ) . append ( used / 1024 ) . append ( "k used, " ) ; report . append ( total / 1024 ) . append ( "k total, " ) ; report . append ( max / 1024 ) . append ( "k max\n" ) ; } for ( Reporter rptr : _reporters . get ( type ) ) { try { rptr . appendReport ( report , now , sinceLast , reset ) ; } catch ( Throwable t ) { log . warning ( "Reporter choked" , "rptr" , rptr , t ) ; } } int blen = report . length ( ) ; if ( report . length ( ) > 0 && report . charAt ( blen - 1 ) == '\n' ) { report . delete ( blen - 1 , blen ) ; } if ( reset ) { _lastReportStamp = now ; } return report . toString ( ) ; }
Generates and logs a state of server report .
13,760
public void init ( NodeRecord record ) { _record = record ; _client = new Client ( null , _omgr ) { protected void convertFromRemote ( DObject target , DEvent event ) { super . convertFromRemote ( target , event ) ; event . setTargetOid ( target . getOid ( ) ) ; event . eventId = PeerNode . this . _omgr . getNextEventId ( true ) ; } protected Communicator createCommunicator ( ) { return PeerNode . this . createCommunicator ( this ) ; } protected boolean isFailureLoggable ( FailureType type ) { return ( type != FailureType . UNSUBSCRIBE_NOT_PROXIED ) && super . isFailureLoggable ( type ) ; } } ; _client . addClientObserver ( this ) ; _client . getInvocationDirector ( ) . setMaximumListenerAge ( getMaximumInvocationWait ( ) ) ; }
Initializes this peer node and creates its internal client .
13,761
public void objectAvailable ( NodeObject object ) { nodeobj = object ; nodeobj . addListener ( _listener = createListener ( ) ) ; _peermgr . connectedToPeer ( this ) ; String nodeName = getNodeName ( ) ; for ( ClientInfo clinfo : nodeobj . clients ) { _peermgr . clientLoggedOn ( nodeName , clinfo ) ; } for ( NodeObject . Lock lock : nodeobj . locks ) { _peermgr . peerAddedLock ( nodeName , lock ) ; } }
documentation inherited from interface Subscriber
13,762
public List < NodeRecord > loadNodes ( String namespace , boolean includeShutdown ) { Query < NodeRecord > query = from ( NodeRecord . class ) . noCache ( ) ; List < SQLExpression < ? > > conditions = Lists . newArrayList ( ) ; if ( ! StringUtil . isBlank ( namespace ) ) { conditions . add ( NodeRecord . NODE_NAME . like ( namespace + "%" ) ) ; } if ( ! includeShutdown ) { conditions . add ( Ops . not ( NodeRecord . SHUTDOWN ) ) ; } return ( conditions . isEmpty ( ) ? query : query . where ( conditions ) ) . select ( ) ; }
Returns a list of all nodes registered in the repository with names starting with the given string optionally including nodes that are explicitly shut down .
13,763
public List < NodeRecord > loadNodesFromRegion ( String region ) { return from ( NodeRecord . class ) . noCache ( ) . where ( NodeRecord . REGION . eq ( region ) , Ops . not ( NodeRecord . SHUTDOWN ) ) . select ( ) ; }
Returns a list of nodes registered in the repository with the specified region that are not explicitly shut down .
13,764
public void updateNode ( NodeRecord record ) { record . lastUpdated = new Timestamp ( System . currentTimeMillis ( ) ) ; store ( record ) ; }
Updates the supplied node record inserting it into the database if necessary .
13,765
public void shutdownNode ( String nodeName ) { updatePartial ( NodeRecord . getKey ( nodeName ) , NodeRecord . SHUTDOWN , true ) ; }
Marks the identified node as shut down in its record .
13,766
public List < byte [ ] > split ( byte sep ) { List < byte [ ] > l = new LinkedList < > ( ) ; int start = 0 ; for ( int i = 0 ; i < bytes . length ; i ++ ) { if ( sep == bytes [ i ] ) { byte [ ] b = Arrays . copyOfRange ( bytes , start , i ) ; if ( b . length > 0 ) { l . add ( b ) ; } start = i + 1 ; i = start ; } } l . add ( Arrays . copyOfRange ( bytes , start , bytes . length ) ) ; return l ; }
Split byte array by a separator byte .
13,767
public OccupantInfo getOccupantInfo ( int bodyOid ) { return ( _place == null ) ? null : _place . occupantInfo . get ( Integer . valueOf ( bodyOid ) ) ; }
Returns the occupant info for the user in question if it exists in the currently occupied place . Returns null if no occupant info exists for the specified body .
13,768
public OccupantInfo getOccupantInfo ( Name username ) { return ( _place == null ) ? null : _place . getOccupantInfo ( username ) ; }
Returns the occupant info for the user in question if it exists in the currently occupied place . Returns null if no occupant info exists with the specified username .
13,769
public void entryAdded ( EntryAddedEvent < OccupantInfo > event ) { if ( ! event . getName ( ) . equals ( PlaceObject . OCCUPANT_INFO ) ) { return ; } final OccupantInfo info = event . getEntry ( ) ; _observers . apply ( new ObserverList . ObserverOp < OccupantObserver > ( ) { public boolean apply ( OccupantObserver observer ) { observer . occupantEntered ( info ) ; return true ; } } ) ; }
Deals with all of the processing when an occupant shows up .
13,770
public void entryUpdated ( EntryUpdatedEvent < OccupantInfo > event ) { if ( ! event . getName ( ) . equals ( PlaceObject . OCCUPANT_INFO ) ) { return ; } final OccupantInfo info = event . getEntry ( ) ; final OccupantInfo oinfo = event . getOldEntry ( ) ; _observers . apply ( new ObserverList . ObserverOp < OccupantObserver > ( ) { public boolean apply ( OccupantObserver observer ) { observer . occupantUpdated ( oinfo , info ) ; return true ; } } ) ; }
Deals with all of the processing when an occupant is updated .
13,771
public void entryRemoved ( EntryRemovedEvent < OccupantInfo > event ) { if ( ! event . getName ( ) . equals ( PlaceObject . OCCUPANT_INFO ) ) { return ; } final OccupantInfo oinfo = event . getOldEntry ( ) ; _observers . apply ( new ObserverList . ObserverOp < OccupantObserver > ( ) { public boolean apply ( OccupantObserver observer ) { observer . occupantLeft ( oinfo ) ; return true ; } } ) ; }
Deals with all of the processing when an occupant leaves .
13,772
public void start ( Activity activity ) { Intent i = new Intent ( activity , CalculatorActivity . class ) ; if ( ! TextUtils . isEmpty ( activityTitle ) ) { i . putExtra ( CalculatorActivity . TITLE_ACTIVITY , activityTitle ) ; } if ( ! TextUtils . isEmpty ( value ) ) { i . putExtra ( CalculatorActivity . VALUE , value ) ; } activity . startActivityForResult ( i , CalculatorActivity . REQUEST_RESULT_SUCCESSFUL ) ; }
Start the activity using the parent activity
13,773
public void start ( Fragment fragment ) { Intent i = new Intent ( fragment . getContext ( ) , CalculatorActivity . class ) ; if ( ! TextUtils . isEmpty ( activityTitle ) ) { i . putExtra ( CalculatorActivity . TITLE_ACTIVITY , activityTitle ) ; } if ( ! TextUtils . isEmpty ( value ) ) { i . putExtra ( CalculatorActivity . VALUE , value ) ; } fragment . startActivityForResult ( i , CalculatorActivity . REQUEST_RESULT_SUCCESSFUL ) ; }
Start the activity using the parent fragment
13,774
public int getIndexWithinSections ( int listPosition ) { boolean isSection = false ; int numPrecedingSections = 0 ; for ( Integer sectionPosition : mSections . keySet ( ) ) { if ( listPosition > sectionPosition ) numPrecedingSections ++ ; else if ( listPosition == sectionPosition ) isSection = true ; else break ; } return isSection ? numPrecedingSections : Math . max ( numPrecedingSections - 1 , 0 ) ; }
Finds the section index for a given list position .
13,775
public int getPositionForSection ( int sectionIndex ) { if ( mSectionList . size ( ) == 0 ) { for ( Integer key : mSections . keySet ( ) ) { mSectionList . add ( key ) ; } } return sectionIndex < mSectionList . size ( ) ? mSectionList . get ( sectionIndex ) : getCount ( ) ; }
Given the index of a section within the array of section objects returns the starting position of that section within the adapter .
13,776
public int getSectionForPosition ( int position ) { Object [ ] objects = getSections ( ) ; int sectionIndex = getIndexWithinSections ( position ) ; return sectionIndex < objects . length ? sectionIndex : 0 ; }
Given a position within the adapter returns the index of the corresponding section within the array of section objects .
13,777
public double getNumericValue ( ) { String original = getText ( ) . toString ( ) . replaceAll ( mNumberFilterRegex , "" ) ; if ( hasCustomDecimalSeparator ) { original = StringUtils . replace ( original , String . valueOf ( mDecimalSeparator ) , String . valueOf ( DECIMAL_SEPARATOR ) ) ; } try { return NumberFormat . getInstance ( ) . parse ( original ) . doubleValue ( ) ; } catch ( ParseException e ) { return Double . NaN ; } }
Return numeric value represented by the text field
13,778
private String format ( final String original ) { final String [ ] parts = original . split ( "\\" + mDecimalSeparator , - 1 ) ; String number = parts [ 0 ] . replaceAll ( mNumberFilterRegex , "" ) . replaceFirst ( LEADING_ZERO_FILTER_REGEX , "" ) ; if ( ! hasCustomDecimalSeparator ) { number = StringUtils . reverse ( StringUtils . reverse ( number ) . replaceAll ( "(.{3})" , "$1" + GROUPING_SEPARATOR ) ) ; number = StringUtils . removeStart ( number , String . valueOf ( GROUPING_SEPARATOR ) ) ; } if ( parts . length > 1 ) { if ( parts [ 1 ] . length ( ) > 2 ) { number += mDecimalSeparator + parts [ 1 ] . substring ( parts [ 1 ] . length ( ) - 2 , parts [ 1 ] . length ( ) ) ; } else { number += mDecimalSeparator + parts [ 1 ] ; } } return number ; }
Add grouping separators to string
13,779
public static Document createEmptyDocument ( ) { Document output = null ; try { final DocumentBuilder db = FACTORY . newDocumentBuilder ( ) ; db . setErrorHandler ( new ParserErrorHandler ( ) ) ; output = db . newDocument ( ) ; } catch ( final Exception ex ) { LOGGER . error ( "Problem creating empty XML document." , ex ) ; } return output ; }
Create an empty XML structure .
13,780
public static boolean validate ( final Source input , final Source [ ] schemas ) { boolean isValid = true ; try { final SchemaFactory factory = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; factory . setResourceResolver ( new SchemaLSResourceResolver ( ) ) ; final Validator val = factory . newSchema ( schemas ) . newValidator ( ) ; final ParserErrorHandler eh = new ParserErrorHandler ( ) ; val . setErrorHandler ( eh ) ; val . validate ( input ) ; if ( eh . didErrorOccur ( ) ) { isValid = false ; eh . logErrors ( LOGGER ) ; } } catch ( final Exception ex ) { LOGGER . error ( "Problem validating the given process definition." , ex ) ; isValid = false ; } return isValid ; }
Validate an XML document against an XML Schema definition .
13,781
public static void transform ( final Source input , final Source sheet , final Result output ) { try { final DOMResult intermediate = new DOMResult ( createEmptyDocument ( ) ) ; createTransformer ( sheet ) . transform ( input , intermediate ) ; format ( new DOMSource ( intermediate . getNode ( ) ) , output ) ; } catch ( final Exception ex ) { LOGGER . error ( "Problem transforming XML file." , ex ) ; } }
Transform an XML document according to an XSL style sheet .
13,782
static Document loadDefinition ( final File def ) { final Document document = XmlUtils . parseFile ( def ) ; if ( document == null ) { return null ; } final Node xmlnsNode = document . getFirstChild ( ) . getAttributes ( ) . getNamedItem ( "xmlns" ) ; if ( xmlnsNode != null && StringUtils . isNotBlank ( xmlnsNode . getNodeValue ( ) ) && xmlnsNode . getNodeValue ( ) . contains ( "jpdl" ) ) { final String version = xmlnsNode . getNodeValue ( ) . substring ( xmlnsNode . getNodeValue ( ) . length ( ) - 3 ) ; LOGGER . info ( "jPDL version == " + version ) ; } return document ; }
Load a process definition from file .
13,783
private static void transform ( final String xmlFileName , final String xsltFileName , final String outputFileName ) { Source xsltSource = null ; if ( StringUtils . isNotBlank ( xsltFileName ) ) { xsltSource = new StreamSource ( new File ( xsltFileName ) ) ; } else { xsltSource = new StreamSource ( Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( DEFAULT_XSLT_SHEET ) ) ; } final Source xmlSource = new StreamSource ( new File ( xmlFileName ) ) ; final Result xmlResult = new StreamResult ( new File ( outputFileName ) ) ; XmlUtils . transform ( xmlSource , xsltSource , xmlResult ) ; }
Perform the transformation called from the main method .
13,784
private static Version parseVersion ( String version ) { String [ ] parts = version . split ( "\\." ) ; int nbParts = parts . length ; int majorIndex = nbParts > 1 ? 1 : 0 ; int major = Integer . parseInt ( parts [ majorIndex ] ) ; return new Version ( major ) ; }
Parse Java version number .
13,785
public void initialize ( URL location , ResourceBundle resources ) { addEventHandler ( WindowEvent . ANY , new EventHandler < WindowEvent > ( ) { public void handle ( WindowEvent window ) { Platform . runLater ( new Runnable ( ) { public void run ( ) { if ( isLoadingError ) { close ( ) ; } } } ) ; } } ) ; Platform . runLater ( new Runnable ( ) { public void run ( ) { switch ( dialogType ) { case INFORMATION : okButton . requestFocus ( ) ; break ; case CONFIRMATION : yesButton . requestFocus ( ) ; break ; case CONFIRMATION_ALT1 : okButton . requestFocus ( ) ; break ; case CONFIRMATION_ALT2 : yesButton . requestFocus ( ) ; break ; case WARNING : okButton . requestFocus ( ) ; break ; case ERROR : okButton . requestFocus ( ) ; break ; case EXCEPTION : okButton . requestFocus ( ) ; break ; case INPUT_TEXT : inputTextField . requestFocus ( ) ; break ; case GENERIC_OK : okButton . requestFocus ( ) ; break ; case GENERIC_OK_CANCEL : okButton . requestFocus ( ) ; break ; case GENERIC_YES_NO : yesButton . requestFocus ( ) ; break ; case GENERIC_YES_NO_CANCEL : yesButton . requestFocus ( ) ; break ; } } } ) ; this . detailsLabel . setWrapText ( true ) ; this . headerLabel . setText ( getHeader ( ) ) ; this . detailsLabel . setText ( getDetails ( ) ) ; if ( dialogType == DialogType . EXCEPTION ) { this . exceptionArea . clear ( ) ; if ( this . exception != null ) { this . exceptionArea . appendText ( Arrays . toString ( this . exception . getStackTrace ( ) ) ) ; } else { this . exceptionArea . appendText ( DialogText . NO_EXCEPTION_TRACE . getText ( ) ) ; } this . exceptionArea . setWrapText ( true ) ; this . exceptionArea . setEditable ( false ) ; } if ( this . dialogStyle == DialogStyle . HEADLESS ) { this . topBoxContainer . getChildren ( ) . remove ( this . headContainer ) ; this . setHeadlessPadding ( ) ; } this . setHeaderColorStyle ( this . headerColorStyle ) ; }
Initializes the dialog . Sets default focus to OK button . Wraps the text for details message label and apply the user - defined header and details . Filter the behavior for the exception dialog for a null and non - null exception object given . Applies corresponding header background css style .
13,786
private void setHeadlessPadding ( ) { if ( dialogType == DialogType . INPUT_TEXT ) { bodyContainer . setStyle ( PreDefinedStyle . INPUT_DIALOG_HEADLESS_PADDING . getStyle ( ) ) ; } else if ( dialogType == DialogType . EXCEPTION ) { bodyContainer . setStyle ( PreDefinedStyle . EXCEPTION_DIALOG_HEADLESS_PADDING . getStyle ( ) ) ; } else { bodyContainer . setStyle ( PreDefinedStyle . HEADLESS_PADDING . getStyle ( ) ) ; } }
Sets the padding for a headless dialog
13,787
public final void setHeaderColorStyle ( HeaderColorStyle headerColorStyle ) { this . headerColorStyle = headerColorStyle ; if ( ! headerColorStyle . getColorStyle ( ) . isEmpty ( ) ) { this . getHeaderLabel ( ) . setStyle ( headerColorStyle . getColorStyle ( ) ) ; } else { if ( headerColorStyle == HeaderColorStyle . DEFAULT ) { switch ( this . dialogType ) { case INFORMATION : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_INFO ) ; break ; case ERROR : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_ERROR ) ; break ; case WARNING : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_WARNING ) ; break ; case CONFIRMATION : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_CONFIRM ) ; break ; case CONFIRMATION_ALT1 : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_CONFIRM ) ; break ; case CONFIRMATION_ALT2 : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_CONFIRM ) ; break ; case EXCEPTION : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_EXCEPTION ) ; break ; case INPUT_TEXT : this . updateHeaderColorStyle ( HeaderColorStyle . GLOSS_INPUT ) ; break ; default : this . updateHeaderColorStyle ( HeaderColorStyle . GENERIC ) ; break ; } } } }
Applies a predefined JavaFX CSS background color style for the header label
13,788
public void setFont ( String header_font_family , int header_font_size , String details_font_family , int details_font_size ) { this . headerLabel . setStyle ( "-fx-font-family: \"" + header_font_family + "\";" + "-fx-font-size:" + Integer . toString ( header_font_size ) + "px;" ) ; this . detailsLabel . setStyle ( "-fx-font-family: \"" + details_font_family + "\";" + "-fx-font-size:" + Integer . toString ( details_font_size ) + "px;" ) ; }
Sets the font sizes and the font families for the header and details label .
13,789
public void setHeaderFont ( String font_family , int font_size ) { this . headerLabel . setStyle ( "-fx-font-family: \"" + font_family + "\";" + "-fx-font-size:" + Integer . toString ( font_size ) + "px;" ) ; }
Sets both header label s font family and size .
13,790
public void setDetailsFont ( String font_family , int font_size ) { this . detailsLabel . setStyle ( "-fx-font-family: \"" + font_family + "\";" + "-fx-font-size:" + Integer . toString ( font_size ) + "px;" ) ; }
Sets both details label s font family and size .
13,791
private void send_btn_on_click ( ActionEvent event ) { if ( this . dialogType == DialogType . INPUT_TEXT ) { this . textEntry = this . inputTextField . getText ( ) ; } setResponse ( DialogResponse . SEND ) ; close ( ) ; }
Event handler when sendButton is pressed . Sets response to SEND and closes the dialog window .
13,792
public static String fingerprint ( String str ) { try { MessageDigest md = MessageDigest . getInstance ( "SHA-1" ) ; return byteArrayToHexString ( md . digest ( str . getBytes ( ) ) ) ; } catch ( NoSuchAlgorithmException nsae ) { LOGGER . warning ( "Unable to calculate the fingerprint for string [" + str + "]." ) ; return null ; } }
Generate a fingerprint for a given string
13,793
public static String fingerprint ( Class cl , Method m ) { return fingerprint ( cl , m . getName ( ) ) ; }
Generate a fingerprint based on class and method
13,794
public static String fingerprint ( Class cl , String methodName ) { return fingerprint ( cl . getCanonicalName ( ) + "." + methodName ) ; }
Generate a fingerprint based on class and method name
13,795
public static Set < String > getContributors ( Set < String > baseContributors , ProbeTest methodAnnotation , ProbeTestClass classAnnotation ) { Set < String > contributors ; if ( baseContributors == null ) { contributors = new HashSet < > ( ) ; } else { contributors = populateContributors ( baseContributors , new HashSet < String > ( ) ) ; } if ( classAnnotation != null && classAnnotation . contributors ( ) != null ) { contributors = populateContributors ( new HashSet < > ( Arrays . asList ( classAnnotation . contributors ( ) ) ) , contributors ) ; } if ( methodAnnotation != null && methodAnnotation . contributors ( ) != null ) { contributors = populateContributors ( new HashSet < > ( Arrays . asList ( methodAnnotation . contributors ( ) ) ) , contributors ) ; } return contributors ; }
Retrieve the contributors and compile them from the different sources
13,796
private static Set < String > populateContributors ( Set < String > source , Set < String > destination ) { for ( String contributor : source ) { if ( ! emailPattern . matcher ( contributor ) . matches ( ) ) { LOGGER . warning ( "The contributor '" + contributor + "' does not respect the email pattern " + emailPattern . pattern ( ) + " and is ignored" ) ; } else if ( destination . contains ( contributor ) ) { LOGGER . info ( "The contributor '" + contributor + "' is already present in the collection and is ignored" ) ; } else { destination . add ( contributor ) ; } } return destination ; }
Populate the source with the destination contributors only if they match the pattern rules for the contributors
13,797
protected int binarySearchHashCode ( int elemHash ) { int left = 0 ; int right = size ( ) - 1 ; while ( left <= right ) { int mid = ( left + right ) >> 1 ; int midHash = get ( mid ) . hashCode ( ) ; if ( elemHash == midHash ) return mid ; if ( elemHash < midHash ) right = mid - 1 ; else left = mid + 1 ; } return - ( left + 1 ) ; }
Performs a binary search on hashCode values only . It will return any matching element not necessarily the first or the last .
13,798
public int indexOf ( int hashCode ) { int pos = binarySearchHashCode ( hashCode ) ; if ( pos < 0 ) return - 1 ; while ( pos > 0 && get ( pos - 1 ) . hashCode ( ) == hashCode ) pos -- ; return pos ; }
Finds the first index where the object has the provided hashCode
13,799
public boolean add ( E o ) { int size = size ( ) ; if ( size == 0 ) { super . add ( o ) ; } else { int Ohash = o . hashCode ( ) ; if ( Ohash >= get ( size - 1 ) . hashCode ( ) ) { super . add ( o ) ; } else { int index = binarySearchHashCode ( Ohash ) ; if ( index < 0 ) { super . add ( - ( index + 1 ) , o ) ; } else { while ( index < ( size - 1 ) && get ( index + 1 ) . hashCode ( ) == Ohash ) index ++ ; super . add ( index + 1 , o ) ; } } } return true ; }
Adds the specified element in sorted position within this list . When two elements have the same hashCode the new item is added at the end of the list of matching hashCodes .