package com.privasphere.privalope.presentation;

/**
 * @author hauser , (c) 2008 all rights granted to the itext project
 * 
 */

import java.util.Iterator;

import org.apache.log4j.Logger;

import com.lowagie.text.xml.xmp.DublinCoreSchema;
import com.lowagie.text.xml.xmp.XmpArray;
import com.lowagie.text.xml.xmp.XmpSchema;

/**
 * as per kkrieg 081115: from PDF/A-1 Corrigendum 1 (ISO-19005-1 TC1):
 * <dc:subject> must no longer be used to reflect Document theme and the
 * Description as well as the title need a language tag.
 */
public class XmpArrayPSPH extends XmpArray {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public XmpArrayPSPH(String type) {
		super(type);
	}

	private static final Logger log = Logger.getLogger(XmpArrayPSPH.class);

	/**
	 * Returns the String representation of the XmpArray.
	 * 
	 * @return a String representation
	 */
	public String toString() {
		StringBuffer buf = new StringBuffer("<");
		buf.append(type);
		buf.append('>');
		String s;
		for (Iterator i = iterator(); i.hasNext();) {
			s = (String) i.next();
			buf.append("<rdf:li xml:lang=\"x-default\">");
			buf.append(XmpSchema.escape(s));
			buf.append("</rdf:li>");
		}
		buf.append("</");
		buf.append(type);
		buf.append('>');
		return buf.toString();
	}

	/**
	 * Adds a description.
	 * 
	 * @param desc
	 */
	public static void addDescription(String desc, DublinCoreSchema dc) {
		XmpArray array = new XmpArrayPSPH(XmpArray.ALTERNATIVE);
		array.add(desc);
		dc.setProperty(DublinCoreSchema.DESCRIPTION, array);
	}
	
	/**
	 * Adds a title.
	 * @param title
	 */
	public static void addTitle(String title, DublinCoreSchema dc) {
		XmpArray array = new XmpArray(XmpArray.ALTERNATIVE);
		array.add(title);
		dc.setProperty(DublinCoreSchema.TITLE, array);
	}


}
