Example usage for java.net URI toString

List of usage examples for java.net URI toString

Introduction

In this page you can find the example usage for java.net URI toString.

Prototype

public String toString() 

Source Link

Document

Returns the content of this URI as a string.

Usage

From source file:com.discovery.darchrow.net.ParamUtil.java

/**
 * ?./*from w  w w. j  ava  2 s.  c  o  m*/
 * 
 * @param uri
 *            the uri
 * @param paramNameList
 *            the param name list
 * @param charsetType
 *            ?
 * @return the string
 */
public static String removeParameterList(URI uri, List<String> paramNameList, String charsetType) {
    if (null == uri) {
        return "";
    }
    String url = uri.toString();
    //  paramNameList null 
    if (Validator.isNullOrEmpty(paramNameList)) {
        return url;
    }
    // ***********************************************************************
    String before = URIUtil.getBeforePath(url);
    // ***********************************************************************
    //  URI ? URI ???? URI 
    String query = uri.getRawQuery();
    // ***********************************************************************
    // url??
    if (Validator.isNullOrEmpty(query)) {
        // ??
        return url;
    } else {
        Map<String, String[]> map = URIUtil.parseQueryToArrayMap(query, null);
        for (String paramName : paramNameList) {
            map.remove(paramName);
        }
        return URIUtil.getEncodedUrlByArrayMap(before, map, charsetType);
    }
}

From source file:de.fuberlin.agcsw.heraclitus.graph.GraphAnalyse.java

