xmlattribute.java
来自「jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用」· Java 代码 · 共 82 行
JAVA
82 行
package org.enhydra.shark.xpdl;import java.util.ArrayList;import java.util.Arrays;import java.util.Iterator;/** * Represents attribute element from XML schema. * * @author Sasa Bojanic */public class XMLAttribute extends XMLElement { /** The possible choices. */ protected ArrayList choices; protected int defaultChoiceIndex; public XMLAttribute(XMLElement parent, String name, boolean isRequired) { super(parent, name, isRequired); } public XMLAttribute(XMLElement parent, String name, boolean isRequired, String[] choices, int choosenIndex) { super(parent, name, isRequired); this.choices = new ArrayList(Arrays.asList(choices)); this.value = choices[choosenIndex]; this.defaultChoiceIndex = choosenIndex; } public void setValue (String v) { if (choices != null) { if (!choices.contains(v)) { throw new RuntimeException("Incorrect value "+v+"! Possible values are: " + choices); } } super.setValue(v); } /** * The possible String choices. * * @return the possible choices for this element. */ public ArrayList getChoices() { return choices; } public String getDefaultChoice () { return (String)choices.get(defaultChoiceIndex); } public int getDefaultChoiceIndex () { return defaultChoiceIndex; } public Object clone() { XMLAttribute d = (XMLAttribute) super.clone(); if (choices != null) { d.choices = new ArrayList(); Iterator it=choices.iterator(); while (it.hasNext()) { d.choices.add(new String(it.next().toString())); } } return d; } public boolean equals (Object e) { boolean equals=super.equals(e); if (equals) { XMLAttribute el=(XMLAttribute)e; equals=(this.choices == null ? el.choices == null : this.choices.equals(el.choices));// System.out.println(" XMLAttribute choices equal - "+equals); } return equals; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?