Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTM#NTYPES

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTM#NTYPES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSLTC.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new Hashtable();
    _attributes     = new Hashtable();
    _namespaces     = new Hashtable();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new Hashtable();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
}
 
Example 2
Source File: SAXImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get mapping from external element/attribute types to DOM types
 */
public int[] getReverseMapping(String[] names, String[] uris, int[] types)
{
    int i;
    final int[] result = new int[names.length + DTM.NTYPES];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = i;
    }

    // caller's types map into appropriate dom types
    for (i = 0; i < names.length; i++) {
        int type = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], true);
        result[i+DTM.NTYPES] = type;
    }
    return(result);
}
 
Example 3
Source File: XSLTC.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new Hashtable();
    _attributes     = new Hashtable();
    _namespaces     = new Hashtable();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new Hashtable();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
}
 
Example 4
Source File: SAXImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get mapping from external element/attribute types to DOM types
 */
public int[] getReverseMapping(String[] names, String[] uris, int[] types)
{
    int i;
    final int[] result = new int[names.length + DTM.NTYPES];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = i;
    }

    // caller's types map into appropriate dom types
    for (i = 0; i < names.length; i++) {
        int type = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], true);
        result[i+DTM.NTYPES] = type;
    }
    return(result);
}
 
Example 5
Source File: SAX2DTM2.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Get the next node in the iteration.
 *
 * @return The next node handle in the iteration, or END.
 */
public int next() {
  if (_currentNode == DTM.NULL) {
    return DTM.NULL;
  }

  int node = _currentNode;
  final int nodeType = _nodeType;

  if (nodeType != DTM.ELEMENT_NODE) {
    while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) != nodeType) {}
  } else {
    while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) < DTM.NTYPES) {}
  }

  _currentNode = node;

  return (node == DTM.NULL)
                  ? DTM.NULL
                  : returnNode(makeNodeHandle(node));
}
 
Example 6
Source File: ExpandedNameTable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Initialize the vector of extended types with the
 *  basic DOM node types.
 */
private void initExtendedTypes()
{
  m_extendedTypes = new ExtendedType[m_initialSize];
  for (int i = 0; i < DTM.NTYPES; i++) {
      m_extendedTypes[i] = m_defaultExtendedTypes[i];
      m_table[i] = new HashEntry(m_defaultExtendedTypes[i], i, i, null);
  }

  m_nextType = DTM.NTYPES;
}
 
Example 7
Source File: XSLTC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new HashMap<>();
    _attributes     = new HashMap<>();
    _namespaces     = new HashMap<>();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new HashMap<>();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
    _externalExtensionFunctions.clear();
}
 
Example 8
Source File: SAXImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types
 */
