if (result.containsKey(attr.getKey())) return; List<Attribute> expansion = expansions.get(attr.getKey()); if (expansion == null) { return; switch (attr.getState()) { case UNSET: { for (Attribute e : expansion) { switch (e.getState()) { case SET: expandMacro(new Attribute(e.getKey(), State.UNSET), result); break; case UNSET: expandMacro(new Attribute(e.getKey(), State.SET), result); break; case UNSPECIFIED: expandMacro(new Attribute(e.getKey(), State.UNSPECIFIED), result); break; switch (e.getState()) { case SET: case UNSET: case CUSTOM: default: expandMacro(new Attribute(e.getKey(), attr.getValue()),
/** {@inheritDoc} */ @Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append(getClass().getSimpleName()); buf.append("["); //$NON-NLS-1$ buf.append(" "); //$NON-NLS-1$ for (Attribute a : map.values()) { buf.append(a.toString()); buf.append(" "); //$NON-NLS-1$ } buf.append("]"); //$NON-NLS-1$ return buf.toString(); }
/** Parses an attribute value from a list of rules, returning null if there is no match for the given key. */ private static @Nullable String findAttributeInRules(String subpath, boolean isFolder, String key, List<AttributesRule> rules) { String value = null; // later rules override earlier ones for (AttributesRule rule : rules) { if (rule.isMatch(subpath, isFolder)) { for (Attribute attribute : rule.getAttributes()) { if (attribute.getKey().equals(key)) { value = attribute.getValue(); } } } } return value; } }
/** * Get attribute value * * @param key * an attribute key * @return the attribute value (may be <code>null</code>) */ public String getValue(String key) { Attribute a = map.get(key); return a != null ? a.getValue() : null; }
/** * Put an attribute * * @param a * an {@link org.eclipse.jgit.attributes.Attribute} */ public void put(Attribute a) { map.put(a.getKey(), a); }
/** * Return the state. * * @param key * key of an attribute * @return the state (never returns <code>null</code>) */ public Attribute.State getState(String key) { Attribute a = map.get(key); return a != null ? a.getState() : Attribute.State.UNSPECIFIED; }
result.add(new Attribute(attribute.substring(1), State.UNSET)); continue; result.add(new Attribute(attribute.substring(1), State.UNSPECIFIED)); continue; result.add(new Attribute(attribute, State.SET)); else { String attributeKey = attribute.substring(0, equalsIndex); String attributeValue = attribute .substring(equalsIndex + 1); result.add(new Attribute(attributeKey, attributeValue));
return null; String filterValue = f.getValue(); if (filterValue == null) { return null;
/** Parses an attribute value from a list of rules, returning null if there is no match for the given key. */ private static @Nullable String findAttributeInRules(String subpath, boolean isFolder, String key, List<AttributesRule> rules) { String value = null; // later rules override earlier ones for (AttributesRule rule : rules) { if (rule.isMatch(subpath, isFolder)) { for (Attribute attribute : rule.getAttributes()) { if (attribute.getKey().equals(key)) { value = attribute.getValue(); } } } } return value; } }
/** * @param a */ public void put(Attribute a) { map.put(a.getKey(), a); }
/** * Returns the state. * * @param key * * @return the state (never returns <code>null</code>) */ public Attribute.State getState(String key) { Attribute a = map.get(key); return a != null ? a.getState() : Attribute.State.UNSPECIFIED; }
result.add(new Attribute(attribute.substring(1), State.UNSET)); continue; result.add(new Attribute(attribute.substring(1), State.UNSPECIFIED)); continue; result.add(new Attribute(attribute, State.SET)); else { String attributeKey = attribute.substring(0, equalsIndex); String attributeValue = attribute .substring(equalsIndex + 1); result.add(new Attribute(attributeKey, attributeValue));
if (result.containsKey(attr.getKey())) return; List<Attribute> expansion = expansions.get(attr.getKey()); if (expansion == null) { return; switch (attr.getState()) { case UNSET: { for (Attribute e : expansion) { switch (e.getState()) { case SET: expandMacro(new Attribute(e.getKey(), State.UNSET), result); break; case UNSET: expandMacro(new Attribute(e.getKey(), State.SET), result); break; case UNSPECIFIED: expandMacro(new Attribute(e.getKey(), State.UNSPECIFIED), result); break; switch (e.getState()) { case SET: case UNSET: case CUSTOM: default: expandMacro(new Attribute(e.getKey(), attr.getValue()),
/** * @param key * @return the attribute value (may be <code>null</code>) */ public String getValue(String key) { Attribute a = map.get(key); return a != null ? a.getValue() : null; }
/** * see {@link TreeWalk#getAttributes()} * * @return the {@link Attributes} for the current path represented by the * {@link TreeWalk} * @throws IOException */ public Attributes getAttributes() throws IOException { String entryPath = treeWalk.getPathString(); boolean isDirectory = (treeWalk.getFileMode() == FileMode.TREE); Attributes attributes = new Attributes(); // Gets the info attributes mergeInfoAttributes(entryPath, isDirectory, attributes); // Gets the attributes located on the current entry path mergePerDirectoryEntryAttributes(entryPath, isDirectory, treeWalk.getTree(WorkingTreeIterator.class), treeWalk.getTree(DirCacheIterator.class), treeWalk.getTree(CanonicalTreeParser.class), attributes); // Gets the attributes located in the global attribute file mergeGlobalAttributes(entryPath, isDirectory, attributes); // now after all attributes are collected - in the correct hierarchy // order - remove all unspecified entries (the ! marker) for (Attribute a : attributes.getAll()) { if (a.getState() == State.UNSPECIFIED) attributes.remove(a.getKey()); } return attributes; }
/** * Put an attribute * * @param a * an {@link org.eclipse.jgit.attributes.Attribute} */ public void put(Attribute a) { map.put(a.getKey(), a); }
/** * Return the state. * * @param key * key of an attribute * @return the state (never returns <code>null</code>) */ public Attribute.State getState(String key) { Attribute a = map.get(key); return a != null ? a.getState() : Attribute.State.UNSPECIFIED; }
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append(getClass().getSimpleName()); buf.append("["); //$NON-NLS-1$ buf.append(" "); //$NON-NLS-1$ for (Attribute a : map.values()) { buf.append(a.toString()); buf.append(" "); //$NON-NLS-1$ } buf.append("]"); //$NON-NLS-1$ return buf.toString(); }