Package structures

Examples of structures.DefinitionList


      String table = new String( );
     
      Iterator< String > rightIterator = right.keySet( ).iterator( );
      String rightAcronym = null;
      String rightDef = null;
      DefinitionList rightDefList = null;
     
      int leftWidth  = ( left.getWidestAcronym( )
                         + left.getWidestDefinition( )
                         + ACRONYM_DEF_GAP );
     
      int totalWidth = ( leftWidth
                         + MIDDLE_GAP
                         + right.getWidestAcronym( )
                         + right.getWidestDefinition( )
                         + ACRONYM_DEF_GAP );
     
      table += String.format( "%-" + leftWidth + "s   %s\n", "Existing List", "New List" );
     
      for( int i = 0; i < totalWidth; ++i )
      {
         table += '-';
      }
     
      table += '\n';
     
      for( String leftAcronym : left.keySet( ) )
      {
         String leftDef = String.format(
               "%-" + left.getWidestAcronym( ) + "s%" + ACRONYM_DEF_GAP + "s%-" + left.getWidestDefinition( ) + "s",
               leftAcronym,
               "",
               left.get( leftAcronym ).toString( ) );
        
         while( rightIterator.hasNext( ) )
         {
            if( rightDef == null )
            {
               rightAcronym = rightIterator.next( );
               rightDefList = right.get( rightAcronym );

               rightDef = String.format(
                     "%-" + right.getWidestAcronym( ) + "s%" + ACRONYM_DEF_GAP + "s%s",
                     rightAcronym,
                     "",
                     ( rightDefList == null ? "" : rightDefList.toString( ) ) );
            }

            if( rightAcronym.compareToIgnoreCase( leftAcronym ) < 0 )
            {
               table += String.format( "%" + leftWidth + "s", "" ) + " > " + rightDef + "\n";
               rightDef = null;
            }
            else
            {
               break;
            }
         }
        
         table += leftDef;
        
         if( rightAcronym == null )
         {
            continue;
         }
        
         table += " ";
        
         if( rightDef == null )
         {
            table += "<\n";
            continue;
         }
        
         if( rightDefList.containsCopy( ) )
         {
            table += AcronymList.Symbol.COPIED;
         }
         else if( rightDefList.containsMatch( ) )
         {
            table += AcronymList.Symbol.MATCHING_DEFINITION;
         }
         else
         {
            table += "<\n";
            continue;
         }
        
         table += " " + rightDef + "\n";
         rightDef = null;
      }
     
      while( rightIterator.hasNext( ) )
      {
         rightAcronym = rightIterator.next( );
         rightDefList = right.get( rightAcronym );
        
         rightDef = String.format(
               "%-" + right.getWidestAcronym( ) + "s %s",
               rightAcronym,
               ( rightDefList == null ? "" : rightDefList.toString( ) ) );
        
         table += String.format( "%" + leftWidth + "s", "" ) + " > " + rightDef + "\n";
      }
     
      return table;
View Full Code Here

TOP

Related Classes of structures.DefinitionList

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.