/*
 * Copyright to the original author or authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.rioproject.url.artifact;

import org.rioproject.resolver.RemoteRepository;

import java.util.ArrayList;
import java.util.List;

/**
 * Holds the attributes of a URL of type <code>artifact</code>.
 *
 * <p>The URL scheme that the {@code ArtifactURLConfiguration} decomposes is as follows:<br/>
 * <pre>artifact:groupId/artifactId/version[/type[/classifier]][;[repository[@repositoryId]]</pre></p>
 *
 * @author Dennis Reedy
 */
public class ArtifactURLConfiguration {
    private String artifact;
    private final List<RemoteRepository> repositories = new ArrayList<RemoteRepository>();

    public ArtifactURLConfiguration(String path) {
        int index = path.indexOf(";");
        if(index!=-1) {
            String repositoryString = path.substring(index+1, path.length());
            path = path.substring(0, index);
            String[] parts = repositoryString.split(";");
            for(String s : parts) {
                String url;
                String id = null;
                String[] subParts = s.split("@");
                if(subParts.length>1) {
                    url = subParts[0];
                    id = subParts[1];
                } else {
                    url = subParts[0];
                }
                RemoteRepository r = new RemoteRepository();
                r.setUrl(url);
                r.setId(id);
                repositories.add(r);
            }
        }
        artifact = path.replaceAll("/", ":");
    }

    public String getArtifact() {
        return artifact;
    }

    public RemoteRepository[] getRepositories() {
        return repositories.toArray(new RemoteRepository[repositories.size()]);
    }
}

@@ -1242,16 +1242,22 @@
 uration(
+final 
 String p
@@ -1259,24 +1259,57 @@
 ing path) %7B%0A
+        String pathToUse = path;%0A
         int 
@@ -1320,16 +1320,21 @@
 x = path
+ToUse
 .indexOf
@@ -1402,24 +1402,29 @@
 tring = path
+ToUse
 .substring(i
@@ -1435,16 +1435,21 @@
 +1, path
+ToUse
 .length(
@@ -1468,23 +1468,33 @@
     path
+ToUse
  = path
+ToUse
 .substri
@@ -2117,16 +2117,21 @@
 t = path
+ToUse
 .replace

Fix PMD warnings