idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
13,500 | protected void addChatter ( Name name ) { if ( ( _chatterValidator != null ) && ( ! _chatterValidator . isChatterValid ( name ) ) ) { return ; } boolean wasthere = _chatters . remove ( name ) ; _chatters . addFirst ( name ) ; if ( ! wasthere ) { if ( _chatters . size ( ) > MAX_CHATTERS ) { _chatters . removeLast ( ) ; } notifyChatterObservers ( ) ; } } | Adds a chatter to our list of recent chatters . |
13,501 | protected void setClientInfo ( ChatMessage msg , String localType ) { if ( msg . localtype == null ) { msg . setClientInfo ( xlate ( msg . bundle , msg . message ) , localType ) ; } } | Set the client info on the specified message if not already set . |
13,502 | protected String xlate ( String bundle , String message ) { if ( bundle != null && _ctx . getMessageManager ( ) != null ) { MessageBundle msgb = _ctx . getMessageManager ( ) . getBundle ( bundle ) ; if ( msgb == null ) { log . warning ( "No message bundle available to translate message" , "bundle" , bundle , "message" , message ) ; } else { message = msgb . xlate ( message ) ; } } return message ; } | Translates the specified message using the specified bundle . |
13,503 | protected void displaySystem ( String bundle , String message , byte attLevel , String localtype ) { if ( bundle == null ) { bundle = _bundle ; } SystemMessage msg = new SystemMessage ( message , bundle , attLevel ) ; dispatchMessage ( msg , localtype ) ; } | Display the specified system message as if it had come from the server . |
13,504 | protected String getLocalType ( int oid ) { String type = _auxes . get ( oid ) ; return ( type == null ) ? PLACE_CHAT_TYPE : type ; } | Looks up and returns the message type associated with the specified oid . |
13,505 | public static String dumpArguments ( JCas jCas , boolean includeProperties , boolean includeRelations ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; PrintStream out = new PrintStream ( outputStream ) ; String documentId = DocumentMetaData . get ( jCas ) . getDocumentId ( ) ; out . println ( "======== #" + documentId + " begin ==========================" ) ; Collection < ArgumentComponent > argumentComponents = JCasUtil . select ( jCas , ArgumentComponent . class ) ; out . println ( "----------------- ArgumentComponent -----------------" ) ; out . println ( "# of argument units: " + argumentComponents . size ( ) ) ; for ( ArgumentComponent argumentComponent : argumentComponents ) { out . println ( argumentUnitToString ( argumentComponent ) ) ; if ( includeProperties ) { out . println ( formatProperties ( argumentComponent ) ) ; } if ( argumentComponent instanceof Claim ) { Claim claim = ( Claim ) argumentComponent ; String stance = claim . getStance ( ) ; if ( stance != null ) { out . println ( "Stance: " + stance ) ; } } } Collection < ArgumentRelation > argumentRelations = JCasUtil . select ( jCas , ArgumentRelation . class ) ; if ( includeRelations ) { out . println ( "----------------- ArgumentRelation -----------------" ) ; out . println ( "# of argument relations: " + argumentRelations . size ( ) ) ; for ( ArgumentRelation argumentRelation : argumentRelations ) { out . println ( argumentRelation . getType ( ) . getShortName ( ) ) ; out . println ( " source: " + argumentUnitToString ( argumentRelation . getSource ( ) ) ) ; out . println ( " target: " + argumentUnitToString ( argumentRelation . getTarget ( ) ) ) ; if ( includeProperties ) { out . println ( formatProperties ( argumentRelation ) ) ; } } } out . println ( "======== #" + documentId + " end ==========================" ) ; try { return outputStream . toString ( "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } } | Dump argument components to String . Can be also used outside UIMA pipeline . |
13,506 | public static String argumentUnitToString ( ArgumentUnit argumentUnit ) { return String . format ( "%s [%d, %d] \"%s\"" , argumentUnit . getType ( ) . getShortName ( ) , argumentUnit . getBegin ( ) , argumentUnit . getEnd ( ) , argumentUnit . getCoveredText ( ) ) ; } | Formats argument unit to string with type position and text content |
13,507 | public HashMap < String , String > loadConfig ( String node , String object ) { HashMap < String , String > data = Maps . newHashMap ( ) ; for ( ConfigRecord record : from ( ConfigRecord . class ) . where ( ConfigRecord . OBJECT . eq ( object ) , ConfigRecord . NODE . eq ( node ) ) . select ( ) ) { data . put ( record . field , record . value ) ; } return data ; } | Loads up the configuration data for the specified object . |
13,508 | public void updateConfig ( String node , String object , String field , String value ) { store ( new ConfigRecord ( node , object , field , value ) ) ; } | Updates the specified configuration datum . |
13,509 | public InetAddress getInetAddress ( ) { Connection conn = getConnection ( ) ; return ( conn == null ) ? null : conn . getInetAddress ( ) ; } | Returns the address of the connected client or null if this client is not connected . |
13,510 | public void setClassLoader ( ClassLoader loader ) { _loader = loader ; PresentsConnection conn = getConnection ( ) ; if ( conn != null ) { conn . setClassLoader ( loader ) ; } } | Configures this session with a custom class loader that will be used when unserializing classes from the network . |
13,511 | public void endSession ( ) { _clmgr . clientSessionWillEnd ( this ) ; Connection conn = getConnection ( ) ; if ( conn != null ) { setConnection ( null ) ; _conmgr . closeConnection ( conn ) ; } if ( _clobj != null ) { try { sessionDidEnd ( ) ; } catch ( Exception e ) { log . warning ( "Choked in sessionDidEnd " + this + "." , e ) ; } _clmgr . releaseClientObject ( _clobj . username ) ; _clmgr . clientSessionDidEnd ( this ) ; } _clmgr . clearSession ( this ) ; _clobj = null ; } | Forcibly terminates a client s session . This must be called from the dobjmgr thread . |
13,512 | public void handleMessage ( Message message ) { if ( _throttle == null ) { return ; } else if ( _throttle . throttleOp ( message . received ) ) { handleThrottleExceeded ( ) ; } dispatchMessage ( message ) ; } | from interface Connection . MessageHandler |
13,513 | protected void dispatchMessage ( Message message ) { _messagesIn ++ ; MessageDispatcher disp = _disps . get ( message . getClass ( ) ) ; if ( disp == null ) { log . warning ( "No dispatcher for message" , "msg" , message ) ; return ; } disp . dispatch ( this , message ) ; } | Processes a message without throttling . |
13,514 | protected void startSession ( Name authname , AuthRequest req , PresentsConnection conn , Object authdata ) { _authname = authname ; _areq = req ; _authdata = authdata ; setConnection ( conn ) ; _clmgr . resolveClientObject ( _authname , this ) ; _sessionStamp = System . currentTimeMillis ( ) ; } | Initializes this client instance with the specified username connection instance and client object and begins a client session . |
13,515 | protected void resumeSession ( AuthRequest req , PresentsConnection conn ) { Connection oldconn = getConnection ( ) ; if ( oldconn != null && ! oldconn . isClosed ( ) ) { log . info ( "Closing stale connection" , "old" , oldconn , "new" , conn ) ; oldconn . close ( ) ; } _areq = req ; setConnection ( conn ) ; if ( _clobj == null ) { log . info ( "Rapid-fire reconnect caused us to arrive in resumeSession() before the " + "original session resolved its client object " + this + "." ) ; return ; } _omgr . postRunnable ( new Runnable ( ) { public void run ( ) { finishResumeSession ( ) ; } } ) ; } | Called by the client manager when a new connection arrives that authenticates as this already established client . This must only be called from the congmr thread . |
13,516 | protected void finishResumeSession ( ) { if ( _clobj == null ) { log . info ( "Missing client object for resuming session " + this + "." ) ; endSession ( ) ; return ; } clearSubscrips ( false ) ; _clobj . getLocal ( ClientLocal . class ) . secret = getSecret ( ) ; sessionWillResume ( ) ; sendBootstrap ( ) ; if ( _messagesPerSec != Client . DEFAULT_MSGS_PER_SECOND ) { sendThrottleUpdate ( ) ; } log . info ( "Session resumed " + this + "." ) ; } | This is called from the dobjmgr thread to complete the session resumption . We call some call backs and send the bootstrap info to the client . |
13,517 | protected void safeEndSession ( ) { if ( ! _omgr . isRunning ( ) ) { log . info ( "Dropping end session request as we're shutting down " + this + "." ) ; } else { _omgr . postRunnable ( new Runnable ( ) { public void run ( ) { endSession ( ) ; } } ) ; } } | Queues up a runnable on the object manager thread where we can safely end the session . |
13,518 | protected synchronized void unmapSubscrip ( int oid ) { ClientProxy rec ; synchronized ( _subscrips ) { rec = _subscrips . remove ( oid ) ; } if ( rec != null ) { rec . unsubscribe ( ) ; } else { boolean alreadyDestroyed = _destroyedSubs . remove ( oid ) ; if ( ! alreadyDestroyed ) { log . warning ( "Missing subscription in unmap" , "client" , this , "oid" , oid ) ; } } } | Makes a note that this client is no longer subscribed to this object . The subscription map is used to clean up after the client when it goes away . |
13,519 | protected void clearSubscrips ( boolean verbose ) { for ( ClientProxy rec : _subscrips . values ( ) ) { if ( verbose ) { log . info ( "Clearing subscription" , "client" , this , "obj" , rec . object . getOid ( ) ) ; } rec . unsubscribe ( ) ; } _subscrips . clear ( ) ; } | Clears out the tracked client subscriptions . Called when the client goes away and shouldn t be called otherwise . |
13,520 | protected void sendBootstrap ( ) { BootstrapData data = createBootstrapData ( ) ; populateBootstrapData ( data ) ; postMessage ( new BootstrapNotification ( data ) , null ) ; } | This is called once we have a handle on the client distributed object . It sends a bootstrap notification to the client with all the information it will need to interact with the server . |
13,521 | protected synchronized void setConnection ( PresentsConnection conn ) { long now = System . currentTimeMillis ( ) ; if ( _conn != null ) { if ( conn == null ) { _connectTime += ( ( now - _networkStamp ) / 1000 ) ; _messagesDropped = 0 ; } _conn . clearMessageHandler ( ) ; } _conn = conn ; if ( _conn != null ) { _conn . setMessageHandler ( this ) ; if ( _loader != null ) { _conn . setClassLoader ( _loader ) ; } } _networkStamp = now ; } | Sets our connection reference in a thread safe way . Also establishes the back reference to us as the connection s message handler . |
13,522 | protected void finishCompoundMessage ( ) { if ( -- _compoundDepth == 0 ) { CompoundDownstreamMessage downstream = _compound ; _compound = null ; if ( ! downstream . msgs . isEmpty ( ) ) { postMessage ( downstream , null ) ; } } } | Sends the compound message created in startCompoundMessage . |
13,523 | protected boolean postMessage ( DownstreamMessage msg , PresentsConnection expect ) { PresentsConnection conn = getConnection ( ) ; if ( expect != null && conn != expect ) { return false ; } if ( _compound != null ) { _compound . msgs . add ( msg ) ; return true ; } if ( conn != null ) { conn . postMessage ( msg ) ; _messagesOut ++ ; return true ; } if ( ++ _messagesDropped % 50 == 0 ) { log . warning ( "Dropping many messages?" , "client" , this , "count" , _messagesDropped , "msg" , msg ) ; } if ( _subscrips . size ( ) > 0 ) { clearSubscrips ( _messagesDropped > 10 ) ; } return false ; } | Queues a message for delivery to the client . |
13,524 | protected void throttleUpdated ( ) { int messagesPerSec ; synchronized ( _pendingThrottles ) { if ( _pendingThrottles . size ( ) == 0 ) { log . warning ( "Received throttleUpdated but have no pending throttles" , "client" , this ) ; return ; } messagesPerSec = _pendingThrottles . remove ( 0 ) ; } _throttle . reinit ( 10 * messagesPerSec + 1 , 10 * 1000L ) ; } | Notifies this client that its throttle was updated . |
13,525 | public V get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { return _sync . innerGet ( unit . toNanos ( timeout ) ) ; } | from interface Future |
13,526 | public void requestProcessed ( Object result ) { @ SuppressWarnings ( "unchecked" ) V value = ( V ) result ; _sync . innerSet ( value ) ; } | from interface InvocationService . ResultListener |
13,527 | protected DSetEditor < E > createEditor ( DObject setter , String setName , Class < ? > entryClass , String [ ] editableFields , ObjectEditorTable . FieldInterpreter interp , EntryGrouper < E > grouper , String group ) { return new DSetEditor < E > ( setter , setName , entryClass , editableFields , interp , getDisplayFields ( group ) , grouper . getPredicate ( group ) ) ; } | Creates a DSetEditor for displaying the given group . |
13,528 | public String getPeerHostName ( String region ) { return ( ALWAYS_CONNECT_INTERNAL || Objects . equal ( this . region , region ) ) ? hostName : publicHostName ; } | Returns the host name to which peers in the specified region should connect . |
13,529 | public void setClassLoader ( ClassLoader loader ) { _loader = loader ; if ( _comm != null ) { _comm . setClassLoader ( loader ) ; } } | Configures the client with a custom class loader which will be used when reading objects off of the network . |
13,530 | public void registerFlushDelay ( Class < ? > objclass , long delay ) { ClientDObjectMgr omgr = ( ClientDObjectMgr ) getDObjectManager ( ) ; omgr . registerFlushDelay ( objclass , delay ) ; } | Instructs the distributed object manager associated with this client to allow objects of the specified class to linger around the specified number of milliseconds after their last subscriber has been removed before the client finally removes its object proxy and flushes the object . Normally objects are flushed immediately following the removal of their last subscriber . |
13,531 | public synchronized boolean logon ( ) { if ( _comm != null ) { return false ; } _observers . apply ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientWillLogon ( _client ) ; } } ) ; _comm = createCommunicator ( ) ; _comm . setClassLoader ( _loader ) ; _comm . logon ( ) ; if ( _tickInterval == null ) { _tickInterval = new Interval ( _runQueue ) { public void expired ( ) { tick ( ) ; } public String toString ( ) { return "Client.tickInterval" ; } } ; _tickInterval . schedule ( 5000L , true ) ; } return true ; } | Requests that this client connect and logon to the server with which it was previously configured . |
13,532 | public boolean logoff ( boolean abortable ) { if ( _comm == null ) { log . warning ( "Ignoring request to logoff because we're not logged on." ) ; return true ; } final boolean [ ] rejected = new boolean [ ] { false } ; _observers . apply ( new ObserverOps . Client ( this ) { protected void notify ( ClientObserver obs ) { if ( ! obs . clientWillLogoff ( _client ) ) { rejected [ 0 ] = true ; } } } ) ; if ( abortable && rejected [ 0 ] ) { return false ; } _comm . logoff ( ) ; return true ; } | Requests that the client log off of the server to which it is connected . |
13,533 | public String [ ] prepareStandaloneLogon ( ) { _standalone = true ; _observers . apply ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientWillLogon ( _client ) ; } } ) ; return getBootGroups ( ) ; } | Prepares the client for a standalone mode logon . Returns the set of bootstrap service groups that should be supplied to the invocation manager to create our fake bootstrap record . |
13,534 | public void standaloneLogon ( BootstrapData data , DObjectManager omgr ) { if ( ! _standalone ) { throw new IllegalStateException ( "Must call prepareStandaloneLogon() first." ) ; } gotBootstrap ( data , omgr ) ; } | Logs this client on in standalone mode with the faked bootstrap data and shared local distributed object manager . |
13,535 | public void standaloneLogoff ( ) { notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientDidLogoff ( _client ) ; } } ) ; cleanup ( null ) ; } | For standalone mode this notifies observers that the client has logged off and cleans up . |
13,536 | protected synchronized void setOutgoingMessageThrottle ( int msgsPerSec ) { log . info ( "Updating outgoing message throttle" , "msgsPerSec" , msgsPerSec ) ; _outThrottle . reinit ( msgsPerSec , 1000L ) ; _comm . postMessage ( new ThrottleUpdatedMessage ( ) ) ; } | Configures the outgoing message throttle . This is done when the server informs us that a new rate is in effect . |
13,537 | protected void tick ( ) { if ( _comm == null ) { return ; } long now = RunAnywhere . currentTimeMillis ( ) ; if ( _dcalc != null ) { if ( _dcalc . isDone ( ) ) { if ( debugLogMessages ( ) ) { log . info ( "Time offset from server: " + _serverDelta + "ms." ) ; } _dcalc = null ; } else if ( _dcalc . shouldSendPing ( ) ) { PingRequest req = new PingRequest ( ) ; _comm . postMessage ( req ) ; _dcalc . sentPing ( req ) ; } } else if ( now - _comm . getLastWrite ( ) > PingRequest . PING_INTERVAL ) { _comm . postMessage ( new PingRequest ( ) ) ; } else if ( now - _lastSync > CLOCK_SYNC_INTERVAL ) { establishClockDelta ( now ) ; } } | Called every five seconds ; ensures that we ping the server if we haven t communicated in a long while and periodically resyncs the client and server clock deltas . |
13,538 | protected void gotClientObject ( ClientObject clobj ) { _clobj = clobj ; notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientDidLogon ( _client ) ; } } ) ; } | Called by the invocation director when it successfully subscribes to the client object immediately following logon . |
13,539 | protected void getClientObjectFailed ( final Exception cause ) { notifyObservers ( new ObserverOps . Client ( this ) { protected void notify ( ClientObserver obs ) { obs . clientFailedToLogon ( _client , cause ) ; } } ) ; } | Called by the invocation director if it fails to subscribe to the client object after logon . |
13,540 | protected void clientObjectDidChange ( ClientObject clobj ) { _clobj = clobj ; _cloid = _clobj . getOid ( ) ; notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientObjectDidChange ( _client ) ; } } ) ; } | Called by the invocation director when it discovers that the client object has changed . |
13,541 | public Deque < Subfield > getSubfield ( String subfieldId ) { return subfields . stream ( ) . filter ( subfield -> subfield . getId ( ) . equals ( subfieldId ) ) . collect ( Collectors . toCollection ( LinkedList :: new ) ) ; } | Return all subfields of a given subfield ID . Multiple occurences may occur . |
13,542 | public MarcField matchValue ( Pattern pattern ) { if ( value != null && pattern . matcher ( value ) . matches ( ) ) { return this ; } for ( Subfield subfield : subfields ) { if ( pattern . matcher ( subfield . getValue ( ) ) . matches ( ) ) { return this ; } } return null ; } | Search for fields that match a pattern . |
13,543 | public String toTagIndicatorKey ( ) { return ( tag == null ? EMPTY_STRING : tag ) + KEY_DELIMITER + ( indicator == null ? EMPTY_STRING : indicator ) ; } | A MARC field can be denoted by a key independent of values . This key is a string consisting of tag and indicator delimited by a dollar sign . |
13,544 | public String toKey ( ) { return ( tag == null ? EMPTY_STRING : tag ) + KEY_DELIMITER + ( indicator == null ? EMPTY_STRING : indicator ) + KEY_DELIMITER + subfieldIds ; } | A MARC field can be denoted by a key independent of values . This key is a string consisting of tag indicator subfield IDs delimited by a dollar sign . |
13,545 | public void updateOccupantStatus ( BodyObject body , final byte status ) { if ( body . status != status ) { body . setStatus ( status ) ; body . getLocal ( BodyLocal . class ) . statusTime = System . currentTimeMillis ( ) ; } updateOccupantInfo ( body , new OccupantInfo . Updater < OccupantInfo > ( ) { public boolean update ( OccupantInfo info ) { if ( info . status == status ) { return false ; } info . status = status ; return true ; } } ) ; } | Updates the connection status for the given body object s occupant info in the specified location . |
13,546 | public void setIdle ( ClientObject caller , boolean idle ) { BodyObject bobj = _locator . forClient ( caller ) ; byte nstatus = ( idle ) ? OccupantInfo . IDLE : OccupantInfo . ACTIVE ; if ( bobj == null || bobj . status == nstatus ) { return ; } log . debug ( "Setting user idle state" , "user" , bobj . username , "status" , nstatus ) ; updateOccupantStatus ( bobj , nstatus ) ; } | from interface BodyProvider |
13,547 | public Stats getStats ( boolean snapshot ) { synchronized ( this ) { if ( snapshot ) { _recent = _current ; _current = new Stats ( ) ; _current . maxQueueSize = _queue . size ( ) ; } return _recent ; } } | Returns a recent snapshot of runtime statistics tracked by the invoker . |
13,548 | public final void requestProcessed ( Object result ) { @ SuppressWarnings ( "unchecked" ) T casted = ( T ) result ; requestCompleted ( casted ) ; } | from InvocationService . ResultListener |
13,549 | public void requestFailed ( Exception cause ) { if ( _chain != null ) { _chain . requestFailed ( cause ) ; } else if ( _invChain != null ) { _invChain . requestFailed ( ( cause instanceof InvocationException ) ? cause . getMessage ( ) : InvocationCodes . INTERNAL_ERROR ) ; } else { Object [ ] logArgs = MoreObjects . firstNonNull ( _logArgs , ArrayUtil . EMPTY_OBJECT ) ; Object [ ] args ; if ( cause instanceof InvocationException ) { args = new Object [ logArgs . length + 4 ] ; args [ args . length - 2 ] = "error" ; args [ args . length - 1 ] = cause . getMessage ( ) ; } else { args = new Object [ logArgs . length + 3 ] ; args [ args . length - 1 ] = cause ; } args [ 0 ] = "Resulting" ; args [ 1 ] = this ; System . arraycopy ( logArgs , 0 , args , 2 , logArgs . length ) ; MoreObjects . firstNonNull ( _log , log ) . warning ( "Request failed" , args ) ; } } | Override this to handle a request failed in your own way . |
13,550 | public void requestCompleted ( T result ) { if ( _chain != null ) { _chain . requestCompleted ( result ) ; } else if ( _invChain instanceof InvocationService . ResultListener ) { ( ( InvocationService . ResultListener ) _invChain ) . requestProcessed ( result ) ; } else if ( _invChain instanceof InvocationService . ConfirmListener ) { ( ( InvocationService . ConfirmListener ) _invChain ) . requestProcessed ( ) ; } } | Override this to handle a request completion in your own way . |
13,551 | public void init ( CrowdContext ctx , PlaceConfig config ) { _ctx = ctx ; _config = config ; _view = createPlaceView ( _ctx ) ; applyToDelegates ( new DelegateOp ( PlaceControllerDelegate . class ) { public void apply ( PlaceControllerDelegate delegate ) { delegate . init ( _ctx , _config ) ; } } ) ; didInit ( ) ; } | Initializes this place controller with a reference to the context that they can use to access client services and to the configuration record for this place . The controller should create as much of its user interface that it can without having access to the place object because this will be invoked in parallel with the fetching of the place object . When the place object is obtained the controller will be notified and it can then finish the user interface configuration and put the user interface into operation . |
13,552 | protected void addDelegate ( PlaceControllerDelegate delegate ) { if ( _delegates == null ) { _delegates = Lists . newArrayList ( ) ; } _delegates . add ( delegate ) ; } | Adds the supplied delegate to the list for this controller . |
13,553 | public void gotConfigInfo ( String [ ] keys , int [ ] oids ) { _csubscribers = new ConfigObjectSubscriber [ keys . length ] ; for ( int ii = 0 ; ii < keys . length ; ii ++ ) { _csubscribers [ ii ] = new ConfigObjectSubscriber ( ) ; _csubscribers [ ii ] . subscribeConfig ( keys [ ii ] , oids [ ii ] ) ; } } | documentation inherited from interface AdminService . ConfigInfoListener |
13,554 | public List < MarcField > getFields ( String tag ) { return marcFields . stream ( ) . filter ( marcField -> marcField . getTag ( ) . equals ( tag ) ) . collect ( Collectors . toList ( ) ) ; } | Return the MARC fields of this record with a given tag . |
13,555 | public List < MarcField > filterKey ( Pattern pattern ) { return marcFields . stream ( ) . map ( field -> field . matchKey ( pattern ) ) . filter ( Objects :: nonNull ) . collect ( Collectors . toList ( ) ) ; } | Return a list of MARC fields of this record where key pattern matches were found . |
13,556 | public List < MarcField > filterValue ( Pattern pattern ) { return marcFields . stream ( ) . map ( field -> field . matchValue ( pattern ) ) . filter ( Objects :: nonNull ) . collect ( Collectors . toList ( ) ) ; } | Return a list of MARC fields of this record where pattern matches were found . |
13,557 | public static SessionFactory newSessionFactory ( final Class < ? extends Credentials > credsClass , final Class < ? extends PresentsSession > sessionClass , final Class < ? extends Name > nameClass , final Class < ? extends ClientResolver > resolverClass ) { return new SessionFactory ( ) { public Class < ? extends PresentsSession > getSessionClass ( AuthRequest areq ) { return credsClass . isInstance ( areq . getCredentials ( ) ) ? sessionClass : null ; } public Class < ? extends ClientResolver > getClientResolverClass ( Name username ) { return nameClass . isInstance ( username ) ? resolverClass : null ; } } ; } | Creates a session factory that handles clients with the supplied credentials and authentication name . |
13,558 | public void init ( DObjectManager omgr , final int cloid , Client client ) { if ( _clobj != null ) { log . warning ( "Zoiks, client object around during invmgr init!" ) ; cleanup ( ) ; } _omgr = omgr ; _client = client ; _omgr . subscribeToObject ( cloid , new Subscriber < ClientObject > ( ) { public void objectAvailable ( ClientObject clobj ) { clobj . addListener ( InvocationDirector . this ) ; _clobj = clobj ; assignReceiverIds ( ) ; _client . gotClientObject ( _clobj ) ; } public void requestFailed ( int oid , ObjectAccessException cause ) { log . warning ( "Invocation director unable to subscribe to client object" , "cloid" , cloid , "cause" , cause + "]!" ) ; _client . getClientObjectFailed ( cause ) ; } } ) ; } | Initializes the invocation director . This is called when the client establishes a connection with the server . |
13,559 | public void registerReceiver ( InvocationDecoder decoder ) { _reclist . add ( decoder ) ; if ( _clobj != null ) { assignReceiverId ( decoder ) ; } } | Registers an invocation notification receiver by way of its notification event decoder . |
13,560 | public void unregisterReceiver ( String receiverCode ) { for ( Iterator < InvocationDecoder > iter = _reclist . iterator ( ) ; iter . hasNext ( ) ; ) { InvocationDecoder decoder = iter . next ( ) ; if ( decoder . getReceiverCode ( ) . equals ( receiverCode ) ) { iter . remove ( ) ; } } if ( _clobj != null ) { Registration rreg = _clobj . receivers . get ( receiverCode ) ; if ( rreg == null ) { log . warning ( "Receiver unregistered for which we have no id to code mapping" , "code" , receiverCode ) ; } else { _receivers . remove ( rreg . receiverId ) ; } _clobj . removeFromReceivers ( receiverCode ) ; } } | Removes a receiver registration . |
13,561 | protected void assignReceiverIds ( ) { _clobj . startTransaction ( ) ; try { _clobj . setReceivers ( new DSet < Registration > ( ) ) ; for ( InvocationDecoder decoder : _reclist ) { assignReceiverId ( decoder ) ; } } finally { _clobj . commitTransaction ( ) ; } } | Called when we log on ; generates mappings for all receivers registered prior to logon . |
13,562 | public void eventReceived ( DEvent event ) { if ( event instanceof InvocationResponseEvent ) { InvocationResponseEvent ire = ( InvocationResponseEvent ) event ; handleInvocationResponse ( ire . getRequestId ( ) , ire . getMethodId ( ) , ire . getArgs ( ) ) ; } else if ( event instanceof InvocationNotificationEvent ) { InvocationNotificationEvent ine = ( InvocationNotificationEvent ) event ; handleInvocationNotification ( ine . getReceiverId ( ) , ine . getMethodId ( ) , ine . getArgs ( ) ) ; } else if ( event instanceof MessageEvent ) { MessageEvent mevt = ( MessageEvent ) event ; if ( mevt . getName ( ) . equals ( ClientObject . CLOBJ_CHANGED ) ) { handleClientObjectChanged ( ( ( Integer ) mevt . getArgs ( ) [ 0 ] ) . intValue ( ) ) ; } } } | Process notification and response events arriving on user object . |
13,563 | protected void handleInvocationResponse ( int reqId , int methodId , Object [ ] args ) { ListenerMarshaller listener = _listeners . remove ( reqId ) ; if ( listener == null ) { log . warning ( "Received invocation response for which we have no registered listener. " + "It is possible that this listener was flushed because the response did " + "not arrive within " + _listenerMaxAge + " milliseconds." , "reqId" , reqId , "methId" , methodId , "args" , args ) ; return ; } try { listener . dispatchResponse ( methodId , args ) ; } catch ( Throwable t ) { log . warning ( "Invocation response listener choked" , "listener" , listener , "methId" , methodId , "args" , args , t ) ; } long now = System . currentTimeMillis ( ) ; if ( now - _lastFlushTime > LISTENER_FLUSH_INTERVAL ) { _lastFlushTime = now ; flushListeners ( now ) ; } } | Dispatches an invocation response . |
13,564 | protected void handleInvocationNotification ( int receiverId , int methodId , Object [ ] args ) { InvocationDecoder decoder = _receivers . get ( receiverId ) ; if ( decoder == null ) { log . warning ( "Received notification for which we have no registered receiver" , "recvId" , receiverId , "methodId" , methodId , "args" , args ) ; return ; } try { decoder . dispatchNotification ( methodId , args ) ; } catch ( Throwable t ) { log . warning ( "Invocation notification receiver choked" , "receiver" , decoder . receiver , "methId" , methodId , "args" , args , t ) ; } } | Dispatches an invocation notification . |
13,565 | protected void handleClientObjectChanged ( int newCloid ) { _omgr . subscribeToObject ( newCloid , new Subscriber < ClientObject > ( ) { public void objectAvailable ( ClientObject clobj ) { DSet < Registration > receivers = _clobj . receivers ; _clobj = clobj ; _clobj . addListener ( InvocationDirector . this ) ; _clobj . startTransaction ( ) ; try { _clobj . setReceivers ( new DSet < Registration > ( ) ) ; for ( Registration reg : receivers ) { _clobj . addToReceivers ( reg ) ; } } finally { _clobj . commitTransaction ( ) ; } _client . clientObjectDidChange ( _clobj ) ; } public void requestFailed ( int oid , ObjectAccessException cause ) { log . warning ( "Aiya! Unable to subscribe to changed client object" , "cloid" , oid , "cause" , cause ) ; } } ) ; } | Called when the server has informed us that our previous client object is going the way of the Dodo because we re changing screen names . We subscribe to the new object and report to the client once we ve got our hands on it . |
13,566 | public PlaceManager createPlace ( PlaceConfig config ) throws InstantiationException , InvocationException { return createPlace ( config , null , null ) ; } | Creates and registers a new place manager with no delegates . |
13,567 | public PlaceManager createPlace ( PlaceConfig config , List < PlaceManagerDelegate > delegates ) throws InstantiationException , InvocationException { return createPlace ( config , delegates , null ) ; } | Creates and registers a new place manager along with the place object to be managed . The registry takes care of tracking the creation of the object and informing the manager when it is created . |
13,568 | public Iterator < PlaceObject > enumeratePlaces ( ) { final Iterator < PlaceManager > itr = _pmgrs . values ( ) . iterator ( ) ; return new Iterator < PlaceObject > ( ) { public boolean hasNext ( ) { return itr . hasNext ( ) ; } public PlaceObject next ( ) { PlaceManager plmgr = itr . next ( ) ; return ( plmgr == null ) ? null : plmgr . getPlaceObject ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; } | Returns an enumeration of all of the registered place objects . This should only be accessed on the dobjmgr thread and shouldn t be kept around across event dispatches . |
13,569 | protected PlaceManager createPlace ( PlaceConfig config , List < PlaceManagerDelegate > delegates , PreStartupHook hook ) throws InstantiationException , InvocationException { PlaceManager pmgr = null ; try { pmgr = createPlaceManager ( config ) ; if ( delegates != null ) { for ( PlaceManagerDelegate delegate : delegates ) { _injector . injectMembers ( delegate ) ; pmgr . addDelegate ( delegate ) ; } } pmgr . init ( this , _invmgr , _omgr , selectLocator ( config ) , config ) ; } catch ( Exception e ) { log . warning ( e ) ; throw new InstantiationException ( "Error creating PlaceManager for " + config ) ; } String errmsg = pmgr . checkPermissions ( ) ; if ( errmsg != null ) { pmgr . permissionsFailed ( ) ; throw new InvocationException ( errmsg ) ; } PlaceObject plobj = pmgr . createPlaceObject ( ) ; _omgr . registerObject ( plobj ) ; _pmgrs . put ( plobj . getOid ( ) , pmgr ) ; try { if ( hook != null ) { hook . invoke ( pmgr ) ; } pmgr . startup ( plobj ) ; } catch ( Exception e ) { log . warning ( "Error starting place manager" , "obj" , plobj , "pmgr" , pmgr , e ) ; } return pmgr ; } | Creates a place manager using the supplied config injects dependencies into and registers the supplied list of delegates runs the supplied pre - startup hook and finally returns it . |
13,570 | protected void unmapPlaceManager ( PlaceManager pmgr ) { int ploid = pmgr . getPlaceObject ( ) . getOid ( ) ; if ( _pmgrs . remove ( ploid ) == null ) { log . warning ( "Requested to unmap unmapped place manager" , "pmgr" , pmgr ) ; } } | Called by the place manager when it has been shut down . |
13,571 | public synchronized static boolean isStreamable ( Class < ? > target ) { maybeInit ( ) ; if ( _streamers . containsKey ( target ) || target . isEnum ( ) ) { return true ; } if ( target . isArray ( ) ) { return isStreamable ( target . getComponentType ( ) ) ; } return Streamable . class . isAssignableFrom ( target ) || Iterable . class . isAssignableFrom ( target ) || Map . class . isAssignableFrom ( target ) ; } | Returns true if the supplied target class can be streamed using a streamer . |
13,572 | public static Class < ? > getStreamerClass ( Object object ) { return ( object instanceof Enum < ? > ) ? ( ( Enum < ? > ) object ) . getDeclaringClass ( ) : object . getClass ( ) ; } | Returns the class that should be used when streaming this object . In general that is the object s natural class but for enum values that might be its declaring class as enums use classes in a way that would otherwise pollute our id to class mapping space . |
13,573 | public static Class < ? > getCollectionClass ( Class < ? > clazz ) { if ( Streamable . class . isAssignableFrom ( clazz ) ) { return null ; } for ( Class < ? > collClass : BasicStreamers . CollectionStreamer . SPECIFICITY_ORDER ) { if ( collClass . isAssignableFrom ( clazz ) ) { return collClass ; } } return null ; } | If the specified class is not Streamable and is a Collection type return the most specific supported Collection interface type ; otherwise return null . |
13,574 | protected static Streamer create ( Class < ? > target ) throws IOException { boolean isInner = false , isStatic = Modifier . isStatic ( target . getModifiers ( ) ) ; try { isInner = ( target . getDeclaringClass ( ) != null ) ; } catch ( Throwable t ) { log . warning ( "Failure checking innerness of class" , "class" , target . getName ( ) , "error" , t ) ; } if ( isInner && ! isStatic ) { throw new IllegalArgumentException ( "Cannot stream non-static inner class: " + target . getName ( ) ) ; } if ( target . isArray ( ) ) { Class < ? > componentType = target . getComponentType ( ) ; if ( Modifier . isFinal ( componentType . getModifiers ( ) ) ) { Streamer delegate = Streamer . getStreamer ( componentType ) ; if ( delegate != null ) { return new FinalArrayStreamer ( componentType , delegate ) ; } } else if ( isStreamable ( componentType ) ) { return new ArrayStreamer ( componentType ) ; } String errmsg = "Aiya! Streamer created for array type but we have no registered " + "streamer for the element type [type=" + target . getName ( ) + "]" ; throw new RuntimeException ( errmsg ) ; } if ( target . isEnum ( ) ) { switch ( ENUM_POLICY ) { case NAME_WITH_BYTE_ENUM : case ORDINAL_WITH_BYTE_ENUM : if ( ByteEnum . class . isAssignableFrom ( target ) ) { return new ByteEnumStreamer ( target ) ; } break ; default : break ; } switch ( ENUM_POLICY ) { case NAME_WITH_BYTE_ENUM : case NAME : return new NameEnumStreamer ( target ) ; default : List < ? > universe = ImmutableList . copyOf ( target . getEnumConstants ( ) ) ; int maxOrdinal = universe . size ( ) - 1 ; if ( maxOrdinal <= Byte . MAX_VALUE ) { return new ByteOrdEnumStreamer ( target , universe ) ; } else if ( maxOrdinal <= Short . MAX_VALUE ) { return new ShortOrdEnumStreamer ( target , universe ) ; } else { return new IntOrdEnumStreamer ( target , universe ) ; } } } Method reader = null ; Method writer = null ; try { reader = target . getMethod ( READER_METHOD_NAME , READER_ARGS ) ; } catch ( NoSuchMethodException nsme ) { } try { writer = target . getMethod ( WRITER_METHOD_NAME , WRITER_ARGS ) ; } catch ( NoSuchMethodException nsme ) { } if ( ( reader == null ) && ( writer == null ) ) { return new ClassStreamer ( target ) ; } else { return new CustomClassStreamer ( target , reader , writer ) ; } } | Create the appropriate Streamer for a newly - seen class . |
13,575 | public void applyToOccupants ( OccupantOp op ) { if ( _plobj != null ) { for ( OccupantInfo info : _plobj . occupantInfo ) { op . apply ( info ) ; } } } | Applies the supplied occupant operation to each occupant currently present in this place . |
13,576 | public void init ( PlaceRegistry registry , InvocationManager invmgr , RootDObjectManager omgr , BodyLocator locator , PlaceConfig config ) { _registry = registry ; _invmgr = invmgr ; _omgr = omgr ; _locator = locator ; _config = config ; applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . init ( PlaceManager . this , _omgr , _invmgr ) ; } } ) ; try { didInit ( ) ; } catch ( Throwable t ) { log . warning ( "Manager choked in didInit()" , "where" , where ( ) , t ) ; } } | Called by the place registry after creating this place manager . |
13,577 | public void addDelegate ( PlaceManagerDelegate delegate ) { if ( _delegates == null ) { _delegates = Lists . newArrayList ( ) ; } if ( _omgr != null ) { delegate . init ( this , _omgr , _invmgr ) ; delegate . didInit ( _config ) ; } _delegates . add ( delegate ) ; } | Adds the supplied delegate to the list for this manager . |
13,578 | public void applyToDelegates ( DelegateOp op ) { if ( _delegates != null ) { for ( int ii = 0 , ll = _delegates . size ( ) ; ii < ll ; ii ++ ) { PlaceManagerDelegate delegate = _delegates . get ( ii ) ; if ( op . shouldApply ( delegate ) ) { op . apply ( delegate ) ; } } } } | Applies the supplied operation to this manager s registered delegates . |
13,579 | public void startup ( PlaceObject plobj ) { _plobj = plobj ; if ( shouldCreateSpeakService ( ) ) { plobj . setSpeakService ( addProvider ( createSpeakHandler ( plobj ) , SpeakMarshaller . class ) ) ; } plobj . addListener ( this ) ; plobj . addListener ( _bodyUpdater ) ; plobj . addListener ( _occListener ) ; plobj . addListener ( _deathListener ) ; plobj . setAccessController ( getAccessController ( ) ) ; try { didStartup ( ) ; } catch ( Throwable t ) { log . warning ( "Manager choked in didStartup()" , "where" , where ( ) , t ) ; } checkShutdownInterval ( ) ; } | Called by the place manager after the place object has been successfully created . |
13,580 | public void registerMessageHandler ( String name , MessageHandler handler ) { if ( _msghandlers == null ) { _msghandlers = Maps . newHashMap ( ) ; } _msghandlers . put ( name , handler ) ; } | Registers a particular message handler instance to be used when processing message events with the specified name . |
13,581 | public void messageReceived ( MessageEvent event ) { if ( _msghandlers != null ) { MessageHandler handler = _msghandlers . get ( event . getName ( ) ) ; if ( handler != null ) { handler . handleEvent ( event , this ) ; } } if ( event . isPrivate ( ) ) { int srcoid = event . getSourceOid ( ) ; DObject source = ( srcoid <= 0 ) ? null : _omgr . getObject ( srcoid ) ; String method = event . getName ( ) ; Object [ ] args = event . getArgs ( ) , nargs ; if ( ! allowManagerCall ( method ) ) { log . warning ( "Client tried to invoke forbidden manager call!" , "source" , source , "method" , method , "args" , args ) ; return ; } if ( args == null ) { nargs = new Object [ ] { source } ; } else { nargs = new Object [ args . length + 1 ] ; nargs [ 0 ] = source ; System . arraycopy ( args , 0 , nargs , 1 , args . length ) ; } if ( _dispatcher == null ) { Class < ? > clazz = getClass ( ) ; MethodFinder finder = _dispatcherFinders . get ( clazz ) ; if ( finder == null ) { finder = new MethodFinder ( clazz ) ; _dispatcherFinders . put ( clazz , finder ) ; } _dispatcher = new DynamicListener < DSet . Entry > ( this , finder ) ; } _dispatcher . dispatchMethod ( method , nargs ) ; } } | from interface MessageListener |
13,582 | protected < T extends InvocationMarshaller < ? > > T addProvider ( InvocationProvider prov , Class < T > mclass ) { T marsh = _invmgr . registerProvider ( prov , mclass ) ; _marshallers . add ( marsh ) ; return marsh ; } | Registers an invocation provider and notes the registration such that it will be automatically cleared when this manager shuts down . |
13,583 | protected < T extends InvocationMarshaller < ? > > T addDispatcher ( InvocationDispatcher < T > disp ) { T marsh = _invmgr . registerDispatcher ( disp ) ; _marshallers . add ( marsh ) ; return marsh ; } | Registers an invocation dispatcher and notes the registration such that it will be automatically cleared when this manager shuts down . |
13,584 | protected void bodyEntered ( final int bodyOid ) { log . debug ( "Body entered" , "where" , where ( ) , "oid" , bodyOid ) ; applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . bodyEntered ( bodyOid ) ; } } ) ; cancelShutdowner ( ) ; } | Called when a body object enters this place . |
13,585 | protected void bodyLeft ( final int bodyOid ) { log . debug ( "Body left" , "where" , where ( ) , "oid" , bodyOid ) ; Integer key = Integer . valueOf ( bodyOid ) ; if ( _plobj . occupantInfo . containsKey ( key ) ) { _plobj . removeFromOccupantInfo ( key ) ; } OccupantInfo leaver = _occInfo . remove ( bodyOid ) ; applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . bodyLeft ( bodyOid ) ; } } ) ; if ( shouldDeclareEmpty ( leaver ) ) { placeBecameEmpty ( ) ; } } | Called when a body object leaves this place . |
13,586 | protected void bodyUpdated ( final OccupantInfo info ) { applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . bodyUpdated ( info ) ; } } ) ; } | Called when a body s occupant info is updated . |
13,587 | protected void placeBecameEmpty ( ) { applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . placeBecameEmpty ( ) ; } } ) ; checkShutdownInterval ( ) ; } | Called when we transition from having bodies in the place to not having any bodies in the place . Some places may take this as a sign to pack it in others may wish to stick around . In any case they can override this method to do their thing . |
13,588 | protected void checkShutdownInterval ( ) { long idlePeriod = idleUnloadPeriod ( ) ; if ( idlePeriod > 0L && _shutdownInterval == null ) { ( _shutdownInterval = _omgr . newInterval ( new Runnable ( ) { public void run ( ) { log . debug ( "Unloading idle place '" + where ( ) + "'." ) ; shutdown ( ) ; } } ) ) . schedule ( idlePeriod ) ; } } | Called on startup and when the place is empty . |
13,589 | public static void sendInfo ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . INFO ) ; } | Sends a system INFO message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server . |
13,590 | public static void sendFeedback ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . FEEDBACK ) ; } | Sends a system FEEDBACK message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server . |
13,591 | public static void sendAttention ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . ATTENTION ) ; } | Sends a system ATTENTION message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server . |
13,592 | public static void sendMessage ( DObject speakObj , ChatMessage msg ) { if ( speakObj == null ) { log . warning ( "Dropping speak message, no speak obj '" + msg + "'." , new Exception ( ) ) ; return ; } speakObj . postMessage ( ChatCodes . CHAT_NOTIFICATION , new Object [ ] { msg } ) ; if ( ! ( msg instanceof UserMessage ) ) { return ; } else if ( speakObj instanceof SpeakObject ) { _messageMapper . omgr = ( RootDObjectManager ) speakObj . getManager ( ) ; _messageMapper . message = ( UserMessage ) msg ; ( ( SpeakObject ) speakObj ) . applyToListeners ( _messageMapper ) ; _messageMapper . omgr = null ; _messageMapper . message = null ; } else { log . info ( "Unable to note listeners" , "dclass" , speakObj . getClass ( ) , "msg" , msg ) ; } } | Send the specified message on the specified object . |
13,593 | protected static void sendSystem ( DObject speakObj , String bundle , String message , byte level ) { sendMessage ( speakObj , new SystemMessage ( message , bundle , level ) ) ; } | Send the specified system message on the specified dobj . |
13,594 | public static Twilight getTwilight ( double sunDistanceRadians ) { double altDegrees = 90.0 - Math . toDegrees ( sunDistanceRadians ) ; if ( altDegrees >= 0.0 ) { return Twilight . DAYLIGHT ; } else if ( altDegrees >= - 6.0 ) { return Twilight . CIVIL ; } else if ( altDegrees >= - 12.0 ) { return Twilight . NAUTICAL ; } else if ( altDegrees >= - 18.0 ) { return Twilight . ASTRONOMICAL ; } return Twilight . NIGHT ; } | Return the twilight condition for a point which is a given great circle distance from the current sub solar point . |
13,595 | public static Position getSubSolarPoint ( Calendar time ) { double jd = TimeUtil . getJulianDayNumber ( time ) ; double T = ( jd - 2451545.0 ) / 36525 ; double M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T ; double L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T ; double DL = ( 1.914600 - 0.004817 * T - 0.000014 * T * T ) * Math . sin ( Math . toRadians ( M ) ) + ( 0.019993 - 0.000101 * T ) * Math . sin ( Math . toRadians ( 2.0 * M ) ) + 0.000290 * Math . sin ( Math . toRadians ( 3.0 * M ) ) ; double L = L0 + DL ; double eps = 23.0 + 26.0 / 60.0 + 21.448 / 3600.0 - ( 46.8150 * T + 0.00059 * T * T - 0.001813 * T * T * T ) / 3600.0 ; double X = Math . cos ( Math . toRadians ( L ) ) ; double Y = Math . cos ( Math . toRadians ( eps ) ) * Math . sin ( Math . toRadians ( L ) ) ; double Z = Math . sin ( Math . toRadians ( eps ) ) * Math . sin ( Math . toRadians ( L ) ) ; double R = Math . sqrt ( 1.0 - Z * Z ) ; double delta = Math . toDegrees ( Math . atan ( Z / R ) ) ; double p = Y / ( X + R ) ; double ra = Math . toDegrees ( Math . atan ( p ) ) ; double RA = ( 24.0 / 180.0 ) * ra ; double theta0 = 280.46061837 + 360.98564736629 * ( jd - 2451545.0 ) + 0.000387933 * T * T - T * T * T / 38710000.0 ; double sidTime = ( theta0 % 360 ) / 15.0 ; double sunHADeg = ( ( sidTime - RA ) * 15.0 ) % 360.0 ; double lon = 0.0 ; if ( sunHADeg < 180.0 ) { lon = - sunHADeg ; } else { lon = 360.0 - sunHADeg ; } double lat = delta ; log . info ( "Sidereal time is " + sidTime + ", Sun RA/Dec is " + RA + "/" + delta + ", subSolar lat/long is " + lat + "/" + lon ) ; return new Position ( lat , lon ) ; } | Returns the position on the Earth s surface for which the sun appears to be straight above . |
13,596 | public void elementUpdated ( ElementUpdatedEvent event ) { dispatchMethod ( event . getName ( ) + "Updated" , new Object [ ] { event . getIndex ( ) , event . getValue ( ) } ) ; } | from interface ElementUpdateListener |
13,597 | public void dispatchMethod ( String name , Object [ ] arguments ) { Method method = _mcache . get ( name ) ; if ( method == null ) { if ( ! _mcache . containsKey ( name ) ) { _mcache . put ( name , method = resolveMethod ( name , arguments ) ) ; } } if ( method != null ) { try { method . invoke ( _target , arguments ) ; } catch ( Exception e ) { log . warning ( "Failed to dispatch event callback " + name + "(" + StringUtil . toString ( arguments ) + ")." , e ) ; } } } | Dynamically looks up the method in question on our target and dispatches an event if it does . |
13,598 | protected Method resolveMethod ( String name , Object [ ] arguments ) { Class < ? > [ ] ptypes = new Class < ? > [ arguments . length ] ; for ( int ii = 0 ; ii < arguments . length ; ii ++ ) { ptypes [ ii ] = arguments [ ii ] == null ? null : arguments [ ii ] . getClass ( ) ; } try { return _finder . findMethod ( name , ptypes ) ; } catch ( Exception e ) { return null ; } } | Looks for a method that matches the supplied signature . |
13,599 | public static Transport getInstance ( Type type , int channel ) { if ( _unordered == null ) { int length = Type . values ( ) . length ; _unordered = new Transport [ length ] ; @ SuppressWarnings ( { "unchecked" } ) HashIntMap < Transport > [ ] ordered = ( HashIntMap < Transport > [ ] ) new HashIntMap < ? > [ length ] ; _ordered = ordered ; } int idx = type . ordinal ( ) ; if ( ! type . isOrdered ( ) ) { Transport instance = _unordered [ idx ] ; if ( instance == null ) { _unordered [ idx ] = instance = new Transport ( type ) ; } return instance ; } HashIntMap < Transport > instances = _ordered [ idx ] ; if ( instances == null ) { _ordered [ idx ] = instances = new HashIntMap < Transport > ( ) ; } Transport instance = instances . get ( channel ) ; if ( instance == null ) { instances . put ( channel , instance = new Transport ( type , channel ) ) ; } return instance ; } | Returns the shared instance with the specified parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.