src2xml
Class ElementReader

java.lang.Object
  extended by src2xml.ElementReader

public class ElementReader
extends java.lang.Object

ElementReader is a class that represents the generic reader of a source region (element), that is what identifies and stores a particular region in the source code.

It uses two Detectors to recognize the start and the end of the region.

See Also:
Detector

Field Summary
protected  java.lang.String content
           
 java.lang.String end_pattern
           
 java.lang.String id
           
 java.lang.String nested_bag
           
 boolean nested_only
           
 java.lang.String start_pattern
           
 
Constructor Summary
ElementReader(java.lang.String sid, Detector st, Detector en, java.lang.String sptn, java.lang.String eptn, boolean nes)
          Class constructor
 
Method Summary
 void AddNested(ElementReader e)
          Add a new nested region, that is an ElementReader that might be contained in this one
 boolean Ends(Source src)
          Detects the end of read region, invoking the corresponding Detector
 java.lang.String generateCSS()
          Generate an estimated CSS based on child IDs
 Element Read(Source src)
          Read an element from source
 boolean Triggers(Source src)
          Tells if this region starts at current, position in source, invoking the corresponding Detector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public java.lang.String id

content

protected java.lang.String content

nested_bag

public java.lang.String nested_bag

nested_only

public boolean nested_only

start_pattern

public java.lang.String start_pattern

end_pattern

public java.lang.String end_pattern
Constructor Detail

ElementReader

public ElementReader(java.lang.String sid,
                     Detector st,
                     Detector en,
                     java.lang.String sptn,
                     java.lang.String eptn,
                     boolean nes)
Class constructor

Parameters:
sid - An IDentificative String for this reader
st - The element (region) start Detector
en - The element (region) end Detector
sptn - The exported region starting tag pattern - use var (id)
eptn - The exported region ending tag pattern - use var (id)
nes - A boolean true if read elements can appear only as nested in other elements
See Also:
Detector
Method Detail

Read

public Element Read(Source src)
             throws java.io.IOException
Read an element from source

Parameters:
src - The source stream
Returns:
The read Element object
Throws:
java.io.IOException - If an input or output exception occurred
See Also:
Source, Element

Triggers

public boolean Triggers(Source src)
                 throws java.io.IOException
Tells if this region starts at current, position in source, invoking the corresponding Detector

Parameters:
src - The source stream
Returns:
The boolean result
Throws:
java.io.IOException - If an input or output exception occurred
See Also:
Source, Detector

Ends

public boolean Ends(Source src)
             throws java.io.IOException
Detects the end of read region, invoking the corresponding Detector

Parameters:
src - The source stream
Returns:
The boolean result
Throws:
java.io.IOException - If an input or output exception occurred
See Also:
Source, Detector

AddNested

public void AddNested(ElementReader e)
Add a new nested region, that is an ElementReader that might be contained in this one

Parameters:
e - An ElementReader expected to be nested

generateCSS

public java.lang.String generateCSS()
Generate an estimated CSS based on child IDs

Returns:
A String containing CSS code