1 25 package org.archive.util.anvl; 26 27 28 37 class Element { 38 private final SubElement [] subElements; 39 40 public Element(final Label l) { 41 this.subElements = new SubElement [] {l}; 42 } 43 44 public Element(final Label l, final Value v) { 45 this.subElements = new SubElement [] {l, v}; 46 } 47 48 public boolean isValue() { 49 return this.subElements.length > 1; 50 } 51 52 public Label getLabel() { 53 return (Label)this.subElements[0]; 54 } 55 56 public Value getValue() { 57 if (!isValue()) { 58 return null; 59 } 60 return (Value)this.subElements[1]; 61 } 62 63 @Override 64 public String toString() { 65 StringBuilder sb = new StringBuilder (); 66 for (int i = 0; i < subElements.length; i++) { 67 sb.append(subElements[i].toString()); 68 if (i == 0) { 69 sb.append(':'); 71 if (isValue()) { 72 sb.append(' '); 74 } 75 } 76 } 77 return sb.toString(); 78 } 79 } 80 | Popular Tags |