Top Description Fields Constructors Methods
org.eclipse.jgit.attributes

public Class AttributesRule

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.ignore.IMatcher.NO_MATCH

A single attributes rule corresponding to one line in a .gitattributes file. Inspiration from: org.eclipse.jgit.ignore.FastIgnoreRule
Since
3.7

Field Summary

Modifier and TypeField and Description
private final List<Attribute>
private static final String
ATTRIBUTES_SPLIT_REGEX

regular expression for splitting attributes - space, tab and \r (the C implementation oddly enough allows \r between attributes)

private final boolean
private final IMatcher
private final boolean
private final String

Constructor Summary

AccessConstructor and Description
public
AttributesRule(String
Base pattern for the attributes rule. This pattern will be parsed to generate rule parameters. It can not be null.
pattern
,
String
the rule attributes. This string will be parsed to read the attributes.
attributes
)

Create a new attribute rule with the given pattern.

Method Summary

Modifier and TypeMethod and Description
public List<Attribute>

Returns:

an unmodifiable list of attributes (never returns null)
getAttributes
()

Return the attributes.

public String

Returns:

The blob pattern to be used as a matcher (never returns null)
getPattern
()

Get the pattern

public boolean

Returns:

true if the pattern should match directories only
isDirOnly
()

Whether to match directories only

public boolean

Returns:

True if a match was made.
isMatch
(String
Name pattern of the file, relative to the base directory of this rule
relativeTarget
,
boolean
Whether the target file is a directory or not
isDirectory
)

Returns true if a match was made.

public boolean

Returns:

true if the pattern is just a file name and not a path
isNameOnly
()

Whether the pattern is only a file name and not a path

private static List<Attribute>
parseAttributes(String attributesLine)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributesback to summary
private final List<Attribute> attributes
ATTRIBUTES_SPLIT_REGEXback to summary
private static final String ATTRIBUTES_SPLIT_REGEX

regular expression for splitting attributes - space, tab and \r (the C implementation oddly enough allows \r between attributes)

dirOnlyback to summary
private final boolean dirOnly
matcherback to summary
private final IMatcher matcher
nameOnlyback to summary
private final boolean nameOnly
patternback to summary
private final String pattern

Constructor Detail

AttributesRuleback to summary
public AttributesRule(String pattern, String attributes)

Create a new attribute rule with the given pattern. Assumes that the pattern is already trimmed.

Parameters
pattern:String

Base pattern for the attributes rule. This pattern will be parsed to generate rule parameters. It can not be null.

attributes:String

the rule attributes. This string will be parsed to read the attributes.

Method Detail

getAttributesback to summary
public List<Attribute> getAttributes()

Return the attributes.

Returns:List<Attribute>

an unmodifiable list of attributes (never returns null)

getPatternback to summary
public String getPattern()

Get the pattern

Returns:String

The blob pattern to be used as a matcher (never returns null)

isDirOnlyback to summary
public boolean isDirOnly()

Whether to match directories only

Returns:boolean

true if the pattern should match directories only

Since
4.3
isMatchback to summary
public boolean isMatch(String relativeTarget, boolean isDirectory)

Returns true if a match was made.

Parameters
relativeTarget:String

Name pattern of the file, relative to the base directory of this rule

isDirectory:boolean

Whether the target file is a directory or not

Returns:boolean

True if a match was made.

isNameOnlyback to summary
public boolean isNameOnly()

Whether the pattern is only a file name and not a path

Returns:boolean

true if the pattern is just a file name and not a path

parseAttributesback to summary
private static List<Attribute> parseAttributes(String attributesLine)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override