├── .asf.yaml
├── .gitattributes
├── .github
├── GH-ROBOTS.txt
├── dependabot.yml
├── pull_request_template.md
└── workflows
│ ├── codeql-analysis.yml
│ ├── dependency-review.yml
│ ├── maven.yml
│ └── scorecards-analysis.yml
├── .gitignore
├── BUILDING.txt
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── RELEASE-NOTES.txt
├── SECURITY.md
├── pom.xml
└── src
├── changes
├── changes.xml
└── release-notes.vm
├── conf
├── checkstyle-suppressions.xml
└── checkstyle.xml
├── main
├── assembly
│ ├── bin.xml
│ └── src.xml
├── java
│ └── org
│ │ └── apache
│ │ └── commons
│ │ └── beanutils2
│ │ ├── BaseDynaBeanMapDecorator.java
│ │ ├── BasicDynaBean.java
│ │ ├── BasicDynaClass.java
│ │ ├── BeanAccessLanguageException.java
│ │ ├── BeanComparator.java
│ │ ├── BeanIntrospectionData.java
│ │ ├── BeanIntrospector.java
│ │ ├── BeanMap.java
│ │ ├── BeanPredicate.java
│ │ ├── BeanPropertyValueChangeConsumer.java
│ │ ├── BeanPropertyValueEqualsPredicate.java
│ │ ├── BeanToPropertyValueTransformer.java
│ │ ├── BeanUtils.java
│ │ ├── BeanUtilsBean.java
│ │ ├── ConstructorUtils.java
│ │ ├── ContextClassLoaderLocal.java
│ │ ├── ConversionException.java
│ │ ├── ConvertUtils.java
│ │ ├── ConvertUtilsBean.java
│ │ ├── Converter.java
│ │ ├── ConvertingWrapDynaBean.java
│ │ ├── DefaultBeanIntrospector.java
│ │ ├── DefaultIntrospectionContext.java
│ │ ├── DynaBean.java
│ │ ├── DynaBeanPropertyMapDecorator.java
│ │ ├── DynaClass.java
│ │ ├── DynaProperty.java
│ │ ├── FluentPropertyBeanIntrospector.java
│ │ ├── IntrospectionContext.java
│ │ ├── LazyDynaBean.java
│ │ ├── LazyDynaClass.java
│ │ ├── LazyDynaList.java
│ │ ├── LazyDynaMap.java
│ │ ├── MappedPropertyDescriptor.java
│ │ ├── MethodUtils.java
│ │ ├── MutableDynaClass.java
│ │ ├── NestedNullException.java
│ │ ├── PropertyDescriptors.java
│ │ ├── PropertyUtils.java
│ │ ├── PropertyUtilsBean.java
│ │ ├── SuppressPropertiesBeanIntrospector.java
│ │ ├── TestEnum.java
│ │ ├── WrapDynaBean.java
│ │ ├── WrapDynaClass.java
│ │ ├── converters
│ │ ├── AbstractConverter.java
│ │ ├── ArrayConverter.java
│ │ ├── BigDecimalConverter.java
│ │ ├── BigIntegerConverter.java
│ │ ├── BooleanConverter.java
│ │ ├── ByteConverter.java
│ │ ├── CalendarConverter.java
│ │ ├── CharacterConverter.java
│ │ ├── ClassConverter.java
│ │ ├── ColorConverter.java
│ │ ├── ConverterFacade.java
│ │ ├── DateConverter.java
│ │ ├── DateTimeConverter.java
│ │ ├── DimensionConverter.java
│ │ ├── DoubleConverter.java
│ │ ├── DurationConverter.java
│ │ ├── EnumConverter.java
│ │ ├── FileConverter.java
│ │ ├── FloatConverter.java
│ │ ├── InetAddressConverter.java
│ │ ├── IntegerConverter.java
│ │ ├── LocalDateConverter.java
│ │ ├── LocalDateTimeConverter.java
│ │ ├── LocalTimeConverter.java
│ │ ├── LocaleConverter.java
│ │ ├── LongConverter.java
│ │ ├── MonthDayConverter.java
│ │ ├── NumberConverter.java
│ │ ├── OffsetDateTimeConverter.java
│ │ ├── OffsetTimeConverter.java
│ │ ├── PathConverter.java
│ │ ├── PatternConverter.java
│ │ ├── PeriodConverter.java
│ │ ├── PointConverter.java
│ │ ├── ShortConverter.java
│ │ ├── StringConverter.java
│ │ ├── URIConverter.java
│ │ ├── URLConverter.java
│ │ ├── UUIDConverter.java
│ │ ├── YearConverter.java
│ │ ├── YearMonthConverter.java
│ │ ├── ZoneIdConverter.java
│ │ ├── ZoneOffsetConverter.java
│ │ ├── ZonedDateTimeConverter.java
│ │ └── package-info.java
│ │ ├── expression
│ │ ├── DefaultResolver.java
│ │ ├── Resolver.java
│ │ └── package-info.java
│ │ ├── locale
│ │ ├── BaseLocaleConverter.java
│ │ ├── LocaleBeanUtils.java
│ │ ├── LocaleBeanUtilsBean.java
│ │ ├── LocaleConvertUtils.java
│ │ ├── LocaleConvertUtilsBean.java
│ │ ├── LocaleConverter.java
│ │ ├── converters
│ │ │ ├── BigDecimalLocaleConverter.java
│ │ │ ├── BigIntegerLocaleConverter.java
│ │ │ ├── ByteLocaleConverter.java
│ │ │ ├── DateLocaleConverter.java
│ │ │ ├── DecimalLocaleConverter.java
│ │ │ ├── DoubleLocaleConverter.java
│ │ │ ├── FloatLocaleConverter.java
│ │ │ ├── IntegerLocaleConverter.java
│ │ │ ├── LongLocaleConverter.java
│ │ │ ├── ShortLocaleConverter.java
│ │ │ ├── StringLocaleConverter.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ │ ├── package-info.java
│ │ └── sql
│ │ ├── AbstractJdbcDynaClass.java
│ │ ├── ResultSetDynaClass.java
│ │ ├── ResultSetIterator.java
│ │ ├── RowSetDynaClass.java
│ │ ├── converters
│ │ ├── SqlDateConverter.java
│ │ ├── SqlTimeConverter.java
│ │ ├── SqlTimestampConverter.java
│ │ ├── locale
│ │ │ ├── SqlDateLocaleConverter.java
│ │ │ ├── SqlTimeLocaleConverter.java
│ │ │ ├── SqlTimestampLocaleConverter.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ │ └── package-info.java
└── javadoc
│ └── overview.html
├── media
└── logo.xcf
├── site
├── resources
│ ├── .htaccess
│ ├── download_beanutils.cgi
│ ├── images
│ │ └── logo.png
│ └── profile.jacoco
├── site.xml
└── xdoc
│ ├── bean-collections.xml
│ ├── building.xml
│ ├── download_beanutils.xml
│ ├── index.xml
│ ├── issue-tracking.xml
│ ├── mail-lists.xml
│ ├── proposal.xml
│ └── security.xml
└── test
└── java
└── org
└── apache
└── commons
└── beanutils2
├── AbstractChild.java
├── AbstractParent.java
├── AlphaBean.java
├── BasicDynaBeanTest.java
├── BeanComparatorTest.java
├── BeanIntrospectionDataTest.java
├── BeanMapTest.java
├── BeanPredicateTest.java
├── BeanPropertyValueChangeConsumerTest.java
├── BeanPropertyValueEqualsPredicateTest.java
├── BeanToPropertyValueTransformerTest.java
├── BeanUtilsBeanTest.java
├── BeanUtilsBenchCase.java
├── BeanWithInnerBean.java
├── BeanificationTest.java
├── BenchBean.java
├── BetaBean.java
├── Child.java
├── ConstructorUtilsTest.java
├── ConvertUtilsTest.java
├── DefaultIntrospectionContextTest.java
├── DynaBeanMapDecoratorTest.java
├── DynaBeanUtilsTest.java
├── DynaPropertyTest.java
├── DynaPropertyUtilsTest.java
├── ExtendMapBean.java
├── FluentIntrospectionTestBean.java
├── FluentPropertyBeanIntrospectorTest.java
├── IndexedPropertyTest.java
├── IndexedTestBean.java
├── LazyDynaBeanTest.java
├── LazyDynaClassTest.java
├── LazyDynaListTest.java
├── LazyDynaMapTest.java
├── MappedPropertyChildBean.java
├── MappedPropertyChildInterface.java
├── MappedPropertyTest.java
├── MappedPropertyTestBean.java
├── MappedPropertyTestInterface.java
├── MethodUtilsTest.java
├── NestedTestBean.java
├── PassTestException.java
├── PrimitiveBean.java
├── PropertyUtilsBeanTest.java
├── PropertyUtilsBenchCase.java
├── PropertyUtilsTest.java
├── PropsFirstPropertyUtilsBean.java
├── SonOfAlphaBean.java
├── SuppressPropertiesBeanIntrospectorTest.java
├── TestBean.java
├── TestBeanPackageSubclass.java
├── TestBeanPublicSubclass.java
├── ThrowExceptionConverter.java
├── WrapDynaBeanTest.java
├── bugs
├── EnumDeclaringClassTest.java
├── Jira157Test.java
├── Jira18Test.java
├── Jira273Test.java
├── Jira298Test.java
├── Jira339Test.java
├── Jira345Test.java
├── Jira347Test.java
├── Jira349Test.java
├── Jira357Test.java
├── Jira358Test.java
├── Jira359Test.java
├── Jira368Test.java
├── Jira369Test.java
├── Jira381Test.java
├── Jira411Test.java
├── Jira422Test.java
├── Jira422bTest.java
├── Jira454Test.java
├── Jira456Test.java
├── Jira458Test.java
├── Jira463Test.java
├── Jira465Test.java
├── Jira492Test.java
├── Jira493Test.java
├── Jira509Test.java
├── Jira520Test.java
├── Jira541Test.java
├── Jira61Test.java
├── Jira87Test.java
├── Jira92Test.java
└── other
│ ├── Jira18BeanFactory.java
│ ├── Jira273BeanFactory.java
│ ├── Jira298BeanFactory.java
│ ├── Jira492IndexedListsSupport.java
│ ├── Jira61BeanFactory.java
│ └── Jira87BeanFactory.java
├── converters
├── AbstractDateConverterTest.java
├── AbstractLocaleConverterTest.java
├── AbstractNumberConverterTest.java
├── ArrayConverterTest.java
├── BigDecimalConverterTest.java
├── BigDecimalLocaleConverterTest.java
├── BigIntegerConverterTest.java
├── BigIntegerLocaleConverterTest.java
├── BooleanConverterTest.java
├── ByteConverterTest.java
├── ByteLocaleConverterTest.java
├── CalendarConverterTest.java
├── CharacterConverterTest.java
├── ClassConverterTest.java
├── ClassReloader.java
├── ClassReloaderTest.java
├── ColorConverterTest.java
├── DateConverterTest.java
├── DateLocaleConverterTest.java
├── DimensionConverterTest.java
├── DoubleConverterTest.java
├── DoubleLocaleConverterTest.java
├── DurationConverterTest.java
├── EnumConverterTest.java
├── FileConverterTest.java
├── FloatConverterTest.java
├── FloatLocaleConverterTest.java
├── InetAddressConverterTest.java
├── IntegerConverterTest.java
├── IntegerLocaleConverterTest.java
├── LocalDateConverterTest.java
├── LocalDateTimeConverterTest.java
├── LocalTimeConverterTest.java
├── LocaleConverterTest.java
├── LongConverterTest.java
├── LongLocaleConverterTest.java
├── MemoryTest.java
├── MonthDayConverterTest.java
├── OffsetDateTimeConverterTest.java
├── OffsetTimeConverterTest.java
├── PathConverterTest.java
├── PatternConverterTest.java
├── PeriodConverterTest.java
├── PointConverterTest.java
├── ShortConverterTest.java
├── ShortLocaleConverterTest.java
├── StringConverterTest.java
├── URIConverterTest.java
├── URLConverterTest.java
├── UUIDConverterTest.java
├── YearConverterTest.java
├── YearMonthConverterTest.java
├── ZoneIdConverterTest.java
├── ZoneOffsetConverterTest.java
└── ZonedDateTimeConverterTest.java
├── expression
└── DefaultResolverTest.java
├── locale
├── LocaleBeanUtilsTest.java
├── LocaleBeanificationTest.java
└── LocaleConvertUtilsTest.java
├── memoryleaktests
├── MemoryLeakTest.java
└── pojotests
│ ├── CustomInteger.java
│ ├── SomeMappedPojo.java
│ └── SomePojo.java
├── priv
├── PackageBean.java
├── PrivateBean.java
├── PrivateBeanFactory.java
├── PrivateBeanSubclass.java
├── PrivateDirect.java
├── PrivateIndirect.java
└── PublicSubBean.java
└── sql
├── DynaResultSetTest.java
├── DynaRowSetTest.java
├── TestResultSet.java
├── TestResultSetMetaData.java
└── converters
├── SqlDateConverterTest.java
├── SqlTimeConverterTest.java
└── SqlTimestampConverterTest.java
/.asf.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | github:
17 | description: "Apache Commons Beanutils"
18 | homepage: https://commons.apache.org/beanutils/
19 |
20 | notifications:
21 | commits: commits@commons.apache.org
22 | issues: issues@commons.apache.org
23 | pullrequests: issues@commons.apache.org
24 | jira_options: link label
25 | jobs: notifications@commons.apache.org
26 | issues_bot_dependabot: notifications@commons.apache.org
27 | pullrequests_bot_dependabot: notifications@commons.apache.org
28 | issues_bot_codecov-commenter: notifications@commons.apache.org
29 | pullrequests_bot_codecov-commenter: notifications@commons.apache.org
30 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | * text=auto
17 |
--------------------------------------------------------------------------------
/.github/GH-ROBOTS.txt:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | # Keeps on creating FUD PRs in test code
17 | # Does not follow Apache disclosure policies
18 | User-agent: JLLeitschuh/security-research
19 | Disallow: *
20 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | version: 2
17 | updates:
18 | - package-ecosystem: "maven"
19 | directory: "/"
20 | schedule:
21 | interval: "weekly"
22 | day: "friday"
23 | - package-ecosystem: "github-actions"
24 | directory: "/"
25 | schedule:
26 | interval: "weekly"
27 | day: "friday"
28 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | Thanks for your contribution to [Apache Commons](https://commons.apache.org/)! Your help is appreciated!
21 |
22 | Before you push a pull request, review this list:
23 |
24 | - [ ] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
25 | - [ ] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself.
26 | - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice.
27 | - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
28 | - [ ] Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge.
29 |
--------------------------------------------------------------------------------
/.github/workflows/dependency-review.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # https://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: 'Dependency Review'
19 | on: [pull_request]
20 |
21 | permissions:
22 | contents: read
23 |
24 | jobs:
25 | dependency-review:
26 | runs-on: ubuntu-latest
27 | steps:
28 | - name: 'Checkout Repository'
29 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30 | - name: 'Dependency Review PR'
31 | uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
32 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | name: Java CI
17 |
18 | on:
19 | push:
20 | branches: [ master ]
21 | pull_request:
22 | branches: [ master ]
23 |
24 | permissions:
25 | contents: read
26 |
27 | jobs:
28 | build:
29 |
30 | runs-on: ubuntu-latest
31 | continue-on-error: ${{ matrix.experimental }}
32 | strategy:
33 | matrix:
34 | java: [ 8, 11, 17, 21 ]
35 | experimental: [false]
36 | include:
37 | - java: 24
38 | experimental: true
39 | - java: 25-ea
40 | experimental: true
41 |
42 | steps:
43 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44 | with:
45 | persist-credentials: false
46 | - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
47 | with:
48 | path: ~/.m2/repository
49 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
50 | restore-keys: |
51 | ${{ runner.os }}-maven-
52 | - name: Set up JDK ${{ matrix.java }}
53 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
54 | with:
55 | distribution: 'temurin'
56 | java-version: ${{ matrix.java }}
57 | - name: Build with Maven
58 | run: mvn --errors --show-version --batch-mode --no-transfer-progress -e
59 |
60 | # For Java 11, you can be more strict: -DadditionalJOption=-Xdoclint/package:-org.apache.commons.configuration2.plist
61 |
--------------------------------------------------------------------------------
/.github/workflows/scorecards-analysis.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache license, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the license for the specific language governing permissions and
14 | # limitations under the license.
15 |
16 | name: "Scorecards supply-chain security"
17 |
18 | on:
19 | branch_protection_rule:
20 | schedule:
21 | - cron: "30 1 * * 6" # Weekly on Saturdays
22 | push:
23 | branches: [ "master" ]
24 |
25 | permissions: read-all
26 |
27 | jobs:
28 |
29 | analysis:
30 |
31 | name: "Scorecards analysis"
32 | runs-on: ubuntu-latest
33 | permissions:
34 | # Needed to upload the results to the code-scanning dashboard.
35 | security-events: write
36 | actions: read
37 | id-token: write # This is required for requesting the JWT
38 | contents: read # This is required for actions/checkout
39 |
40 | steps:
41 |
42 | - name: "Checkout code"
43 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44 | with:
45 | persist-credentials: false
46 |
47 | - name: "Run analysis"
48 | uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # 2.4.2
49 | with:
50 | results_file: results.sarif
51 | results_format: sarif
52 | # A read-only PAT token, which is sufficient for the action to function.
53 | # The relevant discussion: https://github.com/ossf/scorecard-action/issues/188
54 | repo_token: ${{ secrets.GITHUB_TOKEN }}
55 | # Publish the results for public repositories to enable scorecard badges.
56 | # For more details: https://github.com/ossf/scorecard-action#publishing-results
57 | publish_results: true
58 |
59 | - name: "Upload artifact"
60 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
61 | with:
62 | name: SARIF file
63 | path: results.sarif
64 | retention-days: 5
65 |
66 | - name: "Upload to code-scanning"
67 | uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # 3.28.18
68 | with:
69 | sarif_file: results.sarif
70 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | .classpath
3 | .project
4 | .settings/
5 | /.idea/
6 | /commons-beanutils2.iml
7 |
--------------------------------------------------------------------------------
/BUILDING.txt:
--------------------------------------------------------------------------------
1 | # Apache BeanUtils build instructions
2 |
3 | Building BeanUtils requires:
4 |
5 | - JDK 6/OpenJDK 6 or later (recommended: JDK 8)
6 | http://www.oracle.com/technetwork/java/javase/downloads/
7 |
8 | - Apache Maven 3 or later (recommended: Maven 3.3)
9 | https://maven.apache.org/download.cgi
10 |
11 | The compiled BeanUtils JAR should work with Java 6 or later.
12 |
13 |
14 | To build target/commons-beanutils-*.jar
15 |
16 | mvn clean package
17 |
18 | or to install into your ~/.m2/repository
19 |
20 | mvn clean install
21 |
22 |
23 | You can skip the unit tests by adding the parameter
24 |
25 | -DskipTests=true
26 |
27 |
28 |
29 | To regenerate the web site (corresponding to the official
30 | https://commons.apache.org/proper/commons-beanutils/ ) do
31 |
32 | mvn clean site
33 |
34 | Note: the Apache Commons BeanUtils site should include a japicmp report for the
35 | purpose of checking API version compatibility, to enable this, use Java 7 or
36 | later and run instead:
37 |
38 | mvn clean package site -Pjapicmp
39 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 |
17 | The Apache code of conduct page is [https://www.apache.org/foundation/policies/conduct.html](https://www.apache.org/foundation/policies/conduct.html).
18 |
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | Apache Commons BeanUtils
2 | Copyright 2000-2025 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (https://www.apache.org/).
6 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
17 | The Apache Commons security page is [https://commons.apache.org/security.html](https://commons.apache.org/security.html).
18 |
--------------------------------------------------------------------------------
/src/conf/checkstyle-suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/assembly/bin.xml:
--------------------------------------------------------------------------------
1 |
17 |
20 | bin
21 |
22 | tar.gz
23 | zip
24 |
25 | false
26 |
27 |
28 |
29 | LICENSE.txt
30 | NOTICE.txt
31 | RELEASE-NOTES.txt
32 |
33 |
34 |
35 | target
36 |
37 |
38 | *.jar
39 |
40 |
41 |
42 | target/site/apidocs
43 | apidocs
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/main/assembly/src.xml:
--------------------------------------------------------------------------------
1 |
17 |
20 | src
21 |
22 | tar.gz
23 | zip
24 |
25 | ${artifactId}-${version}-src
26 |
27 |
28 |
29 | build.properties.sample
30 | build.xml
31 | src/conf/checkstyle.xml
32 | src/conf/checkstyle-suppressions.xml
33 | CONTRIBUTING.md
34 | BUILDING.txt
35 | LICENSE.txt
36 | NOTICE.txt
37 | pom.xml
38 | README.md
39 | RELEASE-NOTES.txt
40 |
41 |
42 |
43 | src
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/BeanAccessLanguageException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | * Thrown to indicate that the Bean Access Language cannot execute query against given bean. This is a runtime exception and access languages are
22 | * encouraged to subclass to create custom exceptions whenever appropriate.
23 | *
24 | * @since 1.7
25 | */
26 | public class BeanAccessLanguageException extends IllegalArgumentException {
27 |
28 | private static final long serialVersionUID = 1L;
29 |
30 | /**
31 | * Constructs a {@code BeanAccessLanguageException} without a detail message.
32 | */
33 | public BeanAccessLanguageException() {
34 | }
35 |
36 | /**
37 | * Constructs a {@code BeanAccessLanguageException} without a detail message.
38 | *
39 | * @param message the detail message explaining this exception
40 | */
41 | public BeanAccessLanguageException(final String message) {
42 | super(message);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/BeanIntrospector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2;
18 |
19 | import java.beans.IntrospectionException;
20 |
21 | /**
22 | *
23 | * Definition of an interface for components that can perform introspection on bean classes.
24 | *
25 | *
26 | * Before {@link PropertyUtils} can be used for interaction with a specific Java class, the class's properties have to be determined. This is called
27 | * introspection and is initiated automatically on demand. {@code PropertyUtils} does not perform introspection on its own, but delegates this task to
28 | * one or more objects implementing this interface. This makes it possible to customize introspection which may be useful for certain code bases using
29 | * non-standard conventions for accessing properties.
30 | *
31 | *
32 | * @since 1.9
33 | */
34 | public interface BeanIntrospector {
35 |
36 | /**
37 | * Performs introspection on a Java class. The current class to be inspected can be queried from the passed in {@code IntrospectionContext} object. A
38 | * typical implementation has to obtain this class, determine its properties according to the rules it implements, and add them to the passed in context
39 | * object.
40 | *
41 | * @param icontext the context object for interaction with the initiator of the introspection request
42 | * @throws IntrospectionException if an error occurs during introspection
43 | */
44 | void introspect(IntrospectionContext icontext) throws IntrospectionException;
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/ConversionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | * A ConversionException indicates that a call to {@code Converter.convert()} has failed to complete successfully.
22 | *
23 | * @since 1.3
24 | */
25 | public class ConversionException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = 1L;
28 |
29 | /**
30 | * Constructs a new instance with a message formatted using {@link String#format(String, Object...)}.
31 | *
32 | * @param format See {@link String#format(String, Object...)}.
33 | * @param args See {@link String#format(String, Object...)}.
34 | * @return a new instance with a message formatted using {@link String#format(String, Object...)}.
35 | * @since 2.0.0
36 | */
37 | public static ConversionException format(final String format, final Object... args) {
38 | return new ConversionException(String.format(format, args));
39 | }
40 |
41 | /**
42 | * Constructs a new exception with the specified message.
43 | *
44 | * @param message The message describing this exception
45 | */
46 | public ConversionException(final String message) {
47 | super(message);
48 | }
49 |
50 | /**
51 | * Constructs a new exception with the specified message and root cause.
52 | *
53 | * @param message The message describing this exception
54 | * @param cause The root cause of this exception
55 | */
56 | public ConversionException(final String message, final Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Constructs a new exception with the specified root cause.
62 | *
63 | * @param cause The root cause of this exception
64 | */
65 | public ConversionException(final Throwable cause) {
66 | super(cause.getMessage());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/Converter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | *
22 | * General purpose data type converter that can be registered and used within the BeanUtils package to manage the conversion of objects from one type to
23 | * another.
24 | *
25 | *
26 | *
27 | * Converter subclasses bundled with the BeanUtils library are required to be thread-safe, as users of the library may call conversion methods from more than
28 | * one thread simultaneously.
29 | *
30 | *
31 | *
32 | * Custom converter subclasses created by users of the library can be non-thread-safe if the application using them is single-threaded. However it is
33 | * recommended that they be written in a thread-safe manner anyway.
34 | *
35 | *
36 | * @param the convert type.
37 | * @since 1.3
38 | */
39 | @FunctionalInterface
40 | public interface Converter {
41 |
42 | /**
43 | * Convert the specified input object into an output object of the specified type.
44 | *
45 | * @param the result type.
46 | * @param type Data type to which this value should be converted
47 | * @param value The input value to be converted
48 | * @return The converted value
49 | * @throws ConversionException if conversion cannot be performed successfully
50 | */
51 | R convert(Class type, Object value);
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/NestedNullException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | * Thrown to indicate that the Bean Access Language cannot execute query against given bean since a nested bean referenced is null.
22 | *
23 | * @since 1.7
24 | */
25 | public class NestedNullException extends BeanAccessLanguageException {
26 |
27 | private static final long serialVersionUID = 1L;
28 |
29 | /**
30 | * Constructs a {@code NestedNullException} without a detail message.
31 | */
32 | public NestedNullException() {
33 | }
34 |
35 | /**
36 | * Constructs a {@code NestedNullException} without a detail message.
37 | *
38 | * @param message the detail message explaining this exception
39 | */
40 | public NestedNullException(final String message) {
41 | super(message);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/PropertyDescriptors.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | import java.beans.PropertyDescriptor;
21 |
22 | final class PropertyDescriptors {
23 |
24 | static final PropertyDescriptor[] EMPTY_ARRAY = {};
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/TestEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | * An {@code enum} test fixture.
22 | */
23 | public enum TestEnum {
24 |
25 | /** Test fixture. */
26 | A,
27 |
28 | /** Test fixture. */
29 | B,
30 |
31 | /** Test fixture. */
32 | C
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/ByteConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Byte objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Byte's default String conversion, or by using a Locale's pattern or by specifying
23 | * a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class ByteConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.ByteConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public ByteConverter() {
35 | super(false);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.ByteConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public ByteConverter(final Byte defaultValue) {
44 | super(false, defaultValue);
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.ByteConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public ByteConverter(final Number defaultValue) {
53 | this(defaultValue.byteValue());
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Byte.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/CalendarConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.util.Calendar;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.util.Calendar objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Calendar). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
28 | *
29 | * @since 1.8.0
30 | */
31 | public final class CalendarConverter extends DateTimeConverter {
32 |
33 | /**
34 | * Constructs a java.util.CalendarConverter that throws a {@code ConversionException} if an error occurs.
35 | */
36 | public CalendarConverter() {
37 | }
38 |
39 | /**
40 | * Constructs a java.util.CalendarConverter that returns a default value if an error occurs.
41 | *
42 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
43 | */
44 | public CalendarConverter(final Calendar defaultValue) {
45 | super(defaultValue);
46 | }
47 |
48 | /**
49 | * Gets the default type this {@code Converter} handles.
50 | *
51 | * @return The default type this {@code Converter} handles.
52 | */
53 | @Override
54 | protected Class getDefaultType() {
55 | return Calendar.class;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/ConverterFacade.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.util.Objects;
20 |
21 | import org.apache.commons.beanutils2.Converter;
22 |
23 | /**
24 | *
25 | * Provides a facade for {@link Converter} implementations preventing access to any public API in the implementation, other than that specified by
26 | * {@link Converter}.
27 | *
28 | * This implementation can be used to prevent registered {@link Converter} implementations that provide configuration options from being retrieved and modified.
29 | *
30 | *
31 | * @param The converter type.
32 | * @since 1.8.0
33 | */
34 | public final class ConverterFacade implements Converter {
35 |
36 | private final Converter converter;
37 |
38 | /**
39 | * Constructs a converter which delegates to the specified {@link Converter} implementation.
40 | *
41 | * @param converter The converter to delegate to
42 | */
43 | public ConverterFacade(final Converter converter) {
44 | this.converter = Objects.requireNonNull(converter, "converter");
45 | }
46 |
47 | /**
48 | * Convert the input object into an output object of the specified type by delegating to the underlying {@link Converter} implementation.
49 | *
50 | * @param type Data type to which this value should be converted
51 | * @param value The input value to be converted
52 | * @return The converted value.
53 | */
54 | @Override
55 | public R convert(final Class type, final Object value) {
56 | return converter.convert(type, value);
57 | }
58 |
59 | /**
60 | * Provide a String representation of this facade implementation sand the underlying {@link Converter} it delegates to.
61 | *
62 | * @return A String representation of this facade implementation sand the underlying {@link Converter} it delegates to
63 | */
64 | @Override
65 | public String toString() {
66 | return "ConverterFacade[" + converter.toString() + "]";
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/DateConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.util.Date;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.util.Date objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Date). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
28 | *
29 | * @since 1.8.0
30 | */
31 | public final class DateConverter extends DateTimeConverter {
32 |
33 | /**
34 | * Constructs a java.util.DateConverter that throws a {@code ConversionException} if an error occurs.
35 | */
36 | public DateConverter() {
37 | }
38 |
39 | /**
40 | * Constructs a java.util.DateConverter that returns a default value if an error occurs.
41 | *
42 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
43 | */
44 | public DateConverter(final Date defaultValue) {
45 | super(defaultValue);
46 | }
47 |
48 | /**
49 | * Gets the default type this {@code Converter} handles.
50 | *
51 | * @return The default type this {@code Converter} handles.
52 | */
53 | @Override
54 | protected Class getDefaultType() {
55 | return Date.class;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/DoubleConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Double objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Double's default String conversion, or by using a Locale's pattern or by
23 | * specifying a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class DoubleConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.DoubleConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public DoubleConverter() {
35 | super(true);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.DoubleConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public DoubleConverter(final Double defaultValue) {
44 | super(true, defaultValue);
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.DoubleConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public DoubleConverter(final Number defaultValue) {
53 | this(defaultValue.doubleValue());
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Double.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/FloatConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Float objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Float's default String conversion, or by using a Locale's pattern or by specifying
23 | * a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class FloatConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.FloatConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public FloatConverter() {
35 | super(true);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.FloatConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public FloatConverter(final Float defaultValue) {
44 | super(true, defaultValue);
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.FloatConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public FloatConverter(final Number defaultValue) {
53 | this(defaultValue.floatValue());
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Float.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/IntegerConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Integer objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Integer's default String conversion, or by using a Locale's pattern or by
23 | * specifying a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class IntegerConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.IntegerConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public IntegerConverter() {
35 | super(false);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.IntegerConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public IntegerConverter(final Integer defaultValue) {
44 | super(false, defaultValue);
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.IntegerConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public IntegerConverter(final Number defaultValue) {
53 | this(defaultValue.intValue());
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Integer.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/LocalDateConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.time.LocalDate;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.time.LocalDate objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Calendar). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | *
28 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
29 | *
30 | *
31 | * @since 2.0
32 | * @see java.time.LocalDate
33 | */
34 | public final class LocalDateConverter extends DateTimeConverter {
35 |
36 | /**
37 | * Constructs a java.time.LocalDateConverter that throws a {@code ConversionException} if an error occurs.
38 | */
39 | public LocalDateConverter() {
40 | }
41 |
42 | /**
43 | * Constructs a java.time.LocalDateConverter that returns a default value if an error occurs.
44 | *
45 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
46 | */
47 | public LocalDateConverter(final LocalDate defaultValue) {
48 | super(defaultValue);
49 | }
50 |
51 | /**
52 | * Gets the default type this {@code Converter} handles.
53 | *
54 | * @return The default type this {@code Converter} handles.
55 | */
56 | @Override
57 | protected Class getDefaultType() {
58 | return LocalDate.class;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/LocalDateTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.time.LocalDateTime;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.time.LocalDateTime objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Calendar). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | *
28 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
29 | *
30 | *
31 | * @since 2.0
32 | * @see java.time.LocalDateTime
33 | */
34 | public final class LocalDateTimeConverter extends DateTimeConverter {
35 |
36 | /**
37 | * Constructs a java.time.LocalDateTimeConverter that throws a {@code ConversionException} if an error occurs.
38 | */
39 | public LocalDateTimeConverter() {
40 | }
41 |
42 | /**
43 | * Constructs a java.time.LocalDateTimeConverter that returns a default value if an error occurs.
44 | *
45 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
46 | */
47 | public LocalDateTimeConverter(final LocalDateTime defaultValue) {
48 | super(defaultValue);
49 | }
50 |
51 | /**
52 | * Gets the default type this {@code Converter} handles.
53 | *
54 | * @return The default type this {@code Converter} handles.
55 | */
56 | @Override
57 | protected Class getDefaultType() {
58 | return LocalDateTime.class;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/LocaleConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * https://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.commons.beanutils2.converters;
20 |
21 | import java.util.Locale;
22 |
23 | /**
24 | * {@link org.apache.commons.beanutils2.Converter} implementation that handles conversion to and from {@link Locale}.
25 | *
26 | * @since 2.0.0
27 | */
28 | public class LocaleConverter extends AbstractConverter {
29 |
30 | /**
31 | * Construct a {@link Locale}Converter that throws a {@code ConversionException} if an error occurs.
32 | */
33 | public LocaleConverter() {
34 | }
35 |
36 | /**
37 | * Constructs a {@link org.apache.commons.beanutils2.Converter} that will return the specified default value if a conversion error occurs.
38 | *
39 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
40 | */
41 | public LocaleConverter(final Locale defaultValue) {
42 | super(defaultValue);
43 | }
44 |
45 | /**
46 | * Converts the specified input object into an output object of the specified type.
47 | *
48 | * @param type Data type to which this value should be converted.
49 | * @param value The String property value to convert.
50 | * @return A {@link Locale} which represents the configuration property value.
51 | * @throws NullPointerException If the value is null.
52 | */
53 | @Override
54 | protected T convertToType(final Class type, final Object value) throws Throwable {
55 | if (Locale.class.isAssignableFrom(type)) {
56 | final String stringValue = toString(value);
57 | return type.cast(Locale.forLanguageTag(stringValue));
58 | }
59 |
60 | throw conversionException(type, value);
61 | }
62 |
63 | /**
64 | * Gets the default type this {@code Converter} handles.
65 | *
66 | * @return The default type this {@code Converter} handles.
67 | * @since 2.0.0
68 | */
69 | @Override
70 | protected Class getDefaultType() {
71 | return Locale.class;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/LongConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Long objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Long's default String conversion, or by using a Locale's pattern or by specifying
23 | * a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class LongConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.LongConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public LongConverter() {
35 | super(false);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.LongConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public LongConverter(final Long defaultValue) {
44 | super(false, defaultValue);
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.LongConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public LongConverter(final Number defaultValue) {
53 | this(defaultValue.longValue());
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Long.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/OffsetDateTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.time.OffsetDateTime;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.time.OffsetDateTime objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Calendar). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | *
28 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
29 | *
30 | *
31 | * @since 2.0
32 | * @see java.time.OffsetDateTime
33 | */
34 | public final class OffsetDateTimeConverter extends DateTimeConverter {
35 |
36 | /**
37 | * Constructs a java.time.OffsetDateTimeConverter that throws a {@code ConversionException} if an error occurs.
38 | */
39 | public OffsetDateTimeConverter() {
40 | }
41 |
42 | /**
43 | * Constructs a java.time.OffsetDateTimeConverter that returns a default value if an error occurs.
44 | *
45 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
46 | */
47 | public OffsetDateTimeConverter(final OffsetDateTime defaultValue) {
48 | super(defaultValue);
49 | }
50 |
51 | /**
52 | * Gets the default type this {@code Converter} handles.
53 | *
54 | * @return The default type this {@code Converter} handles.
55 | */
56 | @Override
57 | protected Class getDefaultType() {
58 | return OffsetDateTime.class;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/ShortConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | /**
20 | * {@link NumberConverter} implementation that handles conversion to and from java.lang.Short objects.
21 | *
22 | * This implementation can be configured to handle conversion either by using Short's default String conversion, or by using a Locale's pattern or by specifying
23 | * a format pattern. See the {@link NumberConverter} documentation for further details.
24 | *
25 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
26 | *
27 | * @since 1.3
28 | */
29 | public final class ShortConverter extends NumberConverter {
30 |
31 | /**
32 | * Constructs a java.lang.ShortConverter that throws a {@code ConversionException} if an error occurs.
33 | */
34 | public ShortConverter() {
35 | super(false);
36 | }
37 |
38 | /**
39 | * Constructs a java.lang.ShortConverter that returns a default value if an error occurs.
40 | *
41 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
42 | */
43 | public ShortConverter(final Number defaultValue) {
44 | this(defaultValue.shortValue());
45 | }
46 |
47 | /**
48 | * Constructs a java.lang.ShortConverter that returns a default value if an error occurs.
49 | *
50 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
51 | */
52 | public ShortConverter(final Short defaultValue) {
53 | super(false, defaultValue);
54 | }
55 |
56 | /**
57 | * Gets the default type this {@code Converter} handles.
58 | *
59 | * @return The default type this {@code Converter} handles.
60 | * @since 1.8.0
61 | */
62 | @Override
63 | protected Class getDefaultType() {
64 | return Short.class;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/URIConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.net.URI;
20 |
21 | /**
22 | * {@link org.apache.commons.beanutils2.Converter} implementation that handles conversion to and from java.net.URI objects.
23 | *
24 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
25 | *
26 | * @since 2.0
27 | */
28 | public final class URIConverter extends AbstractConverter {
29 |
30 | /**
31 | * Constructs a java.net.URIConverter that throws a {@code ConversionException} if an error occurs.
32 | */
33 | public URIConverter() {
34 | }
35 |
36 | /**
37 | * Constructs a java.net.URIConverter that returns a default value if an error occurs.
38 | *
39 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
40 | */
41 | public URIConverter(final URI defaultValue) {
42 | super(defaultValue);
43 | }
44 |
45 | /**
46 | *
47 | * Converts a java.net.URI or object into a String.
48 | *
49 | *
50 | * @param Target type of the conversion.
51 | * @param type Data type to which this value should be converted.
52 | * @param value The input value to be converted.
53 | * @return The converted value.
54 | * @throws Throwable if an error occurs converting to the specified type
55 | * @since 2.0
56 | */
57 | @Override
58 | protected T convertToType(final Class type, final Object value) throws Throwable {
59 | if (URI.class.equals(type)) {
60 | return type.cast(new URI(toString(value)));
61 | }
62 |
63 | throw conversionException(type, value);
64 | }
65 |
66 | /**
67 | * Gets the default type this {@code Converter} handles.
68 | *
69 | * @return The default type this {@code Converter} handles.
70 | * @since 2.0
71 | */
72 | @Override
73 | protected Class getDefaultType() {
74 | return URI.class;
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/ZonedDateTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.converters;
18 |
19 | import java.time.ZonedDateTime;
20 |
21 | /**
22 | * {@link DateTimeConverter} implementation that handles conversion to and from java.time.ZonedDateTime objects.
23 | *
24 | * This implementation can be configured to handle conversion either by using a Locale's default format or by specifying a set of format patterns (note, there
25 | * is no default String conversion for Calendar). See the {@link DateTimeConverter} documentation for further details.
26 | *
27 | *
28 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
29 | *
30 | *
31 | * @since 2.0
32 | * @see java.time.ZonedDateTime
33 | */
34 | public final class ZonedDateTimeConverter extends DateTimeConverter {
35 |
36 | /**
37 | * Constructs a java.time.ZonedDateTimeConverter that throws a {@code ConversionException} if an error occurs.
38 | */
39 | public ZonedDateTimeConverter() {
40 | }
41 |
42 | /**
43 | * Constructs a java.time.ZonedDateTimeConverter that returns a default value if an error occurs.
44 | *
45 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
46 | */
47 | public ZonedDateTimeConverter(final ZonedDateTime defaultValue) {
48 | super(defaultValue);
49 | }
50 |
51 | /**
52 | * Gets the default type this {@code Converter} handles.
53 | *
54 | * @return The default type this {@code Converter} handles.
55 | */
56 | @Override
57 | protected Class getDefaultType() {
58 | return ZonedDateTime.class;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/converters/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Standard implementations of the {@link org.apache.commons.beanutils2.Converter} interface that are pre-registered with
20 | * {@link org.apache.commons.beanutils2.ConvertUtils} at startup time.
21 | */
22 | package org.apache.commons.beanutils2.converters;
23 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/expression/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Contains the {@link org.apache.commons.beanutils2.expression.Resolver} interface and implementations.
20 | */
21 | package org.apache.commons.beanutils2.expression;
22 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/locale/LocaleConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2.locale;
19 |
20 | import org.apache.commons.beanutils2.ConversionException;
21 | import org.apache.commons.beanutils2.Converter;
22 |
23 | /**
24 | *
25 | * General purpose locale-sensitive data type converter that can be registered and used within the BeanUtils package to manage the conversion of objects from
26 | * one type to another.
27 | *
28 | * @param The converter type.
29 | */
30 | public interface LocaleConverter extends Converter {
31 |
32 | /**
33 | * Convert the specified locale-sensitive input object into an output object of the specified type.
34 | *
35 | * @param the result type.
36 | * @param type Data type to which this value should be converted
37 | * @param value The input value to be converted
38 | * @param pattern The user-defined pattern is used for the input object formatting.
39 | * @return The converted value
40 | * @throws ConversionException if conversion cannot be performed successfully or if the target type is not supported
41 | */
42 | R convert(Class type, Object value, String pattern);
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/locale/converters/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Standard implementations of the locale-aware {@link org.apache.commons.beanutils2.locale.LocaleConverter} interface that are pre-registered with locale-aware
20 | * {@link org.apache.commons.beanutils2.locale.LocaleConvertUtils} at startup time.
21 | */
22 | package org.apache.commons.beanutils2.locale.converters;
23 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/locale/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Locale-aware extensions of the standard BeanUtils classes. This package allows locale-dependent population of JavaBeans.
20 | */
21 | package org.apache.commons.beanutils2.locale;
22 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/sql/converters/SqlDateConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.commons.beanutils2.sql.converters;
18 |
19 | import java.sql.Date;
20 |
21 | import org.apache.commons.beanutils2.converters.DateTimeConverter;
22 |
23 | /**
24 | * {@link DateTimeConverter} implementation that handles conversion to and from java.sql.Date objects.
25 | *
26 | * This implementation can be configured to handle conversion either by using java.sql.Date's default String conversion, or by using a Locale's default format
27 | * or by specifying a set of format patterns. See the {@link DateTimeConverter} documentation for further details.
28 | *
29 | * Can be configured to either return a default value or throw a {@code ConversionException} if a conversion error occurs.
30 | *
31 | * @since 1.3
32 | */
33 | public final class SqlDateConverter extends DateTimeConverter {
34 |
35 | /**
36 | * Constructs a java.sql.DateConverter that throws a {@code ConversionException} if an error occurs.
37 | */
38 | public SqlDateConverter() {
39 | }
40 |
41 | /**
42 | * Constructs a java.sql.DateConverter that returns a default value if an error occurs.
43 | *
44 | * @param defaultValue The default value to be returned if the value to be converted is missing or an error occurs converting the value.
45 | */
46 | public SqlDateConverter(final Date defaultValue) {
47 | super(defaultValue);
48 | }
49 |
50 | /**
51 | * Gets the default type this {@code Converter} handles.
52 | *
53 | * @return The default type this {@code Converter} handles.
54 | * @since 1.8.0
55 | */
56 | @Override
57 | protected Class getDefaultType() {
58 | return Date.class;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/sql/converters/locale/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Contains code that relies on the {@link java.sql} module.
20 | */
21 | package org.apache.commons.beanutils2.sql.converters.locale;
22 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/sql/converters/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Contains code that relies on the {@link java.sql} module.
20 | */
21 | package org.apache.commons.beanutils2.sql.converters;
22 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/beanutils2/sql/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /**
19 | * Contains code that relies on the {@link java.sql} module.
20 | */
21 | package org.apache.commons.beanutils2.sql;
22 |
--------------------------------------------------------------------------------
/src/main/javadoc/overview.html:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | Overview Documentation for Apache Commons BeanUtils
20 |
21 |
22 |
The Bean Introspection Utilities component of the Apache Commons
23 | subproject offers low-level utility classes that assist in getting and setting
24 | property values on Java classes that follow the naming design patterns outlined
25 | in the JavaBeans Specification, as well as mechanisms for dynamically defining
26 | and accessing bean properties.
27 |
28 |
See the
29 |
30 | Package Description for the org.apache.commons.beanutils2
31 | package for more information.
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/media/logo.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/commons-beanutils/732d4940f96308e5e8718c18136ee13579897b4e/src/media/logo.xcf
--------------------------------------------------------------------------------
/src/site/resources/.htaccess:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | AddCharset utf-8 .txt .html
17 |
--------------------------------------------------------------------------------
/src/site/resources/download_beanutils.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Just call the standard mirrors.cgi script. It will use download.html
3 | # as the input template.
4 | exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
--------------------------------------------------------------------------------
/src/site/resources/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/commons-beanutils/732d4940f96308e5e8718c18136ee13579897b4e/src/site/resources/images/logo.png
--------------------------------------------------------------------------------
/src/site/resources/profile.jacoco:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // https://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/AbstractChild.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | */
22 | public class AbstractChild implements Child {
23 |
24 | private String name;
25 |
26 | @Override
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | protected void setName(final String name) {
32 | this.name = name;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/AbstractParent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | */
22 | public abstract class AbstractParent {
23 |
24 | private Child child;
25 |
26 | public Child getChild() {
27 | return child;
28 | }
29 |
30 | public String testAddChild(final Child child) {
31 | this.child = child;
32 | return child.getName();
33 | }
34 |
35 | /**
36 | * Method which matches signature but which has wrong parameters
37 | */
38 | public String testAddChild(final String badParameter) {
39 | return null;
40 | }
41 |
42 | public String testAddChild2(final String ignore, final Child child) {
43 | this.child = child;
44 | return child.getName();
45 | }
46 |
47 | /**
48 | * Method which matches signature but which has wrong parameters
49 | */
50 | public String testAddChild2(final String ignore, final String badParameter) {
51 | return null;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/AlphaBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | */
22 | public class AlphaBean extends AbstractParent implements Child {
23 |
24 | private String name;
25 |
26 | public AlphaBean() {
27 | }
28 |
29 | public AlphaBean(final String name) {
30 | setName(name);
31 | }
32 |
33 | /**
34 | * Used for testing that correct exception is thrown.
35 | */
36 | public void bogus(final String badParameter) {
37 | // noop
38 | }
39 |
40 | @Override
41 | public String getName() {
42 | return name;
43 | }
44 |
45 | public void setName(final String name) {
46 | this.name = name;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/BeanPredicateTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | import static org.junit.jupiter.api.Assertions.assertFalse;
21 | import static org.junit.jupiter.api.Assertions.assertTrue;
22 |
23 | import java.util.function.Predicate;
24 |
25 | import org.junit.jupiter.api.Test;
26 |
27 | /**
28 | * Unit test for {@link BeanPredicate}
29 | */
30 | public class BeanPredicateTest {
31 |
32 | @Test
33 | public void testEqual() {
34 | final Predicate p = s -> s.equals("foo");
35 | final BeanPredicate predicate = new BeanPredicate<>("stringProperty", p);
36 | assertTrue(predicate.test(new TestBean("foo")));
37 | assertFalse(predicate.test(new TestBean("bar")));
38 | }
39 |
40 | @Test
41 | public void testInstanceOf() {
42 | final Predicate p = String.class::isInstance;
43 | final BeanPredicate predicate = new BeanPredicate<>("stringProperty", p);
44 | assertTrue(predicate.test(new TestBean("foo")));
45 | assertTrue(predicate.test(new TestBean("bar")));
46 | }
47 |
48 | @Test
49 | public void testNotEqual() {
50 | final Predicate p = s -> !s.equals("foo");
51 | final BeanPredicate predicate = new BeanPredicate<>("stringProperty", p);
52 | assertFalse(predicate.test(new TestBean("foo")));
53 | assertTrue(predicate.test(new TestBean("bar")));
54 | }
55 |
56 | @Test
57 | public void testNull() {
58 | final Predicate p = s -> s == null;
59 | final BeanPredicate predicate = new BeanPredicate<>("stringProperty", p);
60 | final String nullString = null;
61 | assertTrue(predicate.test(new TestBean(nullString)));
62 | assertFalse(predicate.test(new TestBean("bar")));
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | import java.util.Properties;
21 |
22 | /**
23 | * Bean with inner bean.
24 | */
25 | public class BeanWithInnerBean {
26 | public class InnerBean {
27 | private final Properties fish = new Properties();
28 |
29 | public String getFish(final String key) {
30 | return fish.getProperty(key);
31 | }
32 |
33 | public void setFish(final String key, final String value) {
34 | fish.setProperty(key, value);
35 | }
36 | }
37 |
38 | private final InnerBean innerBean = new InnerBean();
39 |
40 | public BeanWithInnerBean() {
41 | }
42 |
43 | public InnerBean getInnerBean() {
44 | return innerBean;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/BetaBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | */
22 | public class BetaBean extends AbstractChild {
23 |
24 | private String secret = "utah";
25 |
26 | public BetaBean(final String name) {
27 | setName(name);
28 | }
29 |
30 | public String getSecret() {
31 | return secret;
32 | }
33 |
34 | public void setNoGetterMappedProperty(final String secret, final String key) {
35 | this.secret = "MAP:" + secret;
36 | }
37 |
38 | public void setNoGetterProperty(final String secret) {
39 | this.secret = secret;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/Child.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | /**
21 | */
22 | public interface Child {
23 |
24 | String getName();
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.apache.commons.beanutils2;
19 |
20 | import java.util.Hashtable;
21 |
22 | /**
23 | * Used to test
24 | */
25 |
26 | public class ExtendMapBean extends Hashtable