Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBMETA-457 Add missing metadata/parser support for cookie attributes. #181

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ public static AdministeredObjectMetaData parse(XMLStreamReader reader, PropertyR
throws XMLStreamException {
AdministeredObjectMetaData metaData = new AdministeredObjectMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
metaData.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, metaData);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,7 @@ public static ConnectionFactoryMetaData parse(XMLStreamReader reader, PropertyRe
throws XMLStreamException {
ConnectionFactoryMetaData metaData = new ConnectionFactoryMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
metaData.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, metaData);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ public static ContextServiceMetaData parse(XMLStreamReader reader, PropertyRepla
throws XMLStreamException {
ContextServiceMetaData metaData = new ContextServiceMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
metaData.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, metaData);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ public class DataSourceMetaDataParser extends MetaDataElementParser {
public static DataSourceMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException {
DataSourceMetaData dataSource = new DataSourceMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
dataSource.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, dataSource);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,7 @@ public class DescriptionMetaDataParser extends MetaDataElementParser {

public static DescriptionImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
DescriptionImpl description = new DescriptionImpl();
// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i))
&& Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) {
description.setLanguage(value);
}
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
description.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
LanguageMetaDataParser.parseAttributes(reader, description);
description.setDescription(getElementText(reader, propertyReplacer));
return description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,7 @@ public static DisplayNameImpl parse(XMLStreamReader reader) throws XMLStreamExce

public static DisplayNameImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
DisplayNameImpl displayName = new DisplayNameImpl();
// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i))
&& Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) {
displayName.setLanguage(value);
}
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
displayName.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
LanguageMetaDataParser.parseAttributes(reader, displayName);
displayName.setDisplayName(getElementText(reader, propertyReplacer));
return displayName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,7 @@ public static EJBLocalReferenceMetaData parse(XMLStreamReader reader) throws XML
public static EJBLocalReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
EJBLocalReferenceMetaData ejbReference = new EJBLocalReferenceMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
ejbReference.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, ejbReference);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,7 @@ public class EJBReferenceMetaDataParser extends MetaDataElementParser {
public static EJBReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
EJBReferenceMetaData ejbReference = new EJBReferenceMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
ejbReference.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, ejbReference);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,7 @@ public class EnvironmentEntryMetaDataParser extends MetaDataElementParser {
public static EnvironmentEntryMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
EnvironmentEntryMetaData environmentEntry = new EnvironmentEntryMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
environmentEntry.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, environmentEntry);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,7 @@ public static IconImpl parse(XMLStreamReader reader) throws XMLStreamException {

public static IconImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
IconImpl icon = new IconImpl();
// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i))
&& Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) {
icon.setLanguage(value);
}
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
icon.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
LanguageMetaDataParser.parseAttributes(reader, icon);
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The JBoss Metadata Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.metadata.parser.ee;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.metadata.javaee.support.IdMetaData;
import org.jboss.metadata.parser.util.MetaDataElementParser;

/**
* @author Paul Ferraro
*/
public class IdMetaDataParser extends MetaDataElementParser {

public static void parseAttributes(XMLStreamReader reader, IdMetaData metaData) throws XMLStreamException {
for (int i = 0; i < reader.getAttributeCount(); i++) {
parseAttribute(reader, i, metaData);
}
}

public static void parseAttribute(XMLStreamReader reader, int index, IdMetaData metaData) throws XMLStreamException {
if (!attributeHasNamespace(reader, index)) {
switch (Attribute.forName(reader.getAttributeLocalName(index))) {
case ID: {
metaData.setId(reader.getAttributeValue(index));
break;
}
default:
throw unexpectedAttribute(reader, index);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ public static JMSConnectionFactoryMetaData parse(XMLStreamReader reader, Propert
throws XMLStreamException {
JMSConnectionFactoryMetaData metaData = new JMSConnectionFactoryMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
metaData.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, metaData);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ public static JMSDestinationMetaData parse(XMLStreamReader reader, PropertyRepla
throws XMLStreamException {
JMSDestinationMetaData metaData = new JMSDestinationMetaData();

// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
metaData.setId(value);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
IdMetaDataParser.parseAttributes(reader, metaData);

DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright The JBoss Metadata Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.metadata.parser.ee;

import javax.xml.XMLConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.metadata.javaee.support.LanguageMetaData;
import org.jboss.metadata.parser.util.MetaDataElementParser;

/**
* @author Paul Ferraro
*/
public class LanguageMetaDataParser extends MetaDataElementParser {

public static void parseAttributes(XMLStreamReader reader, LanguageMetaData metaData) throws XMLStreamException {
for (int i = 0; i < reader.getAttributeCount(); i++) {
parseAttribute(reader, i, metaData);
}
}

public static void parseAttribute(XMLStreamReader reader, int index, LanguageMetaData metaData) throws XMLStreamException {
switch (Attribute.forName(reader.getAttributeLocalName(index))) {
case LANG: {
if (XMLConstants.XML_NS_URI.equals(reader.getAttributeNamespace(index))) {
metaData.setLanguage(reader.getAttributeValue(index));
break;
} // Otherwise, fall through
}
default:
IdMetaDataParser.parseAttribute(reader, index, metaData);
}
}
}
Loading
Loading