public short[] getMapping(String[] names, String[] uris, int[] types)
{
    // Delegate the work to getMapping2 if the document is not fully built.
    // Some of the processing has to be different in this case.
    if (_namesSize < 0) {
        return getMapping2(names, uris, types);
    }

    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();

    final short[] result = new short[exLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = m_expandedNameTable.getExpandedTypeID(uris[i],
                                                            names[i],
                                                            types[i],
                                                            true);
        if (genType >= 0 && genType < exLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return result;
}
 
Example 9
Source File: SAX2DTM2.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the next node in the iteration.
 *
 * @return The next node handle in the iteration, or END.
 */
public int next() {
  int node = _currentNode;
  if (node == DTM.NULL)
    return DTM.NULL;

  final int nodeType = _nodeType;

  if (nodeType != DTM.ELEMENT_NODE) {
    while (node != DTM.NULL && _exptype2(node) != nodeType) {
      node = _nextsib2(node);
    }
  }
  // %OPT% If the nodeType is element (matching child::*), we only
  // need to compare the expType with DTM.NTYPES. A child node of
  // an element can be either an element, text, comment or
  // processing instruction node. Only element node has an extended
  // type greater than or equal to DTM.NTYPES.
  else {
    int eType;
    while (node != DTM.NULL) {
      eType = _exptype2(node);
      if (eType >= DTM.NTYPES)
        break;
      else
        node = _nextsib2(node);
    }
  }

  if (node == DTM.NULL) {
    _currentNode = DTM.NULL;
    return DTM.NULL;
  } else {
    _currentNode = _nextsib2(node);
    return returnNode(makeNodeHandle(node));
  }
}
 
Example 10
Source File: SAXImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types
 */
public short[] getMapping(String[] names, String[] uris, int[] types)
{
    // Delegate the work to getMapping2 if the document is not fully built.
    // Some of the processing has to be different in this case.
    if (_namesSize < 0) {
        return getMapping2(names, uris, types);
    }

    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();

    final short[] result = new short[exLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = m_expandedNameTable.getExpandedTypeID(uris[i],
                                                            names[i],
                                                            types[i],
                                                            true);
        if (genType >= 0 && genType < exLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return result;
}
 
Example 11
Source File: ExpandedNameTable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Initialize the vector of extended types with the
 *  basic DOM node types.
 */
private void initExtendedTypes()
{
  m_extendedTypes = new ExtendedType[m_initialSize];
  for (int i = 0; i < DTM.NTYPES; i++) {
      m_extendedTypes[i] = m_defaultExtendedTypes[i];
      m_table[i] = new HashEntry(m_defaultExtendedTypes[i], i, i, null);
  }

  m_nextType = DTM.NTYPES;
}
 
Example 12
Source File: XSLTC.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new HashMap<>();
    _attributes     = new HashMap<>();
    _namespaces     = new HashMap<>();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new HashMap<>();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
    _externalExtensionFunctions.clear();
}
 
Example 13
Source File: SAX2DTM2.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the next node in the iteration.
 *
 * @return The next node handle in the iteration, or END.
 */
public int next()
{
  int current;
  int node;
  int type;

  final int nodeType = _nodeType;
  int currentNodeID = makeNodeIdentity(_currentNode);

  if (nodeType >= DTM.NTYPES) {
    do {
      node = currentNodeID;
      current = node;

      do {
        current++;
        type = _type2(current);
      }
      while (type != NULL && (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type));

      currentNodeID = (type != NULL) ? current : NULL;
    }
    while (node != DTM.NULL && _exptype2(node) != nodeType);
  }
  else {
    do {
      node = currentNodeID;
      current = node;

      do {
        current++;
        type = _type2(current);
      }
      while (type != NULL && (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type));

      currentNodeID = (type != NULL) ? current : NULL;
    }
    while (node != DTM.NULL
           && (_exptype2(node) != nodeType && _type2(node) != nodeType));
  }

  _currentNode = makeNodeHandle(currentNodeID);
  return (node == DTM.NULL ? DTM.NULL :returnNode(makeNodeHandle(node)));
}
 
Example 14
Source File: Mode.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
 
Example 15
Source File: SAXImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types.
 * This method is used when the document is not fully built.
 */
private short[] getMapping2(String[] names, String[] uris, int[] types)
{
    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();
    int[] generalizedTypes = null;
    if (namesLength > 0) {
        generalizedTypes = new int[namesLength];
    }

    int resultLength = exLength;

    for (i = 0; i < namesLength; i++) {
        // When the document is not fully built, the searchOnly
        // flag should be set to false. That means we should add
        // the type if it is not already in the expanded name table.
        //generalizedTypes[i] = getGeneralizedType(names[i], false);
        generalizedTypes[i] =
            m_expandedNameTable.getExpandedTypeID(uris[i],
                                                  names[i],
                                                  types[i],
                                                  false);
        if (_namesSize < 0 && generalizedTypes[i] >= resultLength) {
            resultLength = generalizedTypes[i] + 1;
        }
    }

    final short[] result = new short[resultLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = generalizedTypes[i];
        if (genType >= 0 && genType < resultLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return(result);
}
 
Example 16
Source File: Mode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
 
Example 17
Source File: SAXImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types.
 * This method is used when the document is not fully built.
 */
private short[] getMapping2(String[] names, String[] uris, int[] types)
{
    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();
    int[] generalizedTypes = null;
    if (namesLength > 0) {
        generalizedTypes = new int[namesLength];
    }

    int resultLength = exLength;

    for (i = 0; i < namesLength; i++) {
        // When the document is not fully built, the searchOnly
        // flag should be set to false. That means we should add
        // the type if it is not already in the expanded name table.
        //generalizedTypes[i] = getGeneralizedType(names[i], false);
        generalizedTypes[i] =
            m_expandedNameTable.getExpandedTypeID(uris[i],
                                                  names[i],
                                                  types[i],
                                                  false);
        if (_namesSize < 0 && generalizedTypes[i] >= resultLength) {
            resultLength = generalizedTypes[i] + 1;
        }
    }

    final short[] result = new short[resultLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = generalizedTypes[i];
        if (genType >= 0 && genType < resultLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return(result);
}
 
Example 18
Source File: Mode.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private InstructionList compileNamespaces(ClassGenerator classGen,
                                          MethodGenerator methodGen,
                                          boolean[] isNamespace,
                                          boolean[] isAttribute,
                                          boolean attrFlag,
                                          InstructionHandle defaultTarget) {
    final XSLTC xsltc = classGen.getParser().getXSLTC();
    final ConstantPoolGen cpg = classGen.getConstantPool();

    // Append switch() statement - namespace test dispatch loop
    final Vector namespaces = xsltc.getNamespaceIndex();
    final Vector names = xsltc.getNamesIndex();
    final int namespaceCount = namespaces.size() + 1;
    final int namesCount = names.size();

    final InstructionList il = new InstructionList();
    final int[] types = new int[namespaceCount];
    final InstructionHandle[] targets = new InstructionHandle[types.length];

    if (namespaceCount > 0) {
        boolean compiled = false;

        // Initialize targets for namespace() switch statement
        for (int i = 0; i < namespaceCount; i++) {
            targets[i] = defaultTarget;
            types[i] = i;
        }

        // Add test sequences for known namespace types
        for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
            if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
                String name = (String)names.elementAt(i-DTM.NTYPES);
                String namespace = name.substring(0,name.lastIndexOf(':'));
                final int type = xsltc.registerNamespace(namespace);

                if ((i < _testSeq.length) &&
                    (_testSeq[i] != null)) {
                    targets[type] =
                        (_testSeq[i]).compile(classGen,
                                                   methodGen,
                                                   defaultTarget);
                    compiled = true;
                }
            }
        }

        // Return "null" if no test sequences were compiled
        if (!compiled) return(null);

        // Append first code in applyTemplates() - get type of current node
        final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
                                                    "getNamespaceType",
                                                    "(I)I");
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(_currentIndex));
        il.append(new INVOKEINTERFACE(getNS, 2));
        il.append(new SWITCH(types, targets, defaultTarget));
        return(il);
    }
    else {
        return(null);
    }
}
 
Example 19
Source File: SAXImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types.
 * This method is used when the document is not fully built.
 */
private short[] getMapping2(String[] names, String[] uris, int[] types)
{
    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();
    int[] generalizedTypes = null;
    if (namesLength > 0) {
        generalizedTypes = new int[namesLength];
    }

    int resultLength = exLength;

    for (i = 0; i < namesLength; i++) {
        // When the document is not fully built, the searchOnly
        // flag should be set to false. That means we should add
        // the type if it is not already in the expanded name table.
        //generalizedTypes[i] = getGeneralizedType(names[i], false);
        generalizedTypes[i] =
            m_expandedNameTable.getExpandedTypeID(uris[i],
                                                  names[i],
                                                  types[i],
                                                  false);
        if (_namesSize < 0 && generalizedTypes[i] >= resultLength) {
            resultLength = generalizedTypes[i] + 1;
        }
    }

    final short[] result = new short[resultLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = generalizedTypes[i];
        if (genType >= 0 && genType < resultLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return(result);
}
 
Example 20
Source File: SAXImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get mapping from DOM element/attribute types to external types.
 * This method is used when the document is not fully built.
 */
private short[] getMapping2(String[] names, String[] uris, int[] types)
{
    int i;
    final int namesLength = names.length;
    final int exLength = m_expandedNameTable.getSize();
    int[] generalizedTypes = null;
    if (namesLength > 0) {
        generalizedTypes = new int[namesLength];
    }

    int resultLength = exLength;

    for (i = 0; i < namesLength; i++) {
        // When the document is not fully built, the searchOnly
        // flag should be set to false. That means we should add
        // the type if it is not already in the expanded name table.
        //generalizedTypes[i] = getGeneralizedType(names[i], false);
        generalizedTypes[i] =
            m_expandedNameTable.getExpandedTypeID(uris[i],
                                                  names[i],
                                                  types[i],
                                                  false);
        if (_namesSize < 0 && generalizedTypes[i] >= resultLength) {
            resultLength = generalizedTypes[i] + 1;
        }
    }

    final short[] result = new short[resultLength];

    // primitive types map to themselves
    for (i = 0; i < DTM.NTYPES; i++) {
        result[i] = (short)i;
    }

    for (i = NTYPES; i < exLength; i++) {
        result[i] = m_expandedNameTable.getType(i);
    }

    // actual mapping of caller requested names
    for (i = 0; i < namesLength; i++) {
        int genType = generalizedTypes[i];
        if (genType >= 0 && genType < resultLength) {
            result[genType] = (short)(i + DTM.NTYPES);
        }
    }

    return(result);
}