portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jf...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules LocalizedFieldRule.java
Date Wed, 10 Mar 2004 17:14:00 GMT
jford       2004/03/10 09:13:59

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager/rules
                        LocalizedFieldRule.java
  Log:
  Finished impl
  
  Revision  Changes    Path
  1.2       +62 -1     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules/LocalizedFieldRule.java
  
  Index: LocalizedFieldRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules/LocalizedFieldRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalizedFieldRule.java	10 Mar 2004 01:40:13 -0000	1.1
  +++ LocalizedFieldRule.java	10 Mar 2004 17:13:59 -0000	1.2
  @@ -6,7 +6,15 @@
    */
   package org.apache.jetspeed.tools.pamanager.rules;
   
  +import java.util.Locale;
  +
   import org.apache.commons.digester.Rule;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.om.common.GenericMetadata;
  +import org.apache.jetspeed.om.common.LocalizedField;
  +import org.apache.jetspeed.om.common.impl.LocalizedFieldImpl;
  +import org.xml.sax.Attributes;
   
   /**
    * This class helps load internationalized fields
  @@ -16,5 +24,58 @@
    */
   public class LocalizedFieldRule extends Rule
   {
  +    protected final static Log log = LogFactory.getLog(LocalizedFieldRule.class);
  +    /**
  +     * Handle the beginning of an XML element.
  +     *
  +     * @param attributes The attributes of this element
  +     *
  +     * @exception Exception if a processing error occurs
  +     */
  +    public void begin(String namespace, String name, Attributes attributes)
  +    throws Exception {
  +
  +        if (digester.getLogger().isDebugEnabled())
  +            digester.getLogger().debug("Setting localized field " + name);
  +        
  +        LocalizedField child = new LocalizedFieldImpl();
  +
  +        if(name.equals("metadata"))
  +        {
  +            String nameAttr = attributes.getValue("name");
  +            child.setName(nameAttr);
  +        }
  +        else
  +        {
  +            child.setName(name);
  +        }
  +        String language = attributes.getValue("xml:lang");
  +        Locale locale = null;
  +        if(language == null)
  +        {
  +            locale = new Locale("en");
  +        }
  +        else
  +        {
  +            locale = new Locale(language);
  +        }
  +
  +        child.setLocale(locale);
  +        digester.push(child);
  +    }
  +
  +    public void body(String namespace, String name, String text)
  +    throws Exception
  +    {
  +        LocalizedField child = (LocalizedField) digester.peek(0);
  +        child.setValue(text);
  +    }
   
  +    public void end(String namespace, String name)
  +    throws Exception
  +    {
  +        LocalizedField child = (LocalizedField) digester.pop();
  +        GenericMetadata metadata = (GenericMetadata)digester.peek();
  +        metadata.addField(child);
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message