コード例 #1
0
  /**
   * Copy on write for the internal tables in this context.
   *
   * <p>This class is optimized for the normal case where most elements do not contain Namespace
   * declarations. In that case, the Context2 will share data structures with its parent. New tables
   * are obtained only when new declarations are issued, so they can be popped off the stack.
   *
   * <p>JJK: **** Alternative: each Context2 might declare _only_ its local bindings, and delegate
   * upward if not found.
   */
  private void copyTables() {
    // Start by copying our parent's bindings
    prefixTable = (Hashtable) prefixTable.clone();
    uriTable = (Hashtable) uriTable.clone();

    // Replace the caches with empty ones, rather than
    // trying to determine which bindings should be flushed.
    // As far as I can tell, these caches are never actually
    // used in Xalan... More efficient to remove the whole
    // cache system? ****
    if (elementNameTable != null) elementNameTable = new Hashtable();
    if (attributeNameTable != null) attributeNameTable = new Hashtable();
    tablesDirty = true;
  }
コード例 #2
0
 public Object removeFromEnvironment(String propName) throws NamingException {
   if (myEnv == null) {
     return null;
   }
   myEnv = (Hashtable) myEnv.clone();
   return myEnv.remove(propName);
 }
コード例 #3
0
 public Hashtable getEnvironment() throws NamingException {
   if (myEnv == null) {
     return new Hashtable(5, 0.75f);
   } else {
     return (Hashtable) myEnv.clone();
   }
 }
コード例 #4
0
ファイル: DummyContext.java プロジェクト: nabils/jackrabbit
 /**
  * Constructs a new <code>DummyContext</code> instance
  *
  * @param environment
  */
 DummyContext(Hashtable environment) {
   if (environment == null) {
     this.environment = new Hashtable();
   } else {
     this.environment = (Hashtable) environment.clone();
   }
 }
コード例 #5
0
 /** Clones the attributes. */
 public Object clone() {
   try {
     FigureAttributes a = (FigureAttributes) super.clone();
     a.fMap = (Hashtable) fMap.clone();
     return a;
   } catch (CloneNotSupportedException e) {
     throw new InternalError();
   }
 }
コード例 #6
0
  /**
   * Create a context as a child of this one
   *
   * @param name a <code>Name</code> value
   * @return a <code>Context</code> value
   * @exception NamingException if an error occurs
   */
  public Context createSubcontext(Name name) throws NamingException {
    if (isLocked()) {
      NamingException ne = new NamingException("This context is immutable");
      ne.setRemainingName(name);
      throw ne;
    }

    Name cname = toCanonicalName(name);

    if (cname == null) throw new NamingException("Name is null");
    if (cname.size() == 0) throw new NamingException("Name is empty");

    if (cname.size() == 1) {
      // not permitted to bind if something already bound at that name
      Binding binding = getBinding(cname);
      if (binding != null) throw new NameAlreadyBoundException(cname.toString());

      Context ctx = new NamingContext((Hashtable) _env.clone(), cname.get(0), this, _parser);
      addBinding(cname, ctx);
      return ctx;
    }

    // If the name has multiple subcontexts, walk the hierarchy by
    // fetching the first one. All intermediate subcontexts in the
    // name must already exist.
    String firstComponent = cname.get(0);
    Object ctx = null;

    if (firstComponent.equals("")) ctx = this;
    else {
      Binding binding = getBinding(firstComponent);
      if (binding == null) throw new NameNotFoundException(firstComponent + " is not bound");

      ctx = binding.getObject();

      if (ctx instanceof Reference) {
        // deference the object
        if (__log.isDebugEnabled())
          __log.debug("Object bound at " + firstComponent + " is a Reference");
        try {
          ctx =
              NamingManager.getObjectInstance(
                  ctx, getNameParser("").parse(firstComponent), this, _env);
        } catch (NamingException e) {
          throw e;
        } catch (Exception e) {
          __log.warn("", e);
          throw new NamingException(e.getMessage());
        }
      }
    }

    if (ctx instanceof Context) {
      return ((Context) ctx).createSubcontext(cname.getSuffix(1));
    } else throw new NotContextException(firstComponent + " is not a Context");
  }
