org.xwiki.gwt.dom.client.internal.ie
Class NativeRange

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by org.xwiki.gwt.dom.client.internal.ie.NativeRange
Direct Known Subclasses:
ControlRange, TextRange

public class NativeRange
extends com.google.gwt.core.client.JavaScriptObject

Base class for TextRange and ControlRange, the two types of range provided by Internet Explorer.


Constructor Summary
protected NativeRange()
          Default constructor.
 
Method Summary
static boolean areEqual(NativeRange alice, NativeRange bob)
          NOTE: We added this static method for the same reasons we added the duplicate(NativeRange) method.
static NativeRange duplicate(NativeRange range)
          NOTE: We had to add this method because overlay types don't support method overriding and both TextRange and ControlRange have a duplicate method but with a different implementation.
 Document getOwnerDocument()
           
 boolean isTextRange()
          This method is needed because instanceof operator returns true all the time when applied on a overlay type.
 void select()
          Makes the selection equal to the current object.
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NativeRange

protected NativeRange()
Default constructor. Needs to be protected because all instances are created from JavaScript.

Method Detail

select

public final void select()
Makes the selection equal to the current object. When applied to a TextRange object, the select method causes the current object to be highlighted. When applied to a ControlRange object, the select method produces a shaded rectangle around the elements in the control range.


getOwnerDocument

public final Document getOwnerDocument()
Returns:
The document used to create this range.

isTextRange

public final boolean isTextRange()
This method is needed because instanceof operator returns true all the time when applied on a overlay type. For instance:
 TextRange textRange = TextRange.newInstance(doc);
 boolean result = textRange instanceof TextRange; // result is true, which is right.
 result = textRange instanceof ControlRange // result is also true, which is wrong.
 

Returns:
true if this is a text range, and false if it is a control range.
See Also:
http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes

duplicate

public static NativeRange duplicate(NativeRange range)
NOTE: We had to add this method because overlay types don't support method overriding and both TextRange and ControlRange have a duplicate method but with a different implementation. Using an abstract duplicate method is not an option because overlay types can't implement interfaces and this method can't return an abstract type. We had to make this method static because only static references to overlay types are allowed from JSNI.

Parameters:
range - the native range to be duplicated
Returns:
a duplicate of the given native range

areEqual

public static boolean areEqual(NativeRange alice,
                               NativeRange bob)
NOTE: We added this static method for the same reasons we added the duplicate(NativeRange) method.

Parameters:
alice - a native range
bob - a native range
Returns:
true if the given native ranges are equal, false otherwise
See Also:
duplicate(NativeRange)