@Test public void testReplaceName() throws Exception { assertEquals("universe.doc?query=123", new MMapURI("?query=123#eee").replaceName("universe.doc").asURI().toString()); assertEquals("hello/universe.doc?query=123", new MMapURI("hello/world.txt?query=123#eee").replaceName("universe.doc").asURI().toString()); assertEquals("hello?query=123", new MMapURI("universe/?query=123#eee").replaceName("hello").asURI().toString()); assertEquals("hello?query=123", new MMapURI("universe?query=123#eee").replaceName("hello").asURI().toString()); assertEquals("file: assertEquals("file: assertEquals("file: }
@Nonnull public MMapURI replaceName(@Nonnull final String newName) throws URISyntaxException { final MMapURI result; final String normalizedName = ModelUtils.escapeURIPath(newName).replace('\\', '/'); final String[] parsedNormalized = normalizedName.split("\\/"); final String[] parsedCurrentPath = this.uri.getPath().split("\\/"); final int baseLength = Math.max(0, parsedCurrentPath.length - parsedNormalized.length); final StringBuilder buffer = new StringBuilder(); for (int i = 0; i < baseLength; i++) { if (i > 0) { buffer.append('/'); } buffer.append(parsedCurrentPath[i]); } for (int i = 0; i < parsedNormalized.length; i++) { if ((i == 0 && buffer.length() > 0) || i > 0) { buffer.append('/'); } buffer.append(parsedNormalized[i]); } result = new MMapURI(new URI( this.uri.getScheme(), this.uri.getUserInfo(), extractHost(this.uri), this.uri.getPort(), buffer.toString(), this.uri.getQuery(), this.uri.getFragment()), this.fileUriFlag, parameters); return result; }
MMapURI implements Serializable { @Nonnull public MMapURI replaceName(@Nonnull final String newName) throws URISyntaxException { final MMapURI result; final String normalizedName = ModelUtils.escapeURIPath(newName).replace('\\', '/'); final String[] parsedNormalized = normalizedName.split("\\/"); final String[] parsedCurrentPath = this.uri.getPath().split("\\/"); final int baseLength = Math.max(0, parsedCurrentPath.length - parsedNormalized.length); final StringBuilder buffer = new StringBuilder(); for (int i = 0; i < baseLength; i++) { if (i > 0) { buffer.append('/'); } buffer.append(parsedCurrentPath[i]); } for (int i = 0; i < parsedNormalized.length; i++) { if ((i == 0 && buffer.length() > 0) || i > 0) { buffer.append('/'); } buffer.append(parsedNormalized[i]); } result = new MMapURI(new URI( this.uri.getScheme(), this.uri.getUserInfo(), extractHost(this.uri), this.uri.getPort(), buffer.toString(), this.uri.getQuery(), this.uri.getFragment()), this.fileUriFlag, parameters); return result; } }
MMapURI implements Serializable { @Nonnull public MMapURI replaceName(@Nonnull final String newName) throws URISyntaxException { final MMapURI result; final String normalizedName = ModelUtils.escapeURIPath(newName).replace('\\', '/'); final String[] parsedNormalized = normalizedName.split("\\/"); final String[] parsedCurrentPath = this.uri.getPath().split("\\/"); final int baseLength = Math.max(0, parsedCurrentPath.length - parsedNormalized.length); final StringBuilder buffer = new StringBuilder(); for (int i = 0; i < baseLength; i++) { if (i > 0) { buffer.append('/'); } buffer.append(parsedCurrentPath[i]); } for (int i = 0; i < parsedNormalized.length; i++) { if ((i == 0 && buffer.length() > 0) || i > 0) { buffer.append('/'); } buffer.append(parsedNormalized[i]); } result = new MMapURI(new URI( this.uri.getScheme(), this.uri.getUserInfo(), extractHost(this.uri), this.uri.getPort(), buffer.toString(), this.uri.getQuery(), this.uri.getFragment()), this.fileUriFlag, parameters); return result; } MMapURI(@Nonnull final String uri);  MMapURI(@Nonnull final URI uri); private  MMapURI(@Nonnull final URI uri, final boolean isFile, @Nullable final Properties properties);  MMapURI(@Nullable final File nullableBase, @Nonnull final File file, @Nullable final Properties nullableParameters); }
MMapURI implements Serializable { @Nonnull public MMapURI replaceName(@Nonnull final String newName) throws URISyntaxException { final MMapURI result; final String normalizedName = ModelUtils.escapeURIPath(newName).replace('\\', '/'); final String[] parsedNormalized = normalizedName.split("\\/"); final String[] parsedCurrentPath = this.uri.getPath().split("\\/"); final int baseLength = Math.max(0, parsedCurrentPath.length - parsedNormalized.length); final StringBuilder buffer = new StringBuilder(); for (int i = 0; i < baseLength; i++) { if (i > 0) { buffer.append('/'); } buffer.append(parsedCurrentPath[i]); } for (int i = 0; i < parsedNormalized.length; i++) { if ((i == 0 && buffer.length() > 0) || i > 0) { buffer.append('/'); } buffer.append(parsedNormalized[i]); } result = new MMapURI(new URI( this.uri.getScheme(), this.uri.getUserInfo(), extractHost(this.uri), this.uri.getPort(), buffer.toString(), this.uri.getQuery(), this.uri.getFragment()), this.fileUriFlag, parameters); return result; } MMapURI(@Nonnull final String uri);  MMapURI(@Nonnull final URI uri); private  MMapURI(@Nonnull final URI uri, final boolean isFile, @Nullable final Properties properties);  MMapURI(@Nullable final File nullableBase, @Nonnull final File file, @Nullable final Properties nullableParameters); @SuppressWarnings("ConstantConditions") @Nonnull static MMapURI makeFromFilePath(@Nullable final File base, @Nonnull final String filePath, @Nullable final Properties properties); @Override int hashCode(); @Override boolean equals(@Nullable final Object that); @Nonnull MMapURI replaceBaseInPath(final boolean replaceHost, @Nonnull final URI newBase, int currentNumberOfResourceItemsTheLasIsZero); @Nonnull MMapURI replaceName(@Nonnull final String newName); @Nonnull URI asURI(); @Nonnull String getExtension(); @Nonnull String asString(final boolean ascII, final boolean addPropertiesAsQuery); @Nonnull File asFile(@Nullable final File base); @Nonnull Properties getParameters(); boolean isAbsolute(); @Override @Nonnull String toString(); }
MMapURI implements Serializable { @Nonnull public MMapURI replaceName(@Nonnull final String newName) throws URISyntaxException { final MMapURI result; final String normalizedName = ModelUtils.escapeURIPath(newName).replace('\\', '/'); final String[] parsedNormalized = normalizedName.split("\\/"); final String[] parsedCurrentPath = this.uri.getPath().split("\\/"); final int baseLength = Math.max(0, parsedCurrentPath.length - parsedNormalized.length); final StringBuilder buffer = new StringBuilder(); for (int i = 0; i < baseLength; i++) { if (i > 0) { buffer.append('/'); } buffer.append(parsedCurrentPath[i]); } for (int i = 0; i < parsedNormalized.length; i++) { if ((i == 0 && buffer.length() > 0) || i > 0) { buffer.append('/'); } buffer.append(parsedNormalized[i]); } result = new MMapURI(new URI( this.uri.getScheme(), this.uri.getUserInfo(), extractHost(this.uri), this.uri.getPort(), buffer.toString(), this.uri.getQuery(), this.uri.getFragment()), this.fileUriFlag, parameters); return result; } MMapURI(@Nonnull final String uri);  MMapURI(@Nonnull final URI uri); private  MMapURI(@Nonnull final URI uri, final boolean isFile, @Nullable final Properties properties);  MMapURI(@Nullable final File nullableBase, @Nonnull final File file, @Nullable final Properties nullableParameters); @SuppressWarnings("ConstantConditions") @Nonnull static MMapURI makeFromFilePath(@Nullable final File base, @Nonnull final String filePath, @Nullable final Properties properties); @Override int hashCode(); @Override boolean equals(@Nullable final Object that); @Nonnull MMapURI replaceBaseInPath(final boolean replaceHost, @Nonnull final URI newBase, int currentNumberOfResourceItemsTheLasIsZero); @Nonnull MMapURI replaceName(@Nonnull final String newName); @Nonnull URI asURI(); @Nonnull String getExtension(); @Nonnull String asString(final boolean ascII, final boolean addPropertiesAsQuery); @Nonnull File asFile(@Nullable final File base); @Nonnull Properties getParameters(); boolean isAbsolute(); @Override @Nonnull String toString(); static final long serialVersionUID; }