aymens

Untitled

Mar 21st, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. /**
  2.  * Script Node class implementation, specific for use by ScriptService as part of the object model.
  3.  * <p>
  4.  * The class exposes Node properties, children and assocs as dynamically populated maps and lists. The various collection classes are mirrored as JavaScript properties. So can be
  5.  * accessed using standard JavaScript property syntax, such as <code>node.children[0].properties.name</code>.
  6.  * <p>
  7.  * Various helper methods are provided to access common and useful node variables such as the content url and type information.
  8.  *
  9.  * @author Kevin Roast
  10.  */
  11. public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResolverProvider
  12. {
  13.     /* ... */
  14.    
  15.     /** Text fragments with highlighted search keywords, only needed when in the context of a search */
  16.     private Scriptable fragments = null;    
  17.    
  18.     /* ... */
  19.    
  20.     public Scriptable getFragments()
  21.     {          
  22.         return fragments;
  23.     }
  24.    
  25.     public void setFragments (String [] fragments)
  26.     {
  27.         if(fragments == null)
  28.         {
  29.             this.fragments = Context.getCurrentContext().newArray(this.scope, new Object[0]);
  30.             return;
  31.         }
  32.        
  33.         Object[] frgArray = new Object[fragments.length];
  34.         int index = 0;
  35.         for (String fragment : fragments)
  36.         {
  37.             frgArray[index++] = fragment;
  38.         }
  39.         this.fragments = Context.getCurrentContext().newArray(this.scope, frgArray);
  40.     }
  41.    
  42.     /* ... */
  43.    
  44.     /**
  45.      * Reset the Node cached state
  46.      */
  47.     public void reset()
  48.     {
  49.         /* ... */
  50.         this.fragments = null;
  51.        
  52.     /* ... */
Advertisement
Add Comment
Please, Sign In to add comment