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

The following examples show how to use com.sun.org.apache.xml.internal.utils.SuballocatedIntVector. These examples are extracted from open source projects. 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: MultiDOM.java    License: 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 Project: TencentKona-8   Author: Tencent   File: MultiDOM.java    License: 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 #3
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: MultiDOM.java    License: 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 #4
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: MultiDOM.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: MultiDOM.java    License: 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 Project: Bytecoder   Author: mirkosertic   File: MultiDOM.java    License: 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 #7
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: MultiDOM.java    License: 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 #8
Source Project: hottub   Author: dsrg-uoft   File: MultiDOM.java    License: 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: DTMDefaultBase.java    License: 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 #10
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: DTMDefaultBase.java    License: 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 Project: TencentKona-8   Author: Tencent   File: DTMDefaultBase.java    License: 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 Project: TencentKona-8   Author: Tencent   File: DTMDefaultBase.java    License: 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 #13
Source Project: jdk8u60   Author: chenghanpeng   File: DTMDefaultBase.java    License: 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 #14
Source Project: jdk8u60   Author: chenghanpeng   File: DTMDefaultBase.java    License: 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 #15
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: DTMDefaultBase.java    License: 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 #16
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: DTMDefaultBase.java    License: 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 #17
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 #18
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 #19
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 Project: Bytecoder   Author: mirkosertic   File: DTMDefaultBase.java    License: 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 #22
Source Project: Bytecoder   Author: mirkosertic   File: DTMDefaultBase.java    License: 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 #23
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 #24
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: DTMDefaultBase.java    License: 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 #25
Source Project: hottub   Author: dsrg-uoft   File: DTMDefaultBase.java    License: 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 #26
Source Project: hottub   Author: dsrg-uoft   File: DTMDefaultBase.java    License: 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 #27
Source Project: openjdk-8-source   Author: keerath   File: DTMDefaultBase.java    License: 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 #28
Source Project: openjdk-8-source   Author: keerath   File: DTMDefaultBase.java    License: 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 #29
Source Project: openjdk-8   Author: bpupadhyaya   File: DTMDefaultBase.java    License: 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 Project: openjdk-8   Author: bpupadhyaya   File: DTMDefaultBase.java    License: 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;
}