Java Code Examples for com.helger.commons.collection.impl.ICommonsList#iterator()

The following examples show how to use com.helger.commons.collection.impl.ICommonsList#iterator() . 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: HelpFormatter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Appends the usage clause for an OptionGroup to a StringBuilder. The clause
 * is wrapped in square brackets if the group is required. The display of the
 * options is handled by appendOption
 *
 * @param aSB
 *        the StringBuilder to append to
 * @param aGroup
 *        the group to append
 * @see #_appendOption(StringBuilder,Option,boolean)
 */
private void _appendOptionGroup (final StringBuilder aSB, final OptionGroup aGroup)
{
  if (!aGroup.isRequired ())
    aSB.append ('[');

  final ICommonsList <Option> optList = aGroup.getAllOptions ();
  if (m_aOptionComparator != null)
    optList.sort (m_aOptionComparator);

  // for each option in the OptionGroup
  final Iterator <Option> it = optList.iterator ();
  while (it.hasNext ())
  {
    // whether the option is required or not is handled at group level
    _appendOption (aSB, it.next (), true);

    if (it.hasNext ())
      aSB.append (" | ");
  }

  if (!aGroup.isRequired ())
    aSB.append (']');
}
 
Example 2
Source File: GraphIterator.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public GraphIterator (@Nonnull final IMutableGraphNode aStartNode)
{
  ValueEnforcer.notNull (aStartNode, "startNode");

  // Collect all nodes, depth first
  final ICommonsList <IMutableGraphNode> aList = new CommonsArrayList <> ();
  _traverseDFS (aStartNode, aList);
  m_aIter = aList.iterator ();
}
 
Example 3
Source File: RecursiveChildNodeIterator.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public RecursiveChildNodeIterator (@Nonnull final Node aParent)
{
  ValueEnforcer.notNull (aParent, "Parent");

  final ICommonsList <Node> aNodes = new CommonsArrayList <> ();
  _recursiveFillListPrefix (aParent, aNodes);
  m_aIter = aNodes.iterator ();
}
 
Example 4
Source File: SaxonNamespaceContext.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@Nonnull
public Iterator <String> iteratePrefixes ()
{
  final ICommonsList <String> aList = new CommonsArrayList <> (m_aCtx.getPrefixToNamespaceURIMap ().keySet ());
  aList.add ("");
  return aList.iterator ();
}
 
Example 5
Source File: CSSNode.java    From ph-css with Apache License 2.0 5 votes vote down vote up
@Nonnull
public Iterator <CSSNode> iterator ()
{
  final ICommonsList <CSSNode> aChildren = new CommonsArrayList <> (jjtGetNumChildren ());
  if (m_aChildren != null)
    for (final CSSNode aChildNode : m_aChildren)
      if (aChildNode != null)
        aChildren.add (aChildNode);
  return aChildren.iterator ();
}
 
Example 6
Source File: HelpFormatter.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
/**
 * Prints the usage statement for the specified application.
 *
 * @param aPW
 *        The PrintWriter to print the usage statement
 * @param nWidth
 *        The number of characters to display per line
 * @param sAppName
 *        The application name
 * @param aOptions
 *        The command line Options
 */
public void printUsage (@Nonnull final PrintWriter aPW,
                        final int nWidth,
                        final String sAppName,
                        final Options aOptions)
{
  // initialise the string buffer
  final StringBuilder aSB = new StringBuilder (getSyntaxPrefix ()).append (sAppName).append (' ');

  // create a list for processed option groups
  final ICommonsSet <OptionGroup> aProcessedGroups = new CommonsHashSet <> ();

  final ICommonsList <Option> aOptList = aOptions.getAllResolvedOptions ();
  if (m_aOptionComparator != null)
    aOptList.sort (m_aOptionComparator);

  // iterate over the options
  for (final Iterator <Option> aIt = aOptList.iterator (); aIt.hasNext ();)
  {
    // get the next Option
    final Option aOption = aIt.next ();

    // check if the option is part of an OptionGroup
    final OptionGroup group = aOptions.getOptionGroup (aOption);

    // if the option is part of a group
    if (group != null)
    {
      // and if the group has not already been processed
      if (aProcessedGroups.add (group))
      {
        // add the usage clause
        _appendOptionGroup (aSB, group);
      }

      // otherwise the option was displayed in the group
      // previously so ignore it.
    }
    else
    {
      // if the Option is not part of an OptionGroup
      _appendOption (aSB, aOption, aOption.isRequired ());
    }

    if (aIt.hasNext ())
      aSB.append (' ');
  }

  // call printWrapped
  printWrapped (aPW, nWidth, aSB.toString ().indexOf (' ') + 1, aSB.toString ());
}