idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
16,900 | public void init ( Object parent , Object record ) { if ( parent instanceof BaseApplet ) m_strInitParam = ( ( BaseApplet ) parent ) . getProperty ( Params . MENU ) ; super . init ( parent , record ) ; } | Initialize this class . If there is a top - level menu = property save it for later . |
16,901 | public FieldList buildFieldList ( ) { FieldList record = ( FieldList ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( Constants . ROOT_PACKAGE + "thin.main.db.Menus" ) ; if ( record != null ) record . init ( this ) ; else return null ; record . setOpenMode ( Constants . OPEN_READ_ONLY ) ; BaseApplet applet = BaseApplet . getSharedInstance ( ) ; m_remoteSession = applet . makeRemoteSession ( null , ".main.remote.MenusSession" ) ; applet . linkRemoteSessionTable ( m_remoteSession , record , true ) ; if ( m_strInitParam != null ) { try { m_remoteSession . doRemoteAction ( m_strInitParam , null ) ; } catch ( Exception ex ) { } } return record ; } | Build the list of fields that make up the screen . This method creates a new Menus record and links it to the remote MenusSession . |
16,902 | public void setMargin ( Rectangle2D bounds , Direction ... dirs ) { for ( Direction dir : dirs ) { switch ( dir ) { case BOTTOM : combinedTransform . transform ( userBounds . getCenterX ( ) , userBounds . getMinY ( ) , ( x , y ) -> { inverse . transform ( x , y + bounds . getHeight ( ) , this :: updatePoint ) ; } ) ; break ; case LEFT : combinedTransform . transform ( userBounds . getMinX ( ) , userBounds . getCenterY ( ) , ( x , y ) -> { inverse . transform ( x - bounds . getWidth ( ) , y , this :: updatePoint ) ; } ) ; break ; case RIGHT : combinedTransform . transform ( userBounds . getMaxX ( ) , userBounds . getCenterY ( ) , ( x , y ) -> { inverse . transform ( x + bounds . getWidth ( ) , y , this :: updatePoint ) ; } ) ; break ; case TOP : combinedTransform . transform ( userBounds . getCenterX ( ) , userBounds . getMaxY ( ) , ( x , y ) -> { inverse . transform ( x , y - bounds . getHeight ( ) , this :: updatePoint ) ; } ) ; break ; } } } | Enlarges margin in screen coordinates to given directions |
16,903 | public double toScreenX ( double x ) { Point2D src = srcPnt . get ( ) ; Point2D dst = dstPnt . get ( ) ; src . setLocation ( x , 0 ) ; combinedTransform . transform ( src , dst ) ; return dst . getX ( ) ; } | Translates cartesian x - coordinate to screen coordinate . |
16,904 | public double toScreenY ( double y ) { Point2D src = srcPnt . get ( ) ; Point2D dst = dstPnt . get ( ) ; src . setLocation ( 0 , y ) ; combinedTransform . transform ( src , dst ) ; return dst . getY ( ) ; } | Translates cartesian y - coordinate to screen coordinate . |
16,905 | public double fromScreenX ( double x ) { Point2D src = srcPnt . get ( ) ; Point2D dst = dstPnt . get ( ) ; src . setLocation ( x , 0 ) ; inverse . transform ( src , dst ) ; return dst . getX ( ) ; } | Translates screen x - coordinate to cartesian coordinate . |
16,906 | public double fromScreenY ( double y ) { Point2D src = srcPnt . get ( ) ; Point2D dst = dstPnt . get ( ) ; src . setLocation ( 0 , y ) ; inverse . transform ( src , dst ) ; return dst . getY ( ) ; } | Translates screen y - coordinate to cartesian coordinate . |
16,907 | public boolean znodeIsMe ( String path ) { String value = ZKUtils . get ( zk , path ) ; return ( value != null && value == myNodeID ) ; } | Given a path determines whether or not the value of a ZNode is my node ID . |
16,908 | public NodeState join ( ZooKeeperClient injectedClient ) throws InterruptedException { switch ( state . get ( ) ) { case Fresh : connect ( injectedClient ) ; break ; case Shutdown : connect ( injectedClient ) ; break ; case Draining : LOG . warn ( "'join' called while draining; ignoring." ) ; break ; case Started : LOG . warn ( "'join' called after started; ignoring." ) ; break ; } return state . get ( ) ; } | Joins the cluster using a custom zk client claims work and begins operation . |
16,909 | private void connect ( ZooKeeperClient injectedClient ) throws InterruptedException { if ( ! initialized . get ( ) ) { if ( injectedClient == null ) { List < InetSocketAddress > hosts = new ArrayList < InetSocketAddress > ( ) ; for ( String host : config . hosts . split ( "," ) ) { String [ ] parts = host . split ( ":" ) ; try { hosts . add ( new InetSocketAddress ( parts [ 0 ] , Integer . parseInt ( parts [ 1 ] ) ) ) ; } catch ( Exception e ) { LOG . error ( "Invalid ZK host '" + host + "', need to skip, problem: " + e . getMessage ( ) ) ; } } LOG . info ( "Connecting to hosts: {}" , hosts . toString ( ) ) ; injectedClient = new ZooKeeperClient ( Amount . of ( ( int ) config . zkTimeout , Time . MILLISECONDS ) , hosts ) ; } zk = injectedClient ; claimer . start ( ) ; LOG . info ( "Registering connection watcher." ) ; zk . register ( connectionWatcher ) ; } try { zk . get ( ) ; } catch ( ZooKeeperConnectionException e ) { throw ZKException . from ( e ) ; } } | Directs the ZooKeeperClient to connect to the ZooKeeper ensemble and wait for the connection to be established before continuing . |
16,910 | public void stopAndWait ( final long waitTime , final AtomicBoolean stopFlag ) { if ( ! waitInProgress . getAndSet ( true ) ) { stopFlag . set ( true ) ; rejoinExecutor . submit ( new Runnable ( ) { public void run ( ) { balancingPolicy . drainToCount ( 0 , false ) ; try { Thread . sleep ( waitTime ) ; } catch ( InterruptedException e ) { LOG . warn ( "Interrupted while waiting." ) ; } LOG . info ( "Back to work." ) ; stopFlag . set ( false ) ; waitInProgress . set ( false ) ; } } ) ; } } | For handling problematic nodes - drains workers and does not claim work for waitTime seconds |
16,911 | public void completeShutdown ( ) { setState ( NodeState . Shutdown ) ; shutdownAllWorkUnits ( ) ; deleteFromZk ( ) ; if ( claimer != null ) { claimer . interrupt ( ) ; try { claimer . join ( ) ; } catch ( InterruptedException e ) { LOG . warn ( "Shutdown of Claimer interrupted" ) ; } } if ( connectionWatcher != null ) { zk . unregister ( connectionWatcher ) ; } try { zk . close ( ) ; } catch ( Exception e ) { LOG . warn ( "Zookeeper reported exception on shutdown." , e ) ; } listener . onLeave ( ) ; } | Finalizes the shutdown sequence . Called once the drain operation completes . |
16,912 | void onConnect ( ) throws InterruptedException , IOException { if ( state . get ( ) != NodeState . Fresh ) { if ( previousZKSessionStillActive ( ) ) { LOG . info ( "ZooKeeper session re-established before timeout." ) ; return ; } LOG . warn ( "Rejoined after session timeout. Forcing shutdown and clean startup." ) ; ensureCleanStartup ( ) ; } LOG . info ( "Connected to Zookeeper (ID: {})." , myNodeID ) ; ZKUtils . ensureOrdasityPaths ( zk , name , config . workUnitName , config . workUnitShortName ) ; joinCluster ( ) ; listener . onJoin ( zk ) ; if ( watchesRegistered . compareAndSet ( false , true ) ) { registerWatchers ( ) ; } initialized . set ( true ) ; initializedLatch . countDown ( ) ; setState ( NodeState . Started ) ; claimer . requestClaim ( ) ; verifyIntegrity ( ) ; balancingPolicy . onConnect ( ) ; if ( config . enableAutoRebalance ) { scheduleRebalancing ( ) ; } } | Primary callback which is triggered upon successful Zookeeper connection . |
16,913 | private void ensureCleanStartup ( ) { forceShutdown ( ) ; ScheduledThreadPoolExecutor oldPool = pool . getAndSet ( createScheduledThreadExecutor ( ) ) ; oldPool . shutdownNow ( ) ; claimedForHandoff . clear ( ) ; workUnitsPeggedToMe . clear ( ) ; state . set ( NodeState . Fresh ) ; } | In the event that the node has been evicted and is reconnecting this method clears out all existing state before relaunching to ensure a clean launch . |
16,914 | private void scheduleRebalancing ( ) { int interval = config . autoRebalanceInterval ; Runnable runRebalance = new Runnable ( ) { public void run ( ) { try { rebalance ( ) ; } catch ( Exception e ) { LOG . error ( "Error running auto-rebalance." , e ) ; } } } ; autoRebalanceFuture = pool . get ( ) . scheduleAtFixedRate ( runRebalance , interval , interval , TimeUnit . SECONDS ) ; } | Schedules auto - rebalancing if auto - rebalancing is enabled . The task is scheduled to run every 60 seconds by default or according to the config . |
16,915 | private void joinCluster ( ) throws InterruptedException , IOException { while ( true ) { NodeInfo myInfo ; try { myInfo = new NodeInfo ( NodeState . Fresh . toString ( ) , zk . get ( ) . getSessionId ( ) ) ; } catch ( ZooKeeperConnectionException e ) { throw ZKException . from ( e ) ; } byte [ ] encoded = JsonUtil . asJSONBytes ( myInfo ) ; if ( ZKUtils . createEphemeral ( zk , "/" + name + "/nodes/" + myNodeID , encoded ) ) { return ; } else { Stat stat = new Stat ( ) ; try { byte [ ] bytes = zk . get ( ) . getData ( "/" + name + "/nodes/" + myNodeID , false , stat ) ; NodeInfo nodeInfo = JsonUtil . fromJSON ( bytes , NodeInfo . class ) ; if ( nodeInfo . connectionID == zk . get ( ) . getSessionId ( ) ) { return ; } } catch ( ZooKeeperConnectionException e ) { throw ZKException . from ( e ) ; } catch ( KeeperException e ) { throw ZKException . from ( e ) ; } } LOG . warn ( "Unable to register with Zookeeper on launch. " + "Is {} already running on this host? Retrying in 1 second..." , name ) ; Thread . sleep ( 1000 ) ; } } | Registers this node with Zookeeper on startup retrying until it succeeds . This retry logic is important in that a node which restarts before Zookeeper detects the previous disconnect could prohibit the node from properly launching . |
16,916 | public void claimWork ( ) throws InterruptedException { if ( state . get ( ) == NodeState . Started && ! waitInProgress . get ( ) && connected . get ( ) ) { balancingPolicy . claimWork ( ) ; } } | Triggers a work - claiming cycle . If smart balancing is enabled claim work based on node and cluster load . If simple balancing is in effect claim by count . |
16,917 | public void requestHandoff ( String workUnit ) throws InterruptedException { LOG . info ( "Requesting handoff for {}." , workUnit ) ; ZKUtils . createEphemeral ( zk , "/" + name + "/handoff-requests/" + workUnit ) ; } | Requests that another node take over for a work unit by creating a ZNode at handoff - requests . This will trigger a claim cycle and adoption . |
16,918 | public void verifyIntegrity ( ) { LinkedHashSet < String > noLongerActive = new LinkedHashSet < String > ( myWorkUnits ) ; noLongerActive . removeAll ( allWorkUnits . keySet ( ) ) ; for ( String workUnit : noLongerActive ) { shutdownWork ( workUnit , true ) ; } for ( String workUnit : myWorkUnits ) { String claimPath = workUnitClaimPath ( workUnit ) ; if ( ! balancingPolicy . isFairGame ( workUnit ) && ! balancingPolicy . isPeggedToMe ( workUnit ) ) { LOG . info ( "Discovered I'm serving a work unit that's now " + "pegged to someone else. Shutting down {}" , workUnit ) ; shutdownWork ( workUnit , true ) ; } else if ( workUnitMap . containsKey ( workUnit ) && ! workUnitMap . get ( workUnit ) . equals ( myNodeID ) && ! claimedForHandoff . contains ( workUnit ) && ! znodeIsMe ( claimPath ) ) { LOG . info ( "Discovered I'm serving a work unit that's now " + "claimed by {} according to ZooKeeper. Shutting down {}" , workUnitMap . get ( workUnit ) , workUnit ) ; shutdownWork ( workUnit , true ) ; } } } | Verifies that all nodes are hooked up properly . Shuts down any work units which have been removed from the cluster or have been assigned to another node . |
16,919 | public void shutdownWork ( String workUnit , boolean doLog ) { if ( doLog ) { LOG . info ( "Shutting down {}: {}..." , config . workUnitName , workUnit ) ; } myWorkUnits . remove ( workUnit ) ; claimedForHandoff . remove ( workUnit ) ; balancingPolicy . onShutdownWork ( workUnit ) ; try { listener . shutdownWork ( workUnit ) ; } finally { ZKUtils . deleteAtomic ( zk , workUnitClaimPath ( workUnit ) , myNodeID ) ; } } | Shuts down a work unit by removing the claim in ZK and calling the listener . |
16,920 | private boolean setState ( NodeState to ) { try { NodeInfo myInfo = new NodeInfo ( to . toString ( ) , zk . get ( ) . getSessionId ( ) ) ; byte [ ] encoded = JsonUtil . asJSONBytes ( myInfo ) ; ZKUtils . set ( zk , "/" + name + "/nodes/" + myNodeID , encoded ) ; state . set ( to ) ; return true ; } catch ( Exception e ) { LOG . warn ( "Problem trying to setState(" + to + "): " + e . getMessage ( ) , e ) ; return false ; } } | Sets the state of the current Ordasity node and notifies others via ZooKeeper . |
16,921 | private boolean previousZKSessionStillActive ( ) { try { byte [ ] json = zk . get ( ) . getData ( String . format ( "/%s/nodes/%s" , name , myNodeID ) , false , null ) ; NodeInfo nodeInfo = JsonUtil . fromJSON ( json , NodeInfo . class ) ; return ( nodeInfo . connectionID == zk . get ( ) . getSessionId ( ) ) ; } catch ( NoNodeException e ) { ; } catch ( Exception e ) { LOG . error ( "Encountered unexpected error in checking ZK session status." , e ) ; } return false ; } | Determines if another ZooKeeper session is currently active for the current node by comparing the ZooKeeper session ID of the connection stored in NodeState . |
16,922 | public static void updateParticipants ( Encounter encounter ) { if ( encounter == null || encounter . getParticipant ( ) . isEmpty ( ) ) { return ; } RPCParameter params = new RPCParameter ( ) ; for ( EncounterParticipantComponent participant : encounter . getParticipant ( ) ) { String partId = getParticipantId ( participant ) ; params . put ( partId , "+" ) ; } String dfn = PatientContext . getActivePatient ( ) . getIdElement ( ) . getIdPart ( ) ; VistAUtil . getBrokerSession ( ) . callRPC ( "RGCWENCX UPDPRV" , dfn , encode ( encounter ) , params , true ) ; } | Updates the participants associated with an encounter . |
16,923 | public static Encounter decode ( String vstr ) { String [ ] pcs = StrUtil . split ( vstr , VSTR_DELIM , 4 ) ; long encIEN = NumberUtils . toLong ( pcs [ 3 ] ) ; if ( encIEN > 0 ) { return DomainFactoryRegistry . fetchObject ( Encounter . class , pcs [ 3 ] ) ; } long locIEN = NumberUtils . toLong ( pcs [ 0 ] ) ; Location location = locIEN == 0 ? null : DomainFactoryRegistry . fetchObject ( Location . class , pcs [ 0 ] ) ; Date date = FMDate . fromString ( pcs [ 1 ] ) ; return create ( PatientContext . getActivePatient ( ) , date , location , pcs [ 2 ] ) ; } | Decode encounter from visit string . |
16,924 | public static String encode ( Encounter encounter ) { Location location = ClientUtil . getResource ( encounter . getLocationFirstRep ( ) . getLocation ( ) , Location . class ) ; String locIEN = location . isEmpty ( ) ? "" : location . getIdElement ( ) . getIdPart ( ) ; Date date = encounter . getPeriod ( ) . getStart ( ) ; String sc = getServiceCategory ( encounter ) ; String ien = encounter . getId ( ) . isEmpty ( ) ? "" : encounter . getIdElement ( ) . getIdPart ( ) ; return locIEN + VSTR_DELIM + new FMDate ( date ) . getFMDate ( ) + VSTR_DELIM + sc + VSTR_DELIM + ien ; } | Encode an encounter to a visit string . |
16,925 | public void plusMonths ( int delta ) { if ( delta != 0 ) { int result = getMonth ( ) - 1 + delta ; setMonth ( Math . floorMod ( result , 12 ) + 1 ) ; plusYears ( Math . floorDiv ( result , 12 ) ) ; } } | Adds delta months . Delta can be negative . Month and year fields are affected . |
16,926 | public void plusDays ( long delta ) { if ( delta != 0 ) { long result = getDay ( ) + delta ; if ( result >= 1 && result <= 28 ) { setDay ( ( int ) result ) ; } else { ZonedDateTime zonedDateTime = ZonedDateTime . from ( this ) ; ZonedDateTime plusDays = zonedDateTime . plusDays ( delta ) ; set ( plusDays ) ; } } } | Adds delta days . Delta can be negative . Month year and day fields are affected . |
16,927 | public void plusHours ( long delta ) { if ( delta != 0 ) { long result = getHour ( ) + delta ; setHour ( ( int ) Math . floorMod ( result , 24 ) ) ; plusDays ( Math . floorDiv ( result , 24 ) ) ; } } | Adds delta hours . Delta can be negative . Month year day and hour fields are affected . |
16,928 | public void plusMinutes ( long delta ) { if ( delta != 0 ) { long result = getMinute ( ) + delta ; setMinute ( ( int ) Math . floorMod ( result , 60 ) ) ; plusHours ( Math . floorDiv ( result , 60 ) ) ; } } | Adds delta minutes . Delta can be negative . Month year day hour and minute fields are affected . |
16,929 | public void plusSeconds ( long delta ) { if ( delta != 0 ) { long result = getSecond ( ) + delta ; setSecond ( ( int ) Math . floorMod ( result , 60 ) ) ; plusMinutes ( Math . floorDiv ( result , 60 ) ) ; } } | Adds delta seconds . Delta can be negative . Month year day hour minute and seconds fields are affected . |
16,930 | public void plusMilliSeconds ( long delta ) { plusNanoSeconds ( Math . floorMod ( delta , 1000 ) * 1000000 ) ; plusSeconds ( Math . floorDiv ( delta , 1000 ) ) ; } | Adds delta milliseconds . Delta can be negative . Month year day hour minute seconds and nanoSecond fields are affected . |
16,931 | public void plusNanoSeconds ( long delta ) { if ( delta != 0 ) { long result = getNanoSecond ( ) + delta ; setNanoSecond ( ( int ) Math . floorMod ( result , 1000000000 ) ) ; plusSeconds ( Math . floorDiv ( result , 1000000000 ) ) ; } } | Adds delta nanoseconds . Delta can be negative . Month year day hour minute seconds and nanoSecond fields are affected . |
16,932 | public static final SimpleMutableDateTime now ( Clock clock ) { ZonedDateTime zdt = ZonedDateTime . now ( clock ) ; SimpleMutableDateTime smt = SimpleMutableDateTime . from ( zdt ) ; return smt ; } | Creates SimpleMutableDateTime and initializes it using given clock . |
16,933 | public static final SimpleMutableDateTime ofEpochMilli ( long millis ) { ZonedDateTime zdt = ZonedDateTime . ofInstant ( Instant . ofEpochMilli ( millis ) , ZoneOffset . UTC ) ; SimpleMutableDateTime smt = SimpleMutableDateTime . from ( zdt ) ; return smt ; } | Creates SimpleMutableDateTime and initializes it using milliseconds from epoch . |
16,934 | public static final SimpleMutableDateTime now ( ZoneId zoneId ) { ZonedDateTime zdt = ZonedDateTime . now ( zoneId ) ; SimpleMutableDateTime smt = SimpleMutableDateTime . from ( zdt ) ; return smt ; } | Creates SimpleMutableDateTime and initializes it to given ZoneId . |
16,935 | protected void setupForWar ( ) { ProtectionDomain protectionDomain = RunWar . class . getProtectionDomain ( ) ; URL location = protectionDomain . getCodeSource ( ) . getLocation ( ) ; String warFilePath = trimToFile ( location . toExternalForm ( ) ) ; File warFile = new File ( warFilePath ) ; if ( ! warFile . exists ( ) ) { throw new IllegalStateException ( "war file not found: " + warFilePath ) ; } webapp . setWar ( warFilePath ) ; webapp . setClassLoader ( Thread . currentThread ( ) . getContextClassLoader ( ) ) ; if ( ! Boolean . getBoolean ( "webapp.extractWar" ) ) { try { webapp . setExtractWAR ( false ) ; webapp . setBaseResource ( JarResource . newJarResource ( Resource . newResource ( warFile ) ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Error setting base resource to:" + warFilePath , e ) ; } } if ( log ( ) . isDebugEnabled ( ) ) { ClassLoader classLoader = webapp . getClassLoader ( ) ; log ( ) . debug ( "webapp classLoader: " + classLoader ) ; if ( classLoader instanceof URLClassLoader ) { URL [ ] urls = ( ( URLClassLoader ) classLoader ) . getURLs ( ) ; log ( ) . debug ( "webapp classLoader URLs: " + Arrays . toString ( urls ) ) ; } } } | Setup the webapp pointing to the war file that contains this class . |
16,936 | private void addPiece ( String pc , String prefix , StringBuilder sb ) { if ( ! pc . isEmpty ( ) ) { if ( sb . length ( ) > 0 ) { sb . append ( prefix ) ; } sb . append ( pc ) ; } } | Used to build a connection string for display . |
16,937 | private boolean inBaseField ( String strFieldFileName , String [ ] rgstrClassNames ) { for ( int i = 0 ; i < rgstrClassNames . length - 1 ; i ++ ) { if ( strFieldFileName . equals ( rgstrClassNames [ i ] ) ) return true ; } return false ; } | Is this field in my field list already? |
16,938 | private void scanSharedFields ( ) { if ( ! m_bFirstTime ) return ; m_bFirstTime = false ; m_vFieldList = new Vector < FieldSummary > ( ) ; m_iCurrentIndex = 0 ; String strClassName = m_recClassInfo . getField ( ClassInfo . CLASS_NAME ) . toString ( ) ; m_rgstrClasses = this . getBaseRecordClasses ( strClassName ) ; String strBaseSharedRecord = null ; { FileHdr recFileHdr = new FileHdr ( Record . findRecordOwner ( m_recFileHdr ) ) ; recFileHdr . setKeyArea ( FileHdr . FILE_NAME_KEY ) ; try { for ( int i = 0 ; i < m_rgstrClasses . length ; i ++ ) { recFileHdr . addNew ( ) ; recFileHdr . getField ( FileHdr . FILE_NAME ) . setString ( m_rgstrClasses [ i ] ) ; if ( recFileHdr . seek ( null ) == true ) { strBaseSharedRecord = m_rgstrClasses [ i ] ; break ; } } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { if ( recFileHdr != null ) recFileHdr . free ( ) ; } } for ( int i = 0 ; i < m_rgstrClasses . length ; i ++ ) { this . scanBaseFields ( m_rgstrClasses [ i ] , ( i == m_rgstrClasses . length - 1 ) ) ; if ( m_rgstrClasses [ i ] . equals ( strBaseSharedRecord ) ) break ; } if ( strBaseSharedRecord != null ) this . scanExtendedClasses ( strBaseSharedRecord ) ; if ( strBaseSharedRecord != null ) if ( ! strClassName . equals ( strBaseSharedRecord ) ) { this . scanRecordsFields ( m_rgstrClasses ) ; } } | Build the field list from the concrete and base record classes . |
16,939 | private String [ ] getBaseRecordClasses ( String strClassName ) { ClassInfo recClassInfo = new ClassInfo ( Record . findRecordOwner ( m_recClassInfo ) ) ; String [ ] rgstrClasses = new String [ 0 ] ; Record recFileHdr = new FileHdr ( Record . findRecordOwner ( m_recFileHdr ) ) ; try { String strBaseClass = strClassName ; while ( true ) { recClassInfo . setKeyArea ( ClassInfo . CLASS_NAME_KEY ) ; recClassInfo . getField ( ClassInfo . CLASS_NAME ) . setString ( strBaseClass ) ; if ( ! recClassInfo . seek ( null ) ) break ; if ( "Record" . equalsIgnoreCase ( recClassInfo . getField ( ClassInfo . CLASS_NAME ) . toString ( ) ) ) break ; strClassName = strBaseClass ; strBaseClass = recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . toString ( ) ; String [ ] rgstrClassesTemp = new String [ rgstrClasses . length + 1 ] ; for ( int i = 0 ; i < rgstrClasses . length ; i ++ ) { rgstrClassesTemp [ i + 1 ] = rgstrClasses [ i ] ; } rgstrClassesTemp [ 0 ] = strClassName ; rgstrClasses = rgstrClassesTemp ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recClassInfo . free ( ) ; recFileHdr . free ( ) ; } return rgstrClasses ; } | Get the hierarchy of classes starting with this class name . |
16,940 | private boolean isInRecord ( String [ ] strClassNames , int iClassIndex , String strRecordClass ) { boolean bIsInRecord = false ; for ( int i = 0 ; i <= iClassIndex ; i ++ ) { if ( strClassNames [ i ] . equalsIgnoreCase ( strRecordClass ) ) bIsInRecord = true ; } return bIsInRecord ; } | Is this class one of the base class names for this record? |
16,941 | protected Database databaseForResource ( final TokenProxy < ? , TokenType . Simple > tokenProxy , final Resource resource , final String domain ) throws HodErrorException { final ResourceIdentifier resourceIdentifier = new ResourceIdentifier ( domain , resource . getResource ( ) ) ; final Set < String > parametricFields ; if ( tokenProxy == null ) { parametricFields = indexFieldsService . getParametricFields ( resourceIdentifier ) ; } else { parametricFields = indexFieldsService . getParametricFields ( tokenProxy , resourceIdentifier ) ; } return new Database . Builder ( ) . setName ( resource . getResource ( ) ) . setDisplayName ( resource . getDisplayName ( ) ) . setIsPublic ( ResourceIdentifier . PUBLIC_INDEXES_DOMAIN . equals ( domain ) ) . setDomain ( domain ) . setIndexFields ( parametricFields ) . build ( ) ; } | Converts the given resource name to a database |
16,942 | public void setPTableRef ( PTable pTable , PhysicalDatabaseParent dbOwner ) { m_pTable = pTable ; if ( pTable == null ) if ( dbOwner != null ) { FieldList record = this . getRecord ( ) ; if ( record != null ) { PDatabase pDatabase = dbOwner . getPDatabase ( record . getDatabaseName ( ) , ThinPhysicalDatabase . MEMORY_TYPE , true ) ; pDatabase . addPDatabaseOwner ( this ) ; if ( pDatabase != null ) pTable = pDatabase . getPTable ( record , true ) ; pTable . addPTableOwner ( this ) ; m_pTable = pTable ; } } } | Set the raw data table reference . |
16,943 | public void addState ( final String id , final Collection < Attribute > attributes ) { this . stateMap . put ( id , attributes ) ; } | Binds a set of Attribute values to an identifier . |
16,944 | public Collection < String > getIdentifiers ( ) { List < String > keys = new LinkedList < String > ( ) ; keys . addAll ( this . stateMap . keySet ( ) ) ; return keys ; } | Returns a collection containing the same Identifier Strings as this WorldState object . Modifications to the returned Collection do not impact this WorldState . |
16,945 | public static boolean isBetween ( final Interval timeRange , final Interval timeRangeToCheck ) { return ( ( timeRange . getStart ( ) != null && timeRange . getStart ( ) . isBefore ( timeRangeToCheck . getStart ( ) ) ) && ( timeRange . getEnd ( ) != null && timeRange . getEnd ( ) . isAfter ( timeRangeToCheck . getEnd ( ) ) ) ) ; } | Checks if the given time range is between the given time range to check |
16,946 | public static boolean isOverlappingBefore ( final Interval timeRange , final Interval timeRangeToCheck ) { return ( ( timeRange . getStart ( ) != null && timeRange . getStart ( ) . isAfter ( timeRangeToCheck . getStart ( ) ) ) && ( timeRange . getEnd ( ) != null && timeRange . getEnd ( ) . isAfter ( timeRangeToCheck . getEnd ( ) ) ) ) ; } | Checks if the given time range is overlapping before the given time range to check . |
16,947 | public static boolean isOverlappingAfter ( final Interval timeRange , final Interval timeRangeToCheck ) { return ( ( timeRange . getStart ( ) != null && timeRange . getStart ( ) . isBefore ( timeRangeToCheck . getStart ( ) ) ) && ( timeRange . getEnd ( ) != null && timeRange . getEnd ( ) . isBefore ( timeRangeToCheck . getEnd ( ) ) ) ) ; } | Checks if the given time range is overlapping after the given time range to check . |
16,948 | private Subquery < TopicToBugzillaBug > getOpenBugzillaSubquery ( ) { final CriteriaBuilder criteriaBuilder = getCriteriaBuilder ( ) ; final Subquery < TopicToBugzillaBug > subQuery = getCriteriaQuery ( ) . subquery ( TopicToBugzillaBug . class ) ; final Root < TopicToBugzillaBug > root = subQuery . from ( TopicToBugzillaBug . class ) ; subQuery . select ( root ) ; final Predicate topicIdMatch = criteriaBuilder . equal ( getRootPath ( ) , root . get ( "topic" ) ) ; final Predicate bugOpenMatch = criteriaBuilder . isTrue ( root . get ( "bugzillaBug" ) . get ( "bugzillaBugOpen" ) . as ( Boolean . class ) ) ; subQuery . where ( criteriaBuilder . and ( topicIdMatch , bugOpenMatch ) ) ; return subQuery ; } | Create a Subquery to check if a topic has open bugs . |
16,949 | public static void print ( Collection coll , PrintStream out , String separator ) { out . print ( format ( coll , separator ) ) ; } | Prints a collection to the given output stream . |
16,950 | public String signDataWithBase64 ( byte [ ] data ) throws InvalidKeyException , NoSuchAlgorithmException , NoSuchProviderException , SignatureException { String res = null ; byte [ ] signature = this . signData ( data ) ; res = Base64 . toBase64String ( signature ) ; return res ; } | Generate the signature with the enrollment private key |
16,951 | public String encryptWithBase64 ( byte [ ] data ) throws NoSuchAlgorithmException , NoSuchProviderException , NoSuchPaddingException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException , InvalidAlgorithmParameterException , InvalidCipherTextException , IOException { byte [ ] cipher = encryptBytes ( data ) ; return Base64 . toBase64String ( cipher ) ; } | Encrypt data with TLS certificate and convert cipher to base64 |
16,952 | public String signAndEncrypt ( byte [ ] data ) throws NoSuchAlgorithmException , NoSuchProviderException , NoSuchPaddingException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException , SignatureException , InvalidAlgorithmParameterException , InvalidCipherTextException , IOException { String dataBase64 = Base64 . toBase64String ( data ) ; String signBase64 = signDataWithBase64 ( data ) ; JSONObject json = new JSONObject ( ) ; json . put ( "data" , dataBase64 ) ; json . put ( "signature" , signBase64 ) ; String dataStr = json . toString ( ) ; String cipher = encryptWithBase64 ( dataStr . getBytes ( ) ) ; return cipher ; } | Sign and encrypt data then convert cipher to base64 |
16,953 | public String decryptAndVerify ( byte [ ] data ) throws NoSuchAlgorithmException , NoSuchProviderException , NoSuchPaddingException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException , SignatureException , InvalidAlgorithmParameterException , InvalidCipherTextException , IOException { byte [ ] base64DecodedData = Base64 . decode ( data ) ; byte [ ] decryptedData = decryptBytes ( base64DecodedData ) ; JSONObject json = new JSONObject ( new String ( decryptedData ) ) ; String base64Data = json . getString ( "data" ) ; String base64Sign = json . getString ( "signature" ) ; byte [ ] oriData = Base64 . decode ( base64Data . getBytes ( ) ) ; byte [ ] signature = Base64 . decode ( base64Sign . getBytes ( ) ) ; boolean verifyOK = verifyData ( oriData , signature ) ; if ( ! verifyOK ) { return null ; } return new String ( oriData ) ; } | decrypt and verify signature of data |
16,954 | @ SuppressWarnings ( "unchecked" ) public static < T extends View > T get ( View view , int id ) { SparseArray < View > viewHolder = ( SparseArray < View > ) view . getTag ( ) ; if ( viewHolder == null ) { viewHolder = new SparseArray < View > ( ) ; view . setTag ( viewHolder ) ; } View childView = viewHolder . get ( id ) ; if ( childView == null ) { childView = view . findViewById ( id ) ; viewHolder . put ( id , childView ) ; } return ( T ) childView ; } | I added a generic return type to reduce the casting noise in client code |
16,955 | public static Area getArea ( Location ... locations ) { if ( locations . length == 2 ) { if ( locations [ 0 ] . getLongitude ( ) == 0.0 && locations [ 1 ] . getLongitude ( ) == 0.0 ) { return getPolar ( locations [ 0 ] . getLatitude ( ) , locations [ 1 ] . getLatitude ( ) ) ; } else { throw new IllegalArgumentException ( ) ; } } else { return new ConvexArea ( locations ) ; } } | Returns area limited by given coordinates . Area must be convex . If exactly 2 locations are given the longitudes must be 0 defining polar area limited by latitudes . |
16,956 | public double getMarkedness ( Area node ) { double fsz = node . getFontSize ( ) / avgfont ; double fwt = node . getFontWeight ( ) ; double fst = node . getFontStyle ( ) ; double ind = getIndentation ( node ) ; double cen = isCentered ( node ) ? 1.0 : 0.0 ; double contrast = getContrast ( node ) ; double cp = 1.0 - ca . getColorPercentage ( node ) ; double bcp = bca . getColorPercentage ( node ) ; bcp = ( bcp < 0.0 ) ? 0.0 : ( 1.0 - bcp ) ; double exp = weights [ WFSZ ] * fsz + weights [ WFWT ] * fwt + weights [ WFST ] * fst + weights [ WIND ] * ind + weights [ WCON ] * contrast + weights [ WCEN ] * cen + weights [ WCP ] * cp + weights [ WBCP ] * bcp ; return exp ; } | Computes the markedness of the area . The markedness generally describes the visual importance of the area based on different criteria . |
16,957 | private int isCentered ( Area area , boolean askBefore , boolean askAfter ) { Area parent = area . getParent ( ) ; if ( parent != null ) { int left = area . getX1 ( ) - parent . getX1 ( ) ; int right = parent . getX2 ( ) - area . getX2 ( ) ; int limit = ( int ) ( ( ( left + right ) / 2.0 ) * CENTERING_THRESHOLD ) ; if ( limit == 0 ) limit = 1 ; boolean middle = Math . abs ( left - right ) <= limit ; boolean fullwidth = left == 0 && right == 0 ; if ( ! middle && ! fullwidth ) { return 0 ; } else { Area prev = null ; Area next = null ; int pc = 2 ; int nc = 2 ; if ( askBefore || askAfter ) { if ( askBefore ) { prev = area . getPreviousSibling ( ) ; while ( prev != null && ( pc = isCentered ( prev , true , false ) ) == 2 ) prev = prev . getPreviousSibling ( ) ; } if ( askAfter ) { next = area . getNextSibling ( ) ; while ( next != null && ( nc = isCentered ( next , false , true ) ) == 2 ) next = next . getNextSibling ( ) ; } } if ( pc != 2 || nc != 2 ) { if ( fullwidth ) { if ( pc != 0 && nc != 0 ) return 1 ; else return 0 ; } else { if ( prev != null && lrAligned ( area , prev ) == 1 || next != null && lrAligned ( area , next ) == 1 ) return 0 ; else return 1 ; } } else { if ( fullwidth ) return 2 ; else return ( middle ? 1 : 0 ) ; } } } else return 2 ; } | Tries to guess whether the area is horizontally centered within its parent area |
16,958 | private int lrAligned ( Area a1 , Area a2 ) { if ( a1 . getX1 ( ) == a2 . getX1 ( ) ) return ( a1 . getX2 ( ) == a2 . getX2 ( ) ) ? 2 : 1 ; else if ( a1 . getX2 ( ) == a2 . getX2 ( ) ) return 1 ; else return 0 ; } | Checks if the areas are left - or right - aligned . |
16,959 | private int countAreas ( Area a , Rectangular r ) { int ret = 0 ; for ( int i = 0 ; i < a . getChildCount ( ) ; i ++ ) { Area n = a . getChildAt ( i ) ; if ( a . getTopology ( ) . getPosition ( n ) . intersects ( r ) ) ret ++ ; } return ret ; } | Counts the number of sub - areas in the specified region of the area |
16,960 | public RemoteTable getRemoteTable ( String strRecordName ) throws RemoteException { BaseTransport transport = this . createProxyTransport ( GET_REMOTE_TABLE ) ; transport . addParam ( NAME , strRecordName ) ; String strTableID = ( String ) transport . sendMessageAndGetReply ( ) ; TableProxy tableProxy = ( TableProxy ) this . getChildList ( ) . get ( strTableID ) ; if ( tableProxy == null ) tableProxy = new TableProxy ( this , strTableID ) ; return tableProxy ; } | Get this table for this session . |
16,961 | public int setUserID ( int iChangeType , boolean bDisplayOption ) { int iErrorCode = DBConstants . NORMAL_RETURN ; int iUserID = - 1 ; if ( this . getOwner ( ) . getRecordOwner ( ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) . length ( ) > 0 ) iUserID = Integer . parseInt ( ( ( BaseApplication ) this . getOwner ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) ) ; boolean bOldModified = this . getOwner ( ) . getField ( userIdFieldName ) . isModified ( ) ; boolean [ ] rgbEnabled = null ; if ( iChangeType == DBConstants . INIT_MOVE ) rgbEnabled = this . getOwner ( ) . getField ( userIdFieldName ) . setEnableListeners ( false ) ; iErrorCode = this . getOwner ( ) . getField ( userIdFieldName ) . setValue ( iUserID , bDisplayOption , iChangeType ) ; if ( iChangeType == DBConstants . INIT_MOVE ) { this . getOwner ( ) . getField ( userIdFieldName ) . setEnableListeners ( rgbEnabled ) ; this . getOwner ( ) . getField ( userIdFieldName ) . setModified ( bOldModified ) ; } return iErrorCode ; } | Set the user ID . |
16,962 | public void add ( double rad , double weight ) { sin += Math . sin ( rad ) * weight ; cos += Math . cos ( rad ) * weight ; } | Adds angle in radians with weight |
16,963 | public void getGroups ( String startFrom , boolean forward , Collection < Recipient > result ) { List < String > lst = broker . callRPCList ( "RGUTRPC FILGET" , null , 3.8 , startFrom , forward ? 1 : - 1 , MG_SCREEN , 40 ) ; toRecipients ( lst , true , startFrom , result ) ; } | Returns a bolus of mail groups . |
16,964 | public void getUsers ( String startFrom , boolean forward , Collection < Recipient > result ) { List < String > lst = broker . callRPCList ( "RGCWFUSR LOOKUP" , null , startFrom , forward ? 1 : - 1 , null , null , "A" ) ; toRecipients ( lst , false , startFrom , result ) ; } | Returns a bolus of users . |
16,965 | public void getNotifications ( Patient patient , Collection < Notification > result ) { List < String > lst = null ; result . clear ( ) ; if ( patient == null ) { lst = broker . callRPCList ( "RGCWXQ ALRLIST" , null ) ; } else if ( patient != null ) { lst = broker . callRPCList ( "RGCWXQ ALRLIST" , null , patient . getIdElement ( ) . getIdPart ( ) ) ; } if ( lst != null ) { for ( String item : lst ) { result . add ( new Notification ( item ) ) ; } } } | Returns notifications for the current user . |
16,966 | public boolean deleteNotification ( Notification notification ) { boolean result = notification . canDelete ( ) ; if ( result ) { broker . callRPC ( "RGCWXQ ALRPP" , notification . getAlertId ( ) ) ; } return result ; } | Delete a notification . |
16,967 | public void forwardNotifications ( Collection < Notification > notifications , Collection < Recipient > recipients , String comment ) { List < String > lst1 = new ArrayList < > ( ) ; for ( Notification notification : notifications ) { lst1 . add ( notification . getAlertId ( ) ) ; } List < Long > lst2 = prepareRecipients ( recipients ) ; if ( ! lst1 . isEmpty ( ) && ! lst2 . isEmpty ( ) ) { broker . callRPC ( "RGCWXQ FORWARD" , lst1 , lst2 , comment ) ; } } | Forward multiple notifications . |
16,968 | private List < Long > prepareRecipients ( Collection < Recipient > recipients ) { List < Long > lst = new ArrayList < > ( ) ; for ( Recipient recipient : recipients ) { lst . add ( recipient . getIen ( ) ) ; } return lst ; } | Prepares a recipient list for passing to an RPC . |
16,969 | private void toRecipients ( List < String > recipientData , boolean isGroup , String filter , Collection < Recipient > result ) { result . clear ( ) ; for ( String data : recipientData ) { Recipient recipient = new Recipient ( data , isGroup ) ; if ( StringUtils . startsWithIgnoreCase ( recipient . getName ( ) , filter ) ) { result . add ( recipient ) ; } else { break ; } } } | Creates a list of recipients from a list of raw data . |
16,970 | public List < String > getNotificationMessage ( Notification notification ) { List < String > message = notification . getMessage ( ) ; if ( message == null ) { message = broker . callRPCList ( "RGCWXQ ALRMSG" , null , notification . getAlertId ( ) ) ; notification . setMessage ( message ) ; } return message ; } | Returns the message associated with a notification fetching it from the server if necessary . |
16,971 | public void getScheduledNotifications ( Collection < ScheduledNotification > result ) { List < String > lst = broker . callRPCList ( "RGCWXQ SCHLIST" , null , scheduledPrefix ) ; result . clear ( ) ; for ( String data : lst ) { result . add ( new ScheduledNotification ( data ) ) ; } } | Returns all scheduled notifications for the current user . |
16,972 | public void getScheduledNotificationRecipients ( ScheduledNotification notification , Collection < Recipient > result ) { List < String > lst = broker . callRPCList ( "RGCWXQ SCHRECIP" , null , notification . getIen ( ) ) ; result . clear ( ) ; for ( String data : lst ) { result . add ( new Recipient ( data ) ) ; } } | Returns a list of recipients associated with a scheduled notification . |
16,973 | public List < String > getScheduledNotificationMessage ( ScheduledNotification notification ) { return broker . callRPCList ( "RGCWXQ SCHMSG" , null , notification . getIen ( ) ) ; } | Returns the message associated with a scheduled notification . |
16,974 | public boolean scheduleNotification ( ScheduledNotification notification , List < String > message , Collection < Recipient > recipients ) { if ( notification . getIen ( ) > 0 ) { deleteScheduledNotification ( notification ) ; } String extraInfo = StrUtil . fromList ( Arrays . asList ( notification . getExtraInfo ( ) ) , StrUtil . U ) ; return broker . callRPCBool ( "RGCWXQ SCHALR" , notification . getDeliveryDate ( ) , scheduledPrefix , notification . getSubject ( ) , extraInfo , message , prepareRecipients ( recipients ) ) ; } | Creates a schedule notification . If the notification is replacing an existing one the existing one will be first deleted and a new one created in its place . |
16,975 | protected void addPublicanCommonContentToBook ( final BuildData buildData ) throws BuildProcessingException { final ContentSpec contentSpec = buildData . getContentSpec ( ) ; final String commonContentLocale = buildData . getOutputLocale ( ) ; final String commonContentDirectory = buildData . getBuildOptions ( ) . getCommonContentDirectory ( ) == null ? BuilderConstants . LINUX_PUBLICAN_COMMON_CONTENT : buildData . getBuildOptions ( ) . getCommonContentDirectory ( ) ; final String defaultBrand = buildData . getDocBookVersion ( ) == DocBookVersion . DOCBOOK_50 ? BuilderConstants . DEFAULT_DB50_BRAND : BuilderConstants . DEFAULT_DB45_BRAND ; final String brand = contentSpec . getBrand ( ) == null ? defaultBrand : contentSpec . getBrand ( ) ; final String brandDir = commonContentDirectory + ( commonContentDirectory . endsWith ( "/" ) ? "" : "/" ) + brand + File . separator + commonContentLocale + File . separator ; final String commonBrandDir = commonContentDirectory + ( commonContentDirectory . endsWith ( "/" ) ? "" : "/" ) + BuilderConstants . DEFAULT_DB45_BRAND + File . separator + commonContentLocale + File . separator ; final String commonEnglishBrandDir = commonContentDirectory + ( commonContentDirectory . endsWith ( "/" ) ? "" : "/" ) + BuilderConstants . DEFAULT_DB45_BRAND + File . separator + "en-US" + File . separator ; for ( final String fileName : BuilderConstants . COMMON_CONTENT_FILES ) { final File brandFile = new File ( brandDir + fileName ) ; final String file ; if ( brandFile . exists ( ) && brandFile . isFile ( ) ) { file = FileUtilities . readFileContents ( brandFile ) ; } else { final File commonBrandFile = new File ( commonBrandDir + fileName ) ; if ( commonBrandFile . exists ( ) && commonBrandFile . isFile ( ) ) { file = FileUtilities . readFileContents ( commonBrandFile ) ; } else { final File commonEnglishBrandFile = new File ( commonEnglishBrandDir + fileName ) ; if ( commonEnglishBrandFile . exists ( ) && commonEnglishBrandFile . isFile ( ) ) { file = FileUtilities . readFileContents ( commonEnglishBrandFile ) ; } else { continue ; } } } if ( file != null ) { final String rootElementName ; if ( fileName . equals ( "Program_Listing.xml" ) ) { rootElementName = "programlisting" ; } else if ( fileName . equals ( "Legal_Notice.xml" ) ) { rootElementName = "legalnotice" ; } else { rootElementName = "section" ; } final String entityFileName = "../" + buildData . getEntityFileName ( ) ; final String fixedFile = DocBookBuildUtilities . addDocBookPreamble ( buildData . getDocBookVersion ( ) , file , rootElementName , entityFileName ) ; addToZip ( buildData . getBookLocaleFolder ( ) + "Common_Content/" + fileName , fixedFile , buildData ) ; } } } | Adds the Publican Common_Content files specified by the brand locale and directory location build options . If the Common_Content files don t exist at the directory brand and locale specified then the common brand will be used instead . If the file still don t exist then the files are skipped and will rely on XML XI Include Fallbacks . |
16,976 | private static List < String > resolveFields ( final Iterable < ? extends String > fields ) { final List < String > fieldList = new ArrayList < String > ( ) ; for ( final String field : fields ) { Validate . isTrue ( StringUtils . isNotBlank ( field ) , "One of the specified fields was blank" ) ; fieldList . add ( field . trim ( ) ) ; } return fieldList ; } | Private helper method for setting the field names . It converts colons to underscores and removes any blanks or excess whitespace . Instances are immutable so this method cannot be made public . |
16,977 | private static List < String > resolveValues ( final Iterable < ? extends String > values ) { final List < String > valuesList = new ArrayList < String > ( ) ; for ( final String value : values ) { Validate . notNull ( value , "One of the specified values was null" ) ; valuesList . add ( value ) ; } return valuesList ; } | Private helper method for setting the field values . nulls are not permitted . Instances are immutable so this method cannot be made public . |
16,978 | protected String getValuesString ( ) { final StringBuilder builder = new StringBuilder ( ) ; for ( final String value : values ) { builder . append ( AciURLCodec . getInstance ( ) . encode ( value ) ) . append ( ',' ) ; } if ( builder . length ( ) > 0 ) { builder . deleteCharAt ( builder . length ( ) - 1 ) ; } return builder . toString ( ) ; } | Accessor for the specifier s values . The values are URL encoded and separated by commas . |
16,979 | public Stream < T > headStream ( T key , boolean inclusive , boolean parallel ) { return StreamSupport . stream ( headSpliterator ( key , inclusive ) , parallel ) ; } | Returns stream from start to key |
16,980 | public Stream < T > tailStream ( T key , boolean inclusive , boolean parallel ) { return StreamSupport . stream ( tailSpliterator ( key , inclusive ) , parallel ) ; } | Returns stream from key to end |
16,981 | public Spliterator < T > headSpliterator ( T key , boolean inclusive ) { int point = point ( key , ! inclusive ) ; Iterator < T > iterator = subList ( 0 , point ) . iterator ( ) ; return Spliterators . spliterator ( iterator , size ( ) - point , 0 ) ; } | Returns spliterator from start to key |
16,982 | public Iterator < T > headIterator ( T key , boolean inclusive ) { int point = point ( key , ! inclusive ) ; return subList ( 0 , point ) . iterator ( ) ; } | Returns iterator from start to key |
16,983 | public Iterator < T > tailIterator ( T key , boolean inclusive ) { int point = point ( key , inclusive ) ; return subList ( point , size ( ) ) . iterator ( ) ; } | Returns iterator from key to end |
16,984 | public Object stringToBinary ( String tempString ) throws Exception { java . util . Date dateOld = new java . util . Date ( ( long ) this . getValue ( ) ) ; return DateConverter . stringToBinary ( tempString , dateOld , DBConstants . TIME_ONLY_FORMAT ) ; } | Convert this string to this field s binary data format . |
16,985 | public void contextInitialized ( ServletContextEvent sce ) { ServletContext context = sce . getServletContext ( ) ; String propertiesConfig = context . getInitParameter ( PROPERTIES_CONFIG ) ; if ( propertiesConfig == null ) { propertiesConfig = PROPERTIES_CONFIG_DEFAULT ; } SystemProperties config = loadConfiguration ( propertiesConfig , context ) ; addProperties ( config ) ; if ( config . getFile ( ) != null ) { addPropertiesFromFile ( config , context ) ; } } | Sets properties from the context - param named system . properties . file into System . properties . |
16,986 | private SystemProperties loadConfiguration ( String propertiesConfig , ServletContext context ) throws IllegalStateException { InputStream inStream = null ; try { inStream = getStreamForLocation ( propertiesConfig , context ) ; JAXBContext jaxb = JAXBContext . newInstance ( SystemProperties . class . getPackage ( ) . getName ( ) ) ; return ( SystemProperties ) jaxb . createUnmarshaller ( ) . unmarshal ( inStream ) ; } catch ( FileNotFoundException e ) { throw new IllegalStateException ( "Could not find configuration file: " + propertiesConfig , e ) ; } catch ( JAXBException e ) { throw new IllegalStateException ( "Error while reading file: " + propertiesConfig , e ) ; } finally { if ( inStream != null ) { try { inStream . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } } | Loads and returns the configuration . |
16,987 | private InputStream getStreamForLocation ( final String location , final ServletContext context ) throws FileNotFoundException { String fileLocation = StringUtils . replaceVariables ( location , new HashMap < String , Object > ( ) , true ) ; if ( fileLocation . startsWith ( PREFIX_FILE ) ) { return new FileInputStream ( fileLocation . substring ( PREFIX_FILE . length ( ) ) ) ; } else if ( fileLocation . startsWith ( PREFIX_CLASSPATH ) ) { return getClass ( ) . getResourceAsStream ( fileLocation . substring ( PREFIX_CLASSPATH . length ( ) ) ) ; } else { if ( fileLocation . startsWith ( PREFIX_WAR ) ) { fileLocation = fileLocation . substring ( PREFIX_WAR . length ( ) ) ; } return context . getResourceAsStream ( fileLocation ) ; } } | Returns the InputStream to the supplied file location |
16,988 | private void addProperties ( final SystemProperties config ) { for ( Property property : config . getProperty ( ) ) { String name = property . getName ( ) . trim ( ) ; String value = property . getValue ( ) . trim ( ) ; if ( config . isOverrideProperties ( ) || ( System . getProperty ( name ) == null ) ) { System . setProperty ( name , value ) ; } } } | Adds properties from the configuration to system properties . |
16,989 | private void addPropertiesFromFile ( final SystemProperties config , final ServletContext context ) { String fileLocation = StringUtils . replaceVariables ( config . getFile ( ) , new HashMap < String , Object > ( ) , true ) ; InputStream inStream = null ; try { inStream = getStreamForLocation ( fileLocation , context ) ; Properties propsFromFile = new Properties ( ) ; propsFromFile . load ( inStream ) ; for ( String prop : propsFromFile . stringPropertyNames ( ) ) { String propertyValue = propsFromFile . getProperty ( prop ) ; if ( propertyValue != null && ( config . isOverrideProperties ( ) || ( System . getProperty ( prop ) == null ) ) ) { System . setProperty ( prop , propertyValue ) ; } } } catch ( FileNotFoundException e ) { if ( ! config . isIgnoreMissingFile ( ) ) { throw new IllegalStateException ( "Could not find properties file: " + fileLocation , e ) ; } } catch ( IOException e ) { if ( ! config . isIgnoreMissingFile ( ) ) { throw new IllegalStateException ( "Error occurred when reading properties file: " + fileLocation , e ) ; } } finally { if ( inStream != null ) { try { inStream . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } } | Adds properties from the properties file configured in the configuration object . |
16,990 | public Transformer getTransformer ( HttpServletRequest req , ServletTask servletTask , ScreenModel screen ) throws ServletException , IOException { String stylesheet = null ; if ( stylesheet == null ) stylesheet = req . getParameter ( DBParams . TEMPLATE ) ; if ( stylesheet == null ) if ( screen != null ) if ( screen . getScreenFieldView ( ) != null ) stylesheet = screen . getScreenFieldView ( ) . getStylesheetPath ( ) ; if ( stylesheet == null ) stylesheet = req . getParameter ( "stylesheet" ) ; if ( stylesheet == null ) stylesheet = "org/jbundle/res/docs/styles/xsl/flat/base/menus" ; try { if ( hmTransformers . get ( stylesheet ) != null ) return hmTransformers . get ( stylesheet ) ; String stylesheetFixed = BaseServlet . fixStylesheetPath ( stylesheet , screen , true ) ; InputStream stylesheetStream = this . getFileStream ( servletTask , stylesheetFixed , null ) ; if ( stylesheetStream == null ) { stylesheetFixed = BaseServlet . fixStylesheetPath ( stylesheet , screen , false ) ; stylesheetStream = this . getFileStream ( servletTask , stylesheetFixed , null ) ; } if ( stylesheetStream == null ) Utility . getLogger ( ) . warning ( "XmlFile not found " + stylesheetFixed ) ; StreamSource stylesheetSource = new StreamSource ( stylesheetStream ) ; if ( tFact == null ) tFact = TransformerFactory . newInstance ( ) ; URIResolver resolver = new MyURIResolver ( servletTask , stylesheetFixed ) ; tFact . setURIResolver ( resolver ) ; Transformer transformer = tFact . newTransformer ( stylesheetSource ) ; hmTransformers . put ( stylesheet , transformer ) ; return transformer ; } catch ( TransformerConfigurationException ex ) { ex . printStackTrace ( ) ; } return null ; } | Get or Create a transformer for the specified stylesheet . |
16,991 | public static void sort ( double [ ] data , int rowLength ) { quickSort ( data , 0 , ( data . length - 1 ) / rowLength , rowLength , NATURAL_ROW_COMPARATOR , new double [ rowLength ] , new double [ rowLength ] ) ; } | Sorts rows in 1D array in ascending order comparing each rows column . |
16,992 | public static final < T > boolean contains ( T [ ] array , T item ) { for ( T b : array ) { if ( b . equals ( item ) ) { return true ; } } return false ; } | Returns true if one of arr members equals item |
16,993 | public static final < T > boolean containsOnly ( short [ ] array , T ... items ) { for ( short b : array ) { if ( ! contains ( items , b ) ) { return false ; } } return true ; } | Throws UnsupportedOperationException if one of array members is not one of items |
16,994 | public CatalogMetadataBuilder withTables ( TableMetadata ... tableMetadataList ) { for ( TableMetadata tableMetadata : tableMetadataList ) { tables . put ( tableMetadata . getName ( ) , tableMetadata ) ; } return this ; } | Adds tables to the catalog . |
16,995 | public String getQueueType ( boolean bDefaultIfNone ) { String strQueueType = null ; Record recQueueName = ( ( ReferenceField ) this . getField ( MessageProcessInfo . QUEUE_NAME_ID ) ) . getReference ( ) ; if ( recQueueName != null ) if ( recQueueName . getEditMode ( ) == DBConstants . EDIT_CURRENT ) strQueueType = recQueueName . getField ( QueueName . QUEUE_TYPE ) . toString ( ) ; if ( ( strQueueType == null ) || ( strQueueType . length ( ) == 0 ) ) if ( bDefaultIfNone ) strQueueType = MessageConstants . DEFAULT_QUEUE ; return strQueueType ; } | Get the queue type for this message process . |
16,996 | public boolean setupMessageHeaderFromCode ( Message trxMessage , String strMessageCode , String strVersion ) { TrxMessageHeader trxMessageHeader = ( TrxMessageHeader ) ( ( BaseMessage ) trxMessage ) . getMessageHeader ( ) ; if ( ( trxMessageHeader == null ) && ( strMessageCode == null ) ) return false ; if ( trxMessageHeader == null ) { trxMessageHeader = new TrxMessageHeader ( null , null ) ; ( ( BaseMessage ) trxMessage ) . setMessageHeader ( trxMessageHeader ) ; } if ( strMessageCode == null ) strMessageCode = ( String ) trxMessageHeader . get ( TrxMessageHeader . MESSAGE_CODE ) ; Utility . getLogger ( ) . info ( "Message code: " + strMessageCode ) ; if ( strMessageCode == null ) return false ; MessageProcessInfo recMessageProcessInfo = ( MessageProcessInfo ) this . getMessageProcessInfo ( strMessageCode ) ; if ( recMessageProcessInfo == null ) return false ; MessageInfo recMessageInfo = ( MessageInfo ) ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) ; if ( recMessageInfo == null ) return false ; trxMessageHeader = recMessageInfo . addMessageProperties ( trxMessageHeader ) ; trxMessageHeader = this . addMessageProperties ( trxMessageHeader ) ; trxMessageHeader = this . addTransportProperties ( trxMessageHeader , strVersion ) ; return true ; } | SetupMessageHeaderFromCode Method . |
16,997 | public MessageControl getMessageControl ( ) { if ( m_recMessageControl == null ) { RecordOwner recordOwner = this . findRecordOwner ( ) ; m_recMessageControl = new MessageControl ( recordOwner ) ; if ( recordOwner != null ) recordOwner . removeRecord ( m_recMessageControl ) ; this . addListener ( new FreeOnFreeHandler ( m_recMessageControl ) ) ; } return m_recMessageControl ; } | GetMessageControl Method . |
16,998 | public TrxMessageHeader addMessageProperties ( TrxMessageHeader trxMessageHeader ) { Map < String , Object > mapHeaderMessageInfo = trxMessageHeader . getMessageInfoMap ( ) ; Map < String , Object > propMessageProcessInfo = ( ( PropertiesField ) this . getField ( MessageProcessInfo . PROPERTIES ) ) . loadProperties ( ) ; String strQueueName = this . getQueueName ( false ) ; if ( propMessageProcessInfo . get ( MessageConstants . QUEUE_NAME ) == null ) if ( strQueueName != null ) propMessageProcessInfo . put ( MessageConstants . QUEUE_NAME , strQueueName ) ; String strQueueType = this . getQueueType ( false ) ; if ( propMessageProcessInfo . get ( MessageConstants . QUEUE_TYPE ) == null ) if ( strQueueType != null ) propMessageProcessInfo . put ( MessageConstants . QUEUE_TYPE , strQueueType ) ; if ( ! this . getField ( MessageProcessInfo . REPLY_MESSAGE_PROCESS_INFO_ID ) . isNull ( ) ) propMessageProcessInfo . put ( TrxMessageHeader . MESSAGE_RESPONSE_ID , this . getField ( MessageProcessInfo . REPLY_MESSAGE_PROCESS_INFO_ID ) . toString ( ) ) ; if ( ! this . getField ( MessageProcessInfo . LOCAL_MESSAGE_PROCESS_INFO_ID ) . isNull ( ) ) propMessageProcessInfo . put ( LocalMessageTransport . LOCAL_PROCESSOR , this . getField ( MessageProcessInfo . LOCAL_MESSAGE_PROCESS_INFO_ID ) . toString ( ) ) ; if ( ! this . getField ( MessageProcessInfo . MESSAGE_TYPE_ID ) . isNull ( ) ) { MessageType recMessageType = ( MessageType ) ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_TYPE_ID ) ) . getReference ( ) ; if ( recMessageType != null ) propMessageProcessInfo . put ( TrxMessageHeader . MESSAGE_PROCESS_TYPE , recMessageType . getField ( MessageType . CODE ) . toString ( ) ) ; } if ( ! this . getField ( MessageProcessInfo . PROCESSOR_CLASS ) . isNull ( ) ) propMessageProcessInfo . put ( TrxMessageHeader . MESSAGE_PROCESSOR_CLASS , this . getField ( MessageProcessInfo . PROCESSOR_CLASS ) . toString ( ) ) ; if ( mapHeaderMessageInfo != null ) mapHeaderMessageInfo . putAll ( propMessageProcessInfo ) ; else mapHeaderMessageInfo = propMessageProcessInfo ; if ( mapHeaderMessageInfo . get ( TrxMessageHeader . MESSAGE_PROCESSOR_CLASS ) == null ) this . setDefaultMessageProcessor ( mapHeaderMessageInfo ) ; trxMessageHeader . setMessageInfoMap ( mapHeaderMessageInfo ) ; trxMessageHeader . put ( TrxMessageHeader . MESSAGE_PROCESS_INFO_ID , this . getCounterField ( ) . toString ( ) ) ; String strDescription = this . getField ( MessageProcessInfo . DESCRIPTION ) . toString ( ) ; if ( ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) != null ) if ( ! ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) . getField ( MessageInfo . DESCRIPTION ) . isNull ( ) ) strDescription = ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) . getField ( MessageInfo . DESCRIPTION ) . toString ( ) ; trxMessageHeader . put ( TrxMessageHeader . DESCRIPTION , strDescription ) ; return trxMessageHeader ; } | AddMessageProperties Method . |
16,999 | public void setDefaultMessageProcessor ( Map < String , Object > mapHeaderMessageInfo ) { if ( mapHeaderMessageInfo . get ( TrxMessageHeader . MESSAGE_PROCESSOR_CLASS ) == null ) { String strMessageInfoTypeCode = ( String ) mapHeaderMessageInfo . get ( TrxMessageHeader . MESSAGE_INFO_TYPE ) ; String strMessageProcessTypeCode = ( String ) mapHeaderMessageInfo . get ( TrxMessageHeader . MESSAGE_PROCESS_TYPE ) ; if ( ( strMessageInfoTypeCode != null ) && ( strMessageProcessTypeCode != null ) ) { String strProcessorClass = null ; if ( ( MessageInfoType . REQUEST . equals ( strMessageInfoTypeCode ) ) && ( MessageType . MESSAGE_OUT . equals ( strMessageProcessTypeCode ) ) ) strProcessorClass = BaseMessageOutProcessor . class . getName ( ) ; else if ( ( MessageInfoType . REQUEST . equals ( strMessageInfoTypeCode ) ) && ( MessageType . MESSAGE_IN . equals ( strMessageProcessTypeCode ) ) ) strProcessorClass = BaseMessageInProcessor . class . getName ( ) ; else if ( ( MessageInfoType . REPLY . equals ( strMessageInfoTypeCode ) ) && ( MessageType . MESSAGE_OUT . equals ( strMessageProcessTypeCode ) ) ) strProcessorClass = BaseMessageReplyOutProcessor . class . getName ( ) ; if ( ( MessageInfoType . REPLY . equals ( strMessageInfoTypeCode ) ) && ( MessageType . MESSAGE_IN . equals ( strMessageProcessTypeCode ) ) ) strProcessorClass = BaseMessageReplyInProcessor . class . getName ( ) ; if ( strProcessorClass != null ) mapHeaderMessageInfo . put ( TrxMessageHeader . MESSAGE_PROCESSOR_CLASS , strProcessorClass ) ; } } } | et the default processor if one is not specified . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.