@Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append(ID).append(':'); switch(contentItem.getContentType()) { case MISC: buf.append(ContentType.MISC.toString()); break; case MODULE: buf.append(ContentType.MODULE.toString()); break; case BUNDLE: buf.append(ContentType.BUNDLE.toString()); break; default: throw new IllegalStateException(PatchLogger.ROOT_LOGGER.unsupportedContentType(contentItem.getContentType().name())); } return buf.append(':').append(contentItem.getRelativePath()).toString(); } }
@Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append(ID).append(':'); switch(contentItem.getContentType()) { case MISC: buf.append(ContentType.MISC.toString()); break; case MODULE: buf.append(ContentType.MODULE.toString()); break; case BUNDLE: buf.append(ContentType.BUNDLE.toString()); break; default: throw new IllegalStateException(PatchLogger.ROOT_LOGGER.unsupportedContentType(contentItem.getContentType().name())); } return buf.append(':').append(contentItem.getRelativePath()).toString(); } }
public static ModificationCondition fromString(String condition) throws PatchingException { assert condition != null : "condition is null"; if(condition.startsWith(ExistsCondition.ID)) { String str = condition.substring(ExistsCondition.ID.length() + 1); int i = str.indexOf(':'); if(i < 0) { throw PatchLogger.ROOT_LOGGER.contentItemTypeMissing(condition); } final String typeStr = str.substring(0, i); final ContentType type = ContentType.valueOf(typeStr); str = str.substring(i + 1); ContentItem item; switch(type) { case MISC: final String[] s = str.split("/"); final int length = s.length; final String name = s[length - 1]; final String[] itemPath = Arrays.copyOf(s, length - 1); item = new MiscContentItem(name, itemPath, null); break; case MODULE: case BUNDLE: default: throw new PatchingException(PatchLogger.ROOT_LOGGER.unsupportedContentType(type.name())); } return ModificationCondition.Factory.exists(item); } throw PatchLogger.ROOT_LOGGER.unrecognizedConditionFormat(condition); }
public static ModificationCondition fromString(String condition) throws PatchingException { assert condition != null : "condition is null"; if(condition.startsWith(ExistsCondition.ID)) { String str = condition.substring(ExistsCondition.ID.length() + 1); int i = str.indexOf(':'); if(i < 0) { throw PatchLogger.ROOT_LOGGER.contentItemTypeMissing(condition); } final String typeStr = str.substring(0, i); final ContentType type = ContentType.valueOf(typeStr); str = str.substring(i + 1); ContentItem item; switch(type) { case MISC: final String[] s = str.split("/"); final int length = s.length; final String name = s[length - 1]; final String[] itemPath = Arrays.copyOf(s, length - 1); item = new MiscContentItem(name, itemPath, null); break; case MODULE: case BUNDLE: default: throw new PatchingException(PatchLogger.ROOT_LOGGER.unsupportedContentType(type.name())); } return ModificationCondition.Factory.exists(item); } throw PatchLogger.ROOT_LOGGER.unrecognizedConditionFormat(condition); }