Fix index inc in findHeadNode. Improve FilePresenter code.

This commit is contained in:
Christian P. MOMON 2013-08-20 01:05:46 +02:00
parent e9c15da22a
commit 8ecec43df2
3 changed files with 31 additions and 25 deletions

View file

@ -183,34 +183,33 @@ public class FilePresenter extends StringPresenter
* *
*/ */
@Override @Override
public void setSource(final String filePathname) public void setSource(final String source)
{ {
if (filePathname == null) //
File file;
if (source == null)
{ {
setSource((File) null); file = null;
}
else if (source.matches("file://.+"))
{
try
{
file = new File(new URI(source));
}
catch (URISyntaxException exception)
{
exception.printStackTrace();
throw new IllegalArgumentException("Bad URI argument.", exception);
}
} }
else else
{ {
if (this.sourceFilePathname.matches("file://.+")) file = new File(source);
{
try
{
this.source = new File(new URI(this.sourceFilePathname));
}
catch (URISyntaxException exception)
{
exception.printStackTrace();
throw new IllegalArgumentException("Bad URI argument.", exception);
}
}
else
{
this.source = new File(this.sourceFilePathname);
}
this.sourceFilePathname = filePathname;
this.sourceTime = 0;
super.setSource(null);
} }
//
setSource(file);
} }
/** /**

View file

@ -142,6 +142,7 @@ public class URLPresenter extends StringPresenter
@Override @Override
public void setSource(final String source) public void setSource(final String source)
{ {
//
URL url; URL url;
if (source == null) if (source == null)
{ {
@ -165,6 +166,7 @@ public class URLPresenter extends StringPresenter
url = URLPresenter.class.getResource(source); url = URLPresenter.class.getResource(source);
} }
//
setSource(url); setSource(url);
} }

View file

@ -39,9 +39,9 @@ public class XidynUtils
static public void addMetaTag(final Document doc, final String name, final String content) static public void addMetaTag(final Document doc, final String name, final String content)
{ {
// Find head tag. // Find head tag.
Node headNode = findHeadNode(doc); Node headNode = findHeadNode(doc);
logger.debug("headNode = [" + headNode + "]"); logger.debug("headNode = [" + headNode + "]");
if (headNode != null) if (headNode != null)
{ {
Node metaNode = doc.createElement("meta"); Node metaNode = doc.createElement("meta");
@ -432,10 +432,15 @@ public class XidynUtils
{ {
if (childrenIndex < childrenCount) if (childrenIndex < childrenCount)
{ {
result = findNodeByName(children.item(childrenIndex), name); Node subResult = findNodeByName(children.item(childrenIndex), name);
if (result != null) if (subResult == null)
{
childrenIndex += 1;
}
else
{ {
ended = true; ended = true;
result = subResult;
} }
} }
else else