コード例 #7
0
 /**
  * Passes the properties from the source object along after adding a property indicating the
  * stream of filters it has been run through.
  *
  * <p>Note: This method is intended to be called by the ImageProducer of the Image whose pixels
  * are being filtered. Developers using this class to filter pixels from an image should avoid
  * calling this method directly since that operation could interfere with the filtering operation.
  *
  * @param props the properties from the source object
  * @exception NullPointerException if <code>props</code> is null
  */
 public void setProperties(Hashtable<?, ?> props) {
   Hashtable<Object, Object> p = (Hashtable<Object, Object>) props.clone();
   Object o = p.get("filters");
   if (o == null) {
     p.put("filters", toString());
   } else if (o instanceof String) {
     p.put("filters", ((String) o) + toString());
   }
   consumer.setProperties(p);
 }
コード例 #8
0
 // ------------------------------------------------------------------------
 // --- methods                                                          ---
 // ------------------------------------------------------------------------
 public Object clone() {
   NamedIterator c = new NamedIterator(true);
   synchronized (this) {
     c.data = (Vector) data.clone();
     c.hash = (Hashtable) hash.clone();
     c.pos = pos;
     c.readonly = readonly;
   }
   return c;
 }
コード例 #9
0
ファイル: NamingManager.java プロジェクト: CodeingBoy/Java8CN
  /**
   * Creates a context in which to continue a context operation.
   *
   * <p>In performing an operation on a name that spans multiple namespaces, a context from one
   * naming system may need to pass the operation on to the next naming system. The context
   * implementation does this by first constructing a <code>CannotProceedException</code> containing
   * information pinpointing how far it has proceeded. It then obtains a continuation context from
   * JNDI by calling <code>getContinuationContext</code>. The context implementation should then
   * resume the context operation by invoking the same operation on the continuation context, using
   * the remainder of the name that has not yet been resolved.
   *
   * <p>Before making use of the <tt>cpe</tt> parameter, this method updates the environment
   * associated with that object by setting the value of the property <a
   * href="#CPE"><tt>CPE</tt></a> to <tt>cpe</tt>. This property will be inherited by the
   * continuation context, and may be used by that context's service provider to inspect the fields
   * of this exception.
   *
   * @param cpe The non-null exception that triggered this continuation.
   * @return A non-null Context object for continuing the operation.
   * @exception NamingException If a naming exception occurred.
   */
  @SuppressWarnings("unchecked")
  public static Context getContinuationContext(CannotProceedException cpe) throws NamingException {

    Hashtable<Object, Object> env = (Hashtable<Object, Object>) cpe.getEnvironment();
    if (env == null) {
      env = new Hashtable<>(7);
    } else {
      // Make a (shallow) copy of the environment.
      env = (Hashtable<Object, Object>) env.clone();
    }
    env.put(CPE, cpe);

    ContinuationContext cctx = new ContinuationContext(cpe, env);
    return cctx.getTargetContext();
  }
コード例 #10
0
 private void startPlugins() {
   log.trace("startPlugins()");
   // because plugins can add other plugins (and thus add to our plugins
   // hashtable)
   // we need to snapshot the list and iterate over the snapshot,
   // avoiding java.util.ConcurrentModificationException errors.
   Hashtable<String, Plugin> clone = (Hashtable<String, Plugin>) plugins.clone();
   for (Iterator<Plugin> iter = clone.values().iterator(); iter.hasNext(); ) {
     Plugin p = iter.next();
     try {
       startPlugin(p);
     } catch (Exception e) {
       log.warn(
           String.format(
               "Could not start plugin with identifier (%1$s). It will be disabled.",
               p.getIdentifier()));
       log.warn("Could not start plugin", e);
       plugins.remove(p.getIdentifier());
     }
   }
 }
