Class FormattedSourceCorrespondence
- java.lang.Object
-
- com.ensoftcorp.open.commons.utilities.FormattedSourceCorrespondence
-
- All Implemented Interfaces:
java.lang.Comparable<FormattedSourceCorrespondence>
public class FormattedSourceCorrespondence extends java.lang.Object implements java.lang.Comparable<FormattedSourceCorrespondence>
A convenience utility wrapper for pretty printing SourceCorrespondence line numbers and other properties- Author:
- Ben Holland
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FormattedSourceCorrespondence.LineNumberRange
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(FormattedSourceCorrespondence fsc)
long
getEndLineNumber()
Returns the source file ending line number (the number of new lines to reach the offset plus the length of the source correspondent)java.io.File
getFile()
Returns a File object representing the source file location of this correspondentint
getLength()
Returns the length from the beginning file character offset into the source file for this source correspondentstatic FormattedSourceCorrespondence.LineNumberRange
getLineNumberRange(com.ensoftcorp.atlas.core.index.common.SourceCorrespondence sc)
Gets a line number range for a given source correspondentjava.lang.String
getLineNumbers()
Returns the condensed line numbers as a string of ranges for the correspondent(s)java.lang.String
getName()
Returns this formatted source correspondence name if one was set or null otherwiseint
getOffset()
Returns the beginning file character offset into the source file for this source correspondentjava.lang.String
getProject()
Returns the String of the Eclipse project name containing this correspondentjava.lang.String
getRelativeFile()
Returns a relative file path string starting at the Eclipse project to the source file that contains this correspondentstatic FormattedSourceCorrespondence
getSourceCorrespondent(com.ensoftcorp.atlas.core.db.graph.GraphElement ge)
Returns a formatted source correspondent given a GraphElement Returns null if no source correspondents are found.static java.util.Collection<FormattedSourceCorrespondence>
getSourceCorrespondents(com.ensoftcorp.atlas.core.query.Q q)
Returns a collection of source correspondents given a Qlong
getStartLineNumber()
Returns the source file starting line number (the number of new lines to reach the offset of the source correspondent)boolean
hasName()
Returns true if this formatted source correspondence was given a namestatic java.util.Map<java.io.File,java.util.SortedSet<FormattedSourceCorrespondence.LineNumberRange>>
summarize(com.ensoftcorp.atlas.core.query.Q q)
Given a Q gets the mapping of relative files to the line number ranges for each summarized element ofstatic java.lang.String
summarize(com.ensoftcorp.atlas.core.query.Q q, boolean includeFunctionNames)
Given a Q, creates a pretty print summary the source graph element locations, line number ranges, and names of graph elements that were functions (if enabled) ofjava.lang.String
toString()
Returns a pretty print string of the format: "Filename:+ (line(s) )"
-
-
-
Method Detail
-
hasName
public boolean hasName()
Returns true if this formatted source correspondence was given a name- Returns:
-
getName
public java.lang.String getName()
Returns this formatted source correspondence name if one was set or null otherwise- Returns:
-
getProject
public java.lang.String getProject()
Returns the String of the Eclipse project name containing this correspondent- Returns:
-
getFile
public java.io.File getFile()
Returns a File object representing the source file location of this correspondent- Returns:
-
getRelativeFile
public java.lang.String getRelativeFile() throws java.io.IOException
Returns a relative file path string starting at the Eclipse project to the source file that contains this correspondent- Returns:
- Throws:
java.io.IOException
-
getStartLineNumber
public long getStartLineNumber() throws java.io.IOException
Returns the source file starting line number (the number of new lines to reach the offset of the source correspondent)- Returns:
- Throws:
java.io.IOException
-
getEndLineNumber
public long getEndLineNumber() throws java.io.IOException
Returns the source file ending line number (the number of new lines to reach the offset plus the length of the source correspondent)- Returns:
- Throws:
java.io.IOException
-
getLineNumbers
public java.lang.String getLineNumbers() throws java.io.IOException
Returns the condensed line numbers as a string of ranges for the correspondent(s)- Returns:
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
Returns a pretty print string of the format: "Filename:+ (line(s) )" - Overrides:
toString
in classjava.lang.Object
-
getOffset
public int getOffset()
Returns the beginning file character offset into the source file for this source correspondent- Returns:
-
getLength
public int getLength()
Returns the length from the beginning file character offset into the source file for this source correspondent- Returns:
-
getLineNumberRange
public static FormattedSourceCorrespondence.LineNumberRange getLineNumberRange(com.ensoftcorp.atlas.core.index.common.SourceCorrespondence sc) throws java.io.IOException
Gets a line number range for a given source correspondent- Parameters:
sc
-- Returns:
- Throws:
java.io.IOException
-
compareTo
public int compareTo(FormattedSourceCorrespondence fsc)
- Specified by:
compareTo
in interfacejava.lang.Comparable<FormattedSourceCorrespondence>
-
getSourceCorrespondents
public static java.util.Collection<FormattedSourceCorrespondence> getSourceCorrespondents(com.ensoftcorp.atlas.core.query.Q q)
Returns a collection of source correspondents given a Q- Parameters:
q
-- Returns:
-
getSourceCorrespondent
public static FormattedSourceCorrespondence getSourceCorrespondent(com.ensoftcorp.atlas.core.db.graph.GraphElement ge)
Returns a formatted source correspondent given a GraphElement Returns null if no source correspondents are found.- Parameters:
ge
-- Returns:
-
summarize
public static java.lang.String summarize(com.ensoftcorp.atlas.core.query.Q q, boolean includeFunctionNames) throws java.io.IOException
Given a Q, creates a pretty print summary the source graph element locations, line number ranges, and names of graph elements that were functions (if enabled) of- Parameters:
q
-- Returns:
- Throws:
java.io.IOException
-
summarize
public static java.util.Map<java.io.File,java.util.SortedSet<FormattedSourceCorrespondence.LineNumberRange>> summarize(com.ensoftcorp.atlas.core.query.Q q) throws java.io.IOException
Given a Q gets the mapping of relative files to the line number ranges for each summarized element of- Parameters:
q
-- Returns:
- Throws:
java.io.IOException
-
-