cox.jmatt.java.MathTools.markup.latex
Class LaBaseTag

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.latex.LaBaseTag
Direct Known Subclasses:
LaDocument, LaListTag, LaPicture, LaTable, LaTag, LEquation

public abstract class LaBaseTag
extends java.lang.Object

This is the abstract superclass of all other LaTeX markup-generating classes. It is primarily geared for block-style tags therefore it contains the necessary equipment to generate both the initial tag and the end tag.

A quick perusal of the methods here shows more than a few concerning whether or not an '/end...' tag exists, is created or is printed. This was done to allow subclasses fine-grained control over the nesting of blocks. As a general rule the toString() method returns a block of LaTeX ready to be pasted into a document. This means the classes MUST be able to handle nested blocks automatically, consistently and correctly. Of course this also allows users that same fine-grained control while maintaining the integrity of the individual constructs. Use with care!

Two methods give full information on end tags. hasEndTag() returns true only if a non-null, non-blank end tag is defined. If it returns false then no end tag is possible because there isn't one defined. isEndTagEnabled() reports whether or not end-tag printing is enabled. If not then toString() won't include an end tag, even if one exists.getEndTag() always creates an end tag if possible, even if end tags are disabled. This plus the two copy methods allow a tag to be fully printed WITH or WITHOUT an end tag; those can be collected and stored for later use and nesting.


Field Summary
static java.lang.String BS
          This is a Java-escaped backslash, defined here for convenience.
static java.lang.String DBS
          Double-backslash, to prevent frustration.
static java.lang.String DBSN
          Double-backslash plus a newline.
protected  java.lang.String myAuthor
          This is the title information used in LaDocument.
protected  java.lang.String myDate
          This is the title information used in LaDocument.
protected  java.lang.String myEndTag
          This is the end tag.
protected  java.lang.String myEnvironment
          This is the content of the first set of curly braces after the '/begin' tag and also within the braces with the 'end' tag.
protected  java.lang.String[] myEnvParams
          These are the extra curly braces that may appear after the initial set.
protected  java.lang.String myOptions
          Options appear in square brackets between the '/begin' sequence and the first opening curly brace.
protected  boolean myPicHasOrigin
          Flag to indicate whether or not origin coordinates were given.
protected  int myPicX
          This is picture size information stored here for proper print placement.
protected  int myPicXOrigin
          This is picture size information stored here for proper print placement.
protected  int myPicY
          This is picture size information stored here for proper print placement.
protected  int myPicYOrigin
          This is picture size information stored here for proper print placement.
protected  java.lang.String mySectionLabel
          This is the section label.
protected  java.lang.String myTagName
          All LaTeX tags, statements and commands have a name.
protected  java.lang.String myTitle
          This is the title information used in LaDocument.
 
Constructor Summary
protected LaBaseTag(java.lang.String pTagName, java.lang.String pEndTag, java.lang.String pEnvironment, java.lang.String pOptions, java.lang.String pContent)
          This constructor allows every aspect of a subclass to be set.
 
Method Summary
protected  void _addContent(java.lang.String pData)
          Add content to the internal buffer.
protected  void _addRawContent(java.lang.String pData)
          This method adds content with NO checking whatsoever.
protected  java.lang.String _getContent()
          Retrieve the raw content that has been added without any other formatting.
protected  void _setEndTagEnabled(boolean pEnable)
          Subclasses use this method to enable or disable end tag printing.
protected static void _setETEn(boolean pEnable)
          Use this method to allow a tag to be created with its end tag disabled.
abstract  LaBaseTag copyOf()
          This method provides a copy of a LaBaseTag subclass.
abstract  LaBaseTag copyOfSET()
          Create and return a copy of this tag with its end tag suppressed.
 java.lang.String getEndTag()
          This method creates and returns the end tag for this instance.
 boolean hasEndTag()
          This method determines whether or not this instance has a valid ending tag.
 boolean isEndTagEnabled()
          This method determines whether or not the end tag is enabled.
 void reset()
          This method clears all internal content.
 void setLabel(java.lang.String pLabel)
          This method allows a '/label{}' tag to appear immediately after the opening line of the block.
 java.lang.String toString()
          Print all the data within this tag as a properly-formatted String.
 java.lang.String toStringSET()
          This instance method is identical to toString() with the end tag suppressed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BS

public static final java.lang.String BS
This is a Java-escaped backslash, defined here for convenience.

See Also:
Constant Field Values

DBS

public static final java.lang.String DBS
Double-backslash, to prevent frustration.

See Also:
Constant Field Values

DBSN

public static final java.lang.String DBSN
Double-backslash plus a newline.

See Also:
Constant Field Values

myTagName

protected java.lang.String myTagName
All LaTeX tags, statements and commands have a name. This is it. It is protected to allow subclass access but SHOULD NOT be changed without a very good reason. The default value is 'LaTeX' for the LaTeX logo. For block-style tags this is the beginning tag. It defaults to 'begin' only, any options or curly braces are handled later.


myEndTag

