maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [1/2] maven-indexer git commit: use maven codestyle format, just to reduce checkstyle errors number...
Date Mon, 24 Jul 2017 06:59:10 GMT
Repository: maven-indexer
Updated Branches:
  refs/heads/master 0bbcad1fb -> 8d096a88b


http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/8d096a88/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordCompactor.java
----------------------------------------------------------------------
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordCompactor.java
b/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordCompactor.java
index b005400..74a7d11 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordCompactor.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordCompactor.java
@@ -19,15 +19,12 @@ package org.apache.maven.index.reader;
  * under the License.
  */
 
+import org.apache.maven.index.reader.Record.Type;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.maven.index.reader.Record.Type;
-
-import static org.apache.maven.index.reader.Utils.FIELD_SEPARATOR;
-import static org.apache.maven.index.reader.Utils.INFO;
-import static org.apache.maven.index.reader.Utils.UINFO;
-import static org.apache.maven.index.reader.Utils.nvl;
+import static org.apache.maven.index.reader.Utils.*;
 
 /**
  * Maven 2 Index record transformer, that transforms {@link Record}s into "native" Maven
Indexer records.
@@ -36,177 +33,183 @@ import static org.apache.maven.index.reader.Utils.nvl;
  */
 public class RecordCompactor
 {
-  /**
-   * Compacts {@link Record} into low level MI record with all the encoded fields as physically
present in MI binary
-   * chunk.
-   */
-  public Map<String, String> apply(final Record record) {
-    if (Type.DESCRIPTOR == record.getType()) {
-      return compactDescriptor(record);
+    /**
+     * Compacts {@link Record} into low level MI record with all the encoded fields as physically
present in MI binary
+     * chunk.
+     */
+    public Map<String, String> apply( final Record record )
+    {
+        if ( Type.DESCRIPTOR == record.getType() )
+        {
+            return compactDescriptor( record );
+        }
+        else if ( Type.ALL_GROUPS == record.getType() )
+        {
+            return compactAllGroups( record );
+        }
+        else if ( Type.ROOT_GROUPS == record.getType() )
+        {
+            return compactRootGroups( record );
+        }
+        else if ( Type.ARTIFACT_REMOVE == record.getType() )
+        {
+            return compactDeletedArtifact( record );
+        }
+        else if ( Type.ARTIFACT_ADD == record.getType() )
+        {
+            return compactAddedArtifact( record );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "Unknown record: " + record );
+        }
     }
-    else if (Type.ALL_GROUPS == record.getType()) {
-      return compactAllGroups(record);
+
+    private static Map<String, String> compactDescriptor( final Record record )
+    {
+        final Map<String, String> result = new HashMap<String, String>();
+        result.put( "DESCRIPTOR", "NexusIndex" );
+        result.put( "IDXINFO", "1.0|" + record.get( Record.REPOSITORY_ID ) );
+        return result;
     }
-    else if (Type.ROOT_GROUPS == record.getType()) {
-      return compactRootGroups(record);
+
+    private static Map<String, String> compactAllGroups( final Record record )
+    {
+        final Map<String, String> result = new HashMap<String, String>();
+        result.put( "allGroups", "allGroups" );
+        putIfNotNullAsStringArray( record.get( Record.ALL_GROUPS ), result, "allGroupsList"
);
+        return result;
     }
-    else if (Type.ARTIFACT_REMOVE == record.getType()) {
-      return compactDeletedArtifact(record);
+
+    private static Map<String, String> compactRootGroups( final Record record )
+    {
+        final Map<String, String> result = new HashMap<String, String>();
+        result.put( "rootGroups", "allGroups" );
+        putIfNotNullAsStringArray( record.get( Record.ROOT_GROUPS ), result, "rootGroupsList"
);
+        return result;
     }
-    else if (Type.ARTIFACT_ADD == record.getType()) {
-      return compactAddedArtifact(record);
+
+    private static Map<String, String> compactDeletedArtifact( final Record record
)
+    {
+        final Map<String, String> result = new HashMap<String, String>();
+        putIfNotNullTS( record.get( Record.REC_MODIFIED ), result, "m" );
+        result.put( "del", compactUinfo( record ) );
+        return result;
     }
-    else {
-      throw new IllegalArgumentException("Unknown record: " + record);
+
+    /**
+     * Expands the "encoded" Maven Indexer record by splitting the synthetic fields and applying
expanded field naming.
+     */
+    private static Map<String, String> compactAddedArtifact( final Record record )
+    {
+        final Map<String, String> result = new HashMap<String, String>();
+
+        // Minimal
+        result.put( UINFO, compactUinfo( record ) );
+
+        StringBuilder info = new StringBuilder();
+        info.append( nvl( record.get( Record.PACKAGING ) ) );
+        info.append( FIELD_SEPARATOR );
+        info.append( record.get( Record.FILE_MODIFIED ) );
+        info.append( FIELD_SEPARATOR );
+        info.append( record.get( Record.FILE_SIZE ) );
+        info.append( FIELD_SEPARATOR );
+        info.append( record.get( Record.HAS_SOURCES ) ? "1" : "0" );
+        info.append( FIELD_SEPARATOR );
+        info.append( record.get( Record.HAS_JAVADOC ) ? "1" : "0" );
+        info.append( FIELD_SEPARATOR );
+        info.append( record.get( Record.HAS_SIGNATURE ) ? "1" : "0" );
+        info.append( FIELD_SEPARATOR );
+        info.append( nvl( record.get( Record.FILE_EXTENSION ) ) );
+        result.put( INFO, info.toString() );
+
+        putIfNotNullTS( record.get( Record.REC_MODIFIED ), result, "m" );
+        putIfNotNull( record.get( Record.NAME ), result, "n" );
+        putIfNotNull( record.get( Record.DESCRIPTION ), result, "d" );
+        putIfNotNull( record.get( Record.SHA1 ), result, "1" );
+
+        // Jar file contents (optional)
+        putIfNotNullAsStringArray( record.get( Record.CLASSNAMES ), result, "classnames"
);
+
+        // Maven Plugin (optional)
+        putIfNotNull( record.get( Record.PLUGIN_PREFIX ), result, "px" );
+        putIfNotNullAsStringArray( record.get( Record.PLUGIN_GOALS ), result, "gx" );
+
+        // OSGi (optional)
+        putIfNotNull( record.get( Record.OSGI_BUNDLE_SYMBOLIC_NAME ), result, "Bundle-SymbolicName"
);
+        putIfNotNull( record.get( Record.OSGI_BUNDLE_VERSION ), result, "Bundle-Version"
);
+        putIfNotNull( record.get( Record.OSGI_EXPORT_PACKAGE ), result, "Export-Package"
);
+        putIfNotNull( record.get( Record.OSGI_EXPORT_SERVICE ), result, "Export-Service"
);
+        putIfNotNull( record.get( Record.OSGI_BUNDLE_DESCRIPTION ), result, "Bundle-Description"
);
+        putIfNotNull( record.get( Record.OSGI_BUNDLE_NAME ), result, "Bundle-Name" );
+        putIfNotNull( record.get( Record.OSGI_BUNDLE_LICENSE ), result, "Bundle-License"
);
+        putIfNotNull( record.get( Record.OSGI_EXPORT_DOCURL ), result, "Bundle-DocURL" );
+        putIfNotNull( record.get( Record.OSGI_IMPORT_PACKAGE ), result, "Import-Package"
);
+        putIfNotNull( record.get( Record.OSGI_REQUIRE_BUNDLE ), result, "Require-Bundle"
);
+        putIfNotNull( record.get( Record.OSGI_PROVIDE_CAPABILITY ), result, "Provide-Capability"
);
+        putIfNotNull( record.get( Record.OSGI_REQUIRE_CAPABILITY ), result, "Require-Capability"
);
+        putIfNotNull( record.get( Record.OSGI_FRAGMENT_HOST ), result, "Fragment-Host" );
+        putIfNotNull( record.get( Record.OSGI_BREE ), result, "Bundle-RequiredExecutionEnvironment"
);
+        putIfNotNull( record.get( Record.SHA_256 ), result, "sha256" );
+
+        return result;
     }
-  }
-
-  private static Map<String, String> compactDescriptor(final Record record) {
-    final Map<String, String> result = new HashMap<String, String>();
-    result.put("DESCRIPTOR", "NexusIndex");
-    result.put("IDXINFO", "1.0|" + record.get(Record.REPOSITORY_ID));
-    return result;
-  }
-
-  private static Map<String, String> compactAllGroups(final Record record) {
-    final Map<String, String> result = new HashMap<String, String>();
-    result.put("allGroups", "allGroups");
-    putIfNotNullAsStringArray(record.get(Record.ALL_GROUPS), result, "allGroupsList");
-    return result;
-  }
-
-  private static Map<String, String> compactRootGroups(final Record record) {
-    final Map<String, String> result = new HashMap<String, String>();
-    result.put("rootGroups", "allGroups");
-    putIfNotNullAsStringArray(record.get(Record.ROOT_GROUPS), result, "rootGroupsList");
-    return result;
-  }
-
-  private static Map<String, String> compactDeletedArtifact(final Record record) {
-    final Map<String, String> result = new HashMap<String, String>();
-    putIfNotNullTS(record.get(Record.REC_MODIFIED), result, "m");
-    result.put("del", compactUinfo(record));
-    return result;
-  }
-
-  /**
-   * Expands the "encoded" Maven Indexer record by splitting the synthetic fields and applying
expanded field naming.
-   */
-  private static Map<String, String> compactAddedArtifact(final Record record) {
-    final Map<String, String> result = new HashMap<String, String>();
-
-    // Minimal
-    result.put(UINFO, compactUinfo(record));
-
-    StringBuilder info = new StringBuilder();
-    info.append(nvl(record.get(Record.PACKAGING)));
-    info.append(FIELD_SEPARATOR);
-    info.append(record.get(Record.FILE_MODIFIED));
-    info.append(FIELD_SEPARATOR);
-    info.append(record.get(Record.FILE_SIZE));
-    info.append(FIELD_SEPARATOR);
-    info.append(record.get(Record.HAS_SOURCES) ? "1" : "0");
-    info.append(FIELD_SEPARATOR);
-    info.append(record.get(Record.HAS_JAVADOC) ? "1" : "0");
-    info.append(FIELD_SEPARATOR);
-    info.append(record.get(Record.HAS_SIGNATURE) ? "1" : "0");
-    info.append(FIELD_SEPARATOR);
-    info.append(nvl(record.get(Record.FILE_EXTENSION)));
-    result.put(INFO, info.toString());
-
-    putIfNotNullTS(record.get(Record.REC_MODIFIED), result, "m");
-    putIfNotNull(record.get(Record.NAME), result, "n");
-    putIfNotNull(record.get(Record.DESCRIPTION), result, "d");
-    putIfNotNull(record.get(Record.SHA1), result, "1");
-
-    // Jar file contents (optional)
-    putIfNotNullAsStringArray(record.get(Record.CLASSNAMES), result, "classnames");
-
-    // Maven Plugin (optional)
-    putIfNotNull(record.get(Record.PLUGIN_PREFIX), result, "px");
-    putIfNotNullAsStringArray(record.get(Record.PLUGIN_GOALS), result, "gx");
-
-    // OSGi (optional)
-    putIfNotNull(record.get(Record.OSGI_BUNDLE_SYMBOLIC_NAME), result, "Bundle-SymbolicName");
-    putIfNotNull(record.get(Record.OSGI_BUNDLE_VERSION), result, "Bundle-Version");
-    putIfNotNull(record.get(Record.OSGI_EXPORT_PACKAGE), result, "Export-Package");
-    putIfNotNull(record.get(Record.OSGI_EXPORT_SERVICE), result, "Export-Service");
-    putIfNotNull(record.get(Record.OSGI_BUNDLE_DESCRIPTION), result, "Bundle-Description");
-    putIfNotNull(record.get(Record.OSGI_BUNDLE_NAME), result, "Bundle-Name");
-    putIfNotNull(record.get(Record.OSGI_BUNDLE_LICENSE), result, "Bundle-License");
-    putIfNotNull(record.get(Record.OSGI_EXPORT_DOCURL), result, "Bundle-DocURL");
-    putIfNotNull(record.get(Record.OSGI_IMPORT_PACKAGE), result, "Import-Package");
-    putIfNotNull(record.get(Record.OSGI_REQUIRE_BUNDLE), result, "Require-Bundle");
-    putIfNotNull(record.get(Record.OSGI_PROVIDE_CAPABILITY), result, "Provide-Capability");
-    putIfNotNull(record.get(Record.OSGI_REQUIRE_CAPABILITY), result, "Require-Capability");
-    putIfNotNull(record.get(Record.OSGI_FRAGMENT_HOST), result, "Fragment-Host");
-    putIfNotNull(record.get(Record.OSGI_BREE), result, "Bundle-RequiredExecutionEnvironment");
-    putIfNotNull(record.get(Record.SHA_256), result, "sha256");
-
-    return result;
-  }
-
-  /**
-   * Creates UINFO synthetic field.
-   */
-  private static String compactUinfo(final Record record) {
-    final String classifier = record.get(Record.CLASSIFIER);
-    StringBuilder sb = new StringBuilder();
-    sb.append(record.get(Record.GROUP_ID))
-        .append(FIELD_SEPARATOR)
-        .append(record.get(Record.ARTIFACT_ID))
-        .append(FIELD_SEPARATOR)
-        .append(record.get(Record.VERSION))
-        .append(FIELD_SEPARATOR)
-        .append(nvl(classifier));
-    if (classifier != null) {
-      sb.append(FIELD_SEPARATOR).append(record.get(Record.FILE_EXTENSION));
+
+    /**
+     * Creates UINFO synthetic field.
+     */
+    private static String compactUinfo( final Record record )
+    {
+        final String classifier = record.get( Record.CLASSIFIER );
+        StringBuilder sb = new StringBuilder();
+        sb.append( record.get( Record.GROUP_ID ) ).append( FIELD_SEPARATOR ).append(
+            record.get( Record.ARTIFACT_ID ) ).append( FIELD_SEPARATOR ).append( record.get(
Record.VERSION ) ).append(
+            FIELD_SEPARATOR ).append( nvl( classifier ) );
+        if ( classifier != null )
+        {
+            sb.append( FIELD_SEPARATOR ).append( record.get( Record.FILE_EXTENSION ) );
+        }
+        return sb.toString();
     }
-    return sb.toString();
-  }
-
-  /**
-   * Helper to put a value from source map into target map, if not null.
-   */
-  private static void putIfNotNull(
-      final String source,
-      final Map<String, String> target,
-      final String targetName)
-  {
-    if (source != null) {
-      target.put(targetName, source);
+
+    /**
+     * Helper to put a value from source map into target map, if not null.
+     */
+    private static void putIfNotNull( final String source, final Map<String, String>
target, final String targetName )
+    {
+        if ( source != null )
+        {
+            target.put( targetName, source );
+        }
     }
-  }
-
-  /**
-   * Helper to put a {@link Long} value from source map into target map, if not null.
-   */
-  private static void putIfNotNullTS(
-      final Long source,
-      final Map<String, String> target,
-      final String targetName)
-  {
-    if (source != null) {
-      target.put(targetName, String.valueOf(source));
+
+    /**
+     * Helper to put a {@link Long} value from source map into target map, if not null.
+     */
+    private static void putIfNotNullTS( final Long source, final Map<String, String>
target, final String targetName )
+    {
+        if ( source != null )
+        {
+            target.put( targetName, String.valueOf( source ) );
+        }
     }
-  }
-
-  /**
-   * Helper to put a array value from source map into target map joined with {@link Utils#FIELD_SEPARATOR},
if not
-   * null.
-   */
-  private static void putIfNotNullAsStringArray(
-      final String[] source,
-      final Map<String, String> target,
-      final String targetName)
-  {
-    if (source != null && source.length > 0) {
-      StringBuilder sb = new StringBuilder();
-      sb.append(source[0]);
-      for (int i = 1; i < source.length; i++) {
-        sb.append(FIELD_SEPARATOR).append(source[i]);
-      }
-      target.put(targetName, sb.toString());
+
+    /**
+     * Helper to put a array value from source map into target map joined with {@link Utils#FIELD_SEPARATOR},
if not
+     * null.
+     */
+    private static void putIfNotNullAsStringArray( final String[] source, final Map<String,
String> target,
+                                                   final String targetName )
+    {
+        if ( source != null && source.length > 0 )
+        {
+            StringBuilder sb = new StringBuilder();
+            sb.append( source[0] );
+            for ( int i = 1; i < source.length; i++ )
+            {
+                sb.append( FIELD_SEPARATOR ).append( source[i] );
+            }
+            target.put( targetName, sb.toString() );
+        }
     }
-  }
 }

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/8d096a88/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordExpander.java
----------------------------------------------------------------------
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordExpander.java
b/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordExpander.java
index 5d97f2a..3b61307 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordExpander.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/RecordExpander.java
@@ -19,18 +19,13 @@ package org.apache.maven.index.reader;
  * under the License.
  */
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.maven.index.reader.Record.EntryKey;
 import org.apache.maven.index.reader.Record.Type;
 
-import static org.apache.maven.index.reader.Utils.FIELD_SEPARATOR;
-import static org.apache.maven.index.reader.Utils.FS_PATTERN;
-import static org.apache.maven.index.reader.Utils.INFO;
-import static org.apache.maven.index.reader.Utils.NOT_AVAILABLE;
-import static org.apache.maven.index.reader.Utils.UINFO;
-import static org.apache.maven.index.reader.Utils.renvl;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.maven.index.reader.Utils.*;
 
 /**
  * Maven 2 Index record transformer, that transforms "native" Maven Indexer records into
{@link Record}s.
@@ -39,196 +34,213 @@ import static org.apache.maven.index.reader.Utils.renvl;
  */
 public class RecordExpander
 {
-  /**
-   * Expands MI low level record into {@link Record}.
-   */
-  public Record apply(final Map<String, String> recordMap) {
-    if (recordMap.containsKey("DESCRIPTOR")) {
-      return expandDescriptor(recordMap);
+    /**
+     * Expands MI low level record into {@link Record}.
+     */
+    public Record apply( final Map<String, String> recordMap )
+    {
+        if ( recordMap.containsKey( "DESCRIPTOR" ) )
+        {
+            return expandDescriptor( recordMap );
+        }
+        else if ( recordMap.containsKey( "allGroups" ) )
+        {
+            return expandAllGroups( recordMap );
+        }
+        else if ( recordMap.containsKey( "rootGroups" ) )
+        {
+            return expandRootGroups( recordMap );
+        }
+        else if ( recordMap.containsKey( "del" ) )
+        {
+            return expandDeletedArtifact( recordMap );
+        }
+        else
+        {
+            // Fix up UINFO field wrt MINDEXER-41
+            final String uinfo = recordMap.get( UINFO );
+            final String info = recordMap.get( INFO );
+            if ( uinfo != null && !( info == null || info.trim().length() == 0 )
)
+            {
+                final String[] splitInfo = FS_PATTERN.split( info );
+                if ( splitInfo.length > 6 )
+                {
+                    final String extension = splitInfo[6];
+                    if ( uinfo.endsWith( FIELD_SEPARATOR + NOT_AVAILABLE ) )
+                    {
+                        recordMap.put( UINFO, uinfo + FIELD_SEPARATOR + extension );
+                    }
+                }
+            }
+            return expandAddedArtifact( recordMap );
+        }
     }
-    else if (recordMap.containsKey("allGroups")) {
-      return expandAllGroups(recordMap);
+
+    private static Record expandDescriptor( final Map<String, String> raw )
+    {
+        final Record result = new Record( Type.DESCRIPTOR, new HashMap<EntryKey, Object>()
);
+        String[] r = FS_PATTERN.split( raw.get( "IDXINFO" ) );
+        result.put( Record.REPOSITORY_ID, r[1] );
+        return result;
     }
-    else if (recordMap.containsKey("rootGroups")) {
-      return expandRootGroups(recordMap);
+
+    private static Record expandAllGroups( final Map<String, String> raw )
+    {
+        final Record result = new Record( Type.ALL_GROUPS, new HashMap<EntryKey, Object>()
);
+        putIfNotNullAsStringArray( raw, "allGroupsList", result, Record.ALL_GROUPS );
+        return result;
     }
-    else if (recordMap.containsKey("del")) {
-      return expandDeletedArtifact(recordMap);
+
+    private static Record expandRootGroups( final Map<String, String> raw )
+    {
+        final Record result = new Record( Type.ROOT_GROUPS, new HashMap<EntryKey, Object>()
);
+        putIfNotNullAsStringArray( raw, "rootGroupsList", result, Record.ROOT_GROUPS );
+        return result;
     }
-    else {
-      // Fix up UINFO field wrt MINDEXER-41
-      final String uinfo = recordMap.get(UINFO);
-      final String info = recordMap.get(INFO);
-      if (uinfo != null && !(info == null || info.trim().length() == 0)) {
-        final String[] splitInfo = FS_PATTERN.split(info);
-        if (splitInfo.length > 6) {
-          final String extension = splitInfo[6];
-          if (uinfo.endsWith(FIELD_SEPARATOR + NOT_AVAILABLE)) {
-            recordMap.put(UINFO, uinfo + FIELD_SEPARATOR + extension);
-          }
+
+    private static Record expandDeletedArtifact( final Map<String, String> raw )
+    {
+        final Record result = new Record( Type.ARTIFACT_REMOVE, new HashMap<EntryKey,
Object>() );
+        putIfNotNullTS( raw, "m", result, Record.REC_MODIFIED );
+        if ( raw.containsKey( "del" ) )
+        {
+            expandUinfo( raw.get( "del" ), result );
         }
-      }
-      return expandAddedArtifact(recordMap);
-    }
-  }
-
-  private static Record expandDescriptor(final Map<String, String> raw) {
-    final Record result = new Record(Type.DESCRIPTOR, new HashMap<EntryKey, Object>());
-    String[] r = FS_PATTERN.split(raw.get("IDXINFO"));
-    result.put(Record.REPOSITORY_ID, r[1]);
-    return result;
-  }
-
-  private static Record expandAllGroups(final Map<String, String> raw) {
-    final Record result = new Record(Type.ALL_GROUPS, new HashMap<EntryKey, Object>());
-    putIfNotNullAsStringArray(raw, "allGroupsList", result, Record.ALL_GROUPS);
-    return result;
-  }
-
-  private static Record expandRootGroups(final Map<String, String> raw) {
-    final Record result = new Record(Type.ROOT_GROUPS, new HashMap<EntryKey, Object>());
-    putIfNotNullAsStringArray(raw, "rootGroupsList", result, Record.ROOT_GROUPS);
-    return result;
-  }
-
-  private static Record expandDeletedArtifact(final Map<String, String> raw) {
-    final Record result = new Record(Type.ARTIFACT_REMOVE, new HashMap<EntryKey, Object>());
-    putIfNotNullTS(raw, "m", result, Record.REC_MODIFIED);
-    if (raw.containsKey("del")) {
-      expandUinfo(raw.get("del"), result);
+        return result;
     }
-    return result;
-  }
-
-  /**
-   * Expands the "encoded" Maven Indexer record by splitting the synthetic fields and applying
expanded field naming.
-   */
-  private static Record expandAddedArtifact(final Map<String, String> raw) {
-    final Record result = new Record(Type.ARTIFACT_ADD, new HashMap<EntryKey, Object>());
-
-    // Minimal
-    expandUinfo(raw.get(UINFO), result);
-    final String info = raw.get(INFO);
-    if (info != null) {
-      String[] r = FS_PATTERN.split(info);
-      result.put(Record.PACKAGING, renvl(r[0]));
-      result.put(Record.FILE_MODIFIED, Long.valueOf(r[1]));
-      result.put(Record.FILE_SIZE, Long.valueOf(r[2]));
-      result.put(Record.HAS_SOURCES, "1".equals(r[3]) ? Boolean.TRUE : Boolean.FALSE);
-      result.put(Record.HAS_JAVADOC, "1".equals(r[4]) ? Boolean.TRUE : Boolean.FALSE);
-      result.put(Record.HAS_SIGNATURE, "1".equals(r[5]) ? Boolean.TRUE : Boolean.FALSE);
-      if (r.length > 6) {
-        result.put(Record.FILE_EXTENSION, r[6]);
-      }
-      else {
-        final String packaging = Record.PACKAGING.coerce(result.get(Record.PACKAGING));
-        if (result.containsKey(Record.CLASSIFIER)
-            || "pom".equals(packaging)
-            || "war".equals(packaging)
-            || "ear".equals(packaging)) {
-          result.put(Record.FILE_EXTENSION, packaging);
-        }
-        else {
-          result.put(Record.FILE_EXTENSION, "jar"); // best guess
+
+    /**
+     * Expands the "encoded" Maven Indexer record by splitting the synthetic fields and applying
expanded field naming.
+     */
+    private static Record expandAddedArtifact( final Map<String, String> raw )
+    {
+        final Record result = new Record( Type.ARTIFACT_ADD, new HashMap<EntryKey, Object>()
);
+
+        // Minimal
+        expandUinfo( raw.get( UINFO ), result );
+        final String info = raw.get( INFO );
+        if ( info != null )
+        {
+            String[] r = FS_PATTERN.split( info );
+            result.put( Record.PACKAGING, renvl( r[0] ) );
+            result.put( Record.FILE_MODIFIED, Long.valueOf( r[1] ) );
+            result.put( Record.FILE_SIZE, Long.valueOf( r[2] ) );
+            result.put( Record.HAS_SOURCES, "1".equals( r[3] ) ? Boolean.TRUE : Boolean.FALSE
);
+            result.put( Record.HAS_JAVADOC, "1".equals( r[4] ) ? Boolean.TRUE : Boolean.FALSE
);
+            result.put( Record.HAS_SIGNATURE, "1".equals( r[5] ) ? Boolean.TRUE : Boolean.FALSE
);
+            if ( r.length > 6 )
+            {
+                result.put( Record.FILE_EXTENSION, r[6] );
+            }
+            else
+            {
+                final String packaging = Record.PACKAGING.coerce( result.get( Record.PACKAGING
) );
+                if ( result.containsKey( Record.CLASSIFIER ) || "pom".equals( packaging )
|| "war".equals( packaging )
+                    || "ear".equals( packaging ) )
+                {
+                    result.put( Record.FILE_EXTENSION, packaging );
+                }
+                else
+                {
+                    result.put( Record.FILE_EXTENSION, "jar" ); // best guess
+                }
+            }
         }
-      }
+        putIfNotNullTS( raw, "m", result, Record.REC_MODIFIED );
+        putIfNotNull( raw, "n", result, Record.NAME );
+        putIfNotNull( raw, "d", result, Record.DESCRIPTION );
+        putIfNotNull( raw, "1", result, Record.SHA1 );
+
+        // Jar file contents (optional)
+        putIfNotNullAsStringArray( raw, "classnames", result, Record.CLASSNAMES );
+
+        // Maven Plugin (optional)
+        putIfNotNull( raw, "px", result, Record.PLUGIN_PREFIX );
+        putIfNotNullAsStringArray( raw, "gx", result, Record.PLUGIN_GOALS );
+
+        // OSGi (optional)
+        putIfNotNull( raw, "Bundle-SymbolicName", result, Record.OSGI_BUNDLE_SYMBOLIC_NAME
);
+        putIfNotNull( raw, "Bundle-Version", result, Record.OSGI_BUNDLE_VERSION );
+        putIfNotNull( raw, "Export-Package", result, Record.OSGI_EXPORT_PACKAGE );
+        putIfNotNull( raw, "Export-Service", result, Record.OSGI_EXPORT_SERVICE );
+        putIfNotNull( raw, "Bundle-Description", result, Record.OSGI_BUNDLE_DESCRIPTION );
+        putIfNotNull( raw, "Bundle-Name", result, Record.OSGI_BUNDLE_NAME );
+        putIfNotNull( raw, "Bundle-License", result, Record.OSGI_BUNDLE_LICENSE );
+        putIfNotNull( raw, "Bundle-DocURL", result, Record.OSGI_EXPORT_DOCURL );
+        putIfNotNull( raw, "Import-Package", result, Record.OSGI_IMPORT_PACKAGE );
+        putIfNotNull( raw, "Require-Bundle", result, Record.OSGI_REQUIRE_BUNDLE );
+        putIfNotNull( raw, "Provide-Capability", result, Record.OSGI_PROVIDE_CAPABILITY );
+        putIfNotNull( raw, "Require-Capability", result, Record.OSGI_REQUIRE_CAPABILITY );
+        putIfNotNull( raw, "Fragment-Host", result, Record.OSGI_FRAGMENT_HOST );
+        putIfNotNull( raw, "Bundle-RequiredExecutionEnvironment", result, Record.OSGI_BREE
);
+        putIfNotNull( raw, "sha256", result, Record.SHA_256 );
+
+        return result;
     }
-    putIfNotNullTS(raw, "m", result, Record.REC_MODIFIED);
-    putIfNotNull(raw, "n", result, Record.NAME);
-    putIfNotNull(raw, "d", result, Record.DESCRIPTION);
-    putIfNotNull(raw, "1", result, Record.SHA1);
-
-    // Jar file contents (optional)
-    putIfNotNullAsStringArray(raw, "classnames", result, Record.CLASSNAMES);
-
-    // Maven Plugin (optional)
-    putIfNotNull(raw, "px", result, Record.PLUGIN_PREFIX);
-    putIfNotNullAsStringArray(raw, "gx", result, Record.PLUGIN_GOALS);
-
-    // OSGi (optional)
-    putIfNotNull(raw, "Bundle-SymbolicName", result, Record.OSGI_BUNDLE_SYMBOLIC_NAME);
-    putIfNotNull(raw, "Bundle-Version", result, Record.OSGI_BUNDLE_VERSION);
-    putIfNotNull(raw, "Export-Package", result, Record.OSGI_EXPORT_PACKAGE);
-    putIfNotNull(raw, "Export-Service", result, Record.OSGI_EXPORT_SERVICE);
-    putIfNotNull(raw, "Bundle-Description", result, Record.OSGI_BUNDLE_DESCRIPTION);
-    putIfNotNull(raw, "Bundle-Name", result, Record.OSGI_BUNDLE_NAME);
-    putIfNotNull(raw, "Bundle-License", result, Record.OSGI_BUNDLE_LICENSE);
-    putIfNotNull(raw, "Bundle-DocURL", result, Record.OSGI_EXPORT_DOCURL);
-    putIfNotNull(raw, "Import-Package", result, Record.OSGI_IMPORT_PACKAGE);
-    putIfNotNull(raw, "Require-Bundle", result, Record.OSGI_REQUIRE_BUNDLE);
-    putIfNotNull(raw, "Provide-Capability", result, Record.OSGI_PROVIDE_CAPABILITY);
-    putIfNotNull(raw, "Require-Capability", result, Record.OSGI_REQUIRE_CAPABILITY);
-    putIfNotNull(raw, "Fragment-Host", result, Record.OSGI_FRAGMENT_HOST);
-    putIfNotNull(raw, "Bundle-RequiredExecutionEnvironment", result, Record.OSGI_BREE);
-    putIfNotNull(raw, "sha256", result, Record.SHA_256);
-
-    return result;
-  }
-
-  /**
-   * Expands UINFO synthetic field. Handles {@code null} String inputs.
-   */
-  private static void expandUinfo(final String uinfo, final Record result) {
-    if (uinfo != null) {
-      String[] r = FS_PATTERN.split(uinfo);
-      result.put(Record.GROUP_ID, r[0]);
-      result.put(Record.ARTIFACT_ID, r[1]);
-      result.put(Record.VERSION, r[2]);
-      String classifier = renvl(r[3]);
-      if (classifier != null) {
-        result.put(Record.CLASSIFIER, classifier);
-        if (r.length > 4) {
-          result.put(Record.FILE_EXTENSION, r[4]);
+
+    /**
+     * Expands UINFO synthetic field. Handles {@code null} String inputs.
+     */
+    private static void expandUinfo( final String uinfo, final Record result )
+    {
+        if ( uinfo != null )
+        {
+            String[] r = FS_PATTERN.split( uinfo );
+            result.put( Record.GROUP_ID, r[0] );
+            result.put( Record.ARTIFACT_ID, r[1] );
+            result.put( Record.VERSION, r[2] );
+            String classifier = renvl( r[3] );
+            if ( classifier != null )
+            {
+                result.put( Record.CLASSIFIER, classifier );
+                if ( r.length > 4 )
+                {
+                    result.put( Record.FILE_EXTENSION, r[4] );
+                }
+            }
+            else if ( r.length > 4 )
+            {
+                result.put( Record.PACKAGING, r[4] );
+            }
         }
-      }
-      else if (r.length > 4) {
-        result.put(Record.PACKAGING, r[4]);
-      }
     }
-  }
-
-  /**
-   * Helper to put a value from source map into target map, if not null.
-   */
-  private static void putIfNotNull(
-      final Map<String, String> source,
-      final String sourceName,
-      final Record target,
-      final EntryKey targetName)
-  {
-    String value = source.get(sourceName);
-    if (value != null && value.trim().length() != 0) {
-      target.put(targetName, value);
+
+    /**
+     * Helper to put a value from source map into target map, if not null.
+     */
+    private static void putIfNotNull( final Map<String, String> source, final String
sourceName, final Record target,
+                                      final EntryKey targetName )
+    {
+        String value = source.get( sourceName );
+        if ( value != null && value.trim().length() != 0 )
+        {
+            target.put( targetName, value );
+        }
     }
-  }
-
-  /**
-   * Helper to put a {@link Long} value from source map into target map, if not null.
-   */
-  private static void putIfNotNullTS(
-      final Map<String, String> source,
-      final String sourceName,
-      final Record target,
-      final EntryKey targetName)
-  {
-    String value = source.get(sourceName);
-    if (value != null && value.trim().length() != 0) {
-      target.put(targetName, Long.valueOf(value));
+
+    /**
+     * Helper to put a {@link Long} value from source map into target map, if not null.
+     */
+    private static void putIfNotNullTS( final Map<String, String> source, final String
sourceName, final Record target,
+                                        final EntryKey targetName )
+    {
+        String value = source.get( sourceName );
+        if ( value != null && value.trim().length() != 0 )
+        {
+            target.put( targetName, Long.valueOf( value ) );
+        }
     }
-  }
-
-  /**
-   * Helper to put a collection value from source map into target map as {@link java.util.List},
if not null.
-   */
-  private static void putIfNotNullAsStringArray(
-      final Map<String, String> source,
-      final String sourceName,
-      final Record target,
-      final EntryKey targetName)
-  {
-    String value = source.get(sourceName);
-    if (value != null && value.trim().length() != 0) {
-      target.put(targetName, FS_PATTERN.split(value));
+
+    /**
+     * Helper to put a collection value from source map into target map as {@link java.util.List},
if not null.
+     */
+    private static void putIfNotNullAsStringArray( final Map<String, String> source,
final String sourceName,
+                                                   final Record target, final EntryKey targetName
)
+    {
+        String value = source.get( sourceName );
+        if ( value != null && value.trim().length() != 0 )
+        {
+            target.put( targetName, FS_PATTERN.split( value ) );
+        }
     }
-  }
 }

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/8d096a88/indexer-reader/src/main/java/org/apache/maven/index/reader/ResourceHandler.java
----------------------------------------------------------------------
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/ResourceHandler.java
b/indexer-reader/src/main/java/org/apache/maven/index/reader/ResourceHandler.java
index 244a994..02dd913 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/ResourceHandler.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/ResourceHandler.java
@@ -33,19 +33,21 @@ import java.io.InputStream;
 public interface ResourceHandler
     extends Closeable
 {
-  interface Resource
-  {
+    interface Resource
+    {
+        /**
+         * Returns the {@link InputStream} stream of the resource, if exists, {@code null}
otherwise. The stream should
+         * be closed by caller, otherwise resource leaks might be introduced.
+         */
+        InputStream read()
+            throws IOException;
+    }
+
     /**
-     * Returns the {@link InputStream} stream of the resource, if exists, {@code null} otherwise.
The stream should
-     * be closed by caller, otherwise resource leaks might be introduced.
+     * Returns the {@link Resource} with {@code name}, non {@code null}.
+     *
+     * @param name Resource name, guaranteed to be non-{@code null} and is FS and URL safe
string.
      */
-    InputStream read() throws IOException;
-  }
-
-  /**
-   * Returns the {@link Resource} with {@code name}, non {@code null}.
-   *
-   * @param name Resource name, guaranteed to be non-{@code null} and is FS and URL safe
string.
-   */
-  Resource locate(String name) throws IOException;
+    Resource locate( String name )
+        throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/8d096a88/indexer-reader/src/main/java/org/apache/maven/index/reader/WritableResourceHandler.java
----------------------------------------------------------------------
diff --git a/indexer-reader/src/main/java/org/apache/maven/index/reader/WritableResourceHandler.java
b/indexer-reader/src/main/java/org/apache/maven/index/reader/WritableResourceHandler.java
index e3f8ab9..01c7aa5 100644
--- a/indexer-reader/src/main/java/org/apache/maven/index/reader/WritableResourceHandler.java
+++ b/indexer-reader/src/main/java/org/apache/maven/index/reader/WritableResourceHandler.java
@@ -34,25 +34,27 @@ import java.io.OutputStream;
 public interface WritableResourceHandler
     extends ResourceHandler
 {
-  interface WritableResource
-      extends Resource, Closeable
-  {
+    interface WritableResource
+        extends Resource, Closeable
+    {
+        /**
+         * Returns the {@link OutputStream} stream of the resource, if exists, it will replace
the existing content, or if
+         * not exists, the resource will be created. The stream should be closed by caller,
otherwise resource leaks might
+         * be introduced. How and when content is written is left to implementation, but
it is guaranteed that this method
+         * is called only once, and will be followed by {@link #close()} on the resource
itself. Implementation does not
+         * have to be "read consistent", in a way to worry what subsequent {@link #read()}
method will return, as mixed
+         * calls will not happen on same instance of resource.
+         */
+        OutputStream write()
+            throws IOException;
+    }
+
     /**
-     * Returns the {@link OutputStream} stream of the resource, if exists, it will replace
the existing content, or if
-     * not exists, the resource will be created. The stream should be closed by caller, otherwise
resource leaks might
-     * be introduced. How and when content is written is left to implementation, but it is
guaranteed that this method
-     * is called only once, and will be followed by {@link #close()} on the resource itself.
Implementation does not
-     * have to be "read consistent", in a way to worry what subsequent {@link #read()} method
will return, as mixed
-     * calls will not happen on same instance of resource.
+     * Returns the {@link WritableResource} with {@code name}. Returned locator should be
handled as
+     * resource, is {@link Closeable}.
+     *
+     * @param name Resource name, guaranteed to be non-{@code null} and is FS and URL safe
string.
      */
-    OutputStream write() throws IOException;
-  }
-
-  /**
-   * Returns the {@link WritableResource} with {@code name}. Returned locator should be handled
as
-   * resource, is {@link Closeable}.
-   *
-   * @param name Resource name, guaranteed to be non-{@code null} and is FS and URL safe
string.
-   */
-  WritableResource locate(String name) throws IOException;
+    WritableResource locate( String name )
+        throws IOException;
 }


Mime
View raw message