/** * Creates a new Path using the specified base and specified relative context. * * @param basePath * @param context */ public BasicPath(final String basePath, String context) { this(PathUtil.composeAbsoluteContext(basePath, context)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.ArchivePath#getParent() */ @Override public ArchivePath getParent() { return PathUtil.getParent(this); }
/** * Composes an absolute context from a given base and actual context relative to the base, returning the result. ie. * base of "base" and context of "context" will result in form "/base/context". */ public static String composeAbsoluteContext(final String base, final String context) { // Precondition checks assertSpecified(base); assertSpecified(context); // Compose final String relative = PathUtil.adjustToAbsoluteDirectoryContext(base); final String reformedContext = PathUtil.optionallyRemovePrecedingSlash(context); final String actual = relative + reformedContext; // Return return actual; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.path.PathsTestBase#createPath(java.lang.String, * org.jboss.shrinkwrap.api.ArchivePath) */ @Override ArchivePath createPath(final String base, final ArchivePath context) { return new BasicPath(base, context); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#addAsDirectory(org.jboss.shrinkwrap.api.ArchivePath) */ @Override public T addAsDirectory(final ArchivePath path) throws IllegalArgumentException { // Precondition check Validate.notNull(path, "path must be specified"); // Adjust the path to remove any trailing slash ArchivePath adjustedPath = new BasicPath(PathUtil.optionallyRemoveFollowingSlash(path.get())); return addAsset(adjustedPath, null); }
/** * Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyAppendSlash(final String path) { // Precondition check assertSpecified(path); // If the last character is not a slash if (!isLastCharSlash(path)) { // Append return path + ArchivePath.SEPARATOR; } // Return as-is return path; }
/** * Returns whether or not the first character in the specified String is a slash */ private static boolean isFirstCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(0) == ArchivePath.SEPARATOR; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.path.PathsTestBase#createPath(java.lang.String) */ @Override ArchivePath createPath(final String context) { return new BasicPath(context); }
/** * Composes an absolute context from a given base and actual context relative to the base, returning the result. ie. * base of "base" and context of "context" will result in form "/base/context". */ public static String composeAbsoluteContext(final String base, final String context) { // Precondition checks assertSpecified(base); assertSpecified(context); // Compose final String relative = PathUtil.adjustToAbsoluteDirectoryContext(base); final String reformedContext = PathUtil.optionallyRemovePrecedingSlash(context); final String actual = relative + reformedContext; // Return return actual; }
/** * Creates a new Path using the specified base and specified relative context. * * @param basePath * @param context */ public BasicPath(final String basePath, String context) { this(PathUtil.composeAbsoluteContext(basePath, context)); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.ArchivePath#getParent() */ @Override public ArchivePath getParent() { return PathUtil.getParent(this); }
/** * Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result. * * @param path * @return */ public static String optionallyAppendSlash(final String path) { // Precondition check assertSpecified(path); // If the last character is not a slash if (!isLastCharSlash(path)) { // Append return path + ArchivePath.SEPARATOR; } // Return as-is return path; }
/** * Returns whether or not the last character in the specified String is a slash */ private static boolean isLastCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(path.length() - 1) == ArchivePath.SEPARATOR; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.path.PathsTestBase#createPath(org.jboss.shrinkwrap.api.ArchivePath, * java.lang.String) */ @Override ArchivePath createPath(ArchivePath base, String context) { return new BasicPath(base, context); }
/** * Returns whether or not the last character in the specified String is a slash */ private static boolean isLastCharSlash(final String path) { assertSpecified(path); if (path.length() == 0) { return false; } return path.charAt(path.length() - 1) == ArchivePath.SEPARATOR; }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.path.PathsTestBase#createPath(java.lang.String, java.lang.String) */ @Override ArchivePath createPath(String base, String context) { return new BasicPath(base, context); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.impl.base.path.PathsTestBase#createPath(org.jboss.shrinkwrap.api.ArchivePath, * org.jboss.shrinkwrap.api.ArchivePath) */ @Override ArchivePath createPath(ArchivePath base, ArchivePath context) { return new BasicPath(base, context); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive) */ @Override public T merge(final Archive<?> source) throws IllegalArgumentException { return merge(source, new BasicPath()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Filter) */ @Override public T merge(Archive<?> source, Filter<ArchivePath> filter) throws IllegalArgumentException { return merge(source, new BasicPath(), filter); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#merge(org.jboss.shrinkwrap.api.Archive) */ @Override public T merge(final Archive<?> source) throws IllegalArgumentException { return merge(source, new BasicPath()); }