|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.tilman.mathParser.MathMLParser
| Field Summary | |
protected java.lang.String |
COMMENT_PREFIX
The comment prefix for the substitutions file. |
protected java.lang.String |
endTag
|
protected java.lang.StringBuffer |
entity
|
protected java.lang.StringBuffer |
entitySubst
|
protected java.lang.String |
PH_BLOCK
The place holder for blocks in substitutions. |
protected int |
pos
|
protected java.lang.StringBuffer |
result
|
protected char[] |
specialCharacters
|
protected java.lang.String |
startTag
|
protected java.lang.StringBuffer |
strBuf
|
protected java.util.Hashtable |
substitutions
|
protected java.lang.String |
SUBSTITUTIONS_FILE
The default path of the substitutions file |
protected java.lang.StringBuffer |
tagBuf
|
protected boolean |
wrappedEntities
|
| 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,
boolean wrappedEntities)
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) java.lang.String |
parseBlockContent(java.lang.String s)
|
(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 |
protected final java.lang.String SUBSTITUTIONS_FILE
protected final java.lang.String COMMENT_PREFIX
protected final java.lang.String PH_BLOCK
protected final char[] specialCharacters
protected java.util.Hashtable substitutions
protected java.lang.StringBuffer result
protected java.lang.StringBuffer strBuf
protected int pos
protected boolean wrappedEntities
protected java.lang.String startTag
protected java.lang.String endTag
protected java.lang.StringBuffer tagBuf
protected java.lang.StringBuffer entity
protected java.lang.StringBuffer entitySubst
| 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,
boolean wrappedEntities)
throws java.lang.Exception
For example the presentation markup code
<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.
Both notations of entities can be parsed: The plain MathML notation, starting with
an ampersand sign (e.g. '='), or the "HTML wrapped" notation startig with an
entity for the ampersand sign (e.g. '&equals;').
strBuf - a StringBuffer containig the MathML code to parsewrappedEntities - indicates whether the entities in the MathML code are
HTML wrapped (e.g. &PlusMinus;), or not (e.g. ±)
java.lang.Exception - if an error occurs while parsing
java.lang.StringBuffer parseArea(int areaEnd)
throws java.lang.Exception
Pseudocode:
while (pos <= areaEnd) {
if (insideOfInnerstBlock) {
result.append(convertToLatexSyntax(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
java.lang.Exceptionvoid 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.lang.String parseBlockContent(java.lang.String s)
throws java.lang.Exception
java.lang.Exception
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 | |||||||||