001package votorola.s.gwt.scene.feed; // Copyright 2010-2011, Michael Allan, Christian Weilbach. 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.*; 004import java.util.Date; 005import votorola.a.diff.*; 006import votorola.s.gwt.stage.*; 007 008 009/** A bite implemented as a JavaScript overlay type. 010 */ 011public final class BiteJS extends JavaScriptObject implements Bite 012{ 013 014 015 protected BiteJS() {} // "precisely one constructor... protected, empty, and no-argument" 016 017 018 019 /** The empty instance of a bite. 020 */ 021 public static final BiteJS EMPTY_BITE = JavaScriptObject.createObject().cast(); 022 023 024 025 // - B i t e -------------------------------------------------------------------------- 026 027 028 public native DiffLookJS difference() /*-{ return this.difference; }-*/; 029 030 031 032 public MessageJS message() 033 { 034 final JsArray<MessageJS> messages = messages(); 035 return messages.length() > 0? messages.get(0): null; 036 } 037 038 039 040 public native JsArray<MessageJS> messages() 041 /*-{ 042 return this.messages == null? []: this.messages; 043 }-*/; 044 045 public native char relation() /*-{ return this.relation; }-*/; 046 047 048 049 public Date sentDate() { return new Date( (long)sentDateAsDouble() ); } 050 051 052 053 public PersonJS person() 054 { 055 final JsArray<PersonJS> persons = persons(); 056 return persons.length() > 0? persons.get(0): null; 057 } 058 059 060 061 public native JsArray<PersonJS> persons() 062 /*-{ 063 return this.persons == null? []: this.persons; 064 }-*/; 065 066 067 068 public native votorola.s.gwt.stage.poll.PollJS poll() /*-{ return this.poll; }-*/; 069 070 071 072//// P r i v a t e /////////////////////////////////////////////////////////////////////// 073 074 075 private native double sentDateAsDouble() /*-{ return this.sentDate; }-*/; 076 077 078 079}