public static Graph<JungVertex, JungEdge> createGraphModel(URI start) {
    try {//from www  .  j av a 2s.co m
        Graph<JungVertex, JungEdge> g = new DirectedSparseMultigraph<JungVertex, JungEdge>();
        ValueFactory f = rep.getValueFactory();
        System.out.println("Start Node Fragment: " + start);

        if (start == null) {
            return null;
        }

        Resource startRes;
        if (start.toString().startsWith("node")) {
            //its a blank Node
            startRes = f.createBNode(start.toString());
        } else {
            startRes = f.createURI(start.toString());
        }

        //this is the subject direction

        RepositoryResult<Statement> statements = rep.getConnection().getStatements(startRes, null, null, true);

        JungVertex subVer = new JungVertex(start.getFragment(), start);

        while (statements.hasNext()) {
            Statement st = statements.next();

            Resource sub = st.getSubject();
            org.openrdf.model.URI pred = st.getPredicate();
            Value obj = st.getObject();

            System.out.println(
                    "S: " + sub.stringValue() + " P: " + pred.stringValue() + " O: " + obj.stringValue());

            String strPred = pred.stringValue().substring(pred.stringValue().indexOf("#") + 1);
            String strObj = obj.stringValue().substring(obj.stringValue().indexOf("#") + 1);

            JungVertex objVer = null;
            if (obj instanceof Literal) {
                objVer = new JungVertex(strObj, null);
            } else {
                objVer = new JungVertex(strObj, URI.create(obj.stringValue()));
            }

            JungEdge predV = new JungEdge(strPred);

            //test if circle (Schlinge)
            if (strObj.equals(subVer.toString())) {
                g.addEdge(predV, subVer, subVer);
            } else {
                g.addEdge(predV, subVer, objVer);
            }
        }

        //do the object direction
        statements = rep.getConnection().getStatements(null, null, startRes, true);
        JungVertex objVer = subVer;

        while (statements.hasNext()) {
            Statement st = statements.next();

            Resource sub = st.getSubject();
            org.openrdf.model.URI pred = st.getPredicate();
            Value obj = st.getObject();

            System.out.println(
                    "S: " + sub.stringValue() + " P: " + pred.stringValue() + " O: " + obj.stringValue());
            String strSub = sub.stringValue().substring(sub.stringValue().indexOf("#") + 1);
            String strPred = pred.stringValue().substring(pred.stringValue().indexOf("#") + 1);

            subVer = new JungVertex(strSub, URI.create(sub.stringValue()));
            g.addVertex(subVer);

            JungEdge predV = new JungEdge(strPred);

            //test if circle (Schlinge)
            if (strSub.equals(objVer.toString())) {
                //                  g.addEdge(predV,subVer,subVer);
            } else {
                g.addEdge(predV, subVer, objVer);
            }
        }

        return g;
    } catch (RepositoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;

}

From source file:com.discovery.darchrow.net.ParamUtil.java

/**
 * ?./*from   w  w w  .  j a v  a 2  s.  c  o m*/
 * 
 * <p>
 * uri????,?,?{@code a=1&a=2},a,[3,4],{@code a=3&a=4}.
 * </p>
 * 
 * @param uri
 *            ? ?,?,??,<br>
 *            ??, ?
 * @param arrayValueMap
 *            singleValueMap  request.getParameterMap
 * @param charsetType
 *            ??, {@link CharsetType}<br>
 *            <span style="color:green">null empty,?,?</span><br>
 *            ??,??,ie?chrome? url ,?
 * @return  <code>uri</code> null, {@link StringUtils#EMPTY}<br>
 */
public static String addParameterArrayValueMap(URI uri, Map<String, String[]> arrayValueMap,
        String charsetType) {
    return null == uri ? StringUtils.EMPTY
            : addParameterArrayValueMap(uri.toString(), uri.getRawQuery(), arrayValueMap, charsetType);
}

From source file:com.discovery.darchrow.net.ParamUtil.java

/**
 * url?? ?./* w  ww . j a  va 2  s .c  o  m*/
 * 
 * @param uri
 *            the uri
 * @param paramNameList
 *            the param name list
 * @param charsetType
 *            ?
 * @return the string
 */
public static String retentionParamList(URI uri, List<String> paramNameList, String charsetType) {
    if (null == uri) {
        return "";
    } else {
        String url = uri.toString();
        //  paramNameList null 
        if (Validator.isNullOrEmpty(paramNameList)) {
            return url;
        }
        String before = URIUtil.getBeforePath(url);
        // ***********************************************************************
        //  URI ? URI ???? URI 
        String query = uri.getRawQuery();
        // ***********************************************************************
        // url??
        if (Validator.isNullOrEmpty(query)) {
            // ??
            return url;
        } else {
            Map<String, String[]> map = new LinkedHashMap<String, String[]>();

            Map<String, String[]> originalMap = URIUtil.parseQueryToArrayMap(query, null);

            for (String paramName : paramNameList) {
                map.put(paramName, originalMap.get(paramName));
            }
            return URIUtil.getEncodedUrlByArrayMap(before, map, charsetType);
        }
    }
}

From source file:ca.sqlpower.dao.session.URIConverter.java

@Override
public String convertToSimpleType(URI convertFrom, Object... additionalInfo) {
    return convertFrom.toString();
}

From source file:com.github.sardine.impl.methods.HttpCopy.java

public HttpCopy(URI sourceUrl, URI destinationUrl) {
    this.setHeader("Destination", destinationUrl.toString());
    this.setHeader("Overwrite", "T");
    this.setURI(sourceUrl);
}

From source file:com.googlecode.sardine.impl.methods.HttpMove.java

public HttpMove(URI sourceUrl, URI destinationUrl) {
    this.setHeader("Destination", destinationUrl.toString());
    this.setHeader("Overwrite", "T");
    this.setURI(sourceUrl);
}

From source file:com.rogiel.httpchannel.http.HttpContext.java

public GetRequest get(URI uri) {
    return get(uri.toString());
}

From source file:net.ripe.rpki.commons.validation.ValidationLocation.java

public ValidationLocation(URI objectUri) {
    this(objectUri.toString());
}

From source file:fr.ens.biologie.genomique.eoulsan.actions.ExecJarHadoopAction.java

/**
 * Run Eoulsan in hadoop mode// ww  w  .ja  v  a2  s  . com
 * @param workflowPathname workflow file path
 * @param designPathname design file path
 * @param destPathname data path
 * @param jobDescription job description
 * @param jobEnvironment job environment
 * @param millisSinceEpoch milliseconds since epoch
 */
private static void run(final String workflowPathname, final String designPathname, final String destPathname,
        final String jobDescription, final String jobEnvironment, final long millisSinceEpoch) {

    checkNotNull(workflowPathname, "workflowPathname is null");
    checkNotNull(designPathname, "designPathname is null");
    checkNotNull(destPathname, "destPathname is null");

    final String desc;
    final String env;

    if (jobDescription == null) {
        desc = "no job description";
    } else {
        desc = jobDescription;
    }

    if (jobEnvironment == null) {
        env = "no environment description";
    } else {
        env = jobEnvironment;
    }

    try {

        // Get the Hadoop configuration object
        final Configuration conf = ((HadoopEoulsanRuntime) EoulsanRuntime.getRuntime()).getConfiguration();

        // Define parameter URI
        final URI workflowURI;
        if (workflowPathname.contains("://")) {
            workflowURI = new URI(workflowPathname);
        } else {
            workflowURI = new File(workflowPathname).getAbsoluteFile().toURI();
        }

        // Define design URI
        final URI designURI;
        if (designPathname.contains("://")) {
            designURI = new URI(designPathname);
        } else {
            designURI = new File(designPathname).getAbsoluteFile().toURI();
        }

        // Define destination URI
        final URI destURI = new URI(destPathname);

        final Path workflowPath = new Path(workflowURI.toString());
        final Path designPath = new Path(designURI.toString());
        final Path destPath = new Path(destURI.toString());

        // Test if workflow file exists
        FileSystem workflowFs = workflowPath.getFileSystem(conf);
        if (!workflowFs.exists(workflowPath)) {
            throw new FileNotFoundException(workflowPath.toString());
        }

        // Test if design file exists
        FileSystem designFs = designPath.getFileSystem(conf);
        if (!designFs.exists(designPath)) {
            throw new FileNotFoundException(designPath.toString());
        }

        // Create ExecutionArgument object
        final ExecutorArguments arguments = new HadoopExecutorArguments(millisSinceEpoch, workflowPath,
                designPath, destPath);
        arguments.setJobDescription(desc);
        arguments.setJobEnvironment(env);

        // Create the log Files
        Main.getInstance().createLogFiles(arguments.logPath(Globals.LOG_FILENAME),
                arguments.logPath(Globals.OTHER_LOG_FILENAME));

        // Create executor
        final Executor e = new Executor(arguments);

        // Launch executor
        e.execute();

    } catch (FileNotFoundException e) {

        Common.errorExit(e, "File not found: " + e.getMessage());
    } catch (IOException | URISyntaxException e) {

        Common.errorExit(e, "Error: " + e.getMessage());
    } catch (Throwable e) {

        Common.errorExit(e, "Error while executing " + Globals.APP_NAME_LOWER_CASE + ": " + e.getMessage());
    }

}