コード例 #11
0
 public Hashtable getEnvironment() throws NamingException {
   return (Hashtable) environment.clone();
 }
コード例 #12
0
  /** INTERNAL: */
  public void initialize(AbstractSession session) {
    clearInitialization();
    main = new Collection[NUM_OPERATIONS][MAIN_SIZE];

    // The order of descriptor initialization guarantees initialization of Parent before children.
    // main array is copied from Parent's ReturningPolicy
    if (getDescriptor().isChildDescriptor()) {
      ClassDescriptor parentDescriptor =
          getDescriptor().getInheritancePolicy().getParentDescriptor();
      if (parentDescriptor.hasReturningPolicy()) {
        copyMainFrom(parentDescriptor.getReturningPolicy());
      }
    }

    if (!infos.isEmpty()) {
      Hashtable infoHashtable = removeDuplicateAndValidateInfos(session);
      Hashtable infoHashtableUnmapped = (Hashtable) infoHashtable.clone();
      for (Enumeration fields = getDescriptor().getFields().elements();
          fields.hasMoreElements(); ) {
        DatabaseField field = (DatabaseField) fields.nextElement();
        Info info = (Info) infoHashtableUnmapped.get(field);
        if (info != null) {
          infoHashtableUnmapped.remove(field);
          if (verifyFieldAndMapping(session, field)) {
            if (info.getField().getType() == null) {
              addMappedFieldToMain(field, info);
            } else {
              addMappedFieldToMain(info.getField(), info);
              fieldIsNotFromDescriptor(info.getField());
            }
          }
        }
      }

      if (!infoHashtableUnmapped.isEmpty()) {
        Enumeration fields = infoHashtableUnmapped.keys();
        while (fields.hasMoreElements()) {
          DatabaseField field = (DatabaseField) fields.nextElement();
          Info info = (Info) infoHashtableUnmapped.get(field);
          if (verifyField(session, field, getDescriptor())) {
            if (field.getType() != null) {
              addUnmappedFieldToMain(field, info);
              fieldIsNotFromDescriptor(field);
              session.log(
                  SessionLog.FINEST,
                  SessionLog.QUERY,
                  "added_unmapped_field_to_returning_policy",
                  info.toString(),
                  getDescriptor().getJavaClassName());
            } else {
              if (getDescriptor().isReturnTypeRequiredForReturningPolicy()) {
                session
                    .getIntegrityChecker()
                    .handleError(
                        DescriptorException.returningPolicyUnmappedFieldTypeNotSet(
                            field.getName(), getDescriptor()));
              }
            }
          }
        }
      }
    }

    initializeIsUsedToSetPrimaryKey();
  }
