/** * Returns whether it has the letter(s) or integer position of the column. * * @return whether it has the letter(s) or integer position of the column */ public boolean hasIndex() { return getIndex() != null; }
/** * Returns whether it has the user defined name of the column. * * @return whether it has the user defined name of the column */ public boolean hasName() { return getName() != null; }
/** * Immutable constructor. * * @param index letter(s) or integer position of the column. * @param name user defined name of the column. */ public Column(String index, String name) { super(); setIndex(index); setName(name); setImmutable(true); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!sameClassAs(obj)) { return false; } Column other = (Column) obj; return eq(index, other.index) && eq(name, other.name); }
/** * Populates the given Data object with information from the given element. */ private void parseElement(Element element, Data data) { NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) node; if (hasClass(child, "gs:column")) { Column column = new Column(); column.setIndex(child.getAttribute("title")); column.setName(child.getTextContent()); data.addColumn(column); } else { parseElement(child, data); } } } } }
/** * Sets the letter(s) or integer position of the column. * * @param index letter(s) or integer position of the column or * <code>null</code> to reset */ public void setIndex(String index) { throwExceptionIfImmutable(); this.index = index; }
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(Data.class)) { return; } extProfile.declare(Data.class, Column.getDefaultDescription(false, true)); }
@Override protected void validate() { if (index == null) { throwExceptionForMissingAttribute(INDEX); } if (name == null) { throwExceptionForMissingAttribute(NAME); } }
@Override public XmlElement renderList(ListPageEntry entry, @Nullable List<ListItemEntry> listItems) { XmlElement table = new XmlElement("table").setAttribute("border", "1"); XmlElement header = new XmlElement("tr").setAttribute("class", "gs:data"); for (Column col : entry.getData().getColumns()) { XmlElement cell = new XmlElement("th"); cell.setAttribute("class", "gs:column"); cell.setAttribute("title", col.getIndex()); cell.addText(col.getName()); header.addElement(cell); } XmlElement authorCell = new XmlElement("th"); header.addElement(authorCell.addText("Author")); XmlElement updatedCell = new XmlElement("th"); header.addElement(updatedCell.addText("Updated")); XmlElement revisionCell = new XmlElement("th"); header.addElement(revisionCell.addText("Version")); table.addElement(header); if (listItems != null) { for (ListItemEntry item : listItems) { table.addElement(getRow(item)); } } return table; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!sameClassAs(obj)) { return false; } Column other = (Column) obj; return eq(index, other.index) && eq(name, other.name); }
/** * Sets the user defined name of the column. * * @param name user defined name of the column or <code>null</code> to reset */ public void setName(String name) { throwExceptionIfImmutable(); this.name = name; }
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(Data.class)) { return; } extProfile.declare(Data.class, Column.getDefaultDescription(false, true)); }
@Override protected void validate() { if (index == null) { throwExceptionForMissingAttribute(INDEX); } if (name == null) { throwExceptionForMissingAttribute(NAME); } }
/** * Immutable constructor. * * @param index letter(s) or integer position of the column. * @param name user defined name of the column. */ public Column(String index, String name) { super(); setIndex(index); setName(name); setImmutable(true); }
/** * Returns whether it has the letter(s) or integer position of the column. * * @return whether it has the letter(s) or integer position of the column */ public boolean hasIndex() { return getIndex() != null; }
/** * Returns whether it has the user defined name of the column. * * @return whether it has the user defined name of the column */ public boolean hasName() { return getName() != null; }
/** * Sets the user defined name of the column. * * @param name user defined name of the column or <code>null</code> to reset */ public void setName(String name) { throwExceptionIfImmutable(); this.name = name; }
/** * Sets the letter(s) or integer position of the column. * * @param index letter(s) or integer position of the column or * <code>null</code> to reset */ public void setIndex(String index) { throwExceptionIfImmutable(); this.index = index; }