protected java.lang.String myEndTag
This is the end tag. It defaults to 'end' with curly braces added later. If this field is manually set to null or blank NO END TAG IS PRINTED!


myEnvironment

protected java.lang.String myEnvironment
This is the content of the first set of curly braces after the '/begin' tag and also within the braces with the 'end' tag. If null or blank neither it nor the braces appear when the tag is printed. The default value is null.


myOptions

protected java.lang.String myOptions
Options appear in square brackets between the '/begin' sequence and the first opening curly brace. If null (default) or blank nothing prints.


myEnvParams

protected java.lang.String[] myEnvParams
These are the extra curly braces that may appear after the initial set. If not null or empty each individual String is appended after the initial closing curly brace and enclosed in curly braces of its own. If null (default) or empty it is ignored. If any element is null or blank an empty set of curly braces ('{}') is included.


mySectionLabel

protected java.lang.String mySectionLabel
This is the section label. It is protected to allow subclasses to access it if necessary. Subclasses that do not allow labels may alter it but others should not.


myTitle

protected java.lang.String myTitle
This is the title information used in LaDocument. It is stored here to allow proper print placement.


myDate

protected java.lang.String myDate
This is the title information used in LaDocument. It is stored here to allow proper print placement.


myAuthor

protected java.lang.String myAuthor
This is the title information used in LaDocument. It is stored here to allow proper print placement.


myPicX

protected int myPicX
This is picture size information stored here for proper print placement.


myPicY

protected int myPicY
This is picture size information stored here for proper print placement.


myPicXOrigin

protected int myPicXOrigin
This is picture size information stored here for proper print placement.


myPicYOrigin

protected int myPicYOrigin
This is picture size information stored here for proper print placement.


myPicHasOrigin

protected boolean myPicHasOrigin
Flag to indicate whether or not origin coordinates were given.

Constructor Detail

LaBaseTag

protected LaBaseTag(java.lang.String pTagName,
                    java.lang.String pEndTag,
                    java.lang.String pEnvironment,
                    java.lang.String pOptions,
                    java.lang.String pContent)
This constructor allows every aspect of a subclass to be set.

Parameters:
pTagName - The tag name OR beginning tag name. Defaults to 'begin'. Null or blank values are silently ignored.
pEndTag - The end tag name. Defaults to 'end'. Null or blank values are ignored.
pEnvironment - The initial environment. Defaults to null.
pOptions - Initial options. Defaults to null.
pContent - The content to be set. Ignored if null.
Method Detail

_setETEn

protected static final void _setETEn(boolean pEnable)
Use this method to allow a tag to be created with its end tag disabled. Setting this method false suppresses the end tag on THE ONE NEXT instance or subclass created. The internal machinery (private static method) returns false ONCE then resets to true.


reset

public void reset()
This method clears all internal content. It does not alter the tag names, environment or options, only the content and label. Subclasses that override this method to clear their data should issue a call to super.reset() to ensure proper cleaning.


hasEndTag

public final boolean hasEndTag()
This method determines whether or not this instance has a valid ending tag. It returns true if the end tag is not null and not blank, false otherwise.


isEndTagEnabled

public boolean isEndTagEnabled()
This method determines whether or not the end tag is enabled. If false it will not print. If enabled it will print if it is defined.


_setEndTagEnabled

protected void _setEndTagEnabled(boolean pEnable)
Subclasses use this method to enable or disable end tag printing.


getEndTag

public final java.lang.String getEndTag()
This method creates and returns the end tag for this instance. If the end tag is not null or blank this method WILL create one. Enable/disable has no effect on the results. If the end tag is null or blank the return value is an empty String.


_addContent

protected final void _addContent(java.lang.String pData)
Add content to the internal buffer. No linefeeds or other formatting is done, these must be added manually. This method is protected to disallow arbitrary content. Null or blank values are silently ignored.

Parameters:
pData - The content to be added to the internal buffer.

_addRawContent

protected final void _addRawContent(java.lang.String pData)
This method adds content with NO checking whatsoever. USE WITH EXTREME CAUTION!


_getContent

protected final java.lang.String _getContent()
Retrieve the raw content that has been added without any other formatting. Only the content added via _addContent() is returned.


setLabel

public void setLabel(java.lang.String pLabel)
This method allows a '/label{}' tag to appear immediately after the opening line of the block. If the label set is not null or blank it is printed during any output operation. Subclasses that do not allow labels should override this method with an empty one.

Parameters:
pLabel - The label to assign or null to disable.

toString

public java.lang.String toString()
Print all the data within this tag as a properly-formatted String. Newlines are added after each tag command and the (entire!) content.

Overrides:
toString in class java.lang.Object

toStringSET

public java.lang.String toStringSET()
This instance method is identical to toString() with the end tag suppressed. SET means Suppress End Tag and the end tag is explicitly disabled for the duration of this method only. When it returns the original state of the end tag is restored.


copyOf

public abstract LaBaseTag copyOf()
This method provides a copy of a LaBaseTag subclass. Each subclass casts its return value as its own type.


copyOfSET

public abstract LaBaseTag copyOfSET()
Create and return a copy of this tag with its end tag suppressed.