/** For internal use only. */
 private static Object makeDerivedWrapper(Element elt, String baseTypeName) {
   synchronized (DOMUtils.getDOMLock(elt)) {
     QName typeName = XArchUtils.getXSIType(elt);
     if (typeName == null) {
       return null;
     } else {
       if (!DOMUtils.hasXSIType(
           elt, "http://www.ics.uci.edu/pub/arch/xArch/changesets.xsd", baseTypeName)) {
         try {
           String packageTitle = XArchUtils.getPackageTitle(typeName.getNamespaceURI());
           String packageName = XArchUtils.getPackageName(packageTitle);
           String implName = XArchUtils.getImplName(packageName, typeName.getName());
           Class c = Class.forName(implName);
           java.lang.reflect.Constructor con = c.getConstructor(new Class[] {Element.class});
           Object o = con.newInstance(new Object[] {elt});
           return o;
         } catch (Exception e) {
           // Lots of bad things could happen, but this
           // is OK, because this is best-effort anyway.
         }
       }
       return null;
     }
   }
 }
 /**
  * Set the xArchPath attribute on this object.
  *
  * @param xArchPath attribute value.
  */
 public void setXArchPath(String xArchPath) {
   {
     String oldValue = getXArchPath();
     if (oldValue == null ? xArchPath == null : oldValue.equals(xArchPath)) return;
     DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, X_ARCH_PATH_ATTR_NAME);
     IXArch _x = getXArch();
     if (_x != null) {
       _x.fireXArchEvent(
           new XArchEvent(
               this,
               XArchEvent.CLEAR_EVENT,
               XArchEvent.ATTRIBUTE_CHANGED,
               "xArchPath",
               oldValue,
               XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
               true));
     }
   }
   DOMUtils.setAttribute(elt, ChangesetsConstants.NS_URI, X_ARCH_PATH_ATTR_NAME, xArchPath);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.SET_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "xArchPath",
             xArchPath,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
