Skip to content

Commit

Permalink
added uri syntax exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Sep 20, 2023
1 parent d45cb9c commit 72fd4b6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/main/java/io/usethesource/vallang/ISourceLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package io.usethesource.vallang;

import java.net.URI;
import java.net.URISyntaxException;

import io.usethesource.vallang.visitors.IValueVisitor;

Expand Down Expand Up @@ -139,23 +140,23 @@ public interface ISourceLocation extends IValue {

public boolean hasFileName();

public ISourceLocation changeScheme(String newScheme);
public ISourceLocation changeScheme(String newScheme) throws URISyntaxException;

public ISourceLocation changeAuthority(String newAuthority);
public ISourceLocation changeAuthority(String newAuthority) throws URISyntaxException;

public ISourceLocation changePath(String newPath);
public ISourceLocation changePath(String newPath) throws URISyntaxException;

public ISourceLocation changeFile(String newFile);
public ISourceLocation changeFile(String newFile) throws URISyntaxException;

public ISourceLocation changeExtension(String newExtension);
public ISourceLocation changeExtension(String newExtension) throws URISyntaxException;

public ISourceLocation changeFragment(String newFragment);
public ISourceLocation changeFragment(String newFragment) throws URISyntaxException;

public ISourceLocation changeQuery(String newQuery);
public ISourceLocation changeQuery(String newQuery) throws URISyntaxException;

public ISourceLocation changeFileName(String newFileName);
public ISourceLocation changeFileName(String newFileName) throws URISyntaxException;

public ISourceLocation makeChildLocation(String childPath);
public ISourceLocation makeChildLocation(String childPath) throws URISyntaxException;

public ISourceLocation getParentLocation();

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/usethesource/vallang/IValueFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public ISourceLocation sourceLocation(String scheme, String authority,

/**
* Get a set writer of which the element type will be the least upper bound
* of the element types
* of the element types. ISetWriter instances are stream of IValue collectors.
*
* @return a set writer
*/
Expand All @@ -461,7 +461,7 @@ public ISourceLocation sourceLocation(String scheme, String authority,

/**
* Get a list writer of which the element type will be the least upper bound
* of the element types
* of the element types. IListWriter instances are stream of IValue collectors.
*
* @return a list writer
*/
Expand All @@ -478,7 +478,8 @@ public ISourceLocation sourceLocation(String scheme, String authority,

/**
* Get a map writer of which the key and value types will be the least upper
* bound of the keys and values that are put in.
* bound of the keys and values that are put in. IMapWriter instances are
* stream collectors; the stream must be made of binary ITuple instances.
*
* @return a list writer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,70 @@ public boolean hasOffsetLength() {
return false;
}


@Override
public ISourceLocation top() {
return this;
}

@Override
public ISourceLocation changeAuthority(String authority) throws URISyntaxException {
return newURI(scheme, authority, null, null, null);
}

@Override
public ISourceLocation changeScheme(String scheme) throws URISyntaxException {
return newURI(scheme, null, null, null, null);
}

@Override
public ISourceLocation changeFragment(String fragment) throws URISyntaxException {
return newURI(scheme, null, null, null, fragment);
}

@Override
public ISourceLocation changeQuery(String fragment) throws URISyntaxException {
return newURI(scheme, null, null, null, fragment);
}

@Override
public ISourceLocation getParentLocation() {
return this;
}

@Override
public boolean hasFileName() {
return false;
}

@Override
public ISourceLocation changeExtension(String ext) {
throw new UnsupportedOperationException();
}

@Override
public String getFileName() {
throw new UnsupportedOperationException();
}

@Override
public ISourceLocation changeFileName(String file) throws URISyntaxException {
throw new UnsupportedOperationException();
}

@Override
public ISourceLocation changeFile(String file) throws URISyntaxException {
throw new UnsupportedOperationException();
}

@Override
public ISourceLocation changePath(String path) throws URISyntaxException {
throw new UnsupportedOperationException();
}

@Override
public ISourceLocation makeChildLocation(String path) throws URISyntaxException {
return newURI(scheme, null, path, null, null);
}
}

private static final Pattern squareBrackets = Pattern.compile("(\\[|\\])");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public int getLength() throws UnsupportedOperationException {
public int getOffset() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}

}

private static class IntIntIntIntIntInt extends Complete {
Expand Down

0 comments on commit 72fd4b6

Please sign in to comment.