Package jfun.yan.xml.nuts

Source Code of jfun.yan.xml.nuts.PropertiesNut

package jfun.yan.xml.nuts;

import java.util.List;
import java.util.Properties;

import jfun.yan.Component;
import jfun.yan.Components;
import jfun.yan.SimpleComponent;

/**
* The <props> tag that creates Properties object.
* <p>
* @author Ben Yu
* Nov 17, 2005 1:03:30 AM
*/
public class PropertiesNut extends EntriesNut {
  public PropertiesNut(){
    super.setKey_type(String.class);
    super.setOf(String.class);
  }
 
  /**
   * Disable "key-type" by throwing exception.
   */
  public void setKey_type(Class key_type) {
    throw raise("attribute \"key-type\" not supported.");
  }

  /**
   * Disable "of" by throwing exception.
   */
  public void setOf(Class of) {
    throw raise("attribute \"of\" not supported.");
  }

  public Component eval(){
    final List keys = getKeys();
    final Component[] vals = getEntryComponents();
    final Component step1 = new SimpleComponent(Properties.class){
      public Object create(){
        return new Properties();
      }
    };
    return Components.storeMap(step1, keys.toArray(), vals);
  }
}
TOP

Related Classes of jfun.yan.xml.nuts.PropertiesNut

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.