コード例 #13
0
ファイル: GuiChildIterator.java プロジェクト: SAFSDEV/Core
  /**
   * Called only once by some external routine kicking off a TestObject search. The govLevel and
   * objLevel in the ObjectVector will be assumed to be 0. The routine will install an initial class
   * and type indices for the provided parent.
   *
   * <p>If we can deduce that the parent actually exists in the path vector then that govLevel of
   * the vector will be matched and skipped. If we find that the parent info is NOT in the provided
   * vector then we will not skip the govLevel.
   *
   * <p>We can assume the parent info is in the path if the path begins with "\;". The next item in
   * the path is assumed to be the topmost parent.
   *
   * <p>We can ignore the first path info if it instead begins with ".\;". The next item would be
   * considered to be the first child of the parent.
   *
   * <p>
   *
   * @param aparent the topmost parent to search.
   *     <p>
   * @param agovVector the govVector (recognition string) to satisfy with the search.
   *     <p>
   * @param gather, List containing names matched, if null, then match first name
   */
  public GuiChildIterator(Object aparent, GuiObjectVector agovVector, java.util.List gather) {
    this(gather);
    if (agovVector.isFullPathSearchMode()) {
      setSearchMode(FULLPATH_SEARCH_MODE);
    } else {
      setSearchMode(CLASSIC_SEARCH_MODE);
    }
    Hashtable classindices = new Hashtable(8);
    Hashtable typeindices = new Hashtable(8);
    matches = new Vector(10, 3);
    notFound = true;
    hasFinalMatch = false;

    // class (ex: JFrame) and Type (ex: Window) counters are complimentary
    // for each class that is a known type BOTH counters get incremented.

    // always initialize class index counters for the retrieved class

    // it is possible this "parent" info is actually info for the first child govLevel 0
    GuiObjectRecognition gorParent = agovVector.getParentGuiObjectRecognition();
    GuiClassData classdata = agovVector.getGuiClassData();

    String classname = gorParent.getObjectClassName(aparent);
    Log.info("GCI: processing children of parent:" + classname);
    classindices.put(classname, new Integer(1));

    // always initialize the Type index counter if it is equivalent to a known type
    String typeclass = classdata.getMappedClassType(classname, aparent);
    Log.info("GCI: processing parent of type:" + typeclass);
    if (typeclass instanceof String) {
      StringTokenizer toker = new StringTokenizer(typeclass, classdata.DEFAULT_TYPE_SEPARATOR);
      String atoken = null;
      while (toker.hasMoreTokens()) {
        atoken = toker.nextToken().trim();
        typeindices.put(atoken, new Integer(1));
      }
    }

    // add our entry govVector and parent object as the first match
    // CANAGL - modifying to only store finalMatches
    // MatchData adata = new MatchData(agovVector, 0, 0, aparent);
    // matches.addElement(adata);

    int agovDepth = agovVector.getRecognitionDepth();
    Log.info(
        "GCI: processing GOV with depth of:" + agovDepth + ", path=" + agovVector.getPathVector());

    // begin the reentrant search for the matching child
    int startlevel = (agovDepth > 1) ? 1 : 0;
    if ((gorParent.getGovLevel() == 0)
        && (!(gorParent.pathInfo.equals(GuiObjectVector.ACTIVE_WINDOW_REFERENCE)))) {

      // Robot Java recognition strings often contain a JavaWindow reference
      // to the parent window that needs to be skipped.	Same with Flex recognition strings(JunwuMa).
      if (!gorParent.getClassRecognition().equalsIgnoreCase("Type=JavaWindow")
          && !gorParent.getClassRecognition().equalsIgnoreCase("Type=FlexWindow")) {
        startlevel = 0;
      } else {
        Log.info(
            "GCI: bypassing govLevel=0 for child 'Type=JavaWindow'. Assuming duplicate parent info.");
      }
    }
    // Try to match the parent for some popupmenu
    Hashtable save_classindices = (Hashtable) classindices.clone();
    Hashtable save_typeindices = (Hashtable) typeindices.clone();

    processParent(aparent, agovVector, startlevel, 1, classindices, typeindices, typeclass);
    Object matchedObject = this.getMatchedGuiObject();

    if (matchedObject == null) {
      if (SEARCH_MODE != FULLPATH_SEARCH_MODE) {
        Log.info("GCI: CLASSIC_SEARCH_MODE calling processChildren...");
        processChildren(aparent, agovVector, startlevel, 1, classindices, typeindices, typeclass);
      } else {
        Log.info("GCI: FULLPATH_SEARCH_MODE calling processChildren...");
        processChildren(
            aparent, agovVector, startlevel, 1, save_classindices, save_typeindices, typeclass);
      }
    }
  }
コード例 #14
0
 /**
  * Get the environment of this Context.
  *
  * @return a copy of the environment of this Context.
  */
 public Hashtable getEnvironment() {
   return (Hashtable) _env.clone();
 }
コード例 #15
0
 /**
  * returns a copy of the system info. the key is the name of the property and the associated
  * object is the value of the property (a string).
  */
 public Hashtable getSystemInfo() {
   return (Hashtable) m_Info.clone();
 }
