/* (non-Javadoc) * @see org.jboss.as.cli.PrefixFormatter#format(org.jboss.as.cli.Prefix) */ @Override public String format(OperationRequestAddress prefix) { Iterator<Node> iterator = prefix.iterator(); if (!iterator.hasNext()) { return "/"; } StringBuilder builder = new StringBuilder(); builder.append('/'); Node next = iterator.next(); builder.append(next.getType()); if (next.getName() != null) { builder.append('=').append(next.getName()); } while (iterator.hasNext()) { builder.append('/'); next = iterator.next(); builder.append(next.getType()); if (next.getName() != null) { builder.append('=').append(next.getName()); } } return builder.toString(); }
/** * Adds a node path which is required to exist before the command can be used. * * @param requiredPath node path which is required to exist before the command can be used. */ protected void addRequiredPath(OperationRequestAddress requiredPath) { if (requiredPath == null) { throw new IllegalArgumentException("Required path can't be null."); } // there perhaps could be more but for now only one is allowed if (requiredAddress != null) { throw new IllegalStateException("Only one required address is allowed, atm."); } requiredAddress = requiredPath; final Iterator<Node> iterator = requiredAddress.iterator(); if (iterator.hasNext()) { final String firstType = iterator.next().getType(); dependsOnProfile = Util.SUBSYSTEM.equals(firstType) || Util.PROFILE.equals(firstType); } if (requiredAddress.endsOnType()) { requiredType = requiredAddress.toParentNode().getType(); } }