diff options
author | Karsten <karsten.budaeus@sbb.ch> | 2024-10-22 13:20:42 +0200 |
---|---|---|
committer | Karsten <karsten.budaeus@sbb.ch> | 2024-10-22 13:20:42 +0200 |
commit | a2f4bf1c6e2b5eea946d65acb208f7e7848f6015 (patch) | |
tree | 6a9c9e4a3ecc4772aa85ae11f91d685293834e4b /src | |
parent | Update pom version to 1.4.8. to match latest release tag 1.4.8. (diff) | |
download | UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar.gz UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar.bz2 UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar.lz UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar.xz UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.tar.zst UIC-barcode-a2f4bf1c6e2b5eea946d65acb208f7e7848f6015.zip |
Diffstat (limited to 'src')
12 files changed, 104 insertions, 111 deletions
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java index e5cfb4c..f4feb42 100644 --- a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java +++ b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java @@ -19,7 +19,7 @@ public class Asn1Integer { } public Long longObject () { - return Long.valueOf(value()); + return value(); } public Asn1Integer(Long num) { diff --git a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java index 647a550..d834acd 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java @@ -9,10 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import org.uic.barcode.asn1.datatypes.Asn1Default; import org.uic.barcode.asn1.datatypes.Asn1Optional; @@ -31,7 +28,7 @@ import org.uic.barcode.logger.LoggerFactory; * * @see ITU-T Recommendation <a * href="http://www.itu.int/ITU-T/recommendations/rec.aspx?rec=x.691">X.691</a> - * + * <p> * TODO: Cover the rest of (useful) ASN.1 datatypes and PER-visible constraints, * write unit tests for them. Clean-up, do more refactoring. **/ @@ -290,7 +287,7 @@ public final class UperEncoder { T obj, Asn1ContainerFieldSorter sorter) throws IllegalArgumentException, IllegalAccessException { for (Field f : sorter.extensionFields) { - //CG elements with default value will not be not included + //CG elements with a default value will not be included if (f.get(obj) != null && !isDefault(f,f.get(obj)) ) { return true; } @@ -356,7 +353,7 @@ public final class UperEncoder { if (hasExtensionMarker) { boolean extensionIsActive = bitqueue.get(); if (extensionIsActive) { - //in extensions are encoded as uncontraint integers, thius an Asn1BigInteger type should be used(a lower range bound might be applied). + //in extensions are encoded as uncontraint integers, thius an Asn1BigInteger type should be used (a lower range bound might be applied). throw new UnsupportedOperationException("int extension are not supported yet"); } } diff --git a/src/main/java/org/uic/barcode/dynamicFrame/api/SimpleDynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/api/SimpleDynamicFrame.java index 15f169b..7517880 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/api/SimpleDynamicFrame.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/api/SimpleDynamicFrame.java @@ -115,8 +115,8 @@ public class SimpleDynamicFrame implements IDynamicFrame { /**
* Verify the level 2 signature
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
+ * <p>
+ * Note: an appropriate security provider (e.g. BC) must be registered before
*
* @return the int
* @throws EncodingFormatException
@@ -129,10 +129,10 @@ public class SimpleDynamicFrame implements IDynamicFrame { /**
* Verify the level 2 signature
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
+ * <p>
+ * Note: an appropriate security provider (e.g. BC) must be registered before
*
- * @param provider the registered security provider
+ * @param prov the registered security provider
* @return the return error code
* @throws EncodingFormatException
*/
@@ -144,7 +144,7 @@ public class SimpleDynamicFrame implements IDynamicFrame { if (getLevel2Data() == null
|| getLevel2Data().getLevel1Data() == null
|| getLevel2Data().getLevel1Data().getLevel2KeyAlg() == null
- || getLevel2Data().getLevel1Data().getLevel2KeyAlg().length() == 0) {
+ || getLevel2Data().getLevel1Data().getLevel2KeyAlg().isEmpty()) {
return Constants.LEVEL2_VALIDATION_NO_KEY;
}
@@ -152,7 +152,7 @@ public class SimpleDynamicFrame implements IDynamicFrame { String level2SigAlg = this.getLevel2Data().getLevel1Data().getLevel2SigningAlg();
- if (level2KeyAlg == null || level2KeyAlg.length() == 0) {
+ if (level2KeyAlg == null || level2KeyAlg.isEmpty()) {
return Constants.LEVEL2_VALIDATION_NO_KEY;
}
@@ -166,7 +166,7 @@ public class SimpleDynamicFrame implements IDynamicFrame { } catch (Exception e1) {
return Constants.LEVEL2_VALIDATION_KEY_ALG_NOT_IMPLEMENTED;
}
- if (keyAlgName == null || keyAlgName.length() == 0) {
+ if (keyAlgName == null || keyAlgName.isEmpty()) {
return Constants.LEVEL2_VALIDATION_KEY_ALG_NOT_IMPLEMENTED;
}
@@ -260,7 +260,6 @@ public class SimpleDynamicFrame implements IDynamicFrame { if (getLevel2Data() == null
|| getLevel2Data().getLevel1Signature() == null
- || getLevel2Data().getLevel1Signature() == null
|| getLevel2Data().getLevel1Signature().length == 0) {
return Constants.LEVEL1_VALIDATION_NO_SIGNATURE;
}
@@ -274,13 +273,13 @@ public class SimpleDynamicFrame implements IDynamicFrame { if (getLevel2Data() != null
&& getLevel2Data().getLevel1Data() != null
&& getLevel2Data().getLevel1Data().getLevel1SigningAlg() != null
- && getLevel2Data().getLevel1Data().getLevel1SigningAlg().length() > 0) {
+ && !getLevel2Data().getLevel1Data().getLevel1SigningAlg().isEmpty()) {
signingAlgorithmOid = getLevel2Data().getLevel1Data().getLevel1SigningAlg();
} else {
signingAlgorithmOid = signatureAlgorithmOid;
}
- if (signingAlgorithmOid == null || signingAlgorithmOid.length() == 0) {
+ if (signingAlgorithmOid == null || signingAlgorithmOid.isEmpty()) {
return Constants.LEVEL1_VALIDATION_NO_SIGNATURE;
}
@@ -426,12 +425,10 @@ public class SimpleDynamicFrame implements IDynamicFrame { /**
* Sign the contained data block.
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
+ * <p>
+ * Note: an appropriate security provider (e.g. BC) must be registered before
*
* @param key the key
- * @return
- * @return the byte[]
* @throws Exception
*/
@Override
@@ -443,13 +440,11 @@ public class SimpleDynamicFrame implements IDynamicFrame { /**
* Sign the contained data block.
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
+ * <p>
+ * Note: an appropriate security provider (e.g. BC) must be registered before
*
* @param key the key
- * @param security provider - security provider that must be sued to create the signature
- * @return
- * @return the byte[]
+ * @param prov provider - security provider that must be sued to create the signature
* @throws Exception
*/
@Override
diff --git a/src/main/java/org/uic/barcode/package.html b/src/main/java/org/uic/barcode/package.html index 075af29..e68d27f 100644 --- a/src/main/java/org/uic/barcode/package.html +++ b/src/main/java/org/uic/barcode/package.html @@ -1,5 +1,5 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
+<html lang="en">
<head></head>
<body>
diff --git a/src/main/java/org/uic/barcode/staticFrame/package.html b/src/main/java/org/uic/barcode/staticFrame/package.html index 5ad7515..95e1fc9 100644 --- a/src/main/java/org/uic/barcode/staticFrame/package.html +++ b/src/main/java/org/uic/barcode/staticFrame/package.html @@ -1,6 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head></head>
+<html lang="en">
+<head><title>static bar code header frame</title></head>
<body>
<h1>static bar code header frame</h1>
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/package.html b/src/main/java/org/uic/barcode/ticket/api/asn/package.html index 214572b..4d59caa 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/package.html +++ b/src/main/java/org/uic/barcode/ticket/api/asn/package.html @@ -1,9 +1,9 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
+<html lang="en">
<head>asn
</head>
<body>Provides code generated from the asn.1 specification using
- the openAsn compiler to implement the asn.1 encoduing and decoding
+ the openAsn compiler to implement the asn.1 encoding and decoding
using unaligned PER encoding.
</body>
</html>
\ No newline at end of file diff --git a/src/main/java/org/uic/barcode/ticket/api/impl/package.html b/src/main/java/org/uic/barcode/ticket/api/impl/package.html index f2ef54e..9c0cffe 100644 --- a/src/main/java/org/uic/barcode/ticket/api/impl/package.html +++ b/src/main/java/org/uic/barcode/ticket/api/impl/package.html @@ -1,5 +1,5 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
+<html lang="en">
<head>Ticket Data Implementation
</head>
<body>
diff --git a/src/main/java/org/uic/barcode/ticket/api/spec/package.html b/src/main/java/org/uic/barcode/ticket/api/spec/package.html index f3961b8..7105cd9 100644 --- a/src/main/java/org/uic/barcode/ticket/api/spec/package.html +++ b/src/main/java/org/uic/barcode/ticket/api/spec/package.html @@ -1,13 +1,12 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
+<html lang="en">
<head>UIC ticket interface
</head>
<body>
Provides the interface specification of the ticket data. Any ticket
data implementation which wants to use the provided encoder / decoder
function must implement this interface. A simple implementation is
- provided in package
- <b>impl
- </p>.
+ provided in the package
+ <b>impl</b>.
</body>
</html>
\ No newline at end of file diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java index 615f646..da8092b 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java @@ -69,8 +69,10 @@ import org.uic.barcode.ticket.api.asn.omv1.SequenceOfRegisteredLuggageType; import org.uic.barcode.ticket.api.asn.omv1.SequenceOfServiceBrands;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTariffType;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerId;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfValidityPeriodType;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfViaStationType;
import org.uic.barcode.ticket.api.asn.omv1.SeriesDetailType;
import org.uic.barcode.ticket.api.asn.omv1.ServiceType;
@@ -92,8 +94,6 @@ import org.uic.barcode.ticket.api.asn.omv1.VatDetailType; import org.uic.barcode.ticket.api.asn.omv1.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv1.VoucherData;
import org.uic.barcode.ticket.api.asn.omv1.ZoneType;
-import org.uic.barcode.ticket.api.asn.omv1.SequenceOfValidityPeriodType;
-import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
import org.uic.barcode.ticket.api.spec.ICardReference;
@@ -745,7 +745,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { }
- if (document.getTariffs() != null && document.getTariffs().size() > 0){
+ if (document.getTariffs() != null && !document.getTariffs().isEmpty()){
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
}
@@ -753,7 +753,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -765,7 +765,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -795,11 +795,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setFromStationNameUTF8(route.getFromStationName());
asnData.setToStationNameUTF8(route.getToStationName());
- if (route.getValidRegionList()!= null && route.getValidRegionList().size() > 0) {
+ if (route.getValidRegionList()!= null && !route.getValidRegionList().isEmpty()) {
asnData.setValidReturnRegion(encodeRegionCollection(route.getValidRegionList(), issuingDate));
}
- if (route.getValidRegionDesc() != null && route.getValidRegionDesc().length() > 0){
+ if (route.getValidRegionDesc() != null && !route.getValidRegionDesc().isEmpty()){
asnData.setValidReturnRegionDesc(route.getValidRegionDesc());
}
@@ -823,7 +823,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setMaxNonHandLuggagePieces(UicEncoderUtils.getRestrictedIntWithDefault(luggageRestriction.getMaxNonHandLuggagePieces(),1,99,1));
- if (luggageRestriction.getRegisteredLuggage() != null && luggageRestriction.getRegisteredLuggage().size() > 0) {
+ if (luggageRestriction.getRegisteredLuggage() != null && !luggageRestriction.getRegisteredLuggage().isEmpty()) {
asnData.setRegisteredLuggage(encodeRegisteredLuggage(luggageRestriction.getRegisteredLuggage()));
}
@@ -931,7 +931,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -943,12 +943,12 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
- if (document.getIncludedAddOns() != null && document.getIncludedAddOns().size() > 0) {
+ if (document.getIncludedAddOns() != null && !document.getIncludedAddOns().isEmpty()) {
asnData.setIncludedAddOns(encodeIncludedAddons(document.getIncludedAddOns(),issuingDate, document.getClassCode()));
}
@@ -1060,7 +1060,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
@@ -1188,7 +1188,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setCity(Asn1BigInteger.toAsn1(data.getCity()));
}
- if (data.getNUTScode() != null && data.getNUTScode().length() > 0) {
+ if (data.getNUTScode() != null && !data.getNUTScode().isEmpty()) {
asnData.setNutsCode(data.getNUTScode());
}
@@ -1236,7 +1236,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { * @return the polygone type
* @throws EncodingFormatException the encoding format exception
*/
- private PolygoneType encodePolygone(IPolygone data) throws EncodingFormatException {
+ private PolygoneType encodePolygone(IPolygone data) {
if (data == null) return null;
if (data.getEdges() == null || data.getEdges().isEmpty()) {
return null;
@@ -1638,7 +1638,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setClassCode(convertTravelClass(document.getClassCode()));
- if (document.getCountries() != null && document.getCountries().size() > 0){
+ if (document.getCountries() != null && !document.getCountries().isEmpty()){
asnData.setCountries(SequenceOfCountries.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getCountries(),1,250)));
}
@@ -1657,7 +1657,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { - if(document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if(document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -1680,7 +1680,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { }
- private ValidityPeriodDetailType encodeValidityDetails( IValidityDetails validityDetails, Date referenceDate) throws EncodingFormatException {
+ private ValidityPeriodDetailType encodeValidityDetails(IValidityDetails validityDetails, Date referenceDate) {
if ( (validityDetails.getTimeRanges() == null || validityDetails.getTimeRanges().isEmpty())
||
@@ -1828,7 +1828,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { for (String station : document.getStations()) {
String ia5 = UicEncoderUtils.getIA5NonNum(station);
Long num = UicEncoderUtils.getNum(station);
- if (ia5 != null && ia5.length() > 0) {
+ if (ia5 != null && !ia5.isEmpty()) {
stationsIA5.add(ia5);
}
if (num != null && num > 0){
@@ -1847,7 +1847,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { SequenceOfStringUTF8 asnList = new SequenceOfStringUTF8();
for ( String text :document.getStationNames()){
- if (text.length() > 0) {
+ if (!text.isEmpty()) {
asnList.add(text);
}
}
@@ -1963,7 +1963,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { CardReferenceType asnCard = new CardReferenceType();
- if (card.getCardId() != null && card.getCardId().length() > 0){
+ if (card.getCardId() != null && !card.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(card.getCardId());
@@ -2100,7 +2100,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { private IssuingData encodeIssuingDetails(IIssuingDetail data) throws EncodingFormatException {
if (data == null){
- throw new EncodingFormatException("Issuind data missing");
+ throw new EncodingFormatException("Issuing data missing");
}
IssuingData asnData = new IssuingData();
@@ -2218,7 +2218,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnDocument.getTicket().setCustomerCard(asnData);
- if (document.getCardId() != null && document.getCardId().length() > 0){
+ if (document.getCardId() != null && !document.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(document.getCardId());
@@ -2375,7 +2375,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { throw new EncodingFormatException("Extension does not include data");
}
- if (extension.getId() == null || extension.getId().length() == 0) {
+ if (extension.getId() == null || extension.getId().isEmpty()) {
throw new EncodingFormatException("Extension does not include id");
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java index 0656d49..41a70a0 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java @@ -18,6 +18,7 @@ import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType; import org.uic.barcode.ticket.api.asn.omv2.CodeTableType;
import org.uic.barcode.ticket.api.asn.omv2.CompartmentDetailsType;
import org.uic.barcode.ticket.api.asn.omv2.CompartmentGenderType;
+import org.uic.barcode.ticket.api.asn.omv2.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv2.ConfirmationTypeType;
import org.uic.barcode.ticket.api.asn.omv2.ControlData;
import org.uic.barcode.ticket.api.asn.omv2.CountermarkData;
@@ -94,7 +95,6 @@ import org.uic.barcode.ticket.api.asn.omv2.VatDetailType; import org.uic.barcode.ticket.api.asn.omv2.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv2.VoucherData;
import org.uic.barcode.ticket.api.asn.omv2.ZoneType;
-import org.uic.barcode.ticket.api.asn.omv2.CompartmentPositionType;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
import org.uic.barcode.ticket.api.spec.ICardReference;
@@ -745,7 +745,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { }
- if (document.getTariffs() != null && document.getTariffs().size() > 0){
+ if (document.getTariffs() != null && !document.getTariffs().isEmpty()){
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
}
@@ -753,7 +753,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -765,7 +765,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -795,11 +795,11 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setFromStationNameUTF8(route.getFromStationName());
asnData.setToStationNameUTF8(route.getToStationName());
- if (route.getValidRegionList()!= null && route.getValidRegionList().size() > 0) {
+ if (route.getValidRegionList()!= null && !route.getValidRegionList().isEmpty()) {
asnData.setValidReturnRegion(encodeRegionCollection(route.getValidRegionList(), issuingDate));
}
- if (route.getValidRegionDesc() != null && route.getValidRegionDesc().length() > 0){
+ if (route.getValidRegionDesc() != null && !route.getValidRegionDesc().isEmpty()){
asnData.setValidReturnRegionDesc(route.getValidRegionDesc());
}
@@ -823,7 +823,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setMaxNonHandLuggagePieces(UicEncoderUtils.getRestrictedIntWithDefault(luggageRestriction.getMaxNonHandLuggagePieces(),1,99,1));
- if (luggageRestriction.getRegisteredLuggage() != null && luggageRestriction.getRegisteredLuggage().size() > 0) {
+ if (luggageRestriction.getRegisteredLuggage() != null && !luggageRestriction.getRegisteredLuggage().isEmpty()) {
asnData.setRegisteredLuggage(encodeRegisteredLuggage(luggageRestriction.getRegisteredLuggage()));
}
@@ -933,7 +933,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -945,12 +945,12 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
- if (document.getIncludedAddOns() != null && document.getIncludedAddOns().size() > 0) {
+ if (document.getIncludedAddOns() != null && !document.getIncludedAddOns().isEmpty()) {
asnData.setIncludedAddOns(encodeIncludedAddons(document.getIncludedAddOns(),issuingDate, document.getClassCode()));
}
@@ -1061,7 +1061,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
@@ -1189,7 +1189,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setCity(Asn1BigInteger.toAsn1(document.getCity()));
}
- if (document.getNUTScode() != null && document.getNUTScode().length() > 0) {
+ if (document.getNUTScode() != null && !document.getNUTScode().isEmpty()) {
asnData.setNutsCode(document.getNUTScode());
}
@@ -1235,9 +1235,8 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { *
* @param data the data
* @return the polygone type
- * @throws EncodingFormatException the encoding format exception
*/
- private PolygoneType encodePolygone(IPolygone data) throws EncodingFormatException {
+ private PolygoneType encodePolygone(IPolygone data) {
if (data == null) return null;
if (data.getEdges() == null || data.getEdges().isEmpty()) {
return null;
@@ -1642,7 +1641,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getCountries() != null && document.getCountries().size() > 0){
+ if (document.getCountries() != null && !document.getCountries().isEmpty()){
asnData.setCountries(SequenceOfCountries.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getCountries(),1,250)));
}
@@ -1661,7 +1660,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { - if(document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if(document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -1684,7 +1683,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { }
- private ValidityPeriodDetailType encodeValidityDetails( IValidityDetails validityDetails, Date referenceDate) throws EncodingFormatException {
+ private ValidityPeriodDetailType encodeValidityDetails(IValidityDetails validityDetails, Date referenceDate) {
if ( (validityDetails.getTimeRanges() == null || validityDetails.getTimeRanges().isEmpty())
||
@@ -1832,7 +1831,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { for (String station : document.getStations()) {
String ia5 = UicEncoderUtils.getIA5NonNum(station);
Long num = UicEncoderUtils.getNum(station);
- if (ia5 != null && ia5.length() > 0) {
+ if (ia5 != null && !ia5.isEmpty()) {
stationsIA5.add(ia5);
}
if (num != null && num > 0){
@@ -1851,7 +1850,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { SequenceOfStringUTF8 asnList = new SequenceOfStringUTF8();
for ( String text :document.getStationNames()){
- if (text.length() > 0) {
+ if (!text.isEmpty()) {
asnList.add(text);
}
}
@@ -1967,7 +1966,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { CardReferenceType asnCard = new CardReferenceType();
- if (card.getCardId() != null && card.getCardId().length() > 0){
+ if (card.getCardId() != null && !card.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(card.getCardId());
@@ -2104,7 +2103,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { private IssuingData encodeIssuingDetails(IIssuingDetail data) throws EncodingFormatException {
if (data == null){
- throw new EncodingFormatException("Issuind data missing");
+ throw new EncodingFormatException("Issuing data missing");
}
IssuingData asnData = new IssuingData();
@@ -2220,7 +2219,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnDocument.getTicket().setCustomerCard(asnCustomerCard);
- if (document.getCardId() != null && document.getCardId().length() > 0){
+ if (document.getCardId() != null && !document.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(document.getCardId());
@@ -2381,7 +2380,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { throw new EncodingFormatException("Extension does not include data");
}
- if (extension.getId() == null || extension.getId().length() == 0) {
+ if (extension.getId() == null || extension.getId().isEmpty()) {
throw new EncodingFormatException("Extension does not include id");
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java index d97e7b7..3224336 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java @@ -11,7 +11,6 @@ import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5; import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv3.BerthDetailData;
import org.uic.barcode.ticket.api.asn.omv3.BerthTypeType;
import org.uic.barcode.ticket.api.asn.omv3.BoardingOrArrivalType;
@@ -20,6 +19,7 @@ import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType; import org.uic.barcode.ticket.api.asn.omv3.CodeTableType;
import org.uic.barcode.ticket.api.asn.omv3.CompartmentDetailsType;
import org.uic.barcode.ticket.api.asn.omv3.CompartmentGenderType;
+import org.uic.barcode.ticket.api.asn.omv3.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv3.ConfirmationTypeType;
import org.uic.barcode.ticket.api.asn.omv3.ControlData;
import org.uic.barcode.ticket.api.asn.omv3.CountermarkData;
@@ -749,7 +749,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { }
- if (document.getTariffs() != null && document.getTariffs().size() > 0){
+ if (document.getTariffs() != null && !document.getTariffs().isEmpty()){
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
}
@@ -757,7 +757,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -769,7 +769,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -801,11 +801,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setFromStationNameUTF8(route.getFromStationName());
asnData.setToStationNameUTF8(route.getToStationName());
- if (route.getValidRegionList()!= null && route.getValidRegionList().size() > 0) {
+ if (route.getValidRegionList()!= null && !route.getValidRegionList().isEmpty()) {
asnData.setValidReturnRegion(encodeRegionCollection(route.getValidRegionList(), issuingDate));
}
- if (route.getValidRegionDesc() != null && route.getValidRegionDesc().length() > 0){
+ if (route.getValidRegionDesc() != null && !route.getValidRegionDesc().isEmpty()){
asnData.setValidReturnRegionDesc(route.getValidRegionDesc());
}
@@ -829,7 +829,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setMaxNonHandLuggagePieces(UicEncoderUtils.getRestrictedIntWithDefault(luggageRestriction.getMaxNonHandLuggagePieces(),1,99,1));
- if (luggageRestriction.getRegisteredLuggage() != null && luggageRestriction.getRegisteredLuggage().size() > 0) {
+ if (luggageRestriction.getRegisteredLuggage() != null && !luggageRestriction.getRegisteredLuggage().isEmpty()) {
asnData.setRegisteredLuggage(encodeRegisteredLuggage(luggageRestriction.getRegisteredLuggage()));
}
@@ -940,7 +940,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ if (document.getServiceLevel() != null && !document.getServiceLevel().isEmpty()) {
asnData.setServiceLevel(document.getServiceLevel());
}
@@ -952,12 +952,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setIssuerAutorizationId(Long.valueOf(document.getAuthorizationCode()));
}
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
- if (document.getIncludedAddOns() != null && document.getIncludedAddOns().size() > 0) {
+ if (document.getIncludedAddOns() != null && !document.getIncludedAddOns().isEmpty()) {
asnData.setIncludedAddOns(encodeIncludedAddons(document.getIncludedAddOns(),issuingDate, document.getClassCode()));
}
@@ -1070,7 +1070,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
- if (document.getValidRegionList() != null && document.getValidRegionList().size() > 0) {
+ if (document.getValidRegionList() != null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
asnData.setValidRegionDesc(document.getValidRegionDesc());
@@ -1201,7 +1201,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setCity(Asn1BigInteger.toAsn1(document.getCity()));
}
- if (document.getNUTScode() != null && document.getNUTScode().length() > 0) {
+ if (document.getNUTScode() != null && !document.getNUTScode().isEmpty()) {
asnData.setNutsCode(document.getNUTScode());
}
@@ -1247,9 +1247,8 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { *
* @param data the data
* @return the polygone type
- * @throws EncodingFormatException the encoding format exception
- */
- private PolygoneType encodePolygone(IPolygone data) throws EncodingFormatException {
+ */
+ private PolygoneType encodePolygone(IPolygone data) {
if (data == null) return null;
if (data.getEdges() == null || data.getEdges().isEmpty()) {
return null;
@@ -1651,7 +1650,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (document.getCountries() != null && document.getCountries().size() > 0){
+ if (document.getCountries() != null && !document.getCountries().isEmpty()){
asnData.setCountries(SequenceOfCountries.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getCountries(),1,250)));
}
@@ -1670,7 +1669,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { - if(document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
+ if(document.getValidRegionList()!= null && !document.getValidRegionList().isEmpty()) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
@@ -1729,7 +1728,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { }
- private ValidityPeriodDetailType encodeValidityDetails( IValidityDetails validityDetails, Date referenceDate) throws EncodingFormatException {
+ private ValidityPeriodDetailType encodeValidityDetails(IValidityDetails validityDetails, Date referenceDate) {
if ( (validityDetails.getTimeRanges() == null || validityDetails.getTimeRanges().isEmpty())
||
@@ -1877,7 +1876,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { for (String station : document.getStations()) {
String ia5 = UicEncoderUtils.getIA5NonNum(station);
Long num = UicEncoderUtils.getNum(station);
- if (ia5 != null && ia5.length() > 0) {
+ if (ia5 != null && !ia5.isEmpty()) {
stationsIA5.add(ia5);
}
if (num != null && num > 0){
@@ -1896,7 +1895,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { SequenceOfStringUTF8 asnList = new SequenceOfStringUTF8();
for ( String text :document.getStationNames()){
- if (text.length() > 0) {
+ if (!text.isEmpty()) {
asnList.add(text);
}
}
@@ -2012,7 +2011,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { CardReferenceType asnCard = new CardReferenceType();
- if (card.getCardId() != null && card.getCardId().length() > 0){
+ if (card.getCardId() != null && !card.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(card.getCardId());
@@ -2150,7 +2149,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { private IssuingData encodeIssuingDetails(IIssuingDetail data) throws EncodingFormatException {
if (data == null){
- throw new EncodingFormatException("Issuind data missing");
+ throw new EncodingFormatException("Issuing data missing");
}
IssuingData asnData = new IssuingData();
@@ -2266,7 +2265,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnDocument.getTicket().setCustomerCard(asnCustomerCard);
- if (document.getCardId() != null && document.getCardId().length() > 0){
+ if (document.getCardId() != null && !document.getCardId().isEmpty()){
//only longs allowed
try {
long num = Long.parseLong(document.getCardId());
@@ -2425,7 +2424,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { throw new EncodingFormatException("Extension does not include data");
}
- if (extension.getId() == null || extension.getId().length() == 0) {
+ if (extension.getId() == null || extension.getId().isEmpty()) {
throw new EncodingFormatException("Extension does not include id");
}
diff --git a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java index 16cd638..cac2bc7 100644 --- a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java +++ b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java @@ -8,7 +8,11 @@ import java.util.HashMap; /**
* The Class AlgorithmNameResolver.
*/
-public class AlgorithmNameResolver {
+public final class AlgorithmNameResolver {
+
+ private AlgorithmNameResolver() {
+ // Utility class will not be instantiated.
+ }
/** The Constant TYPE_KEY_GENERATOR_ALG. */
@@ -22,7 +26,7 @@ public class AlgorithmNameResolver { /**
- * Adds an entry for a mapping of algorithm type and oid to an algorithm name
+ * Adds an entry for a mapping of an algorithm type and oid to an algorithm name
*
* @param type the algorithm type
* @param oid the algorithm OID
@@ -123,7 +127,7 @@ public class AlgorithmNameResolver { name = service.getAlgorithm();
}
- if (name != null && name.length() > 0) {
+ if (name != null && !name.isEmpty()) {
return name;
}
}
@@ -135,7 +139,7 @@ public class AlgorithmNameResolver { if (service != null) {
name = service.getAlgorithm();
}
- if (name != null && name.length() > 0) {
+ if (name != null && !name.isEmpty()) {
return name;
}
}
|