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
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
{
if (this.sourceFilePathname.matches("file://.+"))
{
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);
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