コード例 #16
0
 /** Fait une copie independante. Ne clone pas les éléments. */
 public Object clone() {
   return new Ensemble((Hashtable) table.clone());
 }
コード例 #17
0
ファイル: GuiChildIterator.java プロジェクト: SAFSDEV/Core
  /**
   * Called internally by processChildren only.
   *
   * <p>
   *
   * @param children -- array of child objects to examine to see if any one of them satisfies the
   *     piece of the recognition string for the current object vector level--the current substring
   *     of the full recognition string. May be array of cached keys if GuiObjectVector is in
   *     EXTERNAL_PROCESSING_MODE.
   *     <p>
   * @param govVector -- the currently active GuiObjectVector.
   *     <p>
   * @param govLevel -- the hierarchy level (current substring)in the GuiObjectVector we are trying
   *     to satisfy.
   *     <p>
   * @param objLevel -- the depth in the actual application's object hierarchy currently being
   *     searched.
   *     <p>
   * @param entry_classindices -- the storage for class counts.
   *     <p>
   * @param entry_typeindices -- the storage for object type counts.
   *     <p>
   * @param onlyOneChildVisible -- true if parent is a TabControl-like component,
   */
  protected void processNextLevel(
      Object[] children, // children\key array to process
      GuiObjectVector govVector, // the full recognition vector
      int govLevel, // depth within the vector to process
      int objLevel, // depth within obj hierarchy being processed
      Hashtable entry_classindices, // class=count storage for class indices
      Hashtable entry_typeindices, // class=count storage for object indices
      boolean onlyOneChildVisible) { // if true, parent is tab
    boolean notDone = true;

    Hashtable classindices = entry_classindices;
    Hashtable typeindices = entry_typeindices;
    Hashtable save_classindices = (Hashtable) entry_classindices.clone();
    Hashtable save_typeindices = (Hashtable) entry_typeindices.clone();

    for (int i = 0; ((notFound) && (notDone) && (i < children.length)); i++) {

      Object _child = null;
      Object child = null;
      Object[] childsChildren = new Object[0];

      // reset indices for all but the last level of searching:
      // when dealing with things like TabControls with non-visible panels
      // and in CLASSIC_SEARCH_MODE.
      // In FULLPATH_SEARCH_MODE these hidden panels get unique indices
      if ((govLevel < govVector.getRecognitionDepth() - 1 && onlyOneChildVisible)
          && (SEARCH_MODE != FULLPATH_SEARCH_MODE)) {
        if (i > 0) {
          Log.info(".....class/type indices reset for all but the last level of searching");
          classindices = (Hashtable) save_classindices.clone();
          typeindices = (Hashtable) save_typeindices.clone();
        }
      }

      // get next child and reset index counters
      // only play with GuiTestObjects
      Log.info("GCI: Seeking child(" + i + ")outof(" + children.length + ")...");
      _child = children[i];
      child = _child;
      if (!govVector.isValidGuiObject(_child)) {
        Log.debug("GCI: skipping invalid Gui Object found in child array.");
        continue;
      }
      Log.info("GCI: child(" + i + ") is a valid GUI object.");

      if (govVector.getProcessMode() == GuiObjectVector.MODE_EXTERNAL_PROCESSING) {
        try {
          child = govVector.getCachedItem(_child);
        } catch (Exception e) {
        }
      }
      GuiObjectRecognition gor = govVector.getParentGuiObjectRecognition();
      String classname = gor.getObjectClassName(child);
      ClassTypeInfo typeinfo = null;

      // **** if (! classname.equalsIgnoreCase("Html.!")) { // this kills IE
      Log.info("GCI: child classname is:" + classname);

      // check to see if it is visible
      if (!gor.isObjectShowing(child)) {

        // if not, skip it if it is a container (like a TabControl Panel)
        Log.info("GCI: child is not showing.");
        if (govVector.isValidGuiContainer(_child)) {
          if (govVector.isFullPathSearchMode()) {
            incrementClassTypeIndices(
                child, govVector, govLevel, objLevel, classindices, typeindices, classname);
          }
          Log.info("GCI: skipping non-visible Gui Container: " + classname);
          continue;
        }
      }
      // } end if classname == "Html.!"
      typeinfo =
          incrementClassTypeIndices(
              child, govVector, govLevel, objLevel, classindices, typeindices, classname);
      if (typeinfo == null) continue; // invalid gorInfo at this level

      int classindex = typeinfo.classindex;
      int typeindex = typeinfo.typeindex;
      int abstypeindex = typeinfo.absolutetypeindex;
      String typeclass = typeinfo.typeclass;
      GuiObjectRecognition gorInfo = typeinfo.gorInfo;

      // classname  will ALWAYS have a class value
      // classindex will ALWAYS be at least 1
      // typeclass MAY BE null if we can't match the type
      // typeindex MAY BE  0   if we can't match the type
      int passindex, abspassindex;
      if (gorInfo.getClassCategoryID() == gorInfo.CATEGORY_CLASS_ID) {
        passindex = classindex;
        abspassindex = typeinfo.absoluteclassindex;
      }
      // TYPE is only alternative to CLASS right now
      else {
        passindex = typeindex;
        abspassindex = abstypeindex;
      }
      // see if we match the object at this level
      boolean classMatch;
      try {
        String[] tmpName = null;
        if (gather != null) tmpName = new String[1];
        classMatch =
            gorInfo.isMatchingObject(
                child, passindex,
                abspassindex, tmpName);

        // this is a special case test when we are doing this algorithm
        // but we want to gather *ALL* of the names which match, rather
        // than just the first name.  In that event, the parameter
        // 'gather' is used.  If not null, then don't let 'classMatch' get
        // beyond this place as 'true', but instead, stuff the name
        // into the List 'gather' and use 'false' for the classMatch...
        if (gather != null) {
          if (tmpName != null && tmpName[0] != null) {
            Log.info(" .....  ADD TO GATHER: " + tmpName[0]);
            gather.add(tmpName[0]);
          } else { // maybe use the index
            Log.info(
                " .....  GATHER INDEX?? passindex, abspassindex: "
                    + passindex
                    + ", "
                    + abspassindex
                    + ", classmatch would be: "
                    + classMatch);
          }
          // if we are gathering then lets also gather matched child objects
          if (classMatch) {
            // for recognitions with Path=, we must get that object
            // this is primarily used when we want ALL possible objects of
            // a given type.  For example, all HTMLLinks on a page.
            Object matchObject = gorInfo.getMatchingObject(child);
            MatchData adata = new MatchData(govVector, govLevel, objLevel, matchObject);
            matches.addElement(adata);
          }
          classMatch = false;
        }
      } catch (SAFSObjectRecognitionException ore) {
        classMatch = false;
        Log.debug(ore.getMessage());
      }

      if (classMatch) {
        // see if we have matched to the last object vector recognition level
        notDone = (govLevel < (govVector.getRecognitionDepth() - 1));
        Log.debug(
            "GCI: notDone matching vector: "
                + notDone
                + " :govLevel="
                + govLevel
                + ", maxLevel="
                + (govVector.getRecognitionDepth() - 1)
                + ", path="
                + govVector.getPathVector());
        if (notDone) {
          // see if this child has some children
          try {
            int lenchildren =
                (typeinfo.childsChildren != null)
                    ? typeinfo.childsChildren.length
                    : govVector.getChildObjects(child).length;
            if (lenchildren > 0) {
              // Log.index("notDone: processChildren: "+(objLevel+1));
              if (SEARCH_MODE == FULLPATH_SEARCH_MODE) {
                processChildren(
                    child,
                    govVector,
                    govLevel + 1,
                    objLevel + 1,
                    save_classindices,
                    save_typeindices,
                    typeclass);
              } else { // assume CLASSIC_SEARCH_MODE
                processChildren(
                    child,
                    govVector,
                    govLevel + 1,
                    objLevel + 1,
                    classindices,
                    typeindices,
                    typeclass);
              }
            }
            // if there are no children, then we are done going down this branch
            // and this path will not be a match for our recognition string
            else {
              // signal this branch is done
              // should this just be a continue?
              Log.debug("GCI: Branch completed. 0 children for " + gorInfo);
              notDone = false;
            }
            // signal this branch is done if no children (exception thrown for .length)
          } catch (Exception np) {
            Log.debug("GCI: Branch completed. NullPointer/No children for " + gorInfo, np);
            notDone = false;
          }
        }
        // **************************************************************
        // **** see if this is THEE child that completes our search! ****
        // **************************************************************
        else {
          hasFinalMatch = gorInfo.isFinalMatch(child);
          notFound = !hasFinalMatch;
          // for recognitions with Path=, we must get that object
          Object matchObject = gorInfo.getMatchingObject(child);
          // removing this unregister because currently unregistering any one reference
          // to an object seems to unregister ALL stored references to an object,
          // including cached references in our AppMaps.
          // // must unregister child if a subitem was actually the finalObject
          // if( !(matchObject == child)) {
          //   Log.debug("RGCI: Unregistering parent "+ child.getObjectClassName() +" from JVM as
          // needed.");
          //   child.unregister();
          // }
          //
          MatchData adata = new MatchData(govVector, govLevel, objLevel, matchObject);
          matches.addElement(adata);
        }
      }
      // not a class match for this object
      // we have to handle looking for the nth match inside a container
      // if not complete match, see if the match is farther down the hierarchy
      // but only for the CLASSIC_SEARCH_MODE.
      // We do not go down hierarchy paths for FULLPATH_SEARCH_MODE if the parent did not match
      else if (SEARCH_MODE
          != FULLPATH_SEARCH_MODE) { // will be CLASSIC_SEARCH_MODE (or anything else) by default
        // Log.index("processChildren: "+(objLevel+1));
        processChildren(
            child, govVector, govLevel, objLevel + 1, classindices, typeindices, typeclass);
      }
    } // end FOR LOOP
  }
