idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
15,700
public String getRemoteClassName ( ) { String strClassName = Appointment . class . getName ( ) . toString ( ) ; int iThinPos = strClassName . indexOf ( "thin." ) ; return strClassName . substring ( 0 , iThinPos ) + strClassName . substring ( iThinPos + 5 ) ; }
Get the name of the remote class .
15,701
public Date setEndDate ( Date time ) { try { this . getTable ( ) . edit ( ) ; this . getField ( "EndDateTime" ) . setData ( time ) ; this . getTable ( ) . set ( this ) ; this . getTable ( ) . seek ( null ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return this . getEndDate ( ) ; }
Change the ending time of this service .
15,702
public List < String > getSourceUrls ( boolean useInherited ) { List < String > temp = new ArrayList < String > ( ) ; if ( useInherited && parent != null ) { if ( parent instanceof ContentSpec ) { temp = ( ( ContentSpec ) parent ) . getBaseLevel ( ) . getSourceUrls ( true ) ; } else if ( parent instanceof KeyValueNode ) { temp = ( ( KeyValueNode ) parent ) . getParent ( ) . getBaseLevel ( ) . getSourceUrls ( true ) ; } else { temp = ( ( SpecNode ) parent ) . getSourceUrls ( true ) ; } } if ( sourceUrls != null ) { temp . addAll ( sourceUrls ) ; } return temp ; }
Get the Source Urls for a node and also checks to make sure the url hasn t already been inherited
15,703
public static < R extends Resource , X > ResourcePredicate < R > distinctFilter ( FunctionWithThrowable < R , X , IOException > function ) { final Map < X , Boolean > seen = Maps . newConcurrentMap ( ) ; return resource -> seen . putIfAbsent ( function . apply ( resource ) , Boolean . TRUE ) == null ; }
A predicate to filter out already seen resources by function .
15,704
public RemoteLockSession getRemoteLockSession ( SessionInfo sessionInfo ) { if ( m_lockServer == null ) { Application app = ( Application ) ( ( Environment ) m_owner ) . getDefaultApplication ( ) ; if ( m_gbRemoteTaskServer ) { String strServer = app . getAppServerName ( ) ; String strRemoteApp = DBParams . DEFAULT_REMOTE_LOCK ; String strUserID = null ; String strPassword = null ; m_lockServer = ( RemoteTask ) app . createRemoteTask ( strServer , strRemoteApp , strUserID , strPassword ) ; } if ( m_lockServer == null ) { m_gbRemoteTaskServer = false ; try { m_lockServer = new org . jbundle . base . remote . db . TaskSession ( app ) ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; } } } RemoteLockSession remoteLockSession = ( RemoteLockSession ) sessionInfo . m_remoteLockSession ; if ( remoteLockSession == null ) { try { if ( m_gbRemoteTaskServer ) { remoteLockSession = ( RemoteLockSession ) m_lockServer . makeRemoteSession ( LockSession . class . getName ( ) ) ; } else { remoteLockSession = new LockSession ( ( org . jbundle . base . remote . db . TaskSession ) m_lockServer ) ; } sessionInfo . m_remoteLockSession = remoteLockSession ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; } } return remoteLockSession ; }
Get the remote lock server .
15,705
public void setInputEncoding ( String inputEncoding ) { this . log ( "Setting input encoding to " + inputEncoding , LogLevel . DEBUG . getLevel ( ) ) ; this . inputEncoding = inputEncoding ; }
Optional . Sets the file encoding to be used when reading the input files . Defaults to the system file encoding .
15,706
public void setOutputEncoding ( String outputEncoding ) { this . log ( "Setting output encoding to " + outputEncoding , LogLevel . DEBUG . getLevel ( ) ) ; this . outputEncoding = outputEncoding ; }
Optional . Set the file encoding of the generated files . Defaults to the system file encoding .
15,707
public void setStylesheet ( FileResource stylesheet ) { this . log ( "Setting custom stylesheet " + stylesheet . toString ( ) , LogLevel . DEBUG . getLevel ( ) ) ; this . stylesheet = stylesheet ; }
Optional . Set a custom stylesheet to be used
15,708
public float addValue ( final float value ) { long now = System . currentTimeMillis ( ) ; if ( now - this . last_time > this . ageGap ) { this . reset ( ) ; } this . last_time = now ; if ( this . sizeHistory < this . maxHistory ) { this . sum += value ; this . sum_squares += Math . pow ( value , 2 ) ; ++ this . sizeHistory ; } else { Float oldest_val = this . history . poll ( ) ; if ( oldest_val != null ) { this . sum = this . sum - oldest_val . floatValue ( ) + value ; this . sum_squares = this . sum_squares - ( float ) Math . pow ( oldest_val . floatValue ( ) , 2 ) + ( float ) Math . pow ( value , 2 ) ; } else { log . warn ( "Could not poll history to update variance." ) ; } } this . history . offer ( Float . valueOf ( value ) ) ; float degrees_of_freedom = this . sizeHistory - 1 ; if ( degrees_of_freedom < 1.0 ) { return 0f ; } this . currentVariance = ( this . sum_squares - ( ( float ) Math . pow ( this . sum , 2 ) / this . sizeHistory ) ) / degrees_of_freedom ; return this . currentVariance ; }
Adds a value to this variance . If the time between the previous addition and this addition exceeds the age gap for this object then the variance will be reset to 0 before this value is added .
15,709
public void dumpTo ( AreaTree tree , PrintWriter out ) { if ( produceHeader ) out . println ( "<?xml version=\"1.0\"?>" ) ; out . println ( "<areaTree base=\"" + HTMLEntities ( tree . getRoot ( ) . getPage ( ) . getSourceURL ( ) . toString ( ) ) + "\">" ) ; recursiveDump ( tree . getRoot ( ) , 1 , out ) ; out . println ( "</areaTree>" ) ; }
Formats the complete tag tree to an output stream
15,710
public static String buildReportTable ( final List < TopicErrorData > topicErrorDatas , final String tableTitle , final boolean showEditorLink , final ZanataDetails zanataDetails ) { final List < String > tableHeaders = CollectionUtilities . toArrayList ( new String [ ] { "Topic Link" , "Topic Title" , "Topic Tags" } ) ; final List < List < String > > rows = new ArrayList < List < String > > ( ) ; for ( final TopicErrorData topicErrorData : topicErrorDatas ) { final BaseTopicWrapper < ? > topic = topicErrorData . getTopic ( ) ; final List < String > topicTitles ; if ( topic instanceof TranslatedTopicWrapper ) { final TranslatedTopicWrapper translatedTopic = ( TranslatedTopicWrapper ) topic ; if ( ! EntityUtilities . isDummyTopic ( translatedTopic ) && translatedTopic . getTopic ( ) != null ) { topicTitles = CollectionUtilities . toArrayList ( DocBookUtilities . wrapInListItem ( DocBookUtilities . wrapInPara ( "[" + translatedTopic . getTopic ( ) . getLocale ( ) . getValue ( ) + "] " + translatedTopic . getTopic ( ) . getTitle ( ) ) ) , DocBookUtilities . wrapInListItem ( DocBookUtilities . wrapInPara ( "[" + translatedTopic . getLocale ( ) . getValue ( ) + "] " + translatedTopic . getTitle ( ) ) ) ) ; } else { topicTitles = CollectionUtilities . toArrayList ( DocBookUtilities . wrapInListItem ( DocBookUtilities . wrapInPara ( topic . getTitle ( ) ) ) ) ; } } else { topicTitles = CollectionUtilities . toArrayList ( DocBookUtilities . wrapInListItem ( DocBookUtilities . wrapInPara ( topic . getTitle ( ) ) ) ) ; } final String topicULink = createTopicTableLinks ( topic , showEditorLink , zanataDetails ) ; final String topicTitle = DocBookUtilities . wrapListItems ( topicTitles ) ; final String topicTags = buildItemizedTopicTagList ( topic ) ; rows . add ( CollectionUtilities . toArrayList ( new String [ ] { topicULink , topicTitle , topicTags } ) ) ; } return rows . size ( ) > 0 ? DocBookUtilities . wrapInTable ( tableTitle , tableHeaders , rows ) : "" ; }
Builds a Table to be used within a report . The table contains a link to the topic in Skynet the topic Title and the list of tags for the topic .
15,711
public static String isbn ( ) { StringBuffer stringBuffer = new StringBuffer ( "09" ) ; stringBuffer . append ( String . format ( "%06d" , JDefaultNumber . randomIntBetweenTwoNumbers ( 0 , 49999 ) ) ) ; stringBuffer . append ( String . format ( "%02d" , JDefaultNumber . randomIntBetweenTwoNumbers ( 0 , 99 ) ) ) ; String numberString = stringBuffer . toString ( ) ; int number = Integer . parseInt ( numberString ) ; int sum = 0 ; for ( int i = 2 ; i <= 10 ; i ++ ) { int digit = number % 10 ; sum = sum + i * digit ; number = number / 10 ; } String checkDigit = null ; if ( sum % 11 == 1 ) { checkDigit = "X" ; } else if ( sum % 11 == 0 ) { checkDigit = "0" ; } else { checkDigit = ( 11 - ( sum % 11 ) ) + "" ; } String returnString = stringBuffer . toString ( ) ; returnString = returnString . substring ( 0 , 1 ) + "-" + returnString . substring ( 1 , 7 ) + "-" + returnString . substring ( 7 , 9 ) + "-" + checkDigit ; return returnString ; }
Generates an English Language Publisher Code in the range of 0 - 900000 - xx - x to 0 - 949999 - xx - x
15,712
protected void checkAndAddListInjections ( final BuildData buildData , final Document doc , final ITopicNode topicNode , final Map < String , TranslationDetails > translations ) { final DocBookXMLPreProcessor preProcessor = buildData . getXMLPreProcessor ( ) ; final List < Integer > types = Arrays . asList ( DocBookXMLPreProcessor . ORDEREDLIST_INJECTION_POINT , DocBookXMLPreProcessor . ITEMIZEDLIST_INJECTION_POINT , DocBookXMLPreProcessor . LIST_INJECTION_POINT ) ; final HashMap < org . w3c . dom . Node , InjectionListData > customInjections = new HashMap < org . w3c . dom . Node , InjectionListData > ( ) ; preProcessor . collectInjectionData ( buildData . getContentSpec ( ) , topicNode , new ArrayList < String > ( ) , doc , buildData . getBuildDatabase ( ) , new ArrayList < String > ( ) , customInjections , buildData . isUseFixedUrls ( ) , types ) ; for ( final org . w3c . dom . Node customInjectionCommentNode : customInjections . keySet ( ) ) { final InjectionListData injectionListData = customInjections . get ( customInjectionCommentNode ) ; if ( injectionListData . listItems . size ( ) != 0 ) { for ( final List < Element > elements : injectionListData . listItems ) { final Element para = doc . createElement ( "para" ) ; for ( final Element element : elements ) { para . appendChild ( element ) ; } final String translationString = XMLUtilities . convertNodeToString ( para , false ) ; translations . put ( translationString , new TranslationDetails ( translationString , false , "para" ) ) ; } } } }
Checks to see if any list injections have been used and if so adds the translation xrefs .
15,713
protected String formatTranslationString ( POBuildData buildData , final String translationString ) { try { final Document doc = TopicUtilities . convertXMLStringToDocument ( "<temp>" + translationString + "</temp>" , buildData . getDocBookVersion ( ) . getId ( ) ) ; return XMLUtilities . convertNodeToString ( doc . getDocumentElement ( ) , false ) ; } catch ( Exception e ) { return translationString ; } }
Formats a string so that it will be compatible with publicans expectations .
15,714
protected void processPOTopicInjections ( final POBuildData buildData , final SpecTopic specTopic , final Map < String , TranslationDetails > translations ) { addStringsFromTopicRelationships ( buildData , specTopic . getPrerequisiteRelationships ( ) , DocBookXMLPreProcessor . PREREQUISITE_PROPERTY , DocBookXMLPreProcessor . ROLE_PREREQUISITE , translations ) ; addStringsFromTopicRelationships ( buildData , specTopic . getRelatedRelationships ( ) , DocBookXMLPreProcessor . SEE_ALSO_PROPERTY , DocBookXMLPreProcessor . ROLE_SEE_ALSO , translations ) ; addStringsFromTopicRelationships ( buildData , specTopic . getLinkListRelationships ( ) , null , DocBookXMLPreProcessor . ROLE_LINK_LIST , translations ) ; final List < Relationship > prevRelationships = specTopic . getPreviousRelationships ( ) ; if ( prevRelationships . size ( ) > 1 ) { addStringsFromProcessRelationships ( buildData , specTopic , prevRelationships , DocBookXMLPreProcessor . PREVIOUS_STEPS_PROPERTY , DocBookXMLPreProcessor . ROLE_PROCESS_PREVIOUS_LINK , DocBookXMLPreProcessor . ROLE_PROCESS_PREVIOUS_TITLE_LINK , translations ) ; } else { addStringsFromProcessRelationships ( buildData , specTopic , prevRelationships , DocBookXMLPreProcessor . PREVIOUS_STEP_PROPERTY , DocBookXMLPreProcessor . ROLE_PROCESS_PREVIOUS_LINK , DocBookXMLPreProcessor . ROLE_PROCESS_PREVIOUS_TITLE_LINK , translations ) ; } final List < Relationship > nextRelationships = specTopic . getNextRelationships ( ) ; if ( nextRelationships . size ( ) > 1 ) { addStringsFromProcessRelationships ( buildData , specTopic , nextRelationships , DocBookXMLPreProcessor . NEXT_STEPS_PROPERTY , DocBookXMLPreProcessor . ROLE_PROCESS_NEXT_LINK , DocBookXMLPreProcessor . ROLE_PROCESS_NEXT_TITLE_LINK , translations ) ; } else { addStringsFromProcessRelationships ( buildData , specTopic , nextRelationships , DocBookXMLPreProcessor . NEXT_STEP_PROPERTY , DocBookXMLPreProcessor . ROLE_PROCESS_NEXT_LINK , DocBookXMLPreProcessor . ROLE_PROCESS_NEXT_TITLE_LINK , translations ) ; } }
Process a spec topic and add any translation strings for it .
15,715
protected void addStringsFromTopicRelationships ( final POBuildData buildData , final List < Relationship > relationships , final String key , final String roleName , final Map < String , TranslationDetails > translations ) { if ( ! relationships . isEmpty ( ) ) { if ( key != null ) { addStringsForConstant ( buildData , key , "title" , translations ) ; } addStringsFromRelationships ( buildData , relationships , roleName , translations ) ; } }
Add the translation strings from a list of relationships for a specific topic .
15,716
protected void addStringsFromProcessRelationships ( final POBuildData buildData , final SpecTopic specTopic , final List < Relationship > relationships , final String key , final String roleName , final String titleRoleName , final Map < String , TranslationDetails > translations ) { if ( ! relationships . isEmpty ( ) ) { if ( key != null ) { final boolean useFixedUrls = buildData . isUseFixedUrls ( ) ; final Level container = ( Level ) specTopic . getParent ( ) ; String translatedTitle = container . getTitle ( ) ; boolean fuzzy = true ; if ( buildData . getTranslationMap ( ) . containsKey ( "CS" + buildData . getContentSpec ( ) . getId ( ) ) ) { final Map < String , TranslationDetails > containerTranslations = buildData . getTranslationMap ( ) . get ( "CS" + buildData . getContentSpec ( ) . getId ( ) ) ; if ( containerTranslations . containsKey ( container . getTitle ( ) ) ) { final TranslationDetails translationDetails = containerTranslations . get ( container . getTitle ( ) ) ; translatedTitle = translationDetails . getTranslation ( ) ; if ( translatedTitle != null ) { fuzzy = translationDetails . isFuzzy ( ) ; } } } final String titleLinkId = ( ( Level ) specTopic . getParent ( ) ) . getUniqueLinkId ( useFixedUrls ) ; final String originalTitleLink = DocBookUtilities . buildLink ( titleLinkId , titleRoleName , container . getTitle ( ) ) ; final String originalString = buildData . getConstants ( ) . getString ( key ) ; final String translationString = buildData . getTranslationConstants ( ) . getString ( key ) ; final String fixedOriginalString = String . format ( originalString , originalTitleLink ) ; if ( ! originalString . equals ( translationString ) ) { final String translatedTitleLink = DocBookUtilities . buildLink ( titleLinkId , titleRoleName , translatedTitle ) ; final String fixedTranslationString = String . format ( translationString , translatedTitleLink ) ; translations . put ( fixedOriginalString , new TranslationDetails ( fixedTranslationString , fuzzy , "title" ) ) ; } else { translations . put ( fixedOriginalString , new TranslationDetails ( null , fuzzy , "title" ) ) ; } } addStringsFromRelationships ( buildData , relationships , roleName , translations ) ; } }
Add the translation strings from a list of relationships for a specific topic in a process .
15,717
protected void addStringsFromRelationships ( final BuildData buildData , final List < Relationship > relationships , final String roleName , final Map < String , TranslationDetails > translations ) { final boolean useFixedUrls = buildData . isUseFixedUrls ( ) ; for ( final Relationship relationship : relationships ) { final SpecNode relatedNode ; if ( relationship instanceof TopicRelationship ) { relatedNode = ( ( TopicRelationship ) relationship ) . getSecondaryRelationship ( ) ; } else { relatedNode = ( ( TargetRelationship ) relationship ) . getSecondaryRelationship ( ) ; } final String xrefString = DocBookUtilities . buildXRef ( relatedNode . getUniqueLinkId ( useFixedUrls ) , roleName ) ; translations . put ( xrefString , new TranslationDetails ( xrefString , false , "para" ) ) ; } }
Add the translation strings from a list of relationships .
15,718
protected void processPOTopicBugLink ( final POBuildData buildData , final SpecTopic specTopic , final Map < String , TranslationDetails > translations ) throws BuildProcessingException { try { final DocBookXMLPreProcessor preProcessor = buildData . getXMLPreProcessor ( ) ; final String bugLinkUrl = preProcessor . getBugLinkUrl ( buildData , specTopic ) ; processPOBugLinks ( buildData , preProcessor , bugLinkUrl , translations ) ; } catch ( BugLinkException e ) { throw new BuildProcessingException ( e ) ; } catch ( Exception e ) { throw new BuildProcessingException ( "Failed to insert Bug Links into the DOM Document" , e ) ; } }
Add any bug link strings for a specific topic .
15,719
protected void processPOInitialContentBugLink ( final POBuildData buildData , final InitialContent initialContent , final Map < String , TranslationDetails > translations ) throws BuildProcessingException { try { final DocBookXMLPreProcessor preProcessor = buildData . getXMLPreProcessor ( ) ; final String bugLinkUrl = preProcessor . getBugLinkUrl ( buildData , initialContent ) ; processPOBugLinks ( buildData , preProcessor , bugLinkUrl , translations ) ; } catch ( BugLinkException e ) { throw new BuildProcessingException ( e ) ; } catch ( Exception e ) { throw new BuildProcessingException ( "Failed to insert Bug Links into the DOM Document" , e ) ; } }
Add any bug link strings for a specific initial content container .
15,720
protected void processPOBugLinks ( final POBuildData buildData , final DocBookXMLPreProcessor preProcessor , final String bugLinkUrl , final Map < String , TranslationDetails > translations ) { final String originalString = buildData . getConstants ( ) . getString ( "REPORT_A_BUG" ) ; final String translationString = buildData . getTranslationConstants ( ) . getString ( "REPORT_A_BUG" ) ; final String originalLink = preProcessor . createExternalLinkElement ( buildData . getDocBookVersion ( ) , originalString , bugLinkUrl ) ; if ( originalString . equals ( translationString ) ) { translations . put ( originalLink , new TranslationDetails ( null , false , "para" ) ) ; } else { final String translatedLink = preProcessor . createExternalLinkElement ( buildData . getDocBookVersion ( ) , translationString , bugLinkUrl ) ; translations . put ( originalLink , new TranslationDetails ( translatedLink , false , "para" ) ) ; } }
Creates the strings for a specific bug link url .
15,721
protected StringBuilder createBasePOFile ( final BuildData buildData ) { final String formattedDate = POT_DATE_FORMAT . format ( buildData . getBuildDate ( ) ) ; return new StringBuilder ( "# \n" ) . append ( "# AUTHOR <EMAIL@ADDRESS>, YEAR.\n" ) . append ( "#\n" ) . append ( "msgid \"\"\n" ) . append ( "msgstr \"\"\n" ) . append ( "\"Project-Id-Version: 0\\n\"\n" ) . append ( "\"POT-Creation-Date: " ) . append ( formattedDate ) . append ( "\\n\"\n" ) . append ( "\"PO-Revision-Date: " ) . append ( formattedDate ) . append ( "\\n\"\n" ) . append ( "\"Last-Translator: Automatically generated\\n\"\n" ) . append ( "\"Language-Team: None\\n\"\n" ) . append ( "\"MIME-Version: 1.0\\n\"\n" ) . append ( "\"Content-Type: application/x-pressgang-ccms; charset=" ) . append ( ENCODING ) . append ( "\\n\"\n" ) . append ( "\"Content-Transfer-Encoding: 8bit\\n\"\n" ) ; }
Create the base initial content required for all PO and POT files .
15,722
protected void addPOTEntry ( final String tag , final String source , final StringBuilder potFile ) { addPOEntry ( tag , source , "" , false , potFile ) ; }
Add an entry to a POT file .
15,723
protected void addPOEntry ( final String tag , final String source , final String translation , final boolean fuzzy , final StringBuilder poFile ) { if ( source == null || source . length ( ) == 0 ) return ; poFile . append ( "\n" ) ; if ( ! isNullOrEmpty ( tag ) ) { poFile . append ( "#. Tag: " ) . append ( tag ) . append ( "\n" ) ; } if ( fuzzy ) { poFile . append ( "#, fuzzy\n" ) ; } poFile . append ( "#, no-c-format\n" ) . append ( "msgid \"" ) . append ( escapeForPOFile ( source , true ) ) . append ( "\"\n" ) . append ( "msgstr \"" ) . append ( escapeForPOFile ( translation , false ) ) . append ( "\"\n" ) ; }
Add an entry to a PO file .
15,724
@ SuppressWarnings ( "PMD.UnnecessaryLocalBeforeReturn" ) < T > T putIfAbsent ( final Key < T > key , final Provider < T > valueComputer ) throws InterruptedException , ExecutionException { Preconditions . checkArgument ( key != null , "Key must not be null!" ) ; Future < ? > oldValue = contents . get ( key ) ; if ( oldValue != null ) { @ SuppressWarnings ( "unchecked" ) T value = ( T ) oldValue . get ( ) ; return value ; } FutureTask < T > task = new FutureTask < > ( new Callable < T > ( ) { public T call ( ) throws Exception { T value = valueComputer . get ( ) ; if ( value instanceof ScopeListener ) { final ScopeListener listener = ( ScopeListener ) value ; listeners . add ( listener ) ; listener . event ( ScopeEvent . ENTER ) ; } return value ; } } ) ; Future < ? > existingTask = contents . putIfAbsent ( key , task ) ; if ( existingTask == null ) { task . run ( ) ; return task . get ( ) ; } else { @ SuppressWarnings ( "unchecked" ) T newValue = ( T ) existingTask . get ( ) ; return newValue ; } }
Compute and enter a value into the context unless the value has already been computed .
15,725
public boolean includeThis ( ClassProjectModel . CodeType codeType , boolean hasAnInterface ) { int scope = ( int ) ( this . getValue ( ) + 0.5 ) ; int target = 0 ; if ( codeType == ClassProjectModel . CodeType . THICK ) target = LogicFile . INCLUDE_THICK ; if ( codeType == ClassProjectModel . CodeType . THIN ) target = LogicFile . INCLUDE_THIN ; if ( codeType == ClassProjectModel . CodeType . INTERFACE ) target = LogicFile . INCLUDE_INTERFACE ; if ( ( hasAnInterface ) && ( ( scope & LogicFile . INCLUDE_INTERFACE ) != 0 ) && ( codeType != ClassProjectModel . CodeType . INTERFACE ) ) return false ; if ( ( ! hasAnInterface ) && ( scope == LogicFile . INCLUDE_INTERFACE ) && ( codeType == ClassProjectModel . CodeType . THICK ) ) return true ; return ( ( target & scope ) != 0 ) ; }
IncludeThis Method .
15,726
public < T > EntityResponse < List < T > > getWithListResult ( Class < T > entityClass , String path , Map < String , String > params , Map < String , String > headers ) throws IOException , RESTException { HttpGet httpGet = buildHttpGet ( path , params ) ; return parseListEntityResponse ( entityClass , getHttpResponse ( httpGet , headers ) ) ; }
Performs GET request while expected response entity is a list of specified type .
15,727
public < T > EntityResponse < List < T > > postWithListResult ( Class < T > entityClass , String path , Object payload , Map < String , String > headers ) throws IOException , RESTException { return postWithListResultInternal ( entityClass , payload , new HttpPost ( baseUrl + path ) , headers ) ; }
Performs POST request while expected response entity is a list of specified type .
15,728
public < T > EntityResponse < List < T > > deleteWithListResult ( Class < T > entityClass , String path , Map < String , String > headers ) throws IOException , RESTException { return parseListEntityResponse ( entityClass , getHttpResponse ( new HttpDelete ( baseUrl + path ) , headers ) ) ; }
Performs DELETE request while expected response entity is a list of specified type .
15,729
public void setId ( final String id ) { if ( id . matches ( CSConstants . EXISTING_TOPIC_ID_REGEX ) ) { DBId = Integer . parseInt ( id ) ; } this . id = id ; }
Set the ID for the Content Specification Topic .
15,730
public List < TopicRelationship > getTopicRelationships ( ) { ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( topicRelationships ) ; for ( final TargetRelationship relationship : topicTargetRelationships ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } return relationships ; }
Gets the list of Topic to Topic relationships .
15,731
public List < TargetRelationship > getTargetRelationships ( ) { final List < TargetRelationship > relationships = new ArrayList < TargetRelationship > ( levelRelationships ) ; relationships . addAll ( topicTargetRelationships ) ; return relationships ; }
Gets the list of Target relationships .
15,732
public List < TopicRelationship > getRelatedTopicRelationships ( ) { final ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( ) ; for ( final TopicRelationship relationship : topicRelationships ) { if ( relationship . getType ( ) == RelationshipType . REFER_TO ) { relationships . add ( relationship ) ; } } for ( final TargetRelationship relationship : topicTargetRelationships ) { if ( relationship . getType ( ) == RelationshipType . REFER_TO ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } } return relationships ; }
Gets the list of Topic Relationships for this topic whose type is RELATED .
15,733
public List < TargetRelationship > getRelatedLevelRelationships ( ) { final ArrayList < TargetRelationship > relationships = new ArrayList < TargetRelationship > ( ) ; for ( final TargetRelationship relationship : levelRelationships ) { if ( relationship . getType ( ) == RelationshipType . REFER_TO ) { relationships . add ( relationship ) ; } } return relationships ; }
Gets the list of Level Relationships for this topic whose type is RELATED .
15,734
public List < TopicRelationship > getPrerequisiteTopicRelationships ( ) { final ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( ) ; for ( final TopicRelationship relationship : topicRelationships ) { if ( relationship . getType ( ) == RelationshipType . PREREQUISITE ) { relationships . add ( relationship ) ; } } for ( final TargetRelationship relationship : topicTargetRelationships ) { if ( relationship . getType ( ) == RelationshipType . PREREQUISITE ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } } return relationships ; }
Gets the list of Topic Relationships for this topic whose type is PREREQUISITE .
15,735
public List < TargetRelationship > getPrerequisiteLevelRelationships ( ) { final ArrayList < TargetRelationship > relationships = new ArrayList < TargetRelationship > ( ) ; for ( final TargetRelationship relationship : levelRelationships ) { if ( relationship . getType ( ) == RelationshipType . PREREQUISITE ) { relationships . add ( relationship ) ; } } return relationships ; }
Gets the list of Level Relationships for this topic whose type is PREREQUISITE .
15,736
public List < TopicRelationship > getLinkListTopicRelationships ( ) { final ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( ) ; for ( final TopicRelationship relationship : topicRelationships ) { if ( relationship . getType ( ) == RelationshipType . LINKLIST ) { relationships . add ( relationship ) ; } } for ( final TargetRelationship relationship : topicTargetRelationships ) { if ( relationship . getType ( ) == RelationshipType . LINKLIST ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } } return relationships ; }
Gets the list of Topic Relationships for this topic whose type is LINKLIST .
15,737
public List < TargetRelationship > getLinkListLevelRelationships ( ) { final ArrayList < TargetRelationship > relationships = new ArrayList < TargetRelationship > ( ) ; for ( final TargetRelationship relationship : levelRelationships ) { if ( relationship . getType ( ) == RelationshipType . LINKLIST ) { relationships . add ( relationship ) ; } } return relationships ; }
Gets the list of Level Relationships for this topic whose type is LINKLIST .
15,738
public List < TopicRelationship > getNextTopicRelationships ( ) { ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( ) ; for ( TopicRelationship relationship : topicRelationships ) { if ( relationship . getType ( ) == RelationshipType . NEXT ) { relationships . add ( relationship ) ; } } for ( TargetRelationship relationship : topicTargetRelationships ) { if ( relationship . getType ( ) == RelationshipType . NEXT ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } } return relationships ; }
Gets the list of Topic Relationships for this topic whose type is NEXT .
15,739
public List < TopicRelationship > getPrevTopicRelationships ( ) { ArrayList < TopicRelationship > relationships = new ArrayList < TopicRelationship > ( ) ; for ( TopicRelationship relationship : topicRelationships ) { if ( relationship . getType ( ) == RelationshipType . PREVIOUS ) { relationships . add ( relationship ) ; } } for ( TargetRelationship relationship : topicTargetRelationships ) { if ( relationship . getType ( ) == RelationshipType . PREVIOUS ) { relationships . add ( new TopicRelationship ( relationship . getPrimaryRelationship ( ) , ( SpecTopic ) relationship . getSecondaryRelationship ( ) , relationship . getType ( ) ) ) ; } } return relationships ; }
Gets the list of Topic Relationships for this topic whose type is PREVIOUS .
15,740
public SpecTopic getClosestTopic ( final SpecTopic topic , final boolean checkParentNode ) { if ( this == topic || getId ( ) . equals ( topic . getId ( ) ) ) return this ; if ( getParent ( ) != null ) { if ( getParent ( ) instanceof Level ) { return ( ( Level ) getParent ( ) ) . getClosestTopic ( topic , checkParentNode ) ; } else if ( getParent ( ) instanceof KeyValueNode ) { return ( ( KeyValueNode ) getParent ( ) ) . getParent ( ) . getBaseLevel ( ) . getClosestTopic ( topic , checkParentNode ) ; } } return null ; }
Finds the closest node in the contents of a level
15,741
private void add ( FieldFilter filter ) { switch ( operator ) { case NOT : filters . add ( new NegationFieldFilter ( filter ) ) ; operator = Operator . NONE ; break ; case OR : filters . set ( filters . size ( ) - 1 , new OrFieldFilter ( filters . get ( filters . size ( ) - 1 ) , filter ) ) ; operator = Operator . NONE ; break ; default : filters . add ( filter ) ; break ; } }
Adds a filter and applies the current operator .
15,742
public FieldFilterBuilder isDefault ( ) { add ( new NegationFieldFilter ( new ModifierFieldFilter ( Modifier . PUBLIC & Modifier . PROTECTED & Modifier . PRIVATE ) ) ) ; return this ; }
Filter fields with default access .
15,743
public FieldFilter build ( ) throws IllegalStateException { if ( filters . isEmpty ( ) ) { throw new IllegalStateException ( "No field filters configured!" ) ; } if ( filters . size ( ) == 1 ) { return filters . get ( 0 ) ; } FieldFilter [ ] fieldFilters = new FieldFilter [ filters . size ( ) ] ; filters . toArray ( fieldFilters ) ; return new FieldFilterList ( fieldFilters ) ; }
Build and returns a FieldFilter .
15,744
public < T > T asObject ( String string , Class < T > valueType ) throws IllegalArgumentException { int dashIndex = string . indexOf ( '-' ) ; if ( dashIndex == - 1 ) { throw new IllegalArgumentException ( String . format ( "Cannot convert |%s| to locale instance." , string ) ) ; } return ( T ) new Locale ( string . substring ( 0 , dashIndex ) , string . substring ( dashIndex + 1 ) ) ; }
Create locale instance from ISO - 639 language and ISO - 3166 country code for example en - US .
15,745
public String asString ( Object object ) { Locale locale = ( Locale ) object ; StringBuilder builder = new StringBuilder ( 5 ) ; builder . append ( locale . getLanguage ( ) ) ; builder . append ( '-' ) ; builder . append ( locale . getCountry ( ) ) ; return builder . toString ( ) ; }
Return locale instance ISO - 639 language and ISO - 3166 country code for example en - US .
15,746
public RPMBuilder setPreInstallation ( String script , String interpreter ) { addString ( RPMTAG_PREIN , script ) ; addString ( RPMTAG_PREINPROG , interpreter ) ; ensureBinSh ( ) ; return this ; }
Set RPMTAG_PREIN and RPMTAG_PREINPROG
15,747
public RPMBuilder setPostInstallation ( String script , String interpreter ) { addString ( RPMTAG_POSTIN , script ) ; addString ( RPMTAG_POSTINPROG , interpreter ) ; ensureBinSh ( ) ; return this ; }
Set RPMTAG_POSTIN and RPMTAG_POSTINPROG
15,748
public RPMBuilder setPreUnInstallation ( String script , String interpreter ) { addString ( RPMTAG_PREUN , script ) ; addString ( RPMTAG_PREUNPROG , interpreter ) ; ensureBinSh ( ) ; return this ; }
Set RPMTAG_PREUN and RPMTAG_PREUNPROG
15,749
public RPMBuilder setPostUnInstallation ( String script , String interpreter ) { addString ( RPMTAG_POSTUN , script ) ; addString ( RPMTAG_POSTUNPROG , interpreter ) ; ensureBinSh ( ) ; return this ; }
Set RPMTAG_POSTUN and RPMTAG_POSTUNPROG
15,750
public RPMBuilder addProvide ( String name , String version , Condition ... dependency ) { addString ( RPMTAG_PROVIDENAME , name ) ; addString ( RPMTAG_PROVIDEVERSION , version ) ; addInt32 ( RPMTAG_PROVIDEFLAGS , Dependency . or ( dependency ) ) ; ensureVersionReq ( version ) ; return this ; }
Add RPMTAG_PROVIDENAME RPMTAG_PROVIDEVERSION and RPMTAG_PROVIDEFLAGS
15,751
public RPMBuilder addRequire ( String name , String version , Condition ... dependency ) { addString ( RPMTAG_REQUIRENAME , name ) ; addString ( RPMTAG_REQUIREVERSION , version ) ; addInt32 ( RPMTAG_REQUIREFLAGS , Dependency . or ( dependency ) ) ; ensureVersionReq ( version ) ; return this ; }
Add RPMTAG_REQUIRENAME RPMTAG_REQUIREVERSION and RPMTAG_REQUIREFLAGS
15,752
public RPMBuilder addConflict ( String name , String version , Condition ... dependency ) { addString ( RPMTAG_CONFLICTNAME , name ) ; addString ( RPMTAG_CONFLICTVERSION , version ) ; addInt32 ( RPMTAG_CONFLICTFLAGS , Dependency . or ( dependency ) ) ; ensureVersionReq ( version ) ; return this ; }
Add RPMTAG_CONFLICTNAME RPMTAG_CONFLICTVERSION and RPMTAG_CONFLICTFLAGS
15,753
public FileBuilder addFile ( Path source , Path target ) throws IOException { checkTarget ( target ) ; FileBuilder fb = new FileBuilder ( ) ; fb . target = target ; fb . size = ( int ) Files . size ( source ) ; try ( FileChannel fc = FileChannel . open ( source , READ ) ) { fb . content = fc . map ( FileChannel . MapMode . READ_ONLY , 0 , fb . size ) ; } FileTime fileTime = Files . getLastModifiedTime ( source ) ; fb . time = ( int ) fileTime . to ( TimeUnit . SECONDS ) ; fb . compressFilename ( ) ; fileBuilders . add ( fb ) ; return fb ; }
Add file to package from path .
15,754
public FileBuilder addFile ( ByteBuffer content , Path target ) throws IOException { checkTarget ( target ) ; FileBuilder fb = new FileBuilder ( ) ; fb . content = content ; fb . target = target ; fb . size = content . limit ( ) ; fb . compressFilename ( ) ; fileBuilders . add ( fb ) ; return fb ; }
Add file to package from content
15,755
public Path build ( Path dir ) throws IOException { String name = getName ( ) ; lead = new Lead ( name ) ; addProvide ( getString ( RPMTAG_NAME ) , getString ( RPMTAG_VERSION ) , Condition . EQUAL ) ; addRequireInt ( "rpmlib(CompressedFileNames)" , "3.0.4-1" , Dependency . EQUAL , Dependency . LESS , Dependency . RPMLIB ) ; addInt32 ( RPMTAG_SIZE , getInt32Array ( RPMTAG_FILESIZES ) . stream ( ) . collect ( Collectors . summingInt ( ( i ) -> i ) ) ) ; CPIO cpio = new CPIO ( ) ; cpio . namesize = 11 ; fileRecords . add ( new FileRecord ( cpio , "TRAILER!!!" , ByteBuffer . allocate ( 0 ) ) ) ; ByteBuffer hdr = DynamicByteBuffer . create ( Integer . MAX_VALUE ) ; hdr . order ( ByteOrder . BIG_ENDIAN ) ; header . save ( hdr ) ; hdr . flip ( ) ; ByteBuffer payload = DynamicByteBuffer . create ( Integer . MAX_VALUE ) ; payload . order ( ByteOrder . BIG_ENDIAN ) ; try ( final FilterByteBuffer fbb = new FilterByteBuffer ( payload , null , GZIPOutputStream :: new ) ) { for ( FileRecord fr : fileRecords ) { fr . save ( fbb ) ; } } payload . flip ( ) ; MessageDigest md5 ; try { md5 = MessageDigest . getInstance ( "MD5" ) ; } catch ( NoSuchAlgorithmException ex ) { throw new IOException ( ex ) ; } ByteBuffer dupHdr = hdr . duplicate ( ) ; md5 . update ( dupHdr ) ; ByteBuffer dupPayload = payload . duplicate ( ) ; md5 . update ( dupPayload ) ; byte [ ] digest = md5 . digest ( ) ; setBin ( RPMSIGTAG_MD5 , digest ) ; addInt32 ( RPMSIGTAG_SIZE , hdr . limit ( ) + payload . limit ( ) ) ; checkRequiredTags ( ) ; ByteBuffer rpm = DynamicByteBuffer . create ( Integer . MAX_VALUE ) ; rpm . order ( ByteOrder . BIG_ENDIAN ) ; lead . save ( rpm ) ; signature . save ( rpm ) ; align ( rpm , 8 ) ; rpm . put ( hdr ) ; rpm . put ( payload ) ; rpm . flip ( ) ; Path path = dir . resolve ( "lsb-" + name + ".rpm" ) ; try ( final FileChannel fc = FileChannel . open ( path , StandardOpenOption . READ , StandardOpenOption . WRITE , StandardOpenOption . CREATE , StandardOpenOption . TRUNCATE_EXISTING ) ) { fc . write ( rpm ) ; } return path ; }
Creates RPM file in dir . Returns Path of created file .
15,756
public int doSetData ( Object data , boolean bDisplayOption , int iMoveMode ) { int iErrorCode = DBConstants . NORMAL_RETURN ; if ( data != null ) { iErrorCode = this . getFieldCopy ( ) . setData ( data , DBConstants . DONT_DISPLAY , DBConstants . READ_MOVE ) ; if ( iErrorCode != DBConstants . NORMAL_RETURN ) return iErrorCode ; if ( ! this . getFieldCopy ( ) . equals ( this . getOwner ( ) ) ) { double dValue = ( ( NumberField ) this . getFieldCopy ( ) ) . getValue ( ) ; Task task = null ; BaseApplication application = null ; if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) != null ) task = this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) ; if ( task != null ) application = ( BaseApplication ) task . getApplication ( ) ; if ( m_dStartRange != Double . MIN_VALUE ) if ( dValue < m_dStartRange ) return task . setLastError ( MessageFormat . format ( application . getResources ( ResourceConstants . ERROR_RESOURCE , true ) . getString ( TOO_SMALL ) , m_dStartRange ) ) ; if ( m_dEndRange != Double . MAX_VALUE ) if ( dValue > m_dEndRange ) return task . setLastError ( MessageFormat . format ( application . getResources ( ResourceConstants . ERROR_RESOURCE , true ) . getString ( TOO_LARGE ) , m_dEndRange ) ) ; } } return super . doSetData ( data , bDisplayOption , iMoveMode ) ; }
Move the physical binary data to this field . If this value is out of range return an error .
15,757
public void setString ( String string ) { m_StaticString = string ; if ( this . getScreenFieldView ( ) . getControl ( ) != null ) this . getScreenFieldView ( ) . setComponentState ( this . getScreenFieldView ( ) . getControl ( ) , string ) ; }
Set the static string for this label .
15,758
public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { boolean bFlag = this . compareFieldToString ( ) ; if ( m_bDisableIfMatch ) bFlag = ! bFlag ; m_fldToDisable . setEnabled ( bFlag ) ; return DBConstants . NORMAL_RETURN ; }
The Field has Changed . If the target string matches this field disable the target field .
15,759
public void collect ( Path file ) throws IOException { Path targetPath = tempDir . resolve ( projectRoot . relativize ( file ) ) ; Files . createDirectories ( targetPath . getParent ( ) ) ; Files . copy ( file , targetPath ) ; }
Add the given file to the data archive
15,760
public void add ( String file , String contents ) throws IOException { FileUtils . writeStringToFile ( tempDir . resolve ( file ) . toFile ( ) , contents ) ; }
Create new file in the data archive
15,761
public File createArchive ( ) throws IOException , ZipException { File tmpFile = File . createTempFile ( "dw-data" , ".zip" ) ; try { tmpFile . delete ( ) ; ZipFile zipFile = new ZipFile ( tmpFile . getAbsoluteFile ( ) ) ; ZipParameters parameters = new ZipParameters ( ) ; parameters . setCompressionLevel ( Zip4jConstants . DEFLATE_LEVEL_ULTRA ) ; parameters . setIncludeRootFolder ( false ) ; zipFile . addFolder ( tempDir . toFile ( ) , parameters ) ; } finally { dispose ( ) ; } return tmpFile ; }
Creates archive containing collected data
15,762
public static final Stream < String > lines ( InputStream is , Charset cs ) { return StreamSupport . stream ( new StringSplitIterator ( is , cs ) , false ) ; }
Reads InputStream as stream of lines . Line separator is \ n while \ r is simply ignored .
15,763
public static final byte [ ] readAllBytes ( InputStream is ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte [ ] buf = new byte [ 4096 ] ; int rc = is . read ( buf ) ; while ( rc != - 1 ) { baos . write ( buf , 0 , rc ) ; rc = is . read ( buf ) ; } return baos . toByteArray ( ) ; }
Read all bytes from InputStream and returns them as byte array . InputStream is not closed after call .
15,764
public static final BufferedInputStream buffer ( InputStream is ) { if ( is instanceof BufferedInputStream ) { return ( BufferedInputStream ) is ; } else { return new BufferedInputStream ( is ) ; } }
Wraps InputStream with BufferedInputStream if is is not BufferedInputStream . If it is returns is .
15,765
public static final void copyResource ( String source , Path target , Class < ? > cls ) throws IOException { try ( InputStream is = cls . getResourceAsStream ( source ) ) { Files . copy ( is , target , REPLACE_EXISTING ) ; } }
Copies class resource to path
15,766
public static final void setTimes ( FileTime lastModifiedTime , FileTime lastAccessTime , FileTime createTime , Path ... files ) throws IOException { for ( Path file : files ) { BasicFileAttributeView view = Files . getFileAttributeView ( file , BasicFileAttributeView . class ) ; view . setTimes ( lastModifiedTime , lastAccessTime , createTime ) ; } }
Set files times . Non null times are changed .
15,767
public Node loadContent ( final Session session , final URL contentDef ) { final SAXParserFactory factory = this . getSAXParserFactory ( ) ; try { factory . setFeature ( "http://apache.org/xml/features/disallow-doctype-decl" , true ) ; final SAXParser parser = factory . newSAXParser ( ) ; final InputSource source = new InputSource ( contentDef . openStream ( ) ) ; final XMLContentHandler handler = new XMLContentHandler ( session ) ; parser . parse ( source , handler ) ; return handler . getRootNode ( ) ; } catch ( ParserConfigurationException | SAXException | IOException e ) { throw new AssertionError ( "Loading Content to JCR Repository failed" , e ) ; } }
Loads the content from the specified contentDefinition into the JCRRepository using the specified session .
15,768
public static < E extends Comparable < E > > void sortDescending ( List < E > list ) { int index = 0 ; E value = null ; for ( int i = 1 ; i < list . size ( ) ; i ++ ) { index = i ; value = list . remove ( index ) ; while ( index > 0 && value . compareTo ( list . get ( index - 1 ) ) > 0 ) { list . add ( index , list . get ( index - 1 ) ) ; index -- ; } list . add ( index , value ) ; } }
Sort the list in descending order using this algorithm . The run time of this algorithm depends on the implementation of the list since it has elements added and removed from it .
15,769
public static void sortDescending ( byte [ ] byteArray ) { int index = 0 ; byte value = 0 ; for ( int i = 1 ; i < byteArray . length ; i ++ ) { index = i ; value = byteArray [ index ] ; while ( index > 0 && value > byteArray [ index - 1 ] ) { byteArray [ index ] = byteArray [ index - 1 ] ; index -- ; } byteArray [ index ] = value ; } }
Sort the byte array in descending order using this algorithm .
15,770
public static void sortDescending ( char [ ] charArray ) { int index = 0 ; char value = 0 ; for ( int i = 1 ; i < charArray . length ; i ++ ) { index = i ; value = charArray [ index ] ; while ( index > 0 && value > charArray [ index - 1 ] ) { charArray [ index ] = charArray [ index - 1 ] ; index -- ; } charArray [ index ] = value ; } }
Sort the char array in descending order using this algorithm .
15,771
public static void sortDescending ( double [ ] doubleArray ) { int index = 0 ; double value = 0 ; for ( int i = 1 ; i < doubleArray . length ; i ++ ) { index = i ; value = doubleArray [ index ] ; while ( index > 0 && value > doubleArray [ index - 1 ] ) { doubleArray [ index ] = doubleArray [ index - 1 ] ; index -- ; } doubleArray [ index ] = value ; } }
Sort the double array in descending order using this algorithm .
15,772
public static void sortDescending ( float [ ] floatArray ) { int index = 0 ; float value = 0 ; for ( int i = 1 ; i < floatArray . length ; i ++ ) { index = i ; value = floatArray [ index ] ; while ( index > 0 && value > floatArray [ index - 1 ] ) { floatArray [ index ] = floatArray [ index - 1 ] ; index -- ; } floatArray [ index ] = value ; } }
Sort the float array in descending order using this algorithm .
15,773
public static void sortDescending ( long [ ] longArray ) { int index = 0 ; long value = 0 ; for ( int i = 1 ; i < longArray . length ; i ++ ) { index = i ; value = longArray [ index ] ; while ( index > 0 && value > longArray [ index - 1 ] ) { longArray [ index ] = longArray [ index - 1 ] ; index -- ; } longArray [ index ] = value ; } }
Sort the long array in descending order using this algorithm .
15,774
public static void sortDescending ( short [ ] shortArray ) { int index = 0 ; short value = 0 ; for ( int i = 1 ; i < shortArray . length ; i ++ ) { index = i ; value = shortArray [ index ] ; while ( index > 0 && value > shortArray [ index - 1 ] ) { shortArray [ index ] = shortArray [ index - 1 ] ; index -- ; } shortArray [ index ] = value ; } }
Sort the short array in descending order using this algorithm .
15,775
public static Timecode valueOf ( String timecode ) throws IllegalArgumentException { Timecode tc = new Timecode ( ) ; return ( Timecode ) tc . parse ( timecode ) ; }
Returns a Timecode instance for given Timecode storage string . Will return an invalid timecode in case the storage string represents an invalid Timecode
15,776
public static < T > void forEach ( final Iterable < T > iterable , final Consumer < ? super T > consumer ) { checkNotNull ( iterable , "forEach must have a valid iterable" ) ; checkNotNull ( consumer , "forEach must have a valid consumer" ) ; for ( T t : iterable ) { consumer . accept ( t ) ; } }
Accept a consumer for each element of an iterable .
15,777
public static < T , R > R reduce ( final Iterable < T > iterable , final R initial , final BiFunction < R , ? super T , R > accumulator ) { checkNotNull ( iterable , "reduce must have a non null iterable" ) ; checkNotNull ( accumulator , "reduce must have a non null function" ) ; R returnValue = initial ; for ( T r : iterable ) { returnValue = accumulator . apply ( returnValue , r ) ; } return returnValue ; }
Perform a reduction of an iterable using an initial value and a two argument function . The function is applied to each element using the last result as the first argument and the element as the second .
15,778
public static < T > Optional < T > find ( final Iterable < ? extends T > iterable , final Predicate < ? super T > predicate ) { checkNotNull ( iterable , "iterable may not be null" ) ; checkNotNull ( predicate , "the predicate may not be null" ) ; for ( T t : iterable ) { if ( predicate . test ( t ) ) { return of ( t ) ; } } return Optional . empty ( ) ; }
Apply a predicate to an iterable returning an optional of the first element where the predicate is true or empty if no true is found .
15,779
public static < T > boolean any ( final Iterable < T > iterable , final Predicate < ? super T > predicate ) { return find ( iterable , predicate ) . isPresent ( ) ; }
Determine if any element of an iterable matches a given predicate .
15,780
public static < F , T > Iterable < T > map ( final Iterable < F > fromIterable , final Function < ? super F , ? extends T > function ) { checkNotNull ( fromIterable , "iterable must be non null" ) ; checkNotNull ( function , "map function must be non null" ) ; return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { final Iterator < F > fromIterator = fromIterable . iterator ( ) ; return new ImmutableIterator < T > ( ) { public boolean hasNext ( ) { return fromIterator . hasNext ( ) ; } public T next ( ) { return function . apply ( fromIterator . next ( ) ) ; } } ; } } ; }
Create an iterable that maps an existing iterable to a new one by applying a function to each of it s elements .
15,781
public static < T > Iterable < T > filter ( final Iterable < T > fromIterable , final Predicate < ? super T > predicate ) { checkNotNull ( fromIterable , "iterable must be non null" ) ; checkNotNull ( predicate , "predicate must be non null" ) ; return new SupplierIterable < T > ( new Supplier < Optional < T > > ( ) { private final Iterator < T > fromIterator = fromIterable . iterator ( ) ; public Optional < T > get ( ) { while ( fromIterator . hasNext ( ) ) { final T value = fromIterator . next ( ) ; if ( predicate . test ( value ) ) { return of ( value ) ; } } return Optional . empty ( ) ; } } ) ; }
Create an iterable that filters an existing iterable based on a predicate .
15,782
public static < E > Iterable < E > iterable ( final Enumeration < E > enumeration ) { checkNotNull ( enumeration , "Can not create an Iterable from a null enumeration" ) ; return new Iterable < E > ( ) { public Iterator < E > iterator ( ) { return new ImmutableIterator < E > ( ) { public boolean hasNext ( ) { return enumeration . hasMoreElements ( ) ; } public E next ( ) { return enumeration . nextElement ( ) ; } } ; } } ; }
Convert an enumeration to an iterator .
15,783
public static < E > Optional < E > get ( final Iterable < E > iterable , final int position ) { checkNotNull ( iterable , "Get requires an iterable" ) ; if ( position < 0 ) { return Optional . empty ( ) ; } int iterablePosition = 0 ; for ( E anIterable : iterable ) { if ( iterablePosition == position ) { return of ( anIterable ) ; } iterablePosition ++ ; } return Optional . empty ( ) ; }
Return an optional of an element from a specified position in an iterable . If the position is out of bounds an empty optional is returned . Positions start at 0 .
15,784
public static < E > Optional < E > last ( final Iterable < E > iterable ) { checkNotNull ( iterable , "last requires a non null iterable" ) ; final Iterator < E > iterator = iterable . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return Optional . empty ( ) ; } E lastElement ; do { lastElement = iterator . next ( ) ; } while ( iterator . hasNext ( ) ) ; return Optional . of ( lastElement ) ; }
Return the last element of an iterable or empty if the iterable is empty .
15,785
public static String ipV4Address ( ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( JDefaultNumber . randomIntBetweenTwoNumbers ( 2 , 254 ) + "" ) ; sb . append ( "." ) ; sb . append ( JDefaultNumber . randomIntBetweenTwoNumbers ( 2 , 254 ) + "" ) ; sb . append ( "." ) ; sb . append ( JDefaultNumber . randomIntBetweenTwoNumbers ( 2 , 254 ) + "" ) ; sb . append ( "." ) ; sb . append ( JDefaultNumber . randomIntBetweenTwoNumbers ( 2 , 254 ) + "" ) ; return sb . toString ( ) ; }
generates a random IPv4 ip address like 192 . 168 . 2 . 100
15,786
public static String userName ( ) { return fixNonWord ( StringUtils . left ( JDefaultName . firstName ( ) , 1 ) . toLowerCase ( ) + JDefaultName . lastName ( ) . toLowerCase ( ) + JDefaultNumber . randomNumberString ( 2 ) ) ; }
generates a random username in the format of Firstname intial + lastname + random 2 digit ie tjones67
15,787
public CloseableHttpClient NewHttpClient ( ) throws Exception { SSLContext sslcontext = SSLContexts . custom ( ) . loadTrustMaterial ( null , new TrustSelfSignedStrategy ( ) ) . build ( ) ; SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory ( sslcontext ) ; this . httpclient = HttpClients . custom ( ) . setSSLSocketFactory ( sslsf ) . build ( ) ; return this . httpclient ; }
create http client
15,788
public boolean hasNext ( ) { try { if ( ! this . parseNextLine ( ) ) { try { m_record . addNew ( ) ; } catch ( DBException e ) { e . printStackTrace ( ) ; } m_record . close ( ) ; m_reader . close ( ) ; return false ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } return true ; }
HasNext Method .
15,789
private void flushCharactersBuffer ( ) throws IOException { if ( charactersBuffer . position ( ) > 0 ) { writer . write ( charactersBuffer . array ( ) , 0 , charactersBuffer . position ( ) ) ; charactersBuffer . rewind ( ) ; } }
Flush characters buffer to underlying writer .
15,790
public int setFieldState ( Object objValue , boolean bDisplayOption , int iMoveMode ) { if ( this . getScreenField ( ) . getConverter ( ) == null ) return DBConstants . NORMAL_RETURN ; if ( ! ( objValue instanceof String ) ) return this . getScreenField ( ) . getConverter ( ) . setData ( objValue , bDisplayOption , iMoveMode ) ; else return this . getScreenField ( ) . getConverter ( ) . setString ( ( String ) objValue , bDisplayOption , iMoveMode ) ; }
Set the field to this state . State is defined by the component .
15,791
public static char getFirstToUpper ( String string , char chDefault ) { if ( ( string != null ) && ( string . length ( ) > 0 ) ) chDefault = Character . toUpperCase ( string . charAt ( 0 ) ) ; return chDefault ; }
Return the first char of this string converted to upper case .
15,792
public Record getMainRecord ( ) { if ( this . getScreenField ( ) instanceof BasePanel ) return ( ( BasePanel ) this . getScreenField ( ) ) . getMainRecord ( ) ; else return this . getScreenField ( ) . getParentScreen ( ) . getMainRecord ( ) ; }
Convenience method to get the model s main record .
15,793
public void init ( BaseDatabase database , Record record ) { super . init ( database , record ) ; m_iRow = - 1 ; m_iEOFRow = Integer . MAX_VALUE ; m_iLastOrder = - 1 ; }
Init this table .
15,794
public void close ( ) { super . close ( ) ; try { if ( this . lockOnDBTrxType ( null , DBConstants . AFTER_REFRESH_TYPE , false ) ) this . unlockIfLocked ( this . getRecord ( ) , null ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } try { if ( m_seekResultSet != null ) m_seekResultSet . close ( ) ; m_seekResultSet = null ; if ( m_selectResultSet != null ) m_selectResultSet . close ( ) ; m_selectResultSet = null ; if ( m_autoSequenceResultSet != null ) m_autoSequenceResultSet . close ( ) ; m_autoSequenceResultSet = null ; if ( m_queryStatement != null ) m_queryStatement . close ( ) ; m_queryStatement = null ; if ( m_updateStatement != null ) m_updateStatement . close ( ) ; m_updateStatement = null ; if ( m_seekStatement != null ) m_seekStatement . close ( ) ; m_seekStatement = null ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } m_iRow = - 1 ; m_iEOFRow = Integer . MAX_VALUE ; m_strStmtLastSQL = null ; m_strLastSQL = null ; m_strStmtLastSeekSQL = null ; }
Close this table .
15,795
public String getLastSQLStatement ( int iType ) { switch ( iType ) { case DBConstants . SQL_UPDATE_TYPE : case DBConstants . SQL_INSERT_TABLE_TYPE : case DBConstants . SQL_DELETE_TYPE : return m_strLastSQL ; case DBConstants . SQL_AUTOSEQUENCE_TYPE : case DBConstants . SQL_SEEK_TYPE : if ( ! SHARE_STATEMENTS ) return m_strStmtLastSeekSQL ; case DBConstants . SQL_SELECT_TYPE : case DBConstants . SQL_CREATE_TYPE : default : return m_strStmtLastSQL ; } }
Get the last SQL string for this statement type
15,796
public void setResultSet ( ResultSet resultSet , int iType ) { if ( this . getResultSet ( iType ) != null ) { try { this . getResultSet ( iType ) . close ( ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } } switch ( iType ) { case DBConstants . SQL_SEEK_TYPE : if ( ! SHARE_STATEMENTS ) { m_seekResultSet = resultSet ; break ; } case DBConstants . SQL_SELECT_TYPE : case DBConstants . SQL_CREATE_TYPE : m_selectResultSet = resultSet ; break ; case DBConstants . SQL_AUTOSEQUENCE_TYPE : m_autoSequenceResultSet = resultSet ; break ; case DBConstants . SQL_UPDATE_TYPE : case DBConstants . SQL_INSERT_TABLE_TYPE : case DBConstants . SQL_DELETE_TYPE : default : break ; } m_iResultSetType = iType ; if ( iType == DBConstants . SQL_SELECT_TYPE ) { m_iRow = - 1 ; m_iEOFRow = Integer . MAX_VALUE ; } }
Set the ResultSet for this select or seek statement type .
15,797
public int readNextToTarget ( int iTargetPosition , int iRelPosition ) throws DBException { int iRecordStatus = DBConstants . RECORD_NORMAL ; boolean bMore = true ; ResultSet resultSet = ( ResultSet ) this . getResultSet ( ) ; while ( m_iRow < iTargetPosition ) { try { bMore = resultSet . next ( ) ; if ( ! bMore ) { m_iEOFRow = m_iRow ; break ; } m_iRow ++ ; } catch ( SQLException e ) { DBException dbEx = this . getDatabase ( ) . convertError ( e ) ; int iErrorCode = dbEx . getErrorCode ( ) ; if ( ( iRelPosition == DBConstants . FIRST_RECORD ) || ( ( iRelPosition == DBConstants . LAST_RECORD ) ) ) if ( iErrorCode == DBConstants . INVALID_RECORD ) return ( DBConstants . RECORD_INVALID | DBConstants . RECORD_AT_BOF | DBConstants . RECORD_AT_EOF ) ; throw dbEx ; } } if ( ( m_iRow == - 1 ) || ( iTargetPosition == - 1 ) ) iRecordStatus |= DBConstants . RECORD_INVALID | DBConstants . RECORD_AT_BOF ; if ( ! bMore ) { iRecordStatus |= DBConstants . RECORD_AT_EOF ; int iEOFRow = m_iEOFRow ; this . setResultSet ( null , DBConstants . SQL_SELECT_TYPE ) ; m_iEOFRow = iEOFRow ; } return iRecordStatus ; }
Read next until you get to this position .
15,798
public MDecimal getKPa ( ) { MDecimal result = new MDecimal ( currentUnit . getConverterTo ( KILO ( PASCAL ) ) . convert ( doubleValue ( ) ) ) ; logger . trace ( MMarker . GETTER , "Converting from {} to Kilo Pascals : {}" , currentUnit , result ) ; return result ; }
get Kilo Pascals
15,799
public MDecimal getMMHg ( ) { MDecimal result = new MDecimal ( currentUnit . getConverterTo ( MILLIMETER_OF_MERCURY ) . convert ( doubleValue ( ) ) ) ; logger . trace ( MMarker . GETTER , "Converting from {} to millimetres of Mecrcury : {}" , currentUnit , result ) ; return result ; }
get millimetres Mercury