Esempio n. 3
0
 /**
  * Set the generated attribute on this object.
  *
  * @param generated attribute value.
  */
 public void setGenerated(String generated) {
   {
     String oldValue = getGenerated();
     if (oldValue == null ? generated == null : oldValue.equals(generated)) return;
     DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, GENERATED_ATTR_NAME);
     IXArch _x = getXArch();
     if (_x != null) {
       _x.fireXArchEvent(
           new XArchEvent(
               this,
               XArchEvent.CLEAR_EVENT,
               XArchEvent.ATTRIBUTE_CHANGED,
               "generated",
               oldValue,
               XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
               true));
     }
   }
   DOMUtils.setAttribute(elt, ChangesetsConstants.NS_URI, GENERATED_ATTR_NAME, generated);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.SET_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "generated",
             generated,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
  public void setValue(String value) {
    synchronized (DOMUtils.getDOMLock(elt)) {
      {
        String oldValue = getValue();
        if (oldValue == null ? value == null : oldValue.equals(value)) return;
        synchronized (DOMUtils.getDOMLock(elt)) {
          // Get rid of any text nodes that are children of the element.
          elt.normalize();
        }
        NodeList nl = elt.getChildNodes();
        for (int i = (nl.getLength() - 1); i >= 0; i--) {
          Node n = nl.item(i);
          if (n.getNodeType() == Node.TEXT_NODE) {
            synchronized (DOMUtils.getDOMLock(elt)) {
              elt.removeChild(n);
            }

            IXArch context = getXArch();
            if (context != null) {
              context.fireXArchEvent(
                  new XArchEvent(
                      this,
                      XArchEvent.CLEAR_EVENT,
                      XArchEvent.SIMPLE_TYPE_VALUE_CHANGED,
                      "$SIMPLETYPEVALUE$",
                      null,
                      XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
                      true));
            }
          }
        }
      }
      elt.normalize();
      Document doc = elt.getOwnerDocument();
      Text txt = doc.createTextNode(value);
      elt.appendChild(txt);
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.SET_EVENT,
              XArchEvent.SIMPLE_TYPE_VALUE_CHANGED,
              "$SIMPLETYPEVALUE$",
              value,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void removeRepositoryLocation(IRepositoryLocation repositoryLocationToRemove) {
    if (!(repositoryLocationToRemove instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    NodeList nl =
        DOMUtils.getChildren(elt, JavasourcecodeConstants.NS_URI, REPOSITORY_LOCATION_ELT_NAME);
    for (int i = 0; i < nl.getLength(); i++) {
      Node n = nl.item(i);
      if (n == ((DOMBased) repositoryLocationToRemove).getDOMNode()) {
        synchronized (DOMUtils.getDOMLock(elt)) {
          elt.removeChild(n);
        }

        IXArch context = getXArch();
        if (context != null) {
          context.fireXArchEvent(
              new XArchEvent(
                  this,
                  XArchEvent.REMOVE_EVENT,
                  XArchEvent.ELEMENT_CHANGED,
                  "repositoryLocation",
                  repositoryLocationToRemove,
                  XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
        }

        return;
      }
    }
  }
  public void addRepositoryLocation(IRepositoryLocation newRepositoryLocation) {
    if (!(newRepositoryLocation instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    Element newChildElt = (Element) (((DOMBased) newRepositoryLocation).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(
            newChildElt, JavasourcecodeConstants.NS_URI, REPOSITORY_LOCATION_ELT_NAME);
    ((DOMBased) newRepositoryLocation).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.ADD_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "repositoryLocation",
              newRepositoryLocation,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void clearValue() {
    synchronized (DOMUtils.getDOMLock(elt)) {
      // Get rid of any text nodes that are children of the element.
      elt.normalize();
    }
    NodeList nl = elt.getChildNodes();
    for (int i = (nl.getLength() - 1); i >= 0; i--) {
      Node n = nl.item(i);
      if (n.getNodeType() == Node.TEXT_NODE) {
        synchronized (DOMUtils.getDOMLock(elt)) {
          elt.removeChild(n);
        }

        IXArch context = getXArch();
        if (context != null) {
          context.fireXArchEvent(
              new XArchEvent(
                  this,
                  XArchEvent.CLEAR_EVENT,
                  XArchEvent.SIMPLE_TYPE_VALUE_CHANGED,
                  "$SIMPLETYPEVALUE$",
                  null,
                  XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
        }
      }
    }
  }
  public void setSourceCodeManager(IJavaSourceCodeManager value) {
    if (!(value instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    {
      IJavaSourceCodeManager oldElt = getSourceCodeManager();
      DOMUtils.removeChildren(elt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);

      IXArch context = getXArch();
      if (context != null) {
        context.fireXArchEvent(
            new XArchEvent(
                this,
                XArchEvent.CLEAR_EVENT,
                XArchEvent.ELEMENT_CHANGED,
                "sourceCodeManager",
                oldElt,
                XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
                true));
      }
    }
    Element newChildElt = (Element) (((DOMBased) value).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(
            newChildElt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);
    ((DOMBased) value).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.SET_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "sourceCodeManager",
              value,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void setChangeSet(edu.uci.isr.xarch.instance.IXMLLink value) {
    if (!(value instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    {
      edu.uci.isr.xarch.instance.IXMLLink oldElt = getChangeSet();
      DOMUtils.removeChildren(elt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);

      IXArch context = getXArch();
      if (context != null) {
        context.fireXArchEvent(
            new XArchEvent(
                this,
                XArchEvent.CLEAR_EVENT,
                XArchEvent.ELEMENT_CHANGED,
                "changeSet",
                oldElt,
                XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
                true));
      }
    }
    Element newChildElt = (Element) (((DOMBased) value).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(newChildElt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);
    ((DOMBased) value).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.SET_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "changeSet",
              value,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
Esempio n. 10
0
 /** Removes the id attribute from this object. */
 public void clearId() {
   String oldValue = getId();
   if (oldValue == null) return;
   DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, ID_ATTR_NAME);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.CLEAR_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "id",
             oldValue,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
  public void clearChangeSet() {
    edu.uci.isr.xarch.instance.IXMLLink oldElt = getChangeSet();
    DOMUtils.removeChildren(elt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.CLEAR_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "changeSet",
              oldElt,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void clearSourceCodeManager() {
    IJavaSourceCodeManager oldElt = getSourceCodeManager();
    DOMUtils.removeChildren(elt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.CLEAR_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "sourceCodeManager",
              oldElt,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
 public XArchInstanceMetadata getInstanceMetadata() {
   return new XArchInstanceMetadata(XArchUtils.getPackageTitle(elt.getNamespaceURI()));
 }