com.sun.org.apache.xml.internal.utils.SuballocatedIntVector Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.utils.SuballocatedIntVector. 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: MultiDOM.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #2
Source File: MultiDOM.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #3
Source File: MultiDOM.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #4
Source File: MultiDOM.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #5
Source File: MultiDOM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #6
Source File: MultiDOM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #7
Source File: MultiDOM.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #8
Source File: MultiDOM.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example #9
Source File: DTMDefaultBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #10
Source File: DTMDefaultBase.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #11
Source File: DTMDefaultBase.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #12
Source File: DTMDefaultBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #13
Source File: DTMDefaultBase.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #14
Source File: DTMDefaultBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #15
Source File: DTMDefaultBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #16
Source File: DTMDefaultBase.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #17
Source File: DTMDefaultBase.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #18
Source File: DTMDefaultBase.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #19
Source File: DTMDefaultBase.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #20
Source File: DTMDefaultBase.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #21
Source File: DTMDefaultBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #22
Source File: DTMDefaultBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #23
Source File: DTMDefaultBase.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #24
Source File: DTMDefaultBase.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #25
Source File: DTMDefaultBase.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #26
Source File: DTMDefaultBase.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #27
Source File: DTMDefaultBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}
 
Example #28
Source File: DTMDefaultBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #29
Source File: DTMDefaultBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
   * Subroutine: Locate the specified node within
   * m_namespaceDeclSetElements, or the last element which
   * preceeds it in document order
   *
   * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
   *
   * @return If positive or zero, the index of the found item.
   * If negative, index of the point at which it would have appeared,
   * encoded as -1-index and hence reconvertable by subtracting
   * it from -1. (Encoding because I don't want to recompare the strings
   * but don't want to burn bytes on a datatype to hold a flagged value.)
   */
protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
{
  // Binary search
  int i = 0;
  if(vector != null) {
    int first = 0;
    int last  = vector.size() - 1;

    while (first <= last) {
      i = (first + last) / 2;
      int test = lookfor-vector.elementAt(i);
      if(test == 0) {
        return i; // Name found
      }
      else if (test < 0) {
        last = i - 1; // looked too late
      }
      else {
        first = i + 1; // looked ot early
      }
    }

    if (first > i) {
      i = first; // Clean up at loop end
    }
  }

  return -1 - i; // not-found has to be encoded.
}
 
Example #30
Source File: DTMDefaultBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a namespace handle, advance to the next namespace.
 *
 * @param baseHandle handle to original node from where the first namespace
 * was relative to (needed to return nodes in document order).
 * @param nodeHandle A namespace handle for which we will find the next node.
 * @param inScope true if all namespaces that are in scope should be processed,
 * otherwise just process the nodes in the given element handle.
 * @return handle of next namespace, or DTM.NULL to indicate none exists.
 */
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
                                boolean inScope)
{
      if(inScope)
        {
          //Since we've been given the base, try direct lookup
          //(could look from nodeHandle but this is at least one
          //comparison/get-parent faster)
          //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);

              SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));

          if(nsContext==null)
            return NULL;
          int i=1 + nsContext.indexOf(nodeHandle);
          if(i<=0 || i==nsContext.size())
            return NULL;

          return nsContext.elementAt(i);
        }
      else
        {
          // Assume that attributes and namespace nodes immediately follow the element.
          int identity = makeNodeIdentity(nodeHandle);
          while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
            {
              int type = _type(identity);
              if (type == DTM.NAMESPACE_NODE)
                {
                  return makeNodeHandle(identity);
                }
              else if (type != DTM.ATTRIBUTE_NODE)
                {
                  break;
                }
            }
        }
   return DTM.NULL;
}