protected boolean isCharacterPortableTree(Fqn fqn) { List elements = fqn.peekElements(); // Don't assume the Fqn is composed of Strings!! for (Object anElement : elements) { // getFullPath converts Object to String via toString(), so we do too Matcher matcher = FQN_PATTERN.matcher(anElement.toString()); if (matcher.find()) { log.warn("One of the Fqn ( " + fqn + " ) elements contains one of these characters: '*' '<' '>' '|' '\"' '?' '\\' '/' ':' "); log.warn("Directories containing these characters are illegal in some operating systems and could lead to portability issues"); return false; } } return true; }
private StringBuilder key(int depth, Fqn fqn) { StringBuilder sb = new StringBuilder(); List l = fqn.peekElements(); sb.append((char) (DEPTH_0 + depth)); for (Object o : l) { sb.append(SEP); if (o == null) sb.append("_null"); else if (o instanceof String) sb.append("_").append(o); else { // TODO Character c = prefix.get(o.getClass()); if (c == null) throw new IllegalArgumentException("not supported " + o.getClass()); sb.append(c.charValue()).append(o); } } return sb; }
/** * Adds a depth number to the start of the FQN. */ private Fqn withDepth(Fqn name, int depth) { Fqn n = Fqn.fromElements(depth); return Fqn.fromRelativeList(n, name.peekElements()); }
/** * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the buddy group name. * * @param buddyGroupName the buddy group name * @param origFqn the original Fqn * @return a backup Fqn */ public Fqn getBackupFqn(String buddyGroupName, Fqn origFqn) { if (isBackupFqn(origFqn)) throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn); List<Object> elements = new ArrayList<Object>(origFqn.size() + 2); elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE); elements.add(buddyGroupName); elements.addAll(origFqn.peekElements()); return Fqn.fromList(elements, true); }
/** * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the backup subtree for the * buddy group in question * * @param buddyGroupRoot the subtree under which data for a particular buddy is backed up * @param origFqn the original Fqn * @return a backup Fqn */ public Fqn getBackupFqn(Fqn buddyGroupRoot, Fqn origFqn) { if (isBackupFqn(origFqn)) throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn); List<Object> elements = new ArrayList<Object>(origFqn.size() + 2); elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE); elements.add(buddyGroupRoot.get(1)); elements.addAll(origFqn.peekElements()); return Fqn.fromList(elements, true); }
protected void marshallFqn(Fqn fqn, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception { boolean isRoot = fqn.isRoot(); out.writeBoolean(isRoot); if (!isRoot) { out.writeShort(fqn.size()); for (Object o : fqn.peekElements()) { marshallObject(o, out, refMap); } } }
for (Object childName : targetFqn.peekElements())
for (Object o : f.peekElements())