|
From: Andreas V. <a_...@us...> - 2004-04-26 14:09:28
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20183/src/org/cobricks/item Modified Files: Item.java Log Message: Index: Item.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/Item.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Item.java 24 Apr 2004 13:35:10 -0000 1.25 +++ Item.java 26 Apr 2004 14:09:20 -0000 1.26 @@ -122,7 +122,8 @@ private Set usedLanguages = new HashSet(); /** - * This map contains all attributes except local id, global id and item class. + * This map contains all attributes except local id, global id and item + * class. */ protected Map attrs = new HashMap(); @@ -365,16 +366,13 @@ return title; } else { // Try to get a title in any language - Set keys = attrs.keySet(); - Iterator keyIterator = keys.iterator(); + Iterator it = this.usedLanguages.iterator(); - while (keyIterator.hasNext()) { - String key = (String) keyIterator.next(); - if (key.startsWith("title")) { - title = getStringAttribute(key); - if ((title != null) && (title.length() > 0)) { - return title; - } + while (it.hasNext()) { + String next = (String) it.next(); + + if (attrs.containsKey("title_" + next)) { + return this.getStringAttribute("title_" + next); } } // No title was specified for this item @@ -420,10 +418,6 @@ this.usedLanguages.add(lang); setAttribute("description_" + lang, description); } - - public String getDefaultLanguage() { - return defaultLanguage; - } public String getUrl() { return getStringAttribute("url"); @@ -569,8 +563,8 @@ /** * This method returns a String that contains a XML representation of this * item. - * To do this the method calls getItemAttributeAsXML(String, boolean, Object) - * for each attribute of this item. + * To do this the method calls getItemAttributeAsXML(String, boolean, + * Object) for each attribute of this item. * If withAnnotations is set, a representation of the annotations of this * item is added. * If withAttachments is set, a representation of the attachments of this @@ -582,7 +576,8 @@ * attachments of this item should be added * @return String that represents this item */ - public String getItemAsXML(boolean withAnnotations, boolean withAttachments) { + public String getItemAsXML(boolean withAnnotations, + boolean withAttachments) { logger.debug("getItemAsXML"); StringBuffer xml = new StringBuffer(); @@ -624,12 +619,12 @@ return xml.toString(); } - + /** * This method is an auxiliary method for getItemAsXML(boolean, boolean). * It returns a String that contains a XML representation of the item - * attribute specified by the parameter <code>attribute</code> or the - * parameters <code>attribute</code> and <code>value</code>. + * attribute specified by the parameter "attribute" or the parameters + * "attribute" and "value". * * @param attribute The name of the Object to be "transformed" * @param withXMLDeclaration If set a XML declaration is added at the @@ -637,8 +632,8 @@ * @param value Object that should be "transformed" into XML; value is not * required if the Object can be fetched via the parameter attribute * @return String that holds a XML representation of the item attribute - * specified by the parameter <code>attribute</code> or the parameters - * <code>attribute</code> and <code>value</code> + * specified by the parameter "attribute" or the parameters "attribute" and + * "value" */ protected String getItemAttributeAsXML(String attribute, boolean withXMLDeclaration, Object value) { @@ -680,11 +675,9 @@ xml.append(">" + value + "</" + attribute + ">\n"); if (ItemAttrs.checkWellFormedXML(xml.toString()).length() > 0) { - logger.warn( - "getItemAttributeAsXML: Value of XML Attribute " - + attribute - + " isn't well formed.\n I will ignore this " - + "attribute. Check syntax of:\n" + xml); + logger.warn("getItemAttributeAsXML: Value of XML Attribute " + + attribute + " isn't well formed.\n I will ignore this" + + " attribute. Check syntax of:\n" + xml); return null; } @@ -698,9 +691,7 @@ return null; } - xml.append(">\n"); - Object temp = getItemAttributeAsXML("string", false, obj); if (temp != null) { @@ -737,9 +728,7 @@ return null; } - xml.append(">\n"); - Object temp = getItemAttributeAsXML(name, false, obj); if (temp != null) { @@ -773,7 +762,8 @@ xml.append(">" + format.format(value) + "</" + attribute + ">\n"); } else if (value instanceof java.sql.Date) { - DateFormat dateFormat = new SimpleDateFormat(INTERNAL_DATE_FORMAT); + DateFormat dateFormat = + new SimpleDateFormat(INTERNAL_DATE_FORMAT); xml.append(">" + dateFormat.format(value) + "</" + attribute + ">\n"); } else if (value instanceof Integer) { @@ -988,4 +978,5 @@ */ public void removeItemAttachment(ItemAttachment ia) { attachments.remove("" + ia.getId()); - }} \ No newline at end of file + } +} \ No newline at end of file |