Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2012-08-11 12:27:21 -0400
committerFlorian Thienel2012-08-11 12:27:21 -0400
commit331829ed0be9b15ad9a51c4647e5247ca1d28b7a (patch)
tree566387f92e2abe1cdc68051b4f66fc3697dea797 /org.eclipse.vex.xhtml/src/org/eclipse
parentf9c4ec56202398307aa40ec0cbdc981d54d3a3b4 (diff)
downloadorg.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.tar.gz
org.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.tar.xz
org.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.zip
apply project specific formatting and "clean code" conventions
Signed-off-by: Florian Thienel <florian@thienel.org>
Diffstat (limited to 'org.eclipse.vex.xhtml/src/org/eclipse')
-rw-r--r--org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java48
1 files changed, 30 insertions, 18 deletions
diff --git a/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java b/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
index 9b77d372..bbba6e12 100644
--- a/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
+++ b/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
@@ -46,8 +46,9 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
// TODO: compare to all structural element names
final String name = element.getLocalName();
- if (name.equals("h1") || name.equals("h2") || name.equals("h3") || name.equals("h4") || name.equals("h5") || name.equals("h6"))
+ if (name.equals("h1") || name.equals("h2") || name.equals("h3") || name.equals("h4") || name.equals("h5") || name.equals("h6")) {
return element;
+ }
element = element.getParent();
}
@@ -70,10 +71,11 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
public Object getParent(final Object element) {
final Element parent = ((Element) element).getParent();
- if (parent == null)
+ if (parent == null) {
return element;
- else
+ } else {
return getOutlineElement(parent);
+ }
}
public boolean hasChildren(final Object element) {
@@ -88,8 +90,8 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
};
/**
- * Returns an array of the children of the given element that represent
- * nodes in the outline. These are structural elements such as "section".
+ * Returns an array of the children of the given element that represent nodes in the outline. These are structural
+ * elements such as "section".
*
* @param element
* @return
@@ -103,14 +105,18 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
// First, find the lowest numbered h tag available
String lowH = "h6";
- for (final Element child : childElements)
- if (isHTag(child) && child.getLocalName().compareTo(lowH) < 0)
+ for (final Element child : childElements) {
+ if (isHTag(child) && child.getLocalName().compareTo(lowH) < 0) {
lowH = child.getLocalName();
+ }
+ }
// Now, get all body children at that level
- for (final Element child : childElements)
- if (child.getLocalName().equals(lowH))
+ for (final Element child : childElements) {
+ if (child.getLocalName().equals(lowH)) {
children.add(child);
+ }
+ }
}
} else if (isHTag(element)) {
// get siblings with the next lower number
@@ -119,16 +125,18 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
final String childName = "h" + (level + 1);
final List<Element> childElements = element.getParent().getChildElements();
boolean foundSelf = false;
- for (final Element child : childElements)
- if (child == element)
+ for (final Element child : childElements) {
+ if (child == element) {
foundSelf = true;
- else if (!foundSelf)
+ } else if (!foundSelf) {
continue;
- else if (child.getLocalName().equals(childName))
+ } else if (child.getLocalName().equals(childName)) {
children.add(child);
- else if (child.getLocalName().equals(element.getLocalName()))
+ } else if (child.getLocalName().equals(element.getLocalName())) {
// terminate at next sibling at same level
break;
+ }
+ }
}
return (Element[]) children.toArray(new Element[children.size()]);
}
@@ -143,19 +151,23 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
final Element head = findChild(element, "head");
if (head != null) {
final Element title = findChild(head, "title");
- if (title != null)
+ if (title != null) {
text = title.getText();
+ }
}
- } else
+ } else {
text = element.getText();
+ }
return text;
}
};
private Element findChild(final Element parent, final String childName) {
- for (final Element child : parent.getChildElements())
- if (child.getLocalName().equals(childName))
+ for (final Element child : parent.getChildElements()) {
+ if (child.getLocalName().equals(childName)) {
return child;
+ }
+ }
return null;
}

Back to the top