コード例 #18
0
 public Object addToEnvironment(String propName, Object propVal) throws NamingException {
   myEnv = (myEnv == null) ? new Hashtable(11, 0.75f) : (Hashtable) myEnv.clone();
   return myEnv.put(propName, propVal);
 }
コード例 #19
0
ファイル: JavaURLContext.java プロジェクト: phan-pivotal/OSS
 /** Create a context with the specified environment. */
 public JavaURLContext(Hashtable environment) throws NamingException {
   myEnv = (environment != null) ? (Hashtable) (environment.clone()) : null;
 }
コード例 #20
0
ファイル: DummyContext.java プロジェクト: nabils/jackrabbit
 public Object clone() {
   Object obj = super.clone();
   ((DummyContext) obj).environment = (Hashtable) environment.clone();
   return obj;
 }
コード例 #21
0
 /**
  * Returns an array containing all operation sets supported by the current implementation.
  *
  * @return a java.util.Map containing instance of all supported operation sets mapped against
  *     their class names (e.g. OperationSetPresence.class.getName()) .
  */
 public Map getSupportedOperationSets() {
   // Copy the map so that the caller is not able to modify it.
   return (Map) supportedOperationSets.clone();
 }
コード例 #22
0
  /**
   * Bind a name to an object
   *
   * @param name Name of the object
   * @param obj object to bind
   * @exception NamingException if an error occurs
   */
  public void bind(Name name, Object obj) throws NamingException {
    if (isLocked()) throw new NamingException("This context is immutable");

    Name cname = toCanonicalName(name);

    if (cname == null) throw new NamingException("Name is null");

    if (cname.size() == 0) throw new NamingException("Name is empty");

    // if no subcontexts, just bind it
    if (cname.size() == 1) {
      // get the object to be bound
      Object objToBind = NamingManager.getStateToBind(obj, name, this, _env);
      // Check for Referenceable
      if (objToBind instanceof Referenceable) {
        objToBind = ((Referenceable) objToBind).getReference();
      }

      // anything else we should be able to bind directly
      addBinding(cname, objToBind);
    } else {
      if (__log.isDebugEnabled())
        __log.debug(
            "Checking for existing binding for name="
                + cname
                + " for first element of name="
                + cname.get(0));

      // walk down the subcontext hierarchy
      // need to ignore trailing empty "" name components

      String firstComponent = cname.get(0);
      Object ctx = null;

      if (firstComponent.equals("")) ctx = this;
      else {

        Binding binding = getBinding(firstComponent);
        if (binding == null) {
          if (_supportDeepBinding) {
            Name subname = _parser.parse(firstComponent);
            Context subctx =
                new NamingContext((Hashtable) _env.clone(), firstComponent, this, _parser);
            addBinding(subname, subctx);
            binding = getBinding(subname);
          } else {
            throw new NameNotFoundException(firstComponent + " is not bound");
          }
        }

        ctx = binding.getObject();

        if (ctx instanceof Reference) {
          // deference the object
          try {
            ctx =
                NamingManager.getObjectInstance(
                    ctx, getNameParser("").parse(firstComponent), this, _env);
          } catch (NamingException e) {
            throw e;
          } catch (Exception e) {
            __log.warn("", e);
            throw new NamingException(e.getMessage());
          }
        }
      }

      if (ctx instanceof Context) {
        ((Context) ctx).bind(cname.getSuffix(1), obj);
      } else
        throw new NotContextException("Object bound at " + firstComponent + " is not a Context");
    }
  }
