1 19 20 package org.netbeans.modules.xml.schema.model; 21 22 26 public interface Occur { 27 28 public static enum ZeroOne implements Occur { 29 ZERO, ONE; 30 31 public static ZeroOne valueOfNumeric(String owner, String s) { 32 int v = Integer.valueOf(s).intValue(); 33 if (v < 0 || v > 1) { 34 throw new IllegalArgumentException ("'" + owner + "' can only has value 0 or 1"); 35 } 36 return v == 0 ? ZeroOne.ZERO : ZeroOne.ONE; 37 } 38 39 public String toString() { 40 return this == ZeroOne.ZERO ? "0" : "1"; 41 } 42 } 43 } 44 | Popular Tags |