|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectde.tilman.mathParser.mathMLParser.MathMLParser
| Field Summary | |
java.lang.String |
COMMENT_PREFIX
The comment prefix for the substitutions file. |
protected java.lang.String |
endTag
|
java.lang.String |
PH_BLOCK
The place holder for blocks in substitutions. |
protected int |
pos
|
protected java.lang.StringBuffer |
result
|
protected java.lang.String |
startTag
|
protected java.lang.StringBuffer |
strBuf
|
protected java.util.Hashtable |
substitutions
|
java.lang.String |
SUBSTITUTIONS_FILE
The default path of the substitutions file |
protected java.lang.StringBuffer |
tagBuf
|
| Constructor Summary | |
MathMLParser()
Generates the substitution table from the default file path in field SUBSTITUTIONS_FILE. |
|
MathMLParser(java.lang.String substitutionsFile)
Generates the substitution table from the given file path. |
|
| Method Summary | |
(package private) int |
getBlockEnd(java.lang.String startTag,
java.lang.String endTag)
Seeks the end of the block defined by the 'startTag' parameter skipping subblocks of the same type. |
(package private) java.util.Hashtable |
getSubstitutionTable(java.lang.String filePath)
Parses the substitution table from the given file. |
java.lang.StringBuffer |
parse(java.lang.StringBuffer strBuf)
Parses MathML code into LaTeX code using the substitution table genereated by the constructor. |
(package private) java.lang.StringBuffer |
parseArea(int areaEnd)
Parses an area of strBuf recursively into LaTeX code. |
(package private) void |
readNextTag()
Jumps to the next tag, reads it into 'startTag' an generates the corresponding 'endTag'. |
(package private) void |
skipClosingTag()
Skips the next tag. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public final java.lang.String SUBSTITUTIONS_FILE
public final java.lang.String COMMENT_PREFIX
public final java.lang.String PH_BLOCK
protected java.util.Hashtable substitutions
protected java.lang.StringBuffer result
protected java.lang.StringBuffer strBuf
protected int pos
protected java.lang.String startTag
protected java.lang.String endTag
protected java.lang.StringBuffer tagBuf
| Constructor Detail |
public MathMLParser()
throws java.io.FileNotFoundException,
java.io.IOException
java.io.FileNotFoundException - if no file was found at the default position
java.io.IOException - if an I/O error occurs
public MathMLParser(java.lang.String substitutionsFile)
throws java.io.FileNotFoundException,
java.io.IOException
substitutionsFile - the path of the text file with the substitution table.
java.io.FileNotFoundException - if the file could not be found
java.io.IOException - if an I/O error occurs| Method Detail |
public java.lang.StringBuffer parse(java.lang.StringBuffer strBuf)
<mrow>
<msup>
<mfenced>
<mrow>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
</mrow>
</mfenced>
<mn>2</mn>
</msup>
</mrow>
can be parsed by this method, while the equivalent content markup
<mrow>
<apply>
<power/>
<apply>
<plus/>
<ci>a</ci>
<ci>b</ci>
</apply>
<cn>2</cn>
</apply>
</mrow>
can not be parsed.
strBuf - a StringBuffer containig the MathML code to parse
java.lang.StringBuffer parseArea(int areaEnd)
Pseudocode:
while (pos <= areaEnd) {
if (insideOfInnerstBlock) {
result.append(area);
}
else {
tmpTag = getNextTag(); // pos = pos + tmpTag.length();
if (substitutionAvailable(tmpTag)) {
while (substitutionContainsBlock) {
addSubstitutionUpToPlaceHolderOfBlockToOutput();
parseArea(getAreaOfNextBlock());
}
addRestOfSubstitutionOutPut();
}
else {
parseArea(pos, getAreaEnd(tmpTag));
}
skipClosingTag();
}
}
areaEnd - the end of the area to parse
void readNextTag()
void skipClosingTag()
int getBlockEnd(java.lang.String startTag,
java.lang.String endTag)
startTag - the tag that opened the blockendTag - the end tag to seek
java.util.Hashtable getSubstitutionTable(java.lang.String filePath)
throws java.io.FileNotFoundException,
java.io.IOException
filePath - the path of the substitutions file
java.io.FileNotFoundException - if the substitutions file could not be found
java.io.IOException - if an I/O error occurs
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||