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,19 +183,19 @@ public class FilePresenter extends StringPresenter
*
*/
@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 (this.sourceFilePathname.matches("file://.+"))
else if (source.matches("file://.+"))
{
try
{
this.source = new File(new URI(this.sourceFilePathname));
file = new File(new URI(source));
}
catch (URISyntaxException exception)
{
@ -205,12 +205,11 @@ public class FilePresenter extends StringPresenter
}
else
{
this.source = new File(this.sourceFilePathname);
}
this.sourceFilePathname = filePathname;
this.sourceTime = 0;
super.setSource(null);
file = new File(source);
}
//
setSource(file);
}
/**

View file

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

View file

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