Package java.net

Examples of java.net.URI$Parser


            if (getWorker() == null) {
                throw new IllegalStateException("No worker action specified for this worker process.");
            }

            final DefaultWorkerProcess workerProcess = new DefaultWorkerProcess();
            URI localAddress = server.accept(workerProcess.getConnectAction());

            List<URL> implementationClassPath = ClasspathUtil.getClasspath(getWorker().getClass().getClassLoader());
            Object id = idGenerator.generateId();
            String displayName = String.format("Gradle Worker %s", id);
View Full Code Here


     * Returns the class name for use for this script source.  The name is intended to be unique to support mapping
     * class names to source files even if many sources have the same file name (e.g. build.gradle).
     */
    public String getClassName() {
        if (className == null) {
            URI sourceUri = resource.getURI();
            String name = StringUtils.substringAfterLast(sourceUri.getPath(), "/");
            StringBuilder className = new StringBuilder(name.length());
            for (int i = 0; i < name.length(); i++) {
                char ch = name.charAt(i);
                if (Character.isJavaIdentifierPart(ch)) {
                    className.append(ch);
                } else {
                    className.append('_');
                }
            }
            if (!Character.isJavaIdentifierStart(className.charAt(0))) {
                className.insert(0, '_');
            }
            className.append('_');
            String path = sourceUri.toString();
            className.append(HashUtil.createHash(path));

            this.className = className.toString();
        }

View Full Code Here

        return resource;
    }

    public String getFileName() {
        File sourceFile = resource.getFile();
        URI sourceUri = resource.getURI();
        return sourceFile != null ? sourceFile.getPath() : sourceUri.toString();
    }
View Full Code Here

    private URI createJar() throws URISyntaxException {
        TestFile jarFile = tmpDir.getDir().file("test.jar");
        testDir.file("ignoreme").write("content");
        testDir.zipTo(jarFile);
        return new URI(String.format("jar:%s!/build.script", jarFile.toURI()));
    }
View Full Code Here

        assertThat(source.getResource().getFile(), equalTo(scriptFile));
    }

    @Test
    public void canConstructSourceFromJarURI() throws URISyntaxException {
        URI uri = createJar();
        UriScriptSource source = new UriScriptSource("<file-type>", uri);
        assertThat(source.getResource(), instanceOf(UriResource.class));
        assertThat(source.getResource().getURI(), equalTo(uri));
    }
View Full Code Here

        assertThat(source.getDisplayName(), equalTo(String.format("<file-type> '%s'", scriptFile.getAbsolutePath())));
    }

    @Test
    public void usesScriptFileNameToBuildDescriptionWhenUsingHttpUri() throws URISyntaxException {
        UriScriptSource source = new UriScriptSource("<file-type>", new URI("http://www.gradle.org/unknown.txt"));
        assertThat(source.getDisplayName(), equalTo(String.format("<file-type> 'http://www.gradle.org/unknown.txt'")));
    }
View Full Code Here

        assertThat(source.getFileName(), equalTo(scriptFile.getAbsolutePath()));
    }

    @Test
    public void usesScriptUriForFileNameUsingHttpUri() throws URISyntaxException {
        UriScriptSource source = new UriScriptSource("<file-type>", new URI("http://www.gradle.org/unknown.txt"));
        assertThat(source.getFileName(), equalTo("http://www.gradle.org/unknown.txt"));
    }
View Full Code Here

    }
   
    @Test
    public void filesWithSameNameAndUriHaveDifferentClassName() throws URISyntaxException {
        ScriptSource source1 = new UriScriptSource("<file-type>", new File(testDir, "build.gradle"));
        ScriptSource source2 = new UriScriptSource("<file-type>", new URI("http://localhost/build.gradle"));
        assertThat(source1.getClassName(), not(equalTo(source2.getClassName())));

        ScriptSource source3 = new UriScriptSource("<file-type>", new File(testDir, "build.gradle"));
        assertThat(source1.getClassName(), equalTo(source3.getClassName()));
    }
View Full Code Here

        templateHeader.append("<th>Size</td>");
        templateHeader.append("\n</tr>\n");
    }

    private void addFilesAndFolders( HttpRequest request, File[] files, StringBuffer templateHeader ) throws IOException {
        URI rootUri = this.root.toURI();
        ComparableComparator comp = new ComparableComparator();
        TreeMap dirMap = new TreeMap( comp );
        TreeMap fileMap = new TreeMap( comp );
        StringBuffer fileBuffer = new StringBuffer();
        for( int i = 0; i < files.length; i++ ) {
View Full Code Here

     * index. If it is null, we assume it is a property file and load it. Otherwise, we
     * assume it is a valid property file URI and try to download it. */
   
    final String uriString = uri.toString();
    if ( uriString.startsWith( "mg4j:" ) ) {
      final URI u = new URI( uriString );
      return IndexServer.getIndex( u.getHost(), u.getPort(), randomAccess, documentSizes );
    }

    final String basename, query;
   
    if ( uriString.startsWith( "file:" ) ) {
      final URI u = new URI( uriString );
      basename = u.getPath();
      query = u.getQuery();
    }
    else {
      final int questionMarkPos = uriString.indexOf( '?' );
      basename = questionMarkPos == -1 ? uriString : uriString.substring( 0, questionMarkPos );
      query = questionMarkPos == -1 ? null : uriString.substring( questionMarkPos + 1 );
View Full Code Here

TOP

Related Classes of java.net.URI$Parser

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.