Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk13u-dev Public archive

Commit

Permalink
8276141: XPathFactory set/getProperty method
Browse files Browse the repository at this point in the history
Reviewed-by: bae, goetz
Backport-of: b226ab99c872e791d3ed9fca015cf92847904c34
  • Loading branch information
Yuri Nesterenko committed Mar 4, 2022
1 parent b9c0ba8 commit 4b2f75b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,36 @@ public void setXPathVariableResolver(XPathVariableResolver resolver) {

xPathVariableResolver = resolver;
}

public void setProperty(String name, String value) {
// property name cannot be null
if (name == null) {
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_PROPERTY_NAME_NULL,
new Object[] {CLASS_NAME, value} );
throw new NullPointerException(fmsg);
}

// property name not recognized
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_PROPERTY_UNKNOWN,
new Object[] {name, CLASS_NAME, value} );
throw new IllegalArgumentException(fmsg);
}

public String getProperty(String name) {
// property name cannot be null
if (name == null) {
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_GETTING_NULL_PROPERTY,
new Object[] {CLASS_NAME} );
throw new NullPointerException(fmsg);
}

// unknown property
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_GETTING_UNKNOWN_PROPERTY,
new Object[] {name, CLASS_NAME} );
throw new IllegalArgumentException(fmsg);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -31,7 +31,7 @@
* Also you need to update the count of messages(MAX_CODE)or
* the count of warnings(MAX_WARNING) [ Information purpose only]
* @xsl.usage advanced
* @LastModified: May 2019
* @LastModified: Nov 2021
*/
public class XPATHErrorResources extends ListResourceBundle
{
Expand Down Expand Up @@ -322,6 +322,10 @@ public class XPATHErrorResources extends ListResourceBundle
public static final String ER_SECUREPROCESSING_FEATURE = "ER_SECUREPROCESSING_FEATURE";
public static final String ER_NULL_XPATH_FUNCTION_RESOLVER = "ER_NULL_XPATH_FUNCTION_RESOLVER";
public static final String ER_NULL_XPATH_VARIABLE_RESOLVER = "ER_NULL_XPATH_VARIABLE_RESOLVER";
public static final String ER_PROPERTY_NAME_NULL = "ER_PROPERTY_NAME_NULL";
public static final String ER_PROPERTY_UNKNOWN = "ER_PROPERTY_UNKNOWN";
public static final String ER_GETTING_NULL_PROPERTY = "ER_GETTING_NULL_PROPERTY";
public static final String ER_GETTING_UNKNOWN_PROPERTY = "ER_GETTING_UNKNOWN_PROPERTY";
//END: Keys needed for exception messages of JAXP 1.3 XPath API implementation

public static final String WG_LOCALE_NAME_NOT_HANDLED =
Expand Down Expand Up @@ -836,6 +840,26 @@ public class XPATHErrorResources extends ListResourceBundle
{ ER_NULL_XPATH_VARIABLE_RESOLVER,
"Attempting to set a null XPathVariableResolver:{0}#setXPathVariableResolver(null)"},

/** Field ER_PROPERTY_NAME_NULL */

{ ER_PROPERTY_NAME_NULL,
"Trying to set a property with a null name: {0}#setProperty( null, {1})"},

/** Field ER_PROPERTY_UNKNOWN */

{ ER_PROPERTY_UNKNOWN,
"Trying to set the unknown property \"{0}\":{1}#setProperty({0},{2})"},

/** Field ER_GETTING_NULL_PROPERTY */

{ ER_GETTING_NULL_PROPERTY,
"Trying to get a property with a null name: {0}#getProperty(null)"},

/** Field ER_GETTING_NULL_PROPERTY */

{ ER_GETTING_UNKNOWN_PROPERTY,
"Trying to get the unknown property \"{0}\":{1}#getProperty({0})"},

//END: Definitions of error keys used in exception messages of JAXP 1.3 XPath API implementation

// Warnings...
Expand Down

3 comments on commit 4b2f75b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 4b2f75b Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u

@openjdk
Copy link

@openjdk openjdk bot commented on 4b2f75b Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-4b2f75b0 in my personal fork of openjdk/jdk11u. To create a pull request with this backport targeting openjdk/jdk11u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 4b2f75b0 from the openjdk/jdk13u-dev repository.

The commit being backported was authored by Yuri Nesterenko on 4 Mar 2022 and was reviewed by Andrew Brygin and Goetz Lindenmaier.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u:

$ git fetch https://github.com/openjdk-bots/jdk11u GoeLin-backport-4b2f75b0:GoeLin-backport-4b2f75b0
$ git checkout GoeLin-backport-4b2f75b0
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u GoeLin-backport-4b2f75b0

Please sign in to comment.