idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
20,800
public void writeStartObject ( String name ) throws IOException { writeComma ( ) ; writeNewLineIndent ( ) ; if ( name != null ) { writeName ( name ) ; writeNewLineIndent ( ) ; } m_writer . write ( "{" ) ; increaseIndent ( ) ; }
Begin writing a named object attribute .
20,801
public void writeStartList ( String name ) throws IOException { writeComma ( ) ; writeNewLineIndent ( ) ; writeName ( name ) ; writeNewLineIndent ( ) ; m_writer . write ( "[" ) ; increaseIndent ( ) ; }
Begin writing a named list attribute .
20,802
public void writeNameValuePair ( String name , String value ) throws IOException { internalWriteNameValuePair ( name , escapeString ( value ) ) ; }
Write a string attribute .
20,803
public void writeNameValuePair ( String name , int value ) throws IOException { internalWriteNameValuePair ( name , Integer . toString ( value ) ) ; }
Write an int attribute .
20,804
public void writeNameValuePair ( String name , long value ) throws IOException { internalWriteNameValuePair ( name , Long . toString ( value ) ) ; }
Write a long attribute .
20,805
public void writeNameValuePair ( String name , double value ) throws IOException { internalWriteNameValuePair ( name , Double . toString ( value ) ) ; }
Write a double attribute .
20,806
public void writeNameValuePair ( String name , Date value ) throws IOException { internalWriteNameValuePair ( name , m_format . format ( value ) ) ; }
Write a Date attribute .
20,807
private void internalWriteNameValuePair ( String name , String value ) throws IOException { writeComma ( ) ; writeNewLineIndent ( ) ; writeName ( name ) ; if ( m_pretty ) { m_writer . write ( ' ' ) ; } m_writer . write ( value ) ; }
Core write attribute implementation .
20,808
private String escapeString ( String value ) { m_buffer . setLength ( 0 ) ; m_buffer . append ( '"' ) ; for ( int index = 0 ; index < value . length ( ) ; index ++ ) { char c = value . charAt ( index ) ; switch ( c ) { case '"' : { m_buffer . append ( "\\\"" ) ; break ; } case '\\' : { m_buffer . append ( "\\\\" ) ; br...
Escape text to ensure valid JSON .
20,809
private void writeComma ( ) throws IOException { if ( m_firstNameValuePair . peek ( ) . booleanValue ( ) ) { m_firstNameValuePair . pop ( ) ; m_firstNameValuePair . push ( Boolean . FALSE ) ; } else { m_writer . write ( ',' ) ; } }
Write a comma to the output stream if required .
20,810
private void writeNewLineIndent ( ) throws IOException { if ( m_pretty ) { if ( ! m_indent . isEmpty ( ) ) { m_writer . write ( '\n' ) ; m_writer . write ( m_indent ) ; } } }
Write a new line and indent .
20,811
private void writeName ( String name ) throws IOException { m_writer . write ( '"' ) ; m_writer . write ( name ) ; m_writer . write ( '"' ) ; m_writer . write ( ":" ) ; }
Write an attribute name .
20,812
private void decreaseIndent ( ) throws IOException { if ( m_pretty ) { m_writer . write ( '\n' ) ; m_indent = m_indent . substring ( 0 , m_indent . length ( ) - INDENT . length ( ) ) ; m_writer . write ( m_indent ) ; } m_firstNameValuePair . pop ( ) ; }
Decrease the indent level .
20,813
public void process ( AvailabilityTable table , byte [ ] data ) { if ( data != null ) { Calendar cal = DateHelper . popCalendar ( ) ; int items = MPPUtility . getShort ( data , 0 ) ; int offset = 12 ; for ( int loop = 0 ; loop < items ; loop ++ ) { double unitsValue = MPPUtility . getDouble ( data , offset + 4 ) ; if (...
Populates a resource availability table .
20,814
public static final Object getObject ( Locale locale , String key ) { ResourceBundle bundle = ResourceBundle . getBundle ( LocaleData . class . getName ( ) , locale ) ; return ( bundle . getObject ( key ) ) ; }
Convenience method for retrieving an Object resource .
20,815
@ SuppressWarnings ( "rawtypes" ) public static final Map getMap ( Locale locale , String key ) { ResourceBundle bundle = ResourceBundle . getBundle ( LocaleData . class . getName ( ) , locale ) ; return ( ( Map ) bundle . getObject ( key ) ) ; }
Convenience method for retrieving a Map resource .
20,816
public static final Integer getInteger ( Locale locale , String key ) { ResourceBundle bundle = ResourceBundle . getBundle ( LocaleData . class . getName ( ) , locale ) ; return ( ( Integer ) bundle . getObject ( key ) ) ; }
Convenience method for retrieving an Integer resource .
20,817
public static final char getChar ( Locale locale , String key ) { ResourceBundle bundle = ResourceBundle . getBundle ( LocaleData . class . getName ( ) , locale ) ; return ( bundle . getString ( key ) . charAt ( 0 ) ) ; }
Convenience method for retrieving a char resource .
20,818
public boolean getOverAllocated ( ) { Boolean overallocated = ( Boolean ) getCachedValue ( ResourceField . OVERALLOCATED ) ; if ( overallocated == null ) { Number peakUnits = getPeakUnits ( ) ; Number maxUnits = getMaxUnits ( ) ; overallocated = Boolean . valueOf ( NumberHelper . getDouble ( peakUnits ) > NumberHelper ...
Retrieves the overallocated flag .
20,819
public Date getStart ( ) { Date result = null ; for ( ResourceAssignment assignment : m_assignments ) { if ( result == null || DateHelper . compare ( result , assignment . getStart ( ) ) > 0 ) { result = assignment . getStart ( ) ; } } return ( result ) ; }
Retrieves the earliest start date for all assigned tasks .
20,820
public Duration getWorkVariance ( ) { Duration variance = ( Duration ) getCachedValue ( ResourceField . WORK_VARIANCE ) ; if ( variance == null ) { Duration work = getWork ( ) ; Duration baselineWork = getBaselineWork ( ) ; if ( work != null && baselineWork != null ) { variance = Duration . getInstance ( work . getDura...
Retrieves the work variance .
20,821
public String getNotes ( ) { String notes = ( String ) getCachedValue ( ResourceField . NOTES ) ; return ( notes == null ? "" : notes ) ; }
Retrieves the notes text for this resource .
20,822
public void setResourceCalendar ( ProjectCalendar calendar ) { set ( ResourceField . CALENDAR , calendar ) ; if ( calendar == null ) { setResourceCalendarUniqueID ( null ) ; } else { calendar . setResource ( this ) ; setResourceCalendarUniqueID ( calendar . getUniqueID ( ) ) ; } }
This method allows a pre - existing resource calendar to be attached to a resource .
20,823
public ProjectCalendar addResourceCalendar ( ) throws MPXJException { if ( getResourceCalendar ( ) != null ) { throw new MPXJException ( MPXJException . MAXIMUM_RECORDS ) ; } ProjectCalendar calendar = new ProjectCalendar ( getParentFile ( ) ) ; setResourceCalendar ( calendar ) ; return calendar ; }
This method allows a resource calendar to be added to a resource .
20,824
public void setBaseCalendar ( String val ) { set ( ResourceField . BASE_CALENDAR , val == null || val . length ( ) == 0 ? "Standard" : val ) ; }
Sets the Base Calendar field indicates which calendar is the base calendar for a resource calendar . The list includes the three built - in calendars as well as any new base calendars you have created in the Change Working Time dialog box .
20,825
public void setID ( Integer val ) { ProjectFile parent = getParentFile ( ) ; Integer previous = getID ( ) ; if ( previous != null ) { parent . getResources ( ) . unmapID ( previous ) ; } parent . getResources ( ) . mapID ( val , this ) ; set ( ResourceField . ID , val ) ; }
Sets ID field value .
20,826
public boolean getFlag ( int index ) { return BooleanHelper . getBoolean ( ( Boolean ) getCachedValue ( selectField ( ResourceFieldLists . CUSTOM_FLAG , index ) ) ) ; }
Retrieve a flag value .
20,827
private ResourceField selectField ( ResourceField [ ] fields , int index ) { if ( index < 1 || index > fields . length ) { throw new IllegalArgumentException ( index + " is not a valid field index" ) ; } return ( fields [ index - 1 ] ) ; }
Maps a field index to a ResourceField instance .
20,828
protected void mergeSameWork ( LinkedList < TimephasedWork > list ) { LinkedList < TimephasedWork > result = new LinkedList < TimephasedWork > ( ) ; TimephasedWork previousAssignment = null ; for ( TimephasedWork assignment : list ) { if ( previousAssignment == null ) { assignment . setAmountPerDay ( assignment . getTo...
Merges individual days together into time spans where the same work is undertaken each day .
20,829
protected void convertToHours ( LinkedList < TimephasedWork > list ) { for ( TimephasedWork assignment : list ) { Duration totalWork = assignment . getTotalAmount ( ) ; Duration workPerDay = assignment . getAmountPerDay ( ) ; totalWork = Duration . getInstance ( totalWork . getDuration ( ) / 60 , TimeUnit . HOURS ) ; w...
Converts assignment duration values from minutes to hours .
20,830
public void addColumn ( FastTrackColumn column ) { FastTrackField type = column . getType ( ) ; Object [ ] data = column . getData ( ) ; for ( int index = 0 ; index < data . length ; index ++ ) { MapRow row = getRow ( index ) ; row . getMap ( ) . put ( type , data [ index ] ) ; } }
Add data for a column to this table .
20,831
private MapRow getRow ( int index ) { MapRow result ; if ( index == m_rows . size ( ) ) { result = new MapRow ( this , new HashMap < FastTrackField , Object > ( ) ) ; m_rows . add ( result ) ; } else { result = m_rows . get ( index ) ; } return result ; }
Retrieve a specific row by index number creating a blank row if this row does not exist .
20,832
private void setRecordNumber ( LinkedList < String > list ) { try { String number = list . remove ( 0 ) ; m_recordNumber = Integer . valueOf ( number ) ; } catch ( NumberFormatException ex ) { } }
Pop the record number from the front of the list and parse it to ensure that it is a valid integer .
20,833
public String getString ( int field ) { String result ; if ( field < m_fields . length ) { result = m_fields [ field ] ; if ( result != null ) { result = result . replace ( MPXConstants . EOL_PLACEHOLDER , '\n' ) ; } } else { result = null ; } return ( result ) ; }
Accessor method used to retrieve a String object representing the contents of an individual field . If the field does not exist in the record null is returned .
20,834
public Character getCharacter ( int field ) { Character result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = Character . valueOf ( m_fields [ field ] . charAt ( 0 ) ) ; } else { result = null ; } return ( result ) ; }
Accessor method used to retrieve a char representing the contents of an individual field . If the field does not exist in the record the default character is returned .
20,835
public Number getFloat ( int field ) throws MPXJException { try { Number result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = m_formats . getDecimalFormat ( ) . parse ( m_fields [ field ] ) ; } else { result = null ; } return ( result ) ; } catch ( ParseException ex ) { t...
Accessor method used to retrieve a Float object representing the contents of an individual field . If the field does not exist in the record null is returned .
20,836
public boolean getNumericBoolean ( int field ) { boolean result = false ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = Integer . parseInt ( m_fields [ field ] ) == 1 ; } return ( result ) ; }
Accessor method used to retrieve a Boolean object representing the contents of an individual field . If the field does not exist in the record null is returned .
20,837
public Rate getRate ( int field ) throws MPXJException { Rate result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { try { String rate = m_fields [ field ] ; int index = rate . indexOf ( '/' ) ; double amount ; TimeUnit units ; if ( index == - 1 ) { amount = m_formats . getCurrencyF...
Accessor method used to retrieve an Rate object representing the contents of an individual field . If the field does not exist in the record null is returned .
20,838
public Duration getDuration ( int field ) throws MPXJException { Duration result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = DurationUtility . getInstance ( m_fields [ field ] , m_formats . getDurationDecimalFormat ( ) , m_locale ) ; } else { result = null ; } return ( ...
Accessor method used to retrieve an Duration object representing the contents of an individual field . If the field does not exist in the record null is returned .
20,839
public Number getUnits ( int field ) throws MPXJException { Number result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { try { result = Double . valueOf ( m_formats . getUnitsDecimalFormat ( ) . parse ( m_fields [ field ] ) . doubleValue ( ) * 100 ) ; } catch ( ParseException ex ) ...
Accessor method used to retrieve a Number instance representing the contents of an individual field . If the field does not exist in the record null is returned .
20,840
public CodePage getCodePage ( int field ) { CodePage result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = CodePage . getInstance ( m_fields [ field ] ) ; } else { result = CodePage . getInstance ( null ) ; } return ( result ) ; }
Retrieves a CodePage instance . Defaults to ANSI .
20,841
public AccrueType getAccrueType ( int field ) { AccrueType result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = AccrueTypeUtility . getInstance ( m_fields [ field ] , m_locale ) ; } else { result = null ; } return ( result ) ; }
Accessor method to retrieve an accrue type instance .
20,842
public Boolean getBoolean ( int field , String falseText ) { Boolean result ; if ( ( field < m_fields . length ) && ( m_fields [ field ] . length ( ) != 0 ) ) { result = ( ( m_fields [ field ] . equalsIgnoreCase ( falseText ) == true ) ? Boolean . FALSE : Boolean . TRUE ) ; } else { result = null ; } return ( result ) ...
Accessor method to retrieve a Boolean instance .
20,843
public int getIndexFromOffset ( int offset ) { int result = - 1 ; for ( int loop = 0 ; loop < m_offset . length ; loop ++ ) { if ( m_offset [ loop ] == offset ) { result = loop ; break ; } } return ( result ) ; }
This method converts an offset value into an array index which in turn allows the data present in the fixed block to be retrieved . Note that if the requested offset is not found then this method returns - 1 .
20,844
public byte [ ] getByteArray ( int offset ) { byte [ ] result = null ; if ( offset > 0 && offset < m_data . length ) { int nextBlockOffset = MPPUtility . getInt ( m_data , offset ) ; offset += 4 ; int itemSize = MPPUtility . getInt ( m_data , offset ) ; offset += 4 ; if ( itemSize > 0 && itemSize < m_data . length ) { ...
Retrieve a byte array of containing the data starting at the supplied offset in the FixDeferFix file . Note that this method will return null if the requested data is not found for some reason .
20,845
public List < ResourceRequestType . ResourceRequestCriterion > getResourceRequestCriterion ( ) { if ( resourceRequestCriterion == null ) { resourceRequestCriterion = new ArrayList < ResourceRequestType . ResourceRequestCriterion > ( ) ; } return this . resourceRequestCriterion ; }
Gets the value of the resourceRequestCriterion property .
20,846
private Map < UUID , FieldType > populateCustomFieldMap ( ) { byte [ ] data = m_taskProps . getByteArray ( Props . CUSTOM_FIELDS ) ; int length = MPPUtility . getInt ( data , 0 ) ; int index = length + 36 ; int recordCount = MPPUtility . getInt ( data , index ) ; index += 4 ; index += ( 8 * recordCount ) ; Map < UUID ,...
Generate a map of UUID values to field types .
20,847
public static final void deleteQuietly ( File file ) { if ( file != null ) { if ( file . isDirectory ( ) ) { File [ ] children = file . listFiles ( ) ; if ( children != null ) { for ( File child : children ) { deleteQuietly ( child ) ; } } } file . delete ( ) ; } }
Delete a file ignoring failures .
20,848
private void extractFile ( InputStream stream , File dir ) throws IOException { byte [ ] header = new byte [ 8 ] ; byte [ ] fileName = new byte [ 13 ] ; byte [ ] dataSize = new byte [ 4 ] ; stream . read ( header ) ; stream . read ( fileName ) ; stream . read ( dataSize ) ; int dataSizeValue = getInt ( dataSize , 0 ) ;...
Extracts the data for a single file from the input stream and writes it to a target directory .
20,849
private boolean matchesFingerprint ( byte [ ] buffer , byte [ ] fingerprint ) { return Arrays . equals ( fingerprint , Arrays . copyOf ( buffer , fingerprint . length ) ) ; }
Determine if the start of the buffer matches a fingerprint byte array .
20,850
private boolean matchesFingerprint ( byte [ ] buffer , Pattern fingerprint ) { return fingerprint . matcher ( m_charset == null ? new String ( buffer ) : new String ( buffer , m_charset ) ) . matches ( ) ; }
Determine if the buffer when expressed as text matches a fingerprint regular expression .
20,851
private ProjectFile readProjectFile ( ProjectReader reader , InputStream stream ) throws MPXJException { addListeners ( reader ) ; return reader . read ( stream ) ; }
Adds listeners and reads from a stream .
20,852
private ProjectFile readProjectFile ( ProjectReader reader , File file ) throws MPXJException { addListeners ( reader ) ; return reader . read ( file ) ; }
Adds listeners and reads from a file .
20,853
private ProjectFile handleOleCompoundDocument ( InputStream stream ) throws Exception { POIFSFileSystem fs = new POIFSFileSystem ( POIFSFileSystem . createNonClosingInputStream ( stream ) ) ; String fileFormat = MPPReader . getFileFormat ( fs ) ; if ( fileFormat != null && fileFormat . startsWith ( "MSProject" ) ) { MP...
We have an OLE compound document ... but is it an MPP file?
20,854
private ProjectFile handleMDBFile ( InputStream stream ) throws Exception { File file = InputStreamHelper . writeStreamToTempFile ( stream , ".mdb" ) ; try { Class . forName ( "sun.jdbc.odbc.JdbcOdbcDriver" ) ; String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + file . getCanonicalPath ( ) ; Set < St...
We have identified that we have an MDB file . This could be a Microsoft Project database or an Asta database . Open the database and use the table names present to determine which type this is .
20,855
private ProjectFile handleSQLiteFile ( InputStream stream ) throws Exception { File file = InputStreamHelper . writeStreamToTempFile ( stream , ".sqlite" ) ; try { Class . forName ( "org.sqlite.JDBC" ) ; String url = "jdbc:sqlite:" + file . getCanonicalPath ( ) ; Set < String > tableNames = populateTableNames ( url ) ;...
We have identified that we have a SQLite file . This could be a Primavera Project database or an Asta database . Open the database and use the table names present to determine which type this is .
20,856
private ProjectFile handleZipFile ( InputStream stream ) throws Exception { File dir = null ; try { dir = InputStreamHelper . writeZipStreamToTempDir ( stream ) ; ProjectFile result = handleDirectory ( dir ) ; if ( result != null ) { return result ; } } finally { FileHelper . deleteQuietly ( dir ) ; } return null ; }
We have identified that we have a zip file . Extract the contents into a temporary directory and process .
20,857
private ProjectFile handleDirectory ( File directory ) throws Exception { ProjectFile result = handleDatabaseInDirectory ( directory ) ; if ( result == null ) { result = handleFileInDirectory ( directory ) ; } return result ; }
We have a directory . Determine if this contains a multi - file database we understand if so process it . If it does not contain a database test each file within the directory structure to determine if it contains a file whose format we understand .
20,858
private ProjectFile handleDatabaseInDirectory ( File directory ) throws Exception { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; File [ ] files = directory . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { continue ; } FileInputStream fis = new FileInputStream ( file )...
Given a directory determine if it contains a multi - file database whose format we can process .
20,859
private ProjectFile handleByteOrderMark ( InputStream stream , int length , Charset charset ) throws Exception { UniversalProjectReader reader = new UniversalProjectReader ( ) ; reader . setSkipBytes ( length ) ; reader . setCharset ( charset ) ; return reader . read ( stream ) ; }
The file we are working with has a byte order mark . Skip this and try again to read the file .
20,860
private ProjectFile handleDosExeFile ( InputStream stream ) throws Exception { File file = InputStreamHelper . writeStreamToTempFile ( stream , ".tmp" ) ; InputStream is = null ; try { is = new FileInputStream ( file ) ; if ( is . available ( ) > 1350 ) { StreamHelper . skip ( is , 1024 ) ; byte [ ] data = new byte [ 2...
This could be a self - extracting archive . If we understand the format expand it and check the content for files we can read .
20,861
private ProjectFile handleXerFile ( InputStream stream ) throws Exception { PrimaveraXERFileReader reader = new PrimaveraXERFileReader ( ) ; reader . setCharset ( m_charset ) ; List < ProjectFile > projects = reader . readAll ( stream ) ; ProjectFile project = null ; for ( ProjectFile file : projects ) { if ( file . ge...
XER files can contain multiple projects when there are cross - project dependencies . As the UniversalProjectReader is designed just to read a single project we need to select one project from those available in the XER file . The original project selected for export by the user will have its export flag set to true . ...
20,862
private Set < String > populateTableNames ( String url ) throws SQLException { Set < String > tableNames = new HashSet < String > ( ) ; Connection connection = null ; ResultSet rs = null ; try { connection = DriverManager . getConnection ( url ) ; DatabaseMetaData dmd = connection . getMetaData ( ) ; rs = dmd . getTabl...
Open a database and build a set of table names .
20,863
public static void skip ( InputStream stream , long skip ) throws IOException { long count = skip ; while ( count > 0 ) { count -= stream . skip ( count ) ; } }
The documentation for InputStream . skip indicates that it can bail out early and not skip the requested number of bytes . I ve encountered this in practice hence this helper method .
20,864
private void processCustomValueLists ( ) throws IOException { CustomFieldValueReader9 reader = new CustomFieldValueReader9 ( m_projectDir , m_file . getProjectProperties ( ) , m_projectProps , m_file . getCustomFields ( ) ) ; reader . process ( ) ; }
Retrieve any task field value lists defined in the MPP file .
20,865
private void processFieldNameAliases ( Map < Integer , FieldType > map , byte [ ] data ) { if ( data != null ) { int offset = 0 ; int index = 0 ; CustomFieldContainer fields = m_file . getCustomFields ( ) ; while ( offset < data . length ) { String alias = MPPUtility . getUnicodeString ( data , offset ) ; if ( ! alias ...
Retrieve any resource field aliases defined in the MPP file .
20,866
private TreeMap < Integer , Integer > createResourceMap ( FieldMap fieldMap , FixedMeta rscFixedMeta , FixedData rscFixedData ) { TreeMap < Integer , Integer > resourceMap = new TreeMap < Integer , Integer > ( ) ; int itemCount = rscFixedMeta . getAdjustedItemCount ( ) ; for ( int loop = 0 ; loop < itemCount ; loop ++ ...
This method maps the resource unique identifiers to their index number within the FixedData block .
20,867
private void postProcessTasks ( ) { List < Task > allTasks = m_file . getTasks ( ) ; if ( allTasks . size ( ) > 1 ) { Collections . sort ( allTasks ) ; int taskID = - 1 ; int lastTaskID = - 1 ; for ( int i = 0 ; i < allTasks . size ( ) ; i ++ ) { Task task = allTasks . get ( i ) ; taskID = NumberHelper . getInt ( task ...
This method is called to try to catch any invalid tasks that may have sneaked past all our other checks . This is done by validating the tasks by task ID .
20,868
public void process ( String name ) throws Exception { ProjectFile file = new UniversalProjectReader ( ) . read ( name ) ; for ( Task task : file . getTasks ( ) ) { if ( ! task . getSummary ( ) ) { System . out . print ( task . getWBS ( ) ) ; System . out . print ( "\t" ) ; System . out . print ( task . getName ( ) ) ;...
Dump data for all non - summary tasks to stdout .
20,869
private void readProjectProperties ( Document cdp ) { WorkspaceProperties props = cdp . getWorkspaceProperties ( ) ; ProjectProperties mpxjProps = m_projectFile . getProjectProperties ( ) ; mpxjProps . setSymbolPosition ( props . getCurrencyPosition ( ) ) ; mpxjProps . setCurrencyDigits ( props . getCurrencyDigits ( ) ...
Extracts project properties from a ConceptDraw PROJECT file .
20,870
private void readCalendars ( Document cdp ) { for ( Calendar calendar : cdp . getCalendars ( ) . getCalendar ( ) ) { readCalendar ( calendar ) ; } for ( Calendar calendar : cdp . getCalendars ( ) . getCalendar ( ) ) { ProjectCalendar child = m_calendarMap . get ( calendar . getID ( ) ) ; ProjectCalendar parent = m_cale...
Extracts calendar data from a ConceptDraw PROJECT file .
20,871
private void readWeekDay ( ProjectCalendar mpxjCalendar , WeekDay day ) { if ( day . isIsDayWorking ( ) ) { ProjectCalendarHours hours = mpxjCalendar . addCalendarHours ( day . getDay ( ) ) ; for ( Document . Calendars . Calendar . WeekDays . WeekDay . TimePeriods . TimePeriod period : day . getTimePeriods ( ) . getTim...
Reads a single day for a calendar .
20,872
private void readExceptionDay ( ProjectCalendar mpxjCalendar , ExceptedDay day ) { ProjectCalendarException mpxjException = mpxjCalendar . addCalendarException ( day . getDate ( ) , day . getDate ( ) ) ; if ( day . isIsDayWorking ( ) ) { for ( Document . Calendars . Calendar . ExceptedDays . ExceptedDay . TimePeriods ....
Read an exception day for a calendar .
20,873
private void readResources ( Document cdp ) { for ( Document . Resources . Resource resource : cdp . getResources ( ) . getResource ( ) ) { readResource ( resource ) ; } }
Reads resource data from a ConceptDraw PROJECT file .
20,874
private void readResource ( Document . Resources . Resource resource ) { Resource mpxjResource = m_projectFile . addResource ( ) ; mpxjResource . setName ( resource . getName ( ) ) ; mpxjResource . setResourceCalendar ( m_calendarMap . get ( resource . getCalendarID ( ) ) ) ; mpxjResource . setStandardRate ( new Rate (...
Reads a single resource from a ConceptDraw PROJECT file .
20,875
private void readTasks ( Document cdp ) { List < Project > projects = new ArrayList < Project > ( cdp . getProjects ( ) . getProject ( ) ) ; final AlphanumComparator comparator = new AlphanumComparator ( ) ; Collections . sort ( projects , new Comparator < Project > ( ) { public int compare ( Project o1 , Project o2 ) ...
Read the projects from a ConceptDraw PROJECT file as top level tasks .
20,876
private void readProject ( Project project ) { Task mpxjTask = m_projectFile . addTask ( ) ; mpxjTask . setBaselineCost ( project . getBaselineCost ( ) ) ; mpxjTask . setBaselineFinish ( project . getBaselineFinishDate ( ) ) ; mpxjTask . setBaselineStart ( project . getBaselineStartDate ( ) ) ; mpxjTask . setFinish ( p...
Read a project from a ConceptDraw PROJECT file .
20,877
private void readTask ( String projectIdentifier , Map < String , Task > map , Document . Projects . Project . Task task ) { Task parentTask = map . get ( getParentOutlineNumber ( task . getOutlineNumber ( ) ) ) ; Task mpxjTask = parentTask . addTask ( ) ; TimeUnit units = task . getBaseDurationTimeUnit ( ) ; mpxjTask ...
Read a task from a ConceptDraw PROJECT file .
20,878
private void readRelationships ( Document cdp ) { for ( Link link : cdp . getLinks ( ) . getLink ( ) ) { readRelationship ( link ) ; } }
Read all task relationships from a ConceptDraw PROJECT file .
20,879
private void readRelationship ( Link link ) { Task sourceTask = m_taskIdMap . get ( link . getSourceTaskID ( ) ) ; Task destinationTask = m_taskIdMap . get ( link . getDestinationTaskID ( ) ) ; if ( sourceTask != null && destinationTask != null ) { Duration lag = getDuration ( link . getLagUnit ( ) , link . getLag ( ) ...
Read a task relationship .
20,880
private Duration getDuration ( TimeUnit units , Double duration ) { Duration result = null ; if ( duration != null ) { double durationValue = duration . doubleValue ( ) * 100.0 ; switch ( units ) { case MINUTES : { durationValue *= MINUTES_PER_DAY ; break ; } case HOURS : { durationValue *= HOURS_PER_DAY ; break ; } ca...
Read a duration .
20,881
private String getParentOutlineNumber ( String outlineNumber ) { String result ; int index = outlineNumber . lastIndexOf ( '.' ) ; if ( index == - 1 ) { result = "" ; } else { result = outlineNumber . substring ( 0 , index ) ; } return result ; }
Return the parent outline number or an empty string if we have a root task .
20,882
public static ConstraintField getInstance ( int value ) { ConstraintField result = null ; if ( value >= 0 && value < FIELD_ARRAY . length ) { result = FIELD_ARRAY [ value ] ; } return ( result ) ; }
Retrieve an instance of the ConstraintField class based on the data read from an MS Project file .
20,883
public void update ( ) { ProjectProperties properties = m_projectFile . getProjectProperties ( ) ; char decimalSeparator = properties . getDecimalSeparator ( ) ; char thousandsSeparator = properties . getThousandsSeparator ( ) ; m_unitsDecimalFormat . applyPattern ( "#.##" , null , decimalSeparator , thousandsSeparator...
Called to update the cached formats when something changes .
20,884
private void updateCurrencyFormats ( ProjectProperties properties , char decimalSeparator , char thousandsSeparator ) { String prefix = "" ; String suffix = "" ; String currencySymbol = quoteFormatCharacters ( properties . getCurrencySymbol ( ) ) ; switch ( properties . getSymbolPosition ( ) ) { case AFTER : { suffix =...
Update the currency format .
20,885
private String quoteFormatCharacters ( String literal ) { StringBuilder sb = new StringBuilder ( ) ; int length = literal . length ( ) ; char c ; for ( int loop = 0 ; loop < length ; loop ++ ) { c = literal . charAt ( loop ) ; switch ( c ) { case '0' : case '#' : case '.' : case '-' : case ',' : case 'E' : case ';' : c...
This method is used to quote any special characters that appear in literal text that is required as part of the currency format .
20,886
private void updateDateTimeFormats ( ProjectProperties properties ) { String [ ] timePatterns = getTimePatterns ( properties ) ; String [ ] datePatterns = getDatePatterns ( properties ) ; String [ ] dateTimePatterns = getDateTimePatterns ( properties , timePatterns ) ; m_dateTimeFormat . applyPatterns ( dateTimePattern...
Updates the date and time formats .
20,887
private String [ ] getDatePatterns ( ProjectProperties properties ) { String pattern = "" ; char datesep = properties . getDateSeparator ( ) ; DateOrder dateOrder = properties . getDateOrder ( ) ; switch ( dateOrder ) { case DMY : { pattern = "dd" + datesep + "MM" + datesep + "yy" ; break ; } case MDY : { pattern = "MM...
Generate date patterns based on the project configuration .
20,888
private List < String > generateDateTimePatterns ( String datePattern , String [ ] timePatterns ) { List < String > patterns = new ArrayList < String > ( ) ; for ( String timePattern : timePatterns ) { patterns . add ( datePattern + " " + timePattern ) ; } patterns . add ( datePattern ) ; return patterns ; }
Generate a set of datetime patterns to accommodate variations in MPX files .
20,889
public Integer [ ] getUniqueIdentifierArray ( ) { Integer [ ] result = new Integer [ m_table . size ( ) ] ; int index = 0 ; for ( Integer value : m_table . keySet ( ) ) { result [ index ] = value ; ++ index ; } return ( result ) ; }
This method returns an array containing all of the unique identifiers for which data has been stored in the Var2Data block .
20,890
public Integer getOffset ( Integer id , Integer type ) { Integer result = null ; Map < Integer , Integer > map = m_table . get ( id ) ; if ( map != null && type != null ) { result = map . get ( type ) ; } return ( result ) ; }
This method retrieves the offset of a given entry in the Var2Data block . Each entry can be uniquely located by the identifier of the object to which the data belongs and the type of the data .
20,891
public void setRightValue ( int index , Object value ) { m_definedRightValues [ index ] = value ; if ( value instanceof FieldType ) { m_symbolicValues = true ; } else { if ( value instanceof Duration ) { if ( ( ( Duration ) value ) . getUnits ( ) != TimeUnit . HOURS ) { value = ( ( Duration ) value ) . convertUnits ( T...
Add the value to list of values to be used as part of the evaluation of this indicator .
20,892
public boolean evaluate ( FieldContainer container , Map < GenericCriteriaPrompt , Object > promptValues ) { FieldType field = m_leftValue ; Object lhs ; if ( field == null ) { lhs = null ; } else { lhs = container . getCurrentValue ( field ) ; switch ( field . getDataType ( ) ) { case DATE : { if ( lhs != null ) { lhs...
Evaluate the criteria and return a boolean result .
20,893
private boolean evaluateLogicalOperator ( FieldContainer container , Map < GenericCriteriaPrompt , Object > promptValues ) { boolean result = false ; if ( m_criteriaList . size ( ) == 0 ) { result = true ; } else { for ( GenericCriteria criteria : m_criteriaList ) { result = criteria . evaluate ( container , promptValu...
Evalutes AND and OR operators .
20,894
private ProjectFile read ( ) throws Exception { m_project = new ProjectFile ( ) ; m_eventManager = m_project . getEventManager ( ) ; m_project . getProjectProperties ( ) . setFileApplication ( "Synchro" ) ; m_project . getProjectProperties ( ) . setFileType ( "SP" ) ; CustomFieldContainer fields = m_project . getCustom...
Reads data from the SP file .
20,895
private void processCalendars ( ) throws IOException { CalendarReader reader = new CalendarReader ( m_data . getTableData ( "Calendars" ) ) ; reader . read ( ) ; for ( MapRow row : reader . getRows ( ) ) { processCalendar ( row ) ; } m_project . setDefaultCalendar ( m_calendarMap . get ( reader . getDefaultCalendarUUID...
Extract calendar data .
20,896
private void processCalendar ( MapRow row ) { ProjectCalendar calendar = m_project . addCalendar ( ) ; Map < UUID , List < DateRange > > dayTypeMap = processDayTypes ( row . getRows ( "DAY_TYPES" ) ) ; calendar . setName ( row . getString ( "NAME" ) ) ; processRanges ( dayTypeMap . get ( row . getUUID ( "SUNDAY_DAY_TYP...
Extract data for a single calendar .
20,897
private void processRanges ( List < DateRange > ranges , ProjectCalendarDateRanges container ) { if ( ranges != null ) { for ( DateRange range : ranges ) { container . addRange ( range ) ; } } }
Populate time ranges .
20,898
private Map < UUID , List < DateRange > > processDayTypes ( List < MapRow > types ) { Map < UUID , List < DateRange > > map = new HashMap < UUID , List < DateRange > > ( ) ; for ( MapRow row : types ) { List < DateRange > ranges = new ArrayList < DateRange > ( ) ; for ( MapRow range : row . getRows ( "TIME_RANGES" ) ) ...
Extract day type definitions .
20,899
private void processResources ( ) throws IOException { CompanyReader reader = new CompanyReader ( m_data . getTableData ( "Companies" ) ) ; reader . read ( ) ; for ( MapRow companyRow : reader . getRows ( ) ) { for ( MapRow resourceRow : sort ( companyRow . getRows ( "RESOURCES" ) , "NAME" ) ) { processResource ( resou...
Extract resource data .