001package 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. 002 003import com.google.gwt.core.client.*; 004 005 006/** A superaccount register for votes at a particular node. 007 * 008 * @see <a href='http://reluk.ca/w/Wiki:Vote_count' target='_top' 009 * >http://reluk.ca/w/Wiki:Vote count</a> 010 */ 011public final class SacRegisterJS_v extends SacRegisterJS 012{ 013 014 // cf. SacRegisterJS_q 015 016 017 protected SacRegisterJS_v() {} // "precisely one constructor... protected, empty, and no-argument" 018 019 020 021 // ` e a r l y ```````````````````````````````````````````````````````````````````````` 022 023 024 /** An common instance of SacRegisterJS_v set to default values. 025 */ 026 static final SacRegisterJS_v DEFAULT_REGISTER = JavaScriptObject.createObject().cast(); 027 028 029 030 // ------------------------------------------------------------------------------------ 031 032 033 /** The volume of {@linkplain #receiveVolume() received votes} that flows to the 034 * candidate node along with the {@linkplain #castVolume() cast volume}. The cast 035 * volume is excluded from this count. 036 */ 037 public native Long carryVolume() // per CountNodeW.carryVolume 038 /*-{ 039 return @java.lang.Long::new(Ljava/lang/String;)( this.carryVolume ); 040 }-*/; 041 042 043 static { DEFAULT_REGISTER._setString( "carryVolume", "0" ); } 044 045 046 047 /** The {@linkplain votorola.a.count.CountNodeW#voteWeight() weight} of any original 048 * vote that is actually cast for the {@linkplain 049 * votorola.a.count.CountNode#candidateName() candidate} by the node; either 0 or 1. 050 */ 051 public native Long castVolume() // per CountNodeW.castVolume 052 /*-{ 053 return @java.lang.Long::new(Ljava/lang/String;)( this.castVolume ); 054 }-*/; 055 056 057 static { DEFAULT_REGISTER._setString( "castVolume", "0" ); } 058 059 060 061 /** The volume of votes held. This is simply {@linkplain #receiveVolume() 062 * receiveVolume} - {@linkplain #carryVolume() carryVolume}. 063 */ 064 public Long holdVolume() { return receiveVolume() - carryVolume(); } // per CountNodeW.holdVolume 065 066 067 068 /** The volume of votes received from other nodes. 069 */ 070 public native Long receiveVolume() // per CountNodeW.receiveVolume 071 /*-{ 072 return @java.lang.Long::new(Ljava/lang/String;)( this.receiveVolume ); 073 }-*/; 074 075 076 static { DEFAULT_REGISTER._setString( "receiveVolume", "0" ); } 077 078 079}