當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlElementDescriptorImpl類代碼示例

本文整理匯總了Java中com.intellij.xml.impl.dtd.XmlElementDescriptorImpl的典型用法代碼示例。如果您正苦於以下問題:Java XmlElementDescriptorImpl類的具體用法?Java XmlElementDescriptorImpl怎麽用?Java XmlElementDescriptorImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlElementDescriptorImpl類屬於com.intellij.xml.impl.dtd包,在下文中一共展示了XmlElementDescriptorImpl類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testElementDescriptor4

import com.intellij.xml.impl.dtd.XmlElementDescriptorImpl; //導入依賴的package包/類
public void testElementDescriptor4() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<!ELEMENT orion-application (ejb-module*, persistence?, namespace-access)>" +
      "<!ELEMENT ejb-module ANY>" +
      "<!ELEMENT persistence ANY>" +
      "<!ELEMENT namespace-access ANY>");

  XmlTag documentTag = tag("orion-application");
  XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)NSDescriptor.getElementDescriptor(documentTag);

  XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(documentTag);

  assertEquals(3, elements.length);
  assertEquals("ejb-module", elements[0].getName());
  assertEquals("persistence", elements[1].getName());
  assertEquals("namespace-access", elements[2].getName());

  elements = elements[0].getElementsDescriptors(documentTag);
  assertEquals(4, elements.length);
  assertEquals("orion-application", elements[0].getName());
  assertEquals("ejb-module", elements[1].getName());
  assertEquals("persistence", elements[2].getName());
  assertEquals("namespace-access", elements[3].getName());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:XmlDtdTest.java

示例2: getLocationString

import com.intellij.xml.impl.dtd.XmlElementDescriptorImpl; //導入依賴的package包/類
@Override
public String getLocationString() {
  final XmlElement owner = (XmlElement)getElement();

  final XmlAttlistDecl[] attLists= owner instanceof XmlElementDecl ? XmlElementDescriptorImpl.getCachedAttributeDeclarations(owner): XmlAttlistDecl.EMPTY_ARRAY;

  if (attLists.length > 0) {
    Map<String,XmlAttributeDecl> attrMap = null;

    final String name = getElement().getName();
    for(XmlAttlistDecl a:attLists) {
      final String aname = a.getName();
      if (!Comparing.equal(aname, name)) continue;
      if (attrMap == null) attrMap = new LinkedHashMap<String, XmlAttributeDecl>();

      for(XmlAttributeDecl d : a.getAttributeDecls()) {
        attrMap.put(d.getName(), d);
      }
    }

    StringBuilder b = null;
    if (attrMap != null) {
      for(Map.Entry<String,XmlAttributeDecl> e:attrMap.entrySet()) {
        if (b == null) b = new StringBuilder();
        else b.append(", ");
        b.append(e.getKey());
        final XmlAttributeDecl attributeDecl = e.getValue();
        String type = null;

        if (attributeDecl.isIdAttribute()) {
          type = ID;
        } else if (attributeDecl.isIdRefAttribute()) {
          type = IDREF;
        } else if (attributeDecl.isEnumerated()) {
          type = ENUM;
        }

        if (attributeDecl.isAttributeFixed()) {
          if (type == null) type = FIXED;
          else type += " " + FIXED;
        } else if (attributeDecl.isAttributeRequired()) {
          if (type == null) type = REQUIRED;
          else type += " " + REQUIRED;
        } else if (attributeDecl.isAttributeImplied()) {
          if (type == null) type = IMPLIED;
          else type += " " + IMPLIED;
        }

        if (type != null) b.append(':').append(type);
        final XmlAttributeValue value = attributeDecl.getDefaultValue();

        if (value != null) b.append("=").append(value);
      }
    }

    if (b != null) return b.toString();
 }
 return super.getLocationString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:60,代碼來源:DtdFileTreeElement.java

示例3: getLocationString

import com.intellij.xml.impl.dtd.XmlElementDescriptorImpl; //導入依賴的package包/類
public String getLocationString() {
  final XmlElement owner = (XmlElement)getElement();

  final XmlAttlistDecl[] attLists= owner instanceof XmlElementDecl ? XmlElementDescriptorImpl.getCachedAttributeDeclarations(owner): XmlAttlistDecl.EMPTY_ARRAY;

  if (attLists.length > 0) {
    Map<String,XmlAttributeDecl> attrMap = null;

    final String name = getElement().getName();
    for(XmlAttlistDecl a:attLists) {
      final String aname = a.getName();
      if (!Comparing.equal(aname, name)) continue;
      if (attrMap == null) attrMap = new LinkedHashMap<String, XmlAttributeDecl>();

      for(XmlAttributeDecl d : a.getAttributeDecls()) {
        attrMap.put(d.getName(), d);
      }
    }

    StringBuilder b = null;
    if (attrMap != null) {
      for(Map.Entry<String,XmlAttributeDecl> e:attrMap.entrySet()) {
        if (b == null) b = new StringBuilder();
        else b.append(", ");
        b.append(e.getKey());
        final XmlAttributeDecl attributeDecl = e.getValue();
        String type = null;

        if (attributeDecl.isIdAttribute()) {
          type = ID;
        } else if (attributeDecl.isIdRefAttribute()) {
          type = IDREF;
        } else if (attributeDecl.isEnumerated()) {
          type = ENUM;
        }

        if (attributeDecl.isAttributeFixed()) {
          if (type == null) type = FIXED;
          else type += " " + FIXED;
        } else if (attributeDecl.isAttributeRequired()) {
          if (type == null) type = REQUIRED;
          else type += " " + REQUIRED;
        } else if (attributeDecl.isAttributeImplied()) {
          if (type == null) type = IMPLIED;
          else type += " " + IMPLIED;
        }

        if (type != null) b.append(':').append(type);
        final XmlAttributeValue value = attributeDecl.getDefaultValue();

        if (value != null) b.append("=").append(value);
      }
    }

    if (b != null) return b.toString();
 }
 return super.getLocationString();
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:59,代碼來源:DtdFileTreeElement.java


注:本文中的com.intellij.xml.impl.dtd.XmlElementDescriptorImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。