コード例 #23
0
ファイル: Design.java プロジェクト: Laukien/la-OS
 public Hashtable getStyle() {
   return (Hashtable) gStyle.clone();
 }
コード例 #24
0
ファイル: Preferences.java プロジェクト: amaxilat/Arduino
  static protected void init(String commandLinePrefs) {

    // start by loading the defaults, in case something
    // important was deleted from the user prefs
    try {
      load(Base.getLibStream("preferences.txt"));
    } catch (Exception e) {
      Base.showError(null, _("Could not read default settings.\n" +
                             "You'll need to reinstall Arduino."), e);
    }

    // check for platform-specific properties in the defaults
    String platformExt = "." + PConstants.platformNames[PApplet.platform];
    int platformExtLength = platformExt.length();
    Enumeration e = table.keys();
    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      if (key.endsWith(platformExt)) {
        // this is a key specific to a particular platform
        String actualKey = key.substring(0, key.length() - platformExtLength);
        String value = get(key);
        table.put(actualKey, value);
      }
    }

    // clone the hash table
    defaults = (Hashtable) table.clone();

    // other things that have to be set explicitly for the defaults
    setColor("run.window.bgcolor", SystemColor.control);

    // Load a prefs file if specified on the command line
    if (commandLinePrefs != null) {
      try {
        load(new FileInputStream(commandLinePrefs));

      } catch (Exception poe) {
        Base.showError(_("Error"),
                       I18n.format(
			 _("Could not read preferences from {0}"),
			 commandLinePrefs
		       ), poe);
      }
    } else if (!Base.isCommandLine()) {
      // next load user preferences file
      preferencesFile = Base.getSettingsFile(PREFS_FILE);
      if (!preferencesFile.exists()) {
        // create a new preferences file if none exists
        // saves the defaults out to the file
        save();

      } else {
        // load the previous preferences file

        try {
          load(new FileInputStream(preferencesFile));

        } catch (Exception ex) {
          Base.showError(_("Error reading preferences"),
			 I18n.format(
			   _("Error reading the preferences file. " +
			     "Please delete (or move)\n" +
			     "{0} and restart Arduino."),
			   preferencesFile.getAbsolutePath()
			 ), ex);
        }
      }
    }
  }