|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Writer
lp.struct.util.LpPrinter<W>
lp.struct.util.LpPrettyPrinter<W>
lp.struct.util.EvolpPrettyPrinter<W>
lp.struct.util.LpHtmlPrinter<W>
public class LpHtmlPrinter<W extends Writer>
Transforms a logic program (or its components} represented by objects
implementing the LpStructureUnit interface into an HTML
representation. Rules are surrounded by a <p class="rule"> element.
Constants, variables, function symbols and predicate symbols are put inside a
<span> element of the class "constant", "variable", "function" or
"predicate", respectively. All dots, commas, parenthesis and head-body
separators are put inside a <span class="puctuation"> element.
The class also offers two convenience methods for appending a dynamic logic
program and an evolving logic program (append(DynamicLogicProgram)
and append(EvolpProgram)).
EvolpPrettyPrinter| Field Summary |
|---|
| Fields inherited from class lp.struct.util.EvolpPrettyPrinter |
|---|
innerTermsLeft, trackPosition |
| Fields inherited from class lp.struct.util.LpPrettyPrinter |
|---|
ARROW_STRING, SPACE_STRING |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
LpHtmlPrinter(W out)
Creates a new instance of LpHtmlPrinter. |
|
LpHtmlPrinter(W out,
String arrow,
boolean withSpaces)
Creates a new instance of LpHtmlPrinter. |
|
| Method Summary | |
|---|---|
void |
append(DynamicLogicProgram dlp)
Appends a dynamic logic program. |
void |
append(EvolpProgram evolp)
Appends an evolving logic program and a sequence of events. |
protected void |
appendOuterRule(LpRule rule)
Takes care of writing an ordinary rule, just like LpPrettyPrinter
does. |
protected void |
appendPunctuation(char punctuation)
Appends punctuation surrounded by a <span class="punctuation">
element. |
protected void |
appendPunctuation(String punctuation)
Appends punctuation surrounded by a
<span class="punctuation"> element. |
protected void |
arrow()
Appends the LpPrettyPrinter.ARROW_STRING enclosed in a
<span class="punctuation"> element. |
protected void |
beginParen()
Appends a left parenthesis enclosed in a <span class="punctuation"> element. |
protected void |
comma()
Appends a comma enclosed in a <span class="punctuation"> element. |
protected void |
dot()
Appends a dot enclosed in a <span class="punctuation"> element. |
protected void |
endParen()
Appends a right parenthesis enclosed in a <span class="punctuation"> element. |
static LpBuffer |
getBuffer()
A convenience method that creates a new LpBuffer that uses a new
LpHtmlPrinter instance to write
LpStructureUnits. |
static LpBuffer |
getBuffer(String arrow,
boolean withSpaces)
A convenience method that creates a new LpBuffer that uses a new
LpHtmlPrinter instance to write
LpStructureUnits. |
protected void |
literalPrefix(boolean positive)
Appends an empty string when positive is true and the
string "<span class=\"negLitPrefix\">not</span> " otherwise. |
void |
visit(LpConstant con)
Appends an HTML form of a LpConstant instance to this
LpHtmlPrinter. |
void |
visit(LpFunction fun)
Appends an HTML form of a LpFunction instance to this
LpHtmlPrinter. |
void |
visit(LpPredicate pred)
Appends an HTML form of a LpPredicate instance to this
LpHtmlPrinter. |
void |
visit(LpVariable var)
Appends an HTML form of a LpVariable instance to this
LpHtmlPrinter. |
| Methods inherited from class lp.struct.util.EvolpPrettyPrinter |
|---|
appendInnerRule, registerTerm, visit, visit, write |
| Methods inherited from class lp.struct.util.LpPrettyPrinter |
|---|
appendRuleNoDot, space, visit, visit, visitArgumentList |
| Methods inherited from class lp.struct.util.LpPrinter |
|---|
append, append, append, append, close, flush, getOut, setOut, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LpHtmlPrinter(W out)
LpHtmlPrinter. It will use the
string "<-" to separate the head and body of a rule. The output will also
contain extra spaces to enhance readability.
out - the underlying writer into which everything will be written
public LpHtmlPrinter(W out,
String arrow,
boolean withSpaces)
LpHtmlPrinter. It will use the
string arrow to separate the head and body of a rule. If
withSpaces is true, then the output will also contain
extra spaces to enhance readability.
out - the underlying writer into which everything will be writtenarrow - the string to separate the head and body of a rulewithSpaces - determines whether extra spaces should be added to
places where they can make the output more readable
IllegalArgumentException - if arrow is null| Method Detail |
|---|
public static LpBuffer getBuffer()
LpBuffer that uses a new
LpHtmlPrinter instance to write
LpStructureUnits. It will use the string "<-" to
separate the head and body of a rule. The output will also contain extra
spaces to enhance readability.
LpBuffer
public static LpBuffer getBuffer(String arrow,
boolean withSpaces)
LpBuffer that uses a new
LpHtmlPrinter instance to write
LpStructureUnits. It will use the string arrow
to separate the head and body of a rule. If withSpaces is
true, then the output will also contain extra spaces to enhance
readability.
arrow - the string to separate the head and body of a rulewithSpaces - determines whether extra spaces should be added to
places where they can make the output more readable
LpBufferpublic void append(DynamicLogicProgram dlp)
<div class="ruleGroup"> element whose first child
is a <p class="comment"> element containing the text
"% Program no. $i" where $i is the number of the program. The other
children of the <div> are the rules of the program.
dlp - dynamic logic program to be appended
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerpublic void append(EvolpProgram evolp)
<div class="ruleGroup"> element whose first child is a
<p class="comment"> containing either "% Base program" or
"% Event no. $i" where $i is the number of the event. The other children
of the <div> are the rules of the base program or event.
evolp - evolving logic program to be appended
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void appendPunctuation(String punctuation)
punctuation surrounded by a
<span class="punctuation"> element.
punctuation - string to be appended as punctuation
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void appendPunctuation(char punctuation)
punctuation surrounded by a <span class="punctuation">
element.
punctuation - character to be appended as punctuation
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void beginParen()
<span class="punctuation"> element.
beginParen in class LpPrettyPrinter<W extends Writer>IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void endParen()
<span class="punctuation"> element.
endParen in class LpPrettyPrinter<W extends Writer>IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void comma()
<span class="punctuation"> element.
comma in class LpPrettyPrinter<W extends Writer>IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void literalPrefix(boolean positive)
positive is true and the
string "<span class=\"negLitPrefix\">not</span> " otherwise.
literalPrefix in class LpPrettyPrinter<W extends Writer>positive - identifies whether a prefix for a positive or a negative
literal should be appended
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void arrow()
LpPrettyPrinter.ARROW_STRING enclosed in a
<span class="punctuation"> element.
arrow in class LpPrettyPrinter<W extends Writer>IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerprotected void dot()
<span class="punctuation"> element.
dot in class LpPrettyPrinter<W extends Writer>IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writerpublic void visit(LpConstant con)
LpConstant instance to this
LpHtmlPrinter. Shouldn't be called directly,
LpPrinter.append(LpStructureUnit) should be used instead.
The natural form of a constant is its name
(see LpConstant.getName()) enclosed in a
<span class="constant"> element.
visit in interface LpStructureUnitVisitorvisit in class EvolpPrettyPrinter<W extends Writer>con - the LpConstant instance whose HTML representation
should be appended to the underlying Writer
NullPointerException - if con is null
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
WriterLpPrinter,
LpStructureUnitVisitor.visit(LpConstant)public void visit(LpVariable var)
LpVariable instance to this
LpHtmlPrinter. Shouldn't be called directly,
LpPrinter.append(LpStructureUnit) should be used instead.
The HTML of a variable is its name
(see LpVariable.getName()) enclosed in a
<span class="variable"> element.
visit in interface LpStructureUnitVisitorvisit in class EvolpPrettyPrinter<W extends Writer>var - the LpVariable instance whose HTML representation
should be appended to the underlying Writer
NullPointerException - if var is null
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
WriterLpPrinter,
LpStructureUnitVisitor.visit(LpVariable)public void visit(LpFunction fun)
LpFunction instance to this
LpHtmlPrinter. Shouldn't be called directly,
LpPrinter.append(LpStructureUnit) should be used instead.
The HTML form of a function is its name
(see LpFunction.getName()) enclosed in a
<span class="function"> element.
visit in interface LpStructureUnitVisitorvisit in class EvolpPrettyPrinter<W extends Writer>fun - the LpFunction instance whose HTML representation
should be appended to the underlying Writer
NullPointerException - if fun is null
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
WriterLpPrinter,
LpStructureUnitVisitor.visit(LpFunction)public void visit(LpPredicate pred)
LpPredicate instance to this
LpHtmlPrinter. Shouldn't be called directly,
LpPrinter.append(LpStructureUnit) should be used instead.
The natural form of a predicate is its name
(see LpPredicate.getName()) enclosed in a
<span class="predicate"> element.
visit in interface LpStructureUnitVisitorvisit in class EvolpPrettyPrinter<W extends Writer>pred - the LpPredicate instance whose HTML representation
should be appended to the underlying Writer
NullPointerException - if pred is null
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
WriterLpPrinter,
LpStructureUnitVisitor.visit(LpPredicate)protected void appendOuterRule(LpRule rule)
LpPrettyPrinter
does. The rule is enclosed in a <p class="rule"> element.
appendOuterRule in class EvolpPrettyPrinter<W extends Writer>rule - the rule to write
NullPointerException - if rule is null
IOException - (wrapped in an ExceptionAdapter) in
case an I/O exception occurs while writing to the underlying
Writer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||