org.eclipse.pde.core_3.7.1.v20120103_r372

 #359	-> byte code offset #35
    //   Java source line #361	-> byte code offset #39
    //   Java source line #362	-> byte code offset #46
    //   Java source line #364	-> byte code offset #59
    //   Java source line #354	-> byte code offset #63
    //   Java source line #355	-> byte code offset #64
    //   Java source line #358	-> byte code offset #68
    //   Java source line #359	-> byte code offset #72
    //   Java source line #361	-> byte code offset #76
    //   Java source line #362	-> byte code offset #83
    //   Java source line #364	-> byte code offset #96
    //   Java source line #356	-> byte code offset #100
    //   Java source line #358	-> byte code offset #102
    //   Java source line #359	-> byte code offset #106
    //   Java source line #361	-> byte code offset #110
    //   Java source line #362	-> byte code offset #117
    //   Java source line #364	-> byte code offset #130
    //   Java source line #366	-> byte code offset #131
    //   Java source line #358	-> byte code offset #134
    //   Java source line #359	-> byte code offset #138
    //   Java source line #361	-> byte code offset #142
    //   Java source line #362	-> byte code offset #149
    //   Java source line #364	-> byte code offset #162
    //   Java source line #367	-> byte code offset #163
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	164	0	this	Schema
    //   1	149	1	connection	java.net.URLConnection
    //   3	136	2	input	InputStream
    //   63	2	3	e	IOException
    //   100	32	4	localObject	Object
    //   25	1	5	localFileNotFoundException	java.io.FileNotFoundException
    //   59	1	6	localIOException1	IOException
    //   96	1	7	localIOException2	IOException
    //   130	1	8	localIOException3	IOException
    //   162	1	9	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   4	22	25	java/io/FileNotFoundException
    //   31	56	59	java/io/IOException
    //   4	22	63	java/io/IOException
    //   68	93	96	java/io/IOException
    //   4	31	100	finally
    //   63	68	100	finally
    //   102	127	130	java/io/IOException
    //   134	159	162	java/io/IOException
  }
  
  public void load(InputStream stream)
  {
    try
    {
      SAXParserWrapper parser = new SAXParserWrapper();
      XMLDefaultHandler handler = new XMLDefaultHandler(fAbbreviated);
      parser.parse(stream, handler);
      traverseDocumentTree(handler.getDocumentElement());
    }
    catch (SAXException localSAXException) {}catch (IOException e)
    {
      PDECore.logException(e, "IOException reading following URL: " + fURL);
    }
    catch (Exception e)
    {
      PDECore.logException(e);
    }
  }
  
  private ISchemaAttribute processAttribute(ISchemaElement element, Node elementNode)
  {
    String aname = getAttribute(elementNode, "name");
    if (aname == null) {
      return null;
    }
    String atype = getAttribute(elementNode, "type");
    String ause = getAttribute(elementNode, "use");
    String avalue = getAttribute(elementNode, "value");
    ISchemaSimpleType type = null;
    if (atype != null) {
      type = (ISchemaSimpleType)resolveTypeReference(atype);
    }
    SchemaAttribute attribute = new SchemaAttribute(element, aname);
    if (ause != null)
    {
      int use = 0;
      if (ause.equals("required")) {
        use = 1;
      } else if (ause.equals("optional")) {
        use = 0;
      } else if (ause.equals("default")) {
        use = 2;
      }
      attribute.setUse(use);
    }
    if (avalue != null) {
      attribute.setValue(avalue);
    }
    NodeList children = elementNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1)
      {
        String tag = child.getNodeName();
        if (tag.equals("annotation")) {
          processAttributeAnnotation(attribute, child);
        } else if (tag.equals("simpleType")) {
          processAttributeSimpleType(attribute, child);
        }
      }
    }
    if ((type != null) && (attribute.getType() == null)) {
      attribute.setType(type);
    }
    return attribute;
  }
  
  private void processAttributeAnnotation(SchemaAttribute element, Node node)
  {
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1) {
        if (child.getNodeName().equals("documentation"))
        {
          Node doc = child.getFirstChild();
          if (doc != null) {
            element.setDescription(getNormalizedText(doc.getNodeValue()));
          }
        }
        else if ((child.getNodeName().equals("appInfo")) || (child.getNodeName().equals("appinfo")))
        {
          NodeList infos = child.getChildNodes();
          for (int j = 0; j < infos.getLength(); j++)
          {
            Node meta = infos.item(j);
            if ((meta.getNodeType() == 1) && 
              (meta.getNodeName().equals("meta.attribute")))
            {
              element.setKind(processKind(getAttribute(meta, "kind")));
              element.setBasedOn(getAttribute(meta, "basedOn"));
              element.setTranslatableProperty(processTranslatable(getAttribute(meta, "translatable")));
              element.setDeprecatedProperty(processDeprecated(getAttribute(meta, "deprecated")));
            }
          }
        }
      }
    }
  }
  
  private boolean processTranslatable(String value)
  {
    return (value != null) && ("true".equals(value));
  }
  
  private boolean processDeprecated(String value)
  {
    return (value != null) && ("true".equals(value));
  }
  
  private SchemaSimpleType processAttributeRestriction(SchemaAttribute attribute, Node node)
  {
    NodeList children = node.getChildNodes();
    if (children.getLength() == 0) {
      return null;
    }
    String baseName = getAttribute(node, "base");
    if (!baseName.equals("string")) {
      return new SchemaSimpleType(attribute.getSchema(), "string");
    }
    SchemaSimpleType type = new SchemaSimpleType(attribute.getSchema(), baseName);
    Vector items = new Vector();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if ((child.getNodeType() == 1) && 
        (child.getNodeName().equals("enumeration")))
      {
        ISchemaEnumeration enumeration = processEnumeration(attribute.getSchema(), child);
        if (enumeration != null) {
          items.addElement(enumeration);
        }
      }
    }
    ChoiceRestriction restriction = new ChoiceRestriction(attribute.getSchema());
    restriction.setChildren(items);
    type.setRestriction(restriction);
    return type;
  }
  
  private void processAttributeSimpleType(SchemaAttribute attribute, Node node)
  {
    NodeList children = node.getChildNodes();
    if (children.getLength() == 0) {
      return;
    }
    SchemaSimpleType type = null;
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if ((child.getNodeType() == 1) && 
        (child.getNodeName().equals("restriction"))) {
        type = processAttributeRestriction(attribute, child);
      }
    }
    if (type != null) {
      attribute.setType(type);
    }
  }
  
  private SchemaComplexType processComplexType(ISchemaElement owner, Node typeNode)
  {
    String aname = getAttribute(typeNode, "name");
    String amixed = getAttribute(typeNode, "mixed");
    SchemaComplexType complexType = new SchemaComplexType(this, aname);
    if ((amixed != null) && (amixed.equals("true"))) {
      complexType.setMixed(true);
    }
    NodeList children = typeNode.getChildNodes();
    ISchemaCompositor compositor = null;
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1) {
        if (child.getNodeName().equals("attribute"))
        {
          complexType.addAttribute(processAttribute(owner, child));
        }
        else
        {
          ISchemaObject object = processCompositorChild(owner, child, -1);
          if (((object instanceof ISchemaCompositor)) && (compositor == null)) {
            compositor = (ISchemaCompositor)object;
          }
        }
      }
    }
    complexType.setCompositor(compositor);
    return complexType;
  }
  
  private ISchemaCompositor processCompositor(ISchemaObject parent, Node node, int type)
  {
    SchemaCompositor compositor = new SchemaCompositor(parent, type);
    NodeList children = node.getChildNodes();
    int minOccurs = 1;
    int maxOccurs = 1;
    String aminOccurs = getAttribute(node, "minOccurs");
    String amaxOccurs = getAttribute(node, "maxOccurs");
    if (aminOccurs != null) {
      minOccurs = Integer.valueOf(aminOccurs).intValue();
    }
    if (amaxOccurs != null) {
      if (amaxOccurs.equals("unbounded")) {
        maxOccurs = Integer.MAX_VALUE;
      } else {
        maxOccurs = Integer.valueOf(amaxOccurs).intValue();
      }
    }
    compositor.setMinOccurs(minOccurs);
    compositor.setMaxOccurs(maxOccurs);
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      ISchemaObject object = processCompositorChild(compositor, child, type);
      if (object != null) {
        compositor.addChild(object);
      }
    }
    return compositor;
  }
  
  private ISchemaObject processCompositorChild(ISchemaObject parent, Node child, int parentKind)
  {
    String tag = child.getNodeName();
    if ((tag.equals("element")) && (parentKind != -1)) {
      return processElement(parent, child);
    }
    if ((tag.equals("sequence")) && (parentKind != 0)) {
      return processCompositor(parent, child, 2);
    }
    if ((tag.equals("choice")) && (parentKind != 0)) {
      return processCompositor(parent, child, 1);
    }
    if ((tag.equals("all")) && (
      (parentKind == -1) || (parentKind == 3))) {
      return processCompositor(parent, child, 2);
    }
    if ((tag.equals("group")) && (
      (parentKind == 1) || (parentKind == 2))) {
      return processCompositor(parent, child, 2);
    }
    return null;
  }
  
  private ISchemaElement processElement(ISchemaObject parent, Node elementNode)
  {
    if ((parent instanceof ISchemaCompositor)) {
      return processElementReference((ISchemaCompositor)parent, elementNode);
    }
    return processElementDeclaration(parent, elementNode);
  }
  
  private ISchemaElement processElementDeclaration(ISchemaObject parent, Node elementNode)
  {
    String aname = getAttribute(elementNode, "name");
    if (aname == null) {
      return null;
    }
    String atype = getAttribute(elementNode, "type");
    int minOccurs = getMinOccurs(elementNode);
    int maxOccurs = getMaxOccurs(elementNode);
    
    ISchemaType type = null;
    if (atype != null) {
      type = resolveTypeReference(atype);
    }
    SchemaElement element;
    SchemaElement element;
    if (aname.equals("extension")) {
      element = new SchemaRootElement(parent, aname);
    } else {
      element = new SchemaElement(parent, aname);
    }
    element.setMinOccurs(minOccurs);
    element.setMaxOccurs(maxOccurs);
    NodeList children = elementNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1)
      {
        String tag = child.getNodeName();
        if ((type == null) && (tag.equals("complexType"))) {
          type = processComplexType(element, child);
        }
        if (tag.equals("annotation")) {
          processElementAnnotation(element, child);
        }
      }
    }
    element.setType(type);
    return element;
  }
  
  private ISchemaElement processElementReference(ISchemaCompositor compositor, Node elementNode)
  {
    String aref = getAttribute(elementNode, "ref");
    if (aref == null) {
      return null;
    }
    int minOccurs = getMinOccurs(elementNode);
    int maxOccurs = getMaxOccurs(elementNode);
    
    SchemaElementReference reference = new SchemaElementReference(compositor, aref);
    reference.addComments(elementNode);
    reference.setMinOccurs(minOccurs);
    reference.setMaxOccurs(maxOccurs);
    fReferences.addElement(reference);
    
    return reference;
  }
  
  private int getMinOccurs(Node elementNode)
  {
    String aminOccurs = getAttribute(elementNode, "minOccurs");
    if (aminOccurs != null) {
      return Integer.valueOf(aminOccurs).intValue();
    }
    return 1;
  }
  
  private int getMaxOccurs(Node elementNode)
  {
    String amaxOccurs = getAttribute(elementNode, "maxOccurs");
    if (amaxOccurs != null)
    {
      if (amaxOccurs.equals("unbounded")) {
        return Integer.MAX_VALUE;
      }
      return Integer.valueOf(amaxOccurs).intValue();
    }
    return 1;
  }
  
  private void processElementAnnotation(SchemaElement element, Node node)
  {
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1) {
        if ((child.getNodeName().equals("documentation")) && (!fAbbreviated))
        {
          element.setDescription(getNormalizedText(child.getFirstChild().getNodeValue()));
        }
        else if ((child.getNodeName().equals("appInfo")) || (child.getNodeName().equals("appinfo")))
        {
          NodeList infos = child.getChildNodes();
          for (int j = 0; j < infos.getLength(); j++)
          {
            Node meta = infos.item(j);
            if ((meta.getNodeType() == 1) && 
              (meta.getNodeName().equals("meta.element")))
            {
              element.setLabelProperty(getAttribute(meta, "labelAttribute"));
              element.setIconProperty(getAttribute(meta, "icon"));
              if (element.getIconProperty() == null) {
                element.setIconProperty(getAttribute(meta, "iconName"));
              }
              element.setTranslatableProperty(processTranslatable(getAttribute(meta, "translatable")));
              element.setDeprecatedProperty(processDeprecated(getAttribute(meta, "deprecated")));
              if ((element instanceof ISchemaRootElement))
              {
                String depSug = getAttribute(meta, "replacement");
                ((ISchemaRootElement)element).setDeprecatedSuggestion(depSug);
                
                String internal = getAttribute(meta, "internal");
                ((ISchemaRootElement)element).setInternal(Boolean.valueOf(internal).booleanValue());
              }
            }
          }
        }
      }
    }
  }
  
  private ISchemaEnumeration processEnumeration(ISchema schema, Node node)
  {
    String name = getAttribute(node, "value");
    return new SchemaEnumeration(schema, name);
  }
  
  private int processKind(String name)
  {
    if (name != null)
    {
      if (name.equals("java")) {
        return 1;
      }
      if (name.equals("resource")) {
        return 2;
      }
      if (name.equals("identifier")) {
        return 3;
      }
    }
    return 0;
  }
  
  private void processSchemaAnnotation(Node node)
  {
    NodeList children = node.getChildNodes();
    String section = "overview";
    String sectionName = "Overview";
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1) {
        if ((child.getNodeName().equals("documentation")) && (!fAbbreviated))
        {
          String text = getNormalizedText(child.getFirstChild().getNodeValue());
          if (section != null) {
            if (section.equals("overview"))
            {
              setDescription(text);
            }
            else
            {
              DocumentSection sec = new DocumentSection(this, section, sectionName);
              sec.setDescription(text);
              fDocSections.addElement(sec);
            }
          }
        }
        else if ((child.getNodeName().equals("appInfo")) || (child.getNodeName().equals("appinfo")))
        {
          NodeList infos = child.getChildNodes();
          for (int j = 0; j < infos.getLength(); j++)
          {
            Node meta = infos.item(j);
            if (meta.getNodeType() == 1) {
              if (meta.getNodeName().equals("meta.schema"))
              {
                section = "overview";
                setName(getAttribute(meta, "name"));
                fPluginID = getAttribute(meta, "plugin");
                fPointID = getAttribute(meta, "id");
                fValid = true;
              }
              else if (meta.getNodeName().equals("meta.section"))
              {
                section = getAttribute(meta, "type");
                sectionName = getAttribute(meta, "name");
                if (sectionName == null) {
                  sectionName = section;
                }
              }
            }
          }
        }
      }
    }
  }
  
  private void processInclude(Node node)
  {
    String location = getAttribute(node, "schemaLocation");
    SchemaInclude include = new SchemaInclude(this, location, fAbbreviated);
    if (fIncludes == null) {
      fIncludes = new Vector();
    }
    fIncludes.add(include);
  }
  
  public void reload()
  {
    reload(null);
  }
  
  public void reload(InputStream is)
  {
    setNotificationEnabled(false);
    reset();
    if (is != null) {
      load(is);
    } else {
      load();
    }
    setNotificationEnabled(true);
    if (isLoaded()) {
      fireModelChanged(new ModelChangedEvent(this, 99, new Object[0], null));
    }
  }
  
  public void removeDocumentSection(IDocumentSection docSection)
  {
    fDocSections.removeElement(docSection);
    fireModelChanged(new ModelChangedEvent(this, 2, new Object[] { docSection }, null));
  }
  
  public void moveElementToSibling(ISchemaElement element, ISchemaObject sibling)
  {
    if (!isLoaded()) {
      load();
    }
    int index = fElements.indexOf(element);
    int newIndex;
    int newIndex;
    if ((sibling != null) && (fElements.contains(sibling))) {
      newIndex = fElements.indexOf(sibling);
    } else {
      newIndex = fElements.size() - 1;
    }
    if (index > newIndex) {
      for (int i = index; i > newIndex; i--) {
        fElements.set(i, fElements.elementAt(i - 1));
      }
    } else if (index < newIndex) {
      for (int i = index; i < newIndex; i++) {
        fElements.set(i, fElements.elementAt(i + 1));
      }
    } else {
      return;
    }
    fElements.set(newIndex, element);
    fireModelChanged(new ModelChangedEvent(this, 3, new Object[] { this }, null));
  }
  
  public void removeElement(ISchemaElement element)
  {
    fElements.removeElement(element);
    fireModelChanged(new ModelChangedEvent(this, 2, new Object[] { element }, null));
  }
  
  public void removeModelChangedListener(IModelChangedListener listener)
  {
    fListeners.remove(listener);
  }
  
  private void reset()
  {
    fElements = new Vector();
    fDocSections = new Vector();
    fIncludes = null;
    fPointID = null;
    fPluginID = null;
    fReferences = null;
    fDescription = null;
    fName = null;
    fValid = false;
    fLoaded = false;
  }
  
  private void resolveElementReference(ISchemaObjectReference reference)
  {
    ISchemaElement[] elementList = getResolvedElements();
    for (int i = 0; i < elementList.length; i++)
    {
      ISchemaElement element = elementList[i];
      if ((!(element instanceof ISchemaObjectReference)) && (element.getName().equals(reference.getName())))
      {
        reference.setReferencedObject(element);
        break;
      }
    }
  }
  
  private void resolveReference(ISchemaObjectReference reference)
  {
    Class clazz = reference.getReferencedObjectClass();
    if (clazz.equals(ISchemaElement.class)) {
      resolveElementReference(reference);
    }
  }
  
  private void resolveReferences(Vector references)
  {
    for (int i = 0; i < references.size(); i++)
    {
      ISchemaObjectReference reference = (ISchemaObjectReference)references.elementAt(i);
      resolveReference(reference);
    }
  }
  
  private SchemaType resolveTypeReference(String typeName)
  {
    return new SchemaSimpleType(this, typeName);
  }
  
  public void setDescription(String newDescription)
  {
    String oldValue = fDescription;
    fDescription = newDescription;
    fireModelObjectChanged(this, "description", oldValue, fDescription);
  }
  
  public void setName(String newName)
  {
    if (newName == null) {
      newName = "";
    }
    String oldValue = fName;
    fName = newName;
    fireModelObjectChanged(this, "name", oldValue, fName);
  }
  
  public void setPluginId(String newId)
  {
    String oldValue = fPluginID;
    fPluginID = newId;
    fireModelObjectChanged(this, "pluginId", oldValue, newId);
  }
  
  public void setPointId(String newId)
  {
    String oldValue = fPointID;
    fPointID = newId;
    fireModelObjectChanged(this, "pointId", oldValue, newId);
  }
  
  public void setNotificationEnabled(boolean newNotificationEnabled)
  {
    fNotificationEnabled = newNotificationEnabled;
  }
  
  public String toString()
  {
    return fName;
  }
  
  public void traverseDocumentTree(Node root)
  {
    if (root == null) {
      return;
    }
    NodeList children = root.getChildNodes();
    fReferences = new Vector();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1)
      {
        String nodeName = child.getNodeName().toLowerCase(Locale.ENGLISH);
        if (nodeName.equals("element"))
        {
          ISchemaElement element = processElement(this, child);
          if (element == null)
          {
            fValid = false;
            return;
          }
          ISchemaAttribute[] attributes = element.getAttributes();
          for (int j = 0; j < attributes.length; j++) {
            if (attributes[j] == null)
            {
              fValid = false;
              return;
            }
          }
          fElements.addElement(element);
        }
        else if (nodeName.equals("annotation"))
        {
          processSchemaAnnotation(child);
        }
        else if (nodeName.equals("include"))
        {
          processInclude(child);
        }
      }
    }
    addOmittedDocumentSections();
    fLoaded = true;
    if (fReferences.size() > 0) {
      resolveReferences(fReferences);
    }
    fReferences = null;
  }
  
  private void addOmittedDocumentSections()
  {
    for (int i = 0; i < DocumentSection.DOC_SECTIONS.length; i++)
    {
      DocumentSection section = new DocumentSection(this, DocumentSection.DOC_SECTIONS[i], null);
      if (!fDocSections.contains(section)) {
        addDocumentSection(section);
      }
    }
    Collections.sort(fDocSections);
  }
  
  public void updateReferencesFor(ISchemaElement element)
  {
    updateReferencesFor(element, 3);
  }
  
  public void updateReferencesFor(ISchemaElement element, int kind)
  {
    for (int i = 0; i < fElements.size(); i++)
    {
      ISchemaElement el = (ISchemaElement)fElements.elementAt(i);
      if (!el.equals(element))
      {
        ISchemaType type = el.getType();
        if ((type instanceof ISchemaComplexType))
        {
          SchemaCompositor compositor = (SchemaCompositor)((ISchemaComplexType)type).getCompositor();
          if (compositor != null) {
            compositor.updateReferencesFor(element, kind);
          }
        }
      }
    }
  }
  
  public void write(String indent, PrintWriter writer)
  {
    writer.println("<?xml version='1.0' encoding='UTF-8'?>");
    writer.println("<!-- Schema file written by PDE -->");
    writer.println("<schema targetNamespace=\"" + fPluginID + "\" xmlns=\"http://www.w3.org/2001/XMLSchema\">");
    String indent2 = "      ";
    String indent3 = indent2 + "   ";
    writer.println(indent + "<annotation>");
    
    writer.println(indent2 + (getSchemaVersion() >= 3.4D ? "<appinfo>" : "<appInfo>"));
    writer.print(indent3 + "<meta.schema plugin=\"" + fPluginID + "\"");
    writer.print(" id=\"" + fPointID + "\"");
    writer.println(" name=\"" + getName() + "\"/>");
    writer.println(indent2 + (getSchemaVersion() >= 3.4D ? "</appinfo>" : "</appInfo>"));
    writer.println(indent2 + "<documentation>");
    writer.println(indent3 + getWritableDescription());
    writer.println(indent2 + "</documentation>");
    writer.println("   </annotation>");
    writer.println();
    if (fIncludes != null) {
      for (int i = 0; i < fIncludes.size(); i++)
      {
        ISchemaInclude include = (ISchemaInclude)fIncludes.get(i);
        include.write("   ", writer);
        writer.println();
      }
    }
    for (int i = 0; i < fElements.size(); i++)
    {
      ISchemaElement element = (ISchemaElement)fElements.elementAt(i);
      element.write("   ", writer);
      writer.println();
    }
    for (int i = 0; i < fDocSections.size(); i++)
    {
      IDocumentSection section = (IDocumentSection)fDocSections.elementAt(i);
      section.write("   ", writer);
      writer.println();
    }
    writer.println("</schema>");
  }
  
  private String getWritableDescription()
  {
    String lineDelimiter = System.getProperty("line.separator");
    String description = PDEXMLHelper.getWritableString(getDescription());
    String platformDescription = description.replaceAll("\\r\\n|\\r|\\n", lineDelimiter);
    
    return platformDescription;
  }
  
  public boolean isDeperecated()
  {
    Iterator it = fElements.iterator();
    while (it.hasNext())
    {
      Object next = it.next();
      if ((next instanceof SchemaRootElement)) {
        return ((SchemaRootElement)next).isDeprecated();
      }
    }
    return false;
  }
  
  public String getDeprecatedSuggestion()
  {
    Iterator it = fElements.iterator();
    while (it.hasNext())
    {
      Object next = it.next();
      if ((next instanceof SchemaRootElement)) {
        return ((SchemaRootElement)next).getDeprecatedSuggestion();
      }
    }
    return null;
  }
  
  public boolean isInternal()
  {
    Iterator it = fElements.iterator();
    while (it.hasNext())
    {
      Object next = it.next();
      if ((next instanceof SchemaRootElement)) {
        return ((SchemaRootElement)next).isInternal();
      }
    }
    return false;
  }
  
  public double getSchemaVersion()
  {
    if (fTargetVersion == 0.0D)
    {
      IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(fPluginID);
      if (model != null)
      {
        IPluginBase base = model.getPluginBase();
        if ((base != null) && 
          (base.getSchemaVersion() != null)) {
          fTargetVersion = Double.parseDouble(base.getSchemaVersion());
        }
      }
      if (fTargetVersion == 0.0D) {
        fTargetVersion = Double.parseDouble(TargetPlatformHelper.getSchemaVersion());
      }
    }
    return fTargetVersion;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.schema.Schema
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.schema;

import java.util.LinkedList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

public class SchemaAnnotationHandler
  extends BaseSchemaHandler
{
  private static final String[] DESC_NESTED_ELEM = { "documentation", 
    "annotation", "schema" };
  private static final String META_SCHEMA_ELEM = "meta.schema";
  private static final String APP_INFO_ELEM = "appinfo";
  private static final String APP_INFO_ELEM_OLD = "appInfo";
  private static final String NAME_ATTR = "name";
  private StringBuffer fDescription;
  private String fName;
  private boolean fMetaSchemaElemFlag;
  private boolean fAppInfoElemFlag;
  
  protected void reset()
  {
    super.reset();
    fName = null;
    fDescription = new StringBuffer();
    fMetaSchemaElemFlag = false;
    fAppInfoElemFlag = false;
  }
  
  public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
  {
    super.startElement(uri, localName, qName, attributes);
    if ((fElementList.size() >= 2) && ((((String)fElementList.get(1)).compareTo("appinfo") == 0) || (((String)fElementList.get(1)).compareTo("appInfo") == 0)))
    {
      fAppInfoElemFlag = true;
      if (qName.compareTo("meta.schema") == 0)
      {
        fMetaSchemaElemFlag = true;
        if (attributes != null) {
          fName = attributes.getValue("name");
        }
      }
      else
      {
        fMetaSchemaElemFlag = false;
      }
    }
  }
  
  public void characters(char[] ch, int start, int length)
  {
    if (onTarget()) {
      for (int i = 0; i < length; i++) {
        fDescription.append(ch[(start + i)]);
      }
    }
  }
  
  protected boolean onTarget()
  {
    if (fElementList.size() >= DESC_NESTED_ELEM.length)
    {
      for (int i = 0; i < DESC_NESTED_ELEM.length; i++)
      {
        String currentElement = (String)fElementList.get(i);
        if (currentElement.compareTo(DESC_NESTED_ELEM[i]) != 0) {
          return false;
        }
      }
      if ((fMetaSchemaElemFlag) || (!fAppInfoElemFlag)) {
        return true;
      }
    }
    return false;
  }
  
  public String getDescription()
  {
    return fDescription.toString();
  }
  
  public String getName()
  {
    return fName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.schema.SchemaAnnotationHandler
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.schema;

import java.io.PrintWriter;
import java.net.URL;
import org.eclipse.pde.internal.core.ischema.ISchema;
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
import org.eclipse.pde.internal.core.ischema.ISchemaElement;
import org.eclipse.pde.internal.core.ischema.ISchemaObject;
import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType;
import org.eclipse.pde.internal.core.util.SchemaUtil;
import org.eclipse.pde.internal.core.util.XMLComponentRegistry;

public class SchemaAttribute
  extends SchemaObject
  implements ISchemaAttribute
{
  private static final long serialVersionUID = 1L;
  private int kind = 0;
  private int use = 0;
  private String valueFilter;
  private ISchemaSimpleType type;
  private String basedOn;
  private Object value;
  public static final String P_USE = "useProperty";
  public static final String P_VALUE_FILTER = "valueFilterProperty";
  public static final String P_VALUE = "value";
  public static final String P_KIND = "kindProperty";
  public static final String P_TYPE = "typeProperty";
  public static final String P_BASED_ON = "basedOnProperty";
  private boolean fTranslatable;
  private boolean fDeprecated;
  
  public SchemaAttribute(ISchemaAttribute att, String newName)
  {
    super(att.getParent(), newName);
    kind = att.getKind();
    use = att.getUse();
    value = att.getValue();
    type = new SchemaSimpleType(att.getType());
    basedOn = att.getBasedOn();
  }
  
  public SchemaAttribute(ISchemaObject parent, String name)
  {
    super(parent, name);
  }
  
  public String getBasedOn()
  {
    if ((getKind() == 1) || (getKind() == 3)) {
      return basedOn;
    }
    return null;
  }
  
  public int getKind()
  {
    return kind;
  }
  
  public ISchemaSimpleType getType()
  {
    return type;
  }
  
  public int getUse()
  {
    return use;
  }
  
  public Object getValue()
  {
    return value;
  }
  
  public String getValueFilter()
  {
    return valueFilter;
  }
  
  public void setBasedOn(String newBasedOn)
  {
    String oldValue = basedOn;
    basedOn = newBasedOn;
    getSchema().fireModelObjectChanged(this, "basedOnProperty", oldValue, basedOn);
  }
  
  public void setKind(int newKind)
  {
    Integer oldValue = new Integer(kind);
    kind = newKind;
    getSchema().fireModelObjectChanged(this, "kindProperty", oldValue, new Integer(kind));
  }
  
  public void setTranslatableProperty(boolean translatable)
  {
    boolean oldValue = fTranslatable;
    fTranslatable = translatable;
    getSchema().fireModelObjectChanged(this, "translatable", Boolean.valueOf(oldValue), Boolean.valueOf(translatable));
  }
  
  public void setDeprecatedProperty(boolean deprecated)
  {
    boolean oldValue = fDeprecated;
    fDeprecated = deprecated;
    getSchema().fireModelObjectChanged(this, "deprecated", Boolean.valueOf(oldValue), Boolean.valueOf(deprecated));
  }
  
  public void setType(ISchemaSimpleType newType)
  {
    Object oldValue = type;
    type = newType;
    getSchema().fireModelObjectChanged(this, "typeProperty", oldValue, type);
  }
  
  public void setParent(ISchemaObject obj)
  {
    super.setParent(obj);
    if (type != null) {
      type.setSchema(getSchema());
    }
  }
  
  public void setUse(int newUse)
  {
    Integer oldValue = new Integer(use);
    use = newUse;
    getSchema().fireModelObjectChanged(this, "useProperty", oldValue, new Integer(use));
  }
  
  public void setValue(String value)
  {
    String oldValue = (String)this.value;
    this.value = value;
    getSchema().fireModelObjectChanged(this, "value", oldValue, value);
  }
  
  public void setValueFilter(String valueFilter)
  {
    String oldValue = this.valueFilter;
    this.valueFilter = valueFilter;
    getSchema().fireModelObjectChanged(this, "valueFilterProperty", oldValue, valueFilter);
  }
  
  public void write(String indent, PrintWriter writer)
  {
    boolean annotation = false;
    ISchemaSimpleType type = getType();
    String typeName = type.getName();
    writer.print(indent);
    writer.print("<attribute name=\"" + getName() + "\"");
    if (type.getRestriction() == null) {
      writer.print(" type=\"" + typeName + "\"");
    }
    String useString = null;
    switch (getUse())
    {
    case 0: 
      break;
    case 2: 
      useString = "default";
      break;
    case 1: 
      useString = "required";
    }
    if (useString != null) {
      writer.print(" use=\"" + useString + "\"");
    }
    if ((value != null) && (getUse() == 2)) {
      writer.print(" value=\"" + value + "\"");
    }
    String documentation = getWritableDescription();
    if ((documentation != null) || (getBasedOn() != null) || (getKind() != 0))
    {
      annotation = true;
      writer.println(">");
      String annIndent = indent + "   ";
      String indent2 = annIndent + "   ";
      String indent3 = indent2 + "   ";
      writer.print(annIndent);
      writer.println("<annotation>");
      if (documentation != null)
      {
        writer.println(indent2 + "<documentation>");
        writer.println(indent3 + documentation);
        writer.println(indent2 + "</documentation>");
      }
      if ((getBasedOn() != null) || (getKind() != 0) || (isDeprecated()) || (isTranslatable()))
      {
        writer.println(indent2 + (getSchema().getSchemaVersion() >= 3.4D ? "<appinfo>" : "<appInfo>"));
        writer.print(indent3 + "<meta.attribute");
        String kindValue = null;
        switch (getKind())
        {
        case 1: 
          kindValue = "java";
          break;
        case 2: 
          kindValue = "resource";
          break;
        case 3: 
          kindValue = "identifier";
        }
        if (kindValue != null) {
          writer.print(" kind=\"" + kindValue + "\"");
        }
        if (getBasedOn() != null) {
          writer.print(" basedOn=\"" + getBasedOn() + "\"");
        }
        if (isTranslatable()) {
          writer.print(" translatable=\"true\"");
        }
        if (isDeprecated()) {
          writer.print(" deprecated=\"true\"");
        }
        writer.println("/>");
        writer.println(indent2 + (getSchema().getSchemaVersion() >= 3.4D ? "</appinfo>" : "</appInfo>"));
      }
      writer.println(annIndent + "</annotation>");
    }
    if (type.getRestriction() != null) {
      type.write(indent + "   ", writer);
    }
    if ((annotation) || (type.getRestriction() != null)) {
      writer.println(indent + "</attribute>");
    } else {
      writer.println("/>");
    }
  }
  
  public boolean isTranslatable()
  {
    if ((getKind() == 0) && (fTranslatable)) {
      return (type == null) || ("string".equals(type.getName()));
    }
    return false;
  }
  
  public boolean isDeprecated()
  {
    return fDeprecated;
  }
  
  public String getDescription()
  {
    if (super.getDescription() != null) {
      return super.getDescription();
    }
    ISchema schema = getSchema();
    if ((schema == null) || (schema.getURL() == null)) {
      return null;
    }
    String elementName = null;
    if ((getParent() instanceof ISchemaElement))
    {
      elementName = ((ISchemaElement)getParent()).getName();
      if (elementName == null) {
        return null;
      }
    }
    String hashkey = schema.getURL().hashCode() + "_" + elementName + "_" + getName();
    String description = XMLComponentRegistry.Instance().getDescription(hashkey, 8);
    if (description == null)
    {
      SchemaAttributeHandler handler = new SchemaAttributeHandler(elementName, getName());
      SchemaUtil.parseURL(schema.getURL(), handler);
      description = handler.getDescription();
      XMLComponentRegistry.Instance().putDescription(hashkey, description, 8);
    }
    return description;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.schema.SchemaAttribute
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.schema;

import java.util.LinkedList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

public class SchemaAttributeHandler
  extends BaseSchemaHandler
{
  private String fElementName;
  private String fAttributeName;
  private String fTargetElementName;
  private String fTargetAttributeName;
  private StringBuffer fDescription;
  private static final String[] DESC_NESTED_ELEM = { "documentation", 
    "annotation", "attribute", "complexType", "element" };
  private static final String NAME_ATTR = "name";
  
  public SchemaAttributeHandler(String targetElementName, String targetAttributeName)
  {
    setTargetElementName(targetElementName);
    setTargetAttributeName(targetAttributeName);
  }
  
  public void setTargetElementName(String targetElementName)
  {
    fTargetElementName = targetElementName;
  }
  
  public void setTargetAttributeName(String targetAttributeName)
  {
    fTargetAttributeName = targetAttributeName;
  }
  
  protected void reset()
  {
    super.reset();
    fDescription = new StringBuffer();
    fElementName = null;
    fAttributeName = null;
  }
  
  public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
  {
    super.startElement(uri, localName, qName, attributes);
    if (qName.compareTo(DESC_NESTED_ELEM[4]) == 0)
    {
      if ((attributes != null) && (attributes.getValue("name") != null)) {
        fElementName = attributes.getValue("name");
      }
    }
    else if (qName.compareTo(DESC_NESTED_ELEM[2]) == 0) {
      if (attributes != null) {
        fAttributeName = attributes.getValue("name");
      }
    }
  }
  
  public void characters(char[] ch, int start, int length)
    throws SAXException
  {
    if (onTarget()) {
      for (int i = 0; i < length; i++) {
        fDescription.append(ch[(start + i)]);
      }
    }
  }
  
  protected boolean onTarget()
  {
    if (fElementList.size() >= DESC_NESTED_ELEM.length)
    {
      for (int i = 0; i < DESC_NESTED_ELEM.length; i++)
      {
        String currentElement = (String)fElementList.get(i);
        if (currentElement.compareTo(DESC_NESTED_ELEM[i]) != 0) {
          return false;
        }
      }
      if ((fElementName == null) || (fElementName.compareTo(fTargetElementName) != 0)) {
        return false;
      }
      if ((fAttributeName == null) || (fAttributeName.compareTo(fTargetAttributeName) != 0)) {
        return false;
      }
      return true;
    }
    return false;
  }
  
  public String getDescription()
  {
    return fDescription.toString();
  }
}

/* Location:
 * Qualified Name:     org.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd