Fix checkstyle errors

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier committed 2004-05-09 20:58:49 +00:00
1 parent 8ca620c806
commit 399f02f4d8
4 files changed
+669 -399

No files matched your search

+174 -110
View File
@@ -16,141 +16,205 @@ package org.apache.maven;
* limitations under the License.
* ====================================================================
*/
import org.dom4j.Attribute;
import org.dom4j.Node;
import org.dom4j.tree.DefaultElement;
import java.util.List;
import org.dom4j.Attribute;
import org.dom4j.Node;
import org.dom4j.tree.DefaultElement;
/**
* @author <a href="bwalding@jakarta.org">Ben Walding</a>
* @version $Id: NavBean.java,v 1.7 2004/03/02 15:36:14 evenisse Exp $
* Navigation Bean.
*
* @author <a href="mailto:bwalding@jakarta.org">Ben Walding</a>
* @version $Id: NavBean.java,v 1.8 2004/05/09 20:58:49 aheritier Exp $
*/
public class NavBean
{
private String location;
private Node document;
//~ Instance fields ----------------------------------------------------------
public void setDocument(Object o)
/** The current document. */
private Node document;
/** The current location. */
private String location;
//~ Methods ------------------------------------------------------------------
/**
* Determines if the given node is collapsed. If a parent of this node is
* collapsed, this will give spurious results.
*
* @param o the node to test
*
* @return boolean
*/
public boolean isCollapsed(Object o)
{
//If we don't know where we are, collapse it - something outside of our knowledge
if (location == null)
{
document = (Node) o;
return true;
}
private static String getAttribute(DefaultElement elem, String attribute, String defaultValue)
if (!(o instanceof DefaultElement))
{
Attribute attr = elem.attribute(attribute);
if (attr == null)
{
return defaultValue;
}
System.out.println(o.getClass().getName());
return attr.getStringValue();
return false;
}
private static boolean getCollapseAttribute(DefaultElement elem)
DefaultElement elem = (DefaultElement) o;
boolean collapsed = getCollapseAttribute(elem);
if (!collapsed)
{
return Boolean.valueOf(getAttribute(elem, "collapse", "false")).booleanValue();
}
private static String getHREFAttribute(DefaultElement elem)
{
return getAttribute(elem, "href", null);
}
/**
* Determines if the given node is collapsed. If a parent of this node is
* collapsed, this will give spurious results.
* @param o
* @return boolean
*/
public boolean isCollapsed(Object o)
{
//If we don't know where we are, collapse it - something outside of our knowledge
if (location == null)
{
return true;
}
if (!(o instanceof DefaultElement))
{
System.out.println(o.getClass().getName());
return false;
}
DefaultElement elem = (DefaultElement) o;
boolean collapsed = getCollapseAttribute(elem);
if (!collapsed)
{
return false;
}
if (isSelected(o))
{
return false;
}
//System.out.println(elem.asXML());
String xpath;
if (location.startsWith("/") || location.startsWith(".")) {
xpath = ".//item[@href='" + location + "']";
} else {
xpath = ".//item[@href='/" + location + "']";
}
List l = elem.selectNodes(xpath);
if (l.size() != 0)
{
return false;
}
return true;
return false;
}
/**
* Determines if a given <code>item</code> node is the selected node
* @param o
* @return boolean
*/
public boolean isSelected(Object o)
if (isSelected(o))
{
if (location == null)
{
return false;
}
DefaultElement elem = (DefaultElement) o;
if (location.equals(getHREFAttribute(elem)))
{
return true;
}
return false;
return false;
}
/**
* Sets the location.
* @param location The location to set
*/
public void setLocation(String location)
//System.out.println(elem.asXML());
String xpath;
if (location.startsWith("/") || location.startsWith("."))
{
if (!location.startsWith("/"))
location = "/" + location;
this.location = location;
xpath = ".//item[@href='" + location + "']";
}
else
{
xpath = ".//item[@href='/" + location + "']";
}
/**
* Find the first <code>item</code> with a given href
* @param href
* @return DefaultElement
*/
public DefaultElement getFirstNodeByHREF(String href)
List l = elem.selectNodes(xpath);
if (l.size() != 0)
{
String xpath = "//item[@href='" + href + "']";
return (DefaultElement) document.selectSingleNode(xpath);
return false;
}
return true;
}
/**
* Setter.
*
* @param o The new document.
*/
public void setDocument(Object o)
{
document = (Node) o;
}
/**
* Find the first <code>item</code> with a given href
*
* @param href the href to find.
*
* @return DefaultElement
*/
public DefaultElement getFirstNodeByHREF(String href)
{
String xpath = "//item[@href='" + href + "']";
return (DefaultElement) document.selectSingleNode(xpath);
}
/**
* Sets the location.
*
* @param newLocation The location to set
*/
public void setLocation(String newLocation)
{
if (!newLocation.startsWith("/"))
{
newLocation = "/" + newLocation;
}
this.location = newLocation;
}
/**
* Determines if a given <code>item</code> node is the selected node
*
* @param o the item to test
*
* @return true if the item is currently selected.
*/
public boolean isSelected(Object o)
{
if (location == null)
{
return false;
}
DefaultElement elem = (DefaultElement) o;
if (location.equals(getHREFAttribute(elem)))
{
return true;
}
return false;
}
/**
* Return the attribute's value for an element.
*
* @param elem The element to read
* @param attribute The attribute's name to get.
* @param defaultValue A default value to return.
*
* @return The attribute's value for the given element.
*/
private static String getAttribute(
DefaultElement elem,
String attribute,
String defaultValue)
{
Attribute attr = elem.attribute(attribute);
if (attr == null)
{
return defaultValue;
}
return attr.getStringValue();
}
/**
* Test if the element is collapsed.
*
* @param elem The element to test
*
* @return true if the element has a collapse attribute with the value true.
*/
private static boolean getCollapseAttribute(DefaultElement elem)
{
return Boolean.valueOf(getAttribute(
elem,
"collapse",
"false")).booleanValue();
}
/**
* Return href attribute.
*
* @param elem element.
*
* @return href value.
*/
private static String getHREFAttribute(DefaultElement elem)
{
return getAttribute(
elem,
"href",
null);
}
}