Package com.linkedin.data.element

Examples of com.linkedin.data.element.DataElement


   * @param it provides the iterator of Data objects to be removed.
   * @return null if the input Data object is removed, else return the input root.
   */
  public static Object remove(Object root, DataIterator it)
  {
    DataElement element;

    // construct the list of Data objects to remove
    // don't remove in place because iterator behavior with removals while iterating is undefined
    ArrayList<ToRemove> removeList = new ArrayList<ToRemove>();
    while ((element = it.next()) != null)
View Full Code Here


{
  private static class ToRemove
  {
    private ToRemove(DataElement element)
    {
      DataElement parentElement = element.getParent();
      _parent = parentElement == null ? null : parentElement.getValue();
      _name = element.getName();
    }
View Full Code Here

   * @param transform used to provide a replacement value.
   * @return the transformed of root Data object if it was transformed, otherwise the input root with the transformations applied.
   */
  public static Object transform(Object root, DataIterator it, Transform<Object,Object> transform)
  {
    DataElement element;
   
    // don't transform in place because iterator behavior with replacements (which behave like a remove and an add) while iterating is undefined
    ArrayList<ToTransform> transformList = new ArrayList<ToTransform>();
    while ((element = it.next()) != null)
    {
View Full Code Here

  private static class ToTransform
  {
    private ToTransform(DataElement element)
    {
      _value = element.getValue();
      DataElement parentElement = element.getParent();
      _parent = parentElement == null ? null : parentElement.getValue();
      _name = element.getName();
    }
View Full Code Here

  }

  private boolean pass(DataElement element, int i)
  {
    boolean pass = true;
    DataElement currentElement = element;
    for (; i < _matches.size(); ++i)
    {
      Match match = _matches.get(i);
      if (match.name == null)
      {
        int d = 0;
        while (d < match.minDistance)
        {
          if (currentElement.getParent() == null)
          {
            pass = false;
            break;
          }
          currentElement = currentElement.getParent();
          ++d;
        }
        if (pass == false)
        {
          break;
        }
        if (i == (_matches.size() - 1))
        {
          while (d < match.maxDistance && currentElement.getParent() != null)
          {
            currentElement = currentElement.getParent();
            ++d;
          }
        }
        else
        {
          Match nextMatch = _matches.get(i + 1);
          int searchDistance = (match.maxDistance == Integer.MAX_VALUE ?
                                Integer.MAX_VALUE :
                                match.maxDistance - match.minDistance + 1);
          boolean matched = false;
          while (searchDistance > 0 && currentElement.getParent() != null)
          {
            if (matchName(nextMatch, currentElement.getName()))
            {
              boolean subPass = pass(currentElement.getParent(), i + 2);
              if (subPass)
              {
                matched = true;
                i = _matches.size();
                while (currentElement.getParent() != null)
                {
                  currentElement = currentElement.getParent();
                }
                break;
              }
            }
            searchDistance--;
            currentElement = currentElement.getParent();
          }
          if (matched == false)
          {
            pass = false;
            break;
          }
          break;
        }
      }
      else
      {
        if (currentElement.getParent() == null || matchName(match, currentElement.getName()) == false)
        {
          pass = false;
          break;
        }
        currentElement = currentElement.getParent();
      }
    }
    if (pass)
    {
      assert(i == _matches.size());
      pass = (currentElement.getParent() == null);
    }

    return pass;
  }
View Full Code Here

  }

  public void iterate(Callback callback)
  {
    DataIterator it = dataIterator();
    DataElement element;
    while ((element = it.next()) != null)
    {
      callback.callback(element);
    }
  }
View Full Code Here

    }

    @Override
    protected DataElement next()
    {
      DataElement element;
      if (_it.hasNext())
      {
        _currentEntry = _it.next();
        _childElement.setValueNameSchema(_currentEntry.getValue(), _currentEntry.getKey(), currentSchema());
        element = _childElement;
View Full Code Here

    }

    @Override
    protected DataElement next()
    {
      DataElement element;
      if (_it.hasNext())
      {
        _currentIndex = _it.nextIndex();
        Object value = _it.next();
        _childElement.setValueNameSchema(value, _currentIndex, currentSchema());
View Full Code Here

TOP

Related Classes of com.linkedin.data.element.DataElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.