net.sf.plb4jedit.plb
Class SourceLine

java.lang.Object
  extended bynet.sf.plb4jedit.plb.SourceLine

public class SourceLine
extends Object

Description: Represents a PLB-Source line, which is no comment.
Parses a line from a source and determines wether it is a label, a variable, an include or a command. Gives access to these information and has some convenience methods to ask for the type of the line.
Also defines some Comparators to sort SourceLines according to there lineno or in alphabetic order of their labels.
A source line is scanned via a regular expression, which uses the structure/format of the PLB instruction syntax, which defines an instruction as something like (LABEL) (KEYWORD) (REST) where LABEL is of fix width (8 characters at RSI). Depending on the Type of the instruction LABEL can be the name of an instruction label or lroutine or a variable name.
KEYWORD can be the type of a variable or a PLB command/keyword.
Depending on the Type of the line, the REST can be a comment, name of an include, parameters to an lroutine. size of a variable, etc ... Be aware that for lines of Type INCLUDE only the first word of REST is taken where for other Types REST may need further parsing, because it can also contain comments or anything else.
Notice that only a single Line is parsed, so e.g. for a routine which parameters a splitted over more than one line, not all parameter may be recognized. TODO: normalize PLB-Sources so that all line splits (by :) are resolved.

Version:
$Header: /cvsroot/plb4jedit/plb4jedit/Plb/src/java/net/sf/plb4jedit/plb/SourceLine.java,v 1.1 2003/11/04 17:40:31 skopp Exp $
Author:
Peter Schaefer

Field Summary
static String cvsId
           
static Comparator LABEL_ORDERED
           
static Comparator LINE_NUMBER_ORDERED
           
static Comparator REST_ORDERED
           
 
Constructor Summary
SourceLine(String line, int lineNumber)
          Constructs a SourceLine for a given line and it position of occurence in a file.
SourceLine(String line, int lineNumber, List records)
          Constructs a SourceLine for a given line and it position of occurence in a file being nested inside record definitions.
 
Method Summary
 int compareTo(Object obj)
           
 String getKeyword()
          gets keyword of the line.
 String getLabel()
          gets the label of the line, see class documentation.
 String getLine()
           
 int getLineNumber()
           
 String getRest()
          gets rest of the line.
 net.sf.plb4jedit.plb.Type getType()
          gets the Type of the line, which indicates if the line is a comment, a variable definition, an execution label or a command.
 boolean isDimDef()
           
 boolean isFormDef()
           
 boolean isInclude()
           
 boolean isLabel()
           
 boolean isLroutine()
           
 boolean isRecordDef()
          NOTE: records defined via like and record arrays are currently not supported
 boolean isRecordEnd()
           
 boolean isVarDef()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cvsId

public static final String cvsId
See Also:
Constant Field Values

LINE_NUMBER_ORDERED

public static final Comparator LINE_NUMBER_ORDERED

LABEL_ORDERED

public static final Comparator LABEL_ORDERED

REST_ORDERED

public static final Comparator REST_ORDERED
Constructor Detail

SourceLine

public SourceLine(String line,
                  int lineNumber,
                  List records)
Constructs a SourceLine for a given line and it position of occurence in a file being nested inside record definitions.

Parameters:
line - one line of a Source file
lineNumber - where the line appears in the source file.
records - a list of records where this line is nested in

SourceLine

public SourceLine(String line,
                  int lineNumber)
Constructs a SourceLine for a given line and it position of occurence in a file.

Parameters:
line - one line of a Source file
lineNumber - where the line appears in the source file.
Method Detail

isLabel

public boolean isLabel()
Returns:
true if SourceLine defines a label

getLabel

public String getLabel()
gets the label of the line, see class documentation. Depending on Type of the line this may be an execution label/lroutine or variable definition.

Returns:
the label of this line

getLine

public String getLine()
Returns:
the whole line.

getLineNumber

public int getLineNumber()
Returns:
line number

getKeyword

public String getKeyword()
gets keyword of the line. Depending on the Type of the line this may be the variable type, or a PLB keyword (like e.g. inc, lroutine, move, ....)

Returns:
the KEYWORD of the line, see class documentation

getRest

public String getRest()
gets rest of the line. Content depends on Type. See class documentation.

Returns:
rest of the line

getType

public net.sf.plb4jedit.plb.Type getType()
gets the Type of the line, which indicates if the line is a comment, a variable definition, an execution label or a command.

Returns:
type of the line.

isDimDef

public boolean isDimDef()
Returns:
true if the line defines a dim

isFormDef

public boolean isFormDef()
Returns:
true if the line defines a form.

isRecordDef

public boolean isRecordDef()
NOTE: records defined via like and record arrays are currently not supported

Returns:
true if the line defines the beginning of a record definition.

isRecordEnd

public boolean isRecordEnd()
Returns:
true if the line defines the end of a record definition.

isLroutine

public boolean isLroutine()
Returns:
true if the line defines a lroutine.

isInclude

public boolean isInclude()
Returns:
true if the line includes another file

isVarDef

public boolean isVarDef()
Returns:
true if the line defines a variable

toString

public String toString()

compareTo

public int compareTo(Object obj)


Copyright © 2003 Riege Software Internationl. All Rights Reserved.