package votorola.a.count.gwt; // Copyright 2011, 2013, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import com.google.gwt.core.client.*; import votorola.g.web.gwt.*; /** A counting method as a map of {@linkplain SacJS superaccounts} or {@linkplain * SacRegisterJS superaccount registers} that use the method, each keyed by its account * name. This is a JavaScript overlay type; however we do not actually model the * counting methods themselves on the client side, instead we only mirror their * employment in the CountWAP response as namespacing constructs. * * @see Category:Counting method * @see votorola.s.wap.CountWAP */ public final class CountingMethodJS extends JsMap { protected CountingMethodJS() {} // "precisely one constructor... protected, empty, and no-argument" // ==================================================================================== /** Thrown when a requested counting method does not exist. */ public static final class NoSuchMethod extends Exception { NoSuchMethod( String _message ) { super( _message ); } } // ==================================================================================== /** Short names designating particular counting methods, suitable for use in a * ({@linkplain SacSelection#aSacSwitch() superaccount selection switch}). The * names are resticted to ASCII lowercase letters and digits, and must begin with a * letter. */ public static enum SwitchMnemonic { /** Designating a null * count. */ nul( "Wiki:Null count" ), /** Designating a quantitive summation count. */ q( "Wiki:Quantitive summation" ), /** Designating a vote * count. */ v( "Wiki:Vote count" ); private SwitchMnemonic( String _fullName ) { fullName = _fullName; } // -------------------------------------------------------------------------------- /** Returns the full name of the counting method. */ public String fullName() { return fullName; } private final String fullName; /** Returns the switch mnemonic with the specified full name. * * @throws NoSuchMethod if no switch mnemonic has the specified full name. */ public static SwitchMnemonic valueOfFullName( final String fullName ) throws NoSuchMethod { for( SwitchMnemonic m: values() ) if( m.fullName().equals( fullName )) return m; throw new NoSuchMethod( fullName ); } } }