当前位置: 首页>>代码示例>>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;未经允许,请勿转载。