⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributeset.java

📁 著名的开源仿真软件yale
💻 JAVA
字号:
/* *  YALE - Yet Another Learning Environment *  Copyright (C) 2002, 2003 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,  *          Katharina Morik, Oliver Ritthoff *      Artificial Intelligence Unit *      Computer Science Department *      University of Dortmund *      44221 Dortmund,  Germany *  email: yale@ls8.cs.uni-dortmund.de *  web:   http://yale.cs.uni-dortmund.de/ * *  This program is free software; you can redistribute it and/or *  modify it under the terms of the GNU General Public License as  *  published by the Free Software Foundation; either version 2 of the *  License, or (at your option) any later version.  * *  This program is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *  General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *  USA. */package edu.udo.cs.yale.tools.att;import edu.udo.cs.yale.example.Attribute;import edu.udo.cs.yale.tools.xml.XMLException;import java.io.File;import java.io.IOException;import java.util.Iterator;import java.util.List;import java.util.ArrayList;import java.util.LinkedList;import java.util.Map;import java.util.HashMap;import java.util.Set;import org.xml.sax.SAXException;import javax.xml.parsers.ParserConfigurationException;/** Set of regular and special attributes that need not necessarily be associated *  with an {@link edu.udo.cs.yale.example.ExampleSet}. * *  @version $Id: AttributeSet.java,v 2.2 2003/07/30 13:16:45 fischer Exp $ */public class AttributeSet {    /** List of regular attributes. */    private List regularAttributes = new ArrayList();    /** Names, i.e. Strings are mapped to special attributes. */    private Map specialAttributes = new HashMap();    /** The default source file. */    private File defaultSource;        /** Creates an empty attribute set. */    public AttributeSet() { }    /** Creates an empty attribute set. */    public AttributeSet(int initialCapacity) {	regularAttributes = new ArrayList(initialCapacity);    }    /** Creates an attribute set from a list of {@link AttributeDataSource}s. */    public AttributeSet(AttributeDataSources attributeDataSources) {	Iterator i = attributeDataSources.getDataSources().iterator();	while (i.hasNext()) {	    AttributeDataSource ads = (AttributeDataSource)i.next();	    if (ads.getType().equals("attribute")) {		addAttribute(ads.getAttribute());	    } else {		setSpecialAttribute(ads.getType(), ads.getAttribute());	    }	}	this.defaultSource = attributeDataSources.getDefaultSource();    }    /** Reads an xml attribute description file and creates an attribute set. */    public AttributeSet(File attributeDescriptionFile, boolean sourceColRequired) 	throws XMLException, ParserConfigurationException, SAXException, IOException {	this(AttributeDataSource.createAttributeDataSources(attributeDescriptionFile, sourceColRequired));    }    public AttributeSet(List regularAttributes, Map specialAttributes) {	this.regularAttributes = regularAttributes;	this.specialAttributes = specialAttributes;    }    /** Returns the default file. */    public File getDefaultSource() {	return defaultSource;    }    /** Returns an attribute by index. */    public Attribute getAttribute(int index) {	return (Attribute)regularAttributes.get(index);    }    /** Adds an attribute at the end of the list. */    public void addAttribute(Attribute attribute) {	regularAttributes.add(attribute);    }    /** Returns a special attribute by name. */    public Attribute getSpecialAttribute(String name) {	return (Attribute)specialAttributes.get(name);    }    /** Adds a named special attribute. */    public void setSpecialAttribute(String name, Attribute attribute) {	specialAttributes.put(name, attribute);    }    /** Returns a list of all names (Strings) of all special attributes. */    public Set getSpecialNames() {	return specialAttributes.keySet();    }    /** Returns a list of all regular attributes. */    public List getRegularAttributes() {	return regularAttributes;    }    /** Returns the number of regular attributes. */    public int getNumberOfRegularAttributes() {	return regularAttributes.size();    }    /** Returns a Map mapping names to special attributes. */    public Map getSpecialAttributes() {	return specialAttributes;    }    /** Returns a list of all, i.e. regular and special attributes. This method creates     *  a list. The first elements in the list will be the regular attributes, the last     *  elements will be the special attributes. */    public List getAllAttributes() {	List attributes = new LinkedList();	attributes.addAll(regularAttributes);	attributes.addAll(specialAttributes.values());	return attributes;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -