Class GS1AIObject
GS1AIObjectElement instances
and any object-level validation errors.
Both the element list and the error list are mutable after construction.
New elements are appended via add(GS1AIObjectElement) and new
object-level errors via addError(GaiaError). Public accessors
always return defensive unmodifiable views.
Validity is determined by isValid(): the object is valid when
there are no object-level non-WARNING errors and no element has attached
errors. GaiaConstants.ErrorLevel.WARNING advisories do not affect
validity.
-
Constructor Summary
ConstructorsConstructorDescriptionGS1AIObject(List<GS1AIObjectElement> elements, List<GaiaError> errors) Creates a newGS1AIObject.GS1AIObject(List<GS1AIObjectElement> elements, List<GaiaError> errors, GS1DigitalLinkInfo digitalLinkInfo) Creates a newGS1AIObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(GS1AIObjectElement element) Adds aGS1AIObjectElementto this object.voidAdds aGaiaErrorto this object.booleanReturnstrueif an AI with the given code is present.Returns the first AI matching the given code, ornullif not present.getAis()All resolved AIs in input order.All non-WARNING issues from both the object level and every element, in order: object-level errors first, then each element's errors in element order.All issues regardless of level — errors and warnings combined — from both the object level and every element.AllGaiaConstants.ErrorLevel.WARNINGadvisories from both the object level and every element.Returns the canonical GS1 Digital Link URI for this object (GS1 Digital Link Standard: URI Syntax §4.12), ornullif this object was not parsed from a Digital Link — i.e. no element carries theGS1Constants.DigitalLinkAIType.PRIMARY_IDENTIFICATION_KEYrole.Returns theGS1Constants.GS1ContentTypeof the parsed content.Metadata extracted from a GS1 Digital Link URI, ornullif the input was not a Digital Link.Object-level non-WARNING errors produced during parsing.Object-levelGaiaConstants.ErrorLevel.WARNINGadvisories.booleanReturnstrueif the input was a GS1 Digital Link URI carrying at least one primary identification key.booleanisValid()Returnstrueonly when there are no object-level errors and no element has any attached errors.voidRecords the deepest pipeline stage reached.intsize()Number of AIs held.Renders all AIs as a raw GS1 element string — no brackets, each AI code immediately followed by its value, with an FNC1 (GS, ASCII 0x1D) separator after every variable-length element that is not the last (GS1AIObjectElement.isFixedLength()).Returns the Human Readable Interpretation (HRI) of all AIs.toString()
-
Constructor Details
-
GS1AIObject
Creates a newGS1AIObject.- Parameters:
elements- the elementserrors- the errors
-
GS1AIObject
public GS1AIObject(List<GS1AIObjectElement> elements, List<GaiaError> errors, GS1DigitalLinkInfo digitalLinkInfo) Creates a newGS1AIObject.- Parameters:
elements- the elementserrors- the errorsdigitalLinkInfo- the digital link info
-
-
Method Details
-
getAchievedParseMode
The deepest pipeline stage actually reached during parsing (SYNTAX,CONTENT, orINTERPRETATION). This may be shallower than the requested mode when the pipeline stops early on errors. Set by the parsing pipeline;nullif not produced by the pipeline.- Returns:
- the achieved parse mode.
-
setAchievedParseMode
Records the deepest pipeline stage reached. Called by the parsing pipeline.- Parameters:
mode- the mode
-
add
Adds aGS1AIObjectElementto this object.- Parameters:
element- the element to add; must not benull
-
addError
-
getDigitalLinkInfo
Metadata extracted from a GS1 Digital Link URI, ornullif the input was not a Digital Link.- Returns:
- the digital link info.
-
hasDigitalLink
public boolean hasDigitalLink()Returnstrueif the input was a GS1 Digital Link URI carrying at least one primary identification key. The URL metadata may still be present (seegetDigitalLinkInfo()) for a well-formed URL that lacks a primary key — such an input is not a usable Digital Link.- Returns:
trueif this element has digital link.
-
getContentType
Returns theGS1Constants.GS1ContentTypeof the parsed content.GS1Constants.GS1ContentType.GS1_DIGITAL_LINK— whenhasDigitalLink()istrue.GS1Constants.GS1ContentType.GS1_APPLICATION_IDENTIFIERS— otherwise.
- Returns:
- the content type.
-
getAis
-
get
Returns the first AI matching the given code, ornullif not present.- Parameters:
aiCode- the AI code- Returns:
- the .
-
contains
Returnstrueif an AI with the given code is present.- Parameters:
aiCode- the AI code- Returns:
trueif contains.
-
getErrors
Object-level non-WARNING errors produced during parsing. Element-level errors (including structural integrity errors) are held on individual elements — usegetAllErrors()to collect errors from all levels. Warnings are excluded; usegetWarnings()to retrieve those.- Returns:
- the errors.
-
getWarnings
Object-levelGaiaConstants.ErrorLevel.WARNINGadvisories.- Returns:
- the warnings.
-
getAllErrors
-
getAllWarnings
AllGaiaConstants.ErrorLevel.WARNINGadvisories from both the object level and every element.- Returns:
- the all warnings.
-
getAllIssues
-
isValid
public boolean isValid()Returnstrueonly when there are no object-level errors and no element has any attached errors.GaiaConstants.ErrorLevel.WARNINGadvisories do not affect validity.- Returns:
trueif this element is valid.
-
size
public int size()Number of AIs held.- Returns:
- the size.
-
toHriString
Returns the Human Readable Interpretation (HRI) of all AIs. Each AI is rendered as(aiCode)valueand the elements are space-separated, e.g.(01)09506000134352 (17)271231 (10)LOT-ABC.- Returns:
- the to HRI string.
-
toElementString
Renders all AIs as a raw GS1 element string — no brackets, each AI code immediately followed by its value, with an FNC1 (GS, ASCII 0x1D) separator after every variable-length element that is not the last (GS1AIObjectElement.isFixedLength()). Example:010950600013435210LOT-ABC<GS>17271231.Only an error-free object can be rendered faithfully, so this method returns
nullwhenisValid()isfalse.- Returns:
- the element string, or
nullif this object carries errors
-
getCanonicalDigitalLink
Returns the canonical GS1 Digital Link URI for this object (GS1 Digital Link Standard: URI Syntax §4.12), ornullif this object was not parsed from a Digital Link — i.e. no element carries theGS1Constants.DigitalLinkAIType.PRIMARY_IDENTIFICATION_KEYrole.The canonical form uses the
httpsscheme on theid.gs1.orgdomain, the primary identification key and its key qualifiers as path segments (in their canonical order), and data attributes as query parameters sorted lexically by AI key. Reserved characters in values are percent-encoded (§4.2); GTIN values remain 14 digits.Example: an object parsed from
http://example.com/01/09520123456788/22/2A?linkType=gs1:traceabilityyieldshttps://id.gs1.org/01/09520123456788/22/2A.- Returns:
- the canonical GS1 Digital Link URI, or
null
-
toString
-