Fix error in tagData remove action.

This commit is contained in:
Christian P. MOMON 2010-02-24 16:54:53 +01:00
parent 58ffaea88d
commit e473833ccc

View file

@ -117,11 +117,11 @@ public class Presenter
/* /*
* *
*/ */
static protected StringBuffer processChildren (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput) static protected StringBuffer processChildren (Node node, IdsDataById datas, StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
result = processChildren (node, datas, webappPath, "", errorOutput); result = processChildren (node, datas, "", errorOutput);
// //
return (result); return (result);
@ -132,10 +132,9 @@ public class Presenter
* *
*/ */
static protected StringBuffer processChildren (Node node, static protected StringBuffer processChildren (Node node,
IdsDataById datas, IdsDataById datas,
String webappPath, String suffix,
String suffix, StringBuffer errorOutput)
StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
result = new StringBuffer (); result = new StringBuffer ();
@ -182,90 +181,90 @@ public class Presenter
switch (strategy) switch (strategy)
{ {
case ONLY_FIRST_ROW: case ONLY_FIRST_ROW:
int lineCounter = 0; int lineCounter = 0;
for (int childIndex = 0; childIndex < childrenCount; childIndex++) for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
{ {
lineCounter += 1; if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
if (lineCounter == 1) {
lineCounter += 1;
if (lineCounter == 1)
{
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
}
}
else
{
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
}
}
break;
case ONLY_FIRST_TWO_ROWS:
lineCounter = 0;
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
{
lineCounter += 1;
if ((lineCounter == 1) || (lineCounter == 2))
{
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
}
}
else
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); result.append (process (children.item (childIndex), datas, suffix, errorOutput));
} }
} }
else break;
case ONLY_ROWS_WITH_ID:
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
} {
} NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
break;
if ((attrs2 != null) &&
case ONLY_FIRST_TWO_ROWS: (attrs2.getNamedItem ("id") != null))
lineCounter = 0; {
for (int childIndex = 0; childIndex < childrenCount; childIndex++) result.append (process (children.item (childIndex), datas, suffix, errorOutput));
{ }
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) }
{ else
lineCounter += 1;
if ((lineCounter == 1) || (lineCounter == 2))
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); result.append (process (children.item (childIndex), datas, suffix, errorOutput));
} }
} }
else break;
case ONLY_ROWS_WITHOUT_ID:
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
} {
} NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
break; if ((attrs2 == null) ||
(attrs2.getNamedItem ("id") == null))
case ONLY_ROWS_WITH_ID: {
for (int childIndex = 0; childIndex < childrenCount; childIndex++) result.append (process (children.item(childIndex), datas, suffix, errorOutput));
{ }
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) }
{ else
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
if ((attrs2 != null) &&
(attrs2.getNamedItem ("id") != null))
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); result.append (process (children.item (childIndex), datas, suffix, errorOutput));
} }
} }
else break;
case ALL_ROWS:
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{ {
result.append (process (children.item (childIndex), datas, suffix, errorOutput)); result.append (process (children.item(childIndex), datas, suffix, errorOutput));
} }
} break;
break;
case ONLY_ROWS_WITHOUT_ID:
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
{
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
if ((attrs2 == null) ||
(attrs2.getNamedItem ("id") == null))
{
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
}
}
else
{
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
}
}
break;
case ALL_ROWS:
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
{
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
}
break;
} }
// //
@ -285,16 +284,15 @@ public class Presenter
* The ID. * The ID.
*/ */
static protected StringBuffer processElementWithId (Node node, static protected StringBuffer processElementWithId (Node node,
NamedNodeMap attrs, NamedNodeMap attrs,
Node idAttr, Node idAttr,
IdsDataById datas, IdsDataById datas,
String webappPath, StringBuffer errorOutput)
StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
result = processElementWithId (node, attrs, idAttr, datas, "", webappPath, errorOutput); result = processElementWithId (node, attrs, idAttr, datas, "", errorOutput);
// //
return (result); return (result);
@ -316,7 +314,6 @@ public class Presenter
NamedNodeMap attrs, NamedNodeMap attrs,
Node idAttr, Node idAttr,
IdsDataById datas, IdsDataById datas,
String webappPath,
String suffix, String suffix,
StringBuffer errorOutput) StringBuffer errorOutput)
{ {
@ -334,7 +331,7 @@ public class Presenter
if (dataCore == null) if (dataCore == null)
{ {
result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput));
} }
else if (dataCore instanceof IdData) else if (dataCore instanceof IdData)
{ {
@ -351,7 +348,7 @@ public class Presenter
} }
if ((theClass == null) || if ((theClass == null) ||
(!theClass.equals ("xid:nodisplay"))) (!theClass.equals ("xid:nodisplay")))
{ {
// Open the tag. // Open the tag.
result.append ("<"); result.append ("<");
@ -376,7 +373,7 @@ public class Presenter
if ((data == null) || if ((data == null) ||
(data.display () == null)) (data.display () == null))
{ {
result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); result.append (processChildren (node, datas, suffix, errorOutput));
} }
else else
{ {
@ -408,7 +405,7 @@ public class Presenter
result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine))); result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine)));
if ((node.getChildNodes () == null) && if ((node.getChildNodes () == null) &&
((data == null) || (data.display () == null))) ((data == null) || (data.display () == null)))
{ {
// Close the tag. // Close the tag.
result.append (" />\n"); result.append (" />\n");
@ -423,7 +420,7 @@ public class Presenter
// Insert data. // Insert data.
if ((data == null) || (data.display () == null)) if ((data == null) || (data.display () == null))
{ {
result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); result.append (processChildren (node, datas, suffix, errorOutput));
} }
else else
{ {
@ -441,7 +438,7 @@ public class Presenter
// Manage a Hashmap. // Manage a Hashmap.
IdsDataById data = (IdsDataById) tags.elementAt (nLine); IdsDataById data = (IdsDataById) tags.elementAt (nLine);
result.append (Presenter.processElementWithId (node, attrs, idAttr, data, webappPath, Integer.toString (nLine), errorOutput)); result.append (Presenter.processElementWithId (node, attrs, idAttr, data, Integer.toString (nLine), errorOutput));
result.append ('\n'); result.append ('\n');
} }
} }
@ -478,7 +475,7 @@ public class Presenter
*/ */
static protected StringBuffer process (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput) static protected StringBuffer process (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput)
{ {
logger.debug ("Enter"); logger.debug ("process - started");
String TRANSITIONAL_DTD = "xhtml1-transitional.dtd"; String TRANSITIONAL_DTD = "xhtml1-transitional.dtd";
String TRANSITIONAL_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " String TRANSITIONAL_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 "
+ "Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; + "Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
@ -495,114 +492,114 @@ public class Presenter
name = getClassAttributeValue (node); name = getClassAttributeValue (node);
if ((name == null) || if ((name == null) ||
((name != null) && ((name != null) &&
(!name.equals ("xid:nodisplay")))) (!name.equals ("xid:nodisplay"))))
{ {
int type = node.getNodeType(); int type = node.getNodeType();
switch (type) switch (type)
{ {
case Node.DOCUMENT_NODE: case Node.DOCUMENT_NODE:
{
logger.debug ("case Node.DOCUMENT_NODE");
DocumentType dt = ((Document) node).getDoctype();
if (dt != null)
{ {
String publicId = dt.getPublicId(); logger.debug ("case Node.DOCUMENT_NODE");
String systemId = dt.getSystemId(); DocumentType dt = ((Document) node).getDoctype();
if (systemId.equals(TRANSITIONAL_DTD)) if (dt != null)
{ {
result.append(TRANSITIONAL_DOCTYPE); String publicId = dt.getPublicId();
String systemId = dt.getSystemId();
if (systemId.equals(TRANSITIONAL_DTD))
{
result.append(TRANSITIONAL_DOCTYPE);
}
// Log.write(Log.TRACE,"publicId = " + publicId);
// Log.write(Log.TRACE,"systemId = " + systemId);
} }
// Log.write(Log.TRACE,"publicId = " + publicId); result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix, errorOutput));
// Log.write(Log.TRACE,"systemId = " + systemId);
break;
} }
result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix, errorOutput)); case Node.ELEMENT_NODE:
break;
}
case Node.ELEMENT_NODE:
{
logger.debug ("case Node.ELEMENT_NODE");
NamedNodeMap attrs = node.getAttributes ();
Node idAttr = attrs.getNamedItem ("id");
if (idAttr != null)
{ {
result.append (Presenter.processElementWithId (node, logger.debug ("case Node.ELEMENT_NODE");
attrs,
idAttr, NamedNodeMap attrs = node.getAttributes ();
datas, Node idAttr = attrs.getNamedItem ("id");
suffix,
errorOutput)); if (idAttr != null)
{
result.append (Presenter.processElementWithId (node,
attrs,
idAttr,
datas,
suffix,
errorOutput));
}
else
{
result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput));
}
break;
} }
else
// handle entity reference nodes
case Node.ENTITY_REFERENCE_NODE:
{ {
result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput)); logger.debug ("case Node.ENTITY_REFERENCE_NODE");
result.append ('&');
result.append (node.getNodeName());
result.append (';');
break;
} }
break; // print cdata sections
} case Node.CDATA_SECTION_NODE:
// handle entity reference nodes
case Node.ENTITY_REFERENCE_NODE:
{
logger.debug ("case Node.ENTITY_REFERENCE_NODE");
result.append ('&');
result.append (node.getNodeName());
result.append (';');
break;
}
// print cdata sections
case Node.CDATA_SECTION_NODE:
{
logger.debug ("case Node.CDATA_SECTION_NODE");
result.append ("<![CDATA[");
result.append (node.getNodeValue());
result.append ("]]>");
break;
}
// print text
case Node.TEXT_NODE:
{
logger.debug ("case Node.TEXTE_NODE");
result.append (restoreEntities (new StringBuffer(node.getNodeValue())));
break;
}
// print processing instruction
case Node.PROCESSING_INSTRUCTION_NODE:
{
logger.debug ("Node.PROCESSING_INSTRUCTION_NODE");
result.append ("<?");
result.append (node.getNodeName());
String data = node.getNodeValue();
if ((data != null) && (data.length () > 0))
{ {
result.append (' '); logger.debug ("case Node.CDATA_SECTION_NODE");
result.append (data);
result.append ("<![CDATA[");
result.append (node.getNodeValue());
result.append ("]]>");
break;
}
// print text
case Node.TEXT_NODE:
{
logger.debug ("case Node.TEXTE_NODE");
result.append (restoreEntities (new StringBuffer(node.getNodeValue())));
break;
}
// print processing instruction
case Node.PROCESSING_INSTRUCTION_NODE:
{
logger.debug ("Node.PROCESSING_INSTRUCTION_NODE");
result.append ("<?");
result.append (node.getNodeName());
String data = node.getNodeValue();
if ((data != null) && (data.length () > 0))
{
result.append (' ');
result.append (data);
}
result.append ("?>");
break;
} }
result.append ("?>");
break;
}
} }
} }
} }
// //
//logger.info ("result=" + result); //logger.info ("result=" + result);
logger.debug ("Exit"); logger.debug ("process - ended");
return (result); return (result);
} }
@ -610,11 +607,11 @@ public class Presenter
/* /*
* *
*/ */
static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput) static StringBuffer processElementBasically (Node node, IdsDataById datas,StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
result = processElementBasically (node, datas, webappPath, "", errorOutput); result = processElementBasically (node, datas, "", errorOutput);
// //
return (result); return (result);
@ -624,15 +621,24 @@ public class Presenter
/* /*
* *
*/ */
static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, String suffix, StringBuffer errorOutput) static StringBuffer processElementBasically (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
logger.debug("processElementBasically - started");
result = new StringBuffer (); result = new StringBuffer ();
// Open the tag. // Open the tag.
result.append ('<'); result.append ('<');
result.append (node.getNodeName()); result.append (node.getNodeName());
// Build the tag attributes.
Attributes tagAttributes;
result.append (processAttributes (node.getAttributes (),
null,
suffix));
// //
if (node.getChildNodes () == null) if (node.getChildNodes () == null)
{ {
@ -642,13 +648,14 @@ public class Presenter
{ {
result.append('>'); result.append('>');
result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); result.append (processChildren (node, datas, suffix, errorOutput));
result.append("</"); result.append("</");
result.append(node.getNodeName()); result.append(node.getNodeName());
result.append('>'); result.append('>');
} }
logger.debug("processElementBasically - ended");
// //
return (result); return (result);