/** * Checks if two {@code ConfigurationKey} objects are equal. Two instances * of this class are considered equal if they have the same content (i.e. * their internal string representation is equal). The expression engine * property is not taken into account. * * @param obj the object to compare * @return a flag if both objects are equal */ @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof DefaultConfigurationKey)) { return false; } final DefaultConfigurationKey c = (DefaultConfigurationKey) obj; return keyBuffer.toString().equals(c.toString()); }
@Override public String attributeKey(final String parentKey, final String attributeName) { final DefaultConfigurationKey key = new DefaultConfigurationKey(this, parentKey); key.appendAttribute(attributeName); return key.toString(); }
/** * {@inheritDoc} This implementation takes the * given parent key, adds a property delimiter, and then adds the node's * name. * The name of the root node is a blank string. Note that no indices are * returned. */ @Override public <T> String nodeKey(final T node, final String parentKey, final NodeHandler<T> handler) { if (parentKey == null) { // this is the root node return StringUtils.EMPTY; } final DefaultConfigurationKey key = new DefaultConfigurationKey(this, parentKey); key.append(handler.nodeName(node), true); return key.toString(); }
final String k = other.toString().substring(common.length());
/** * {@inheritDoc} This implementation works similar to {@code nodeKey()}; * however, each key returned by this method has an index (except for the * root node). The parent key is prepended to the name of the current node * in any case and without further checks. If it is <b>null</b>, only the * name of the current node with its index is returned. */ @Override public <T> String canonicalKey(final T node, final String parentKey, final NodeHandler<T> handler) { final String nodeName = handler.nodeName(node); final T parent = handler.getParent(node); final DefaultConfigurationKey key = new DefaultConfigurationKey(this, parentKey); key.append(StringUtils.defaultString(nodeName)); if (parent != null) { // this is not the root key key.appendIndex(determineIndex(node, parent, nodeName, handler)); } return key.toString(); }
/** * Fires all necessary element start events for the specified key. This * method is called for each key obtained from the configuration to be * converted. It ensures that all elements "between" the last key and the * actual key are opened and their values are set. * * @param keyLast the last processed key * @param keyAct the actual key * @param config the configuration to process * @param keySet the set with the processed keys * @return the name of the last element on the path */ protected String openElements(final DefaultConfigurationKey keyLast, final DefaultConfigurationKey keyAct, final Configuration config, final Set<String> keySet) { final DefaultConfigurationKey.KeyIterator it = keyLast.differenceKey(keyAct).iterator(); final DefaultConfigurationKey k = keyLast.commonKey(keyAct); for (it.nextKey(); it.hasNext(); it.nextKey()) { k.append(it.currentKey(true)); elementStart(it.currentKey(true), config.getProperty(k.toString())); keySet.add(k.toString()); } return it.currentKey(true); }