1 16 17 package org.apache.axis.constants; 18 19 20 21 22 25 public class Scope extends Enum { 26 private static final Type type = new Type(); 27 28 public static final String REQUEST_STR = "Request"; 29 public static final String APPLICATION_STR = "Application"; 30 public static final String SESSION_STR = "Session"; 31 public static final String FACTORY_STR = "Factory"; 32 33 public static final Scope REQUEST = type.getScope(REQUEST_STR); 34 public static final Scope APPLICATION = type.getScope(APPLICATION_STR); 35 public static final Scope SESSION = type.getScope(SESSION_STR); 36 public static final Scope FACTORY = type.getScope(FACTORY_STR); 37 38 public static final Scope DEFAULT = REQUEST; 39 40 static { type.setDefault(DEFAULT); } 41 42 46 public static Scope getDefault() { return (Scope)type.getDefault(); } 47 48 public static final Scope getScope(int scope) { 49 return type.getScope(scope); 50 } 51 52 public static final Scope getScope(String scope) { 53 return type.getScope(scope); 54 } 55 56 public static final Scope getScope(String scope, Scope dephault) { 57 return type.getScope(scope, dephault); 58 } 59 60 public static final boolean isValid(String scope) { 61 return type.isValid(scope); 62 } 63 64 public static final int size() { 65 return type.size(); 66 } 67 68 public static final String [] getScopes() { 69 return type.getEnumNames(); 70 } 71 72 private Object readResolve() throws java.io.ObjectStreamException { 73 return type.getScope(value); 74 } 75 public static class Type extends Enum.Type { 76 private Type() { 77 super("scope", new Enum [] { 78 new Scope(0, REQUEST_STR), 79 new Scope(1, APPLICATION_STR), 80 new Scope(2, SESSION_STR), 81 new Scope(3, FACTORY_STR) 82 }); 83 } 84 85 public final Scope getScope(int scope) { 86 return (Scope)this.getEnum(scope); 87 } 88 89 public final Scope getScope(String scope) { 90 return (Scope)this.getEnum(scope); 91 } 92 93 public final Scope getScope(String scope, Scope dephault) { 94 return (Scope)this.getEnum(scope, dephault); 95 } 96 97 } 98 99 private Scope(int value, String name) { 100 super(type, value, name); 101 } 102 103 protected Scope() { 104 super(type, DEFAULT.getValue(), DEFAULT.getName()); 105 } 106 } 107 | Popular Tags |