do not throw exception if present operation returns diagnostics, clean up (mostly underscore style issues)

This commit is contained in:
Jörg Prante 2018-09-10 19:11:49 +02:00
parent 00412e7577
commit d0c91568a8
142 changed files with 2794 additions and 4632 deletions

View file

@ -1,323 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file.
-->
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="RegexpSingleline">
<!-- Checks that FIXME is not used in comments. TODO is preferred.
-->
<property name="format" value="((//.*)|(\*.*))FIXME" />
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="RegexpSingleline">
<!-- Checks that TODOs are named. (Actually, just that they are followed
by an open paren.)
-->
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="JavadocPackage">
<!-- Checks that each Java package has a Javadoc file used for commenting.
Only allows a package-info.java, not package.html. -->
</module>
<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">
<!--
IMPORT CHECKS
-->
<module name="RedundantImport">
<!-- Checks for redundant import statements. -->
<property name="severity" value="error"/>
</module>
<module name="ImportOrder">
<!-- Checks for out of order import statements. -->
<property name="severity" value="warning"/>
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
</module>
<!--
JAVADOC CHECKS
-->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="warning"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
<module name="JavadocType">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
</module>
<module name="JavadocStyle">
<property name="severity" value="warning"/>
</module>
<!--
NAMING CHECKS
-->
<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- Validates identifiers for package names against the
supplied expression. -->
<!-- Here the default checkstyle rule restricts package name parts to
seven characters, this is not in line with common practice at Google.
-->
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
<property name="severity" value="warning"/>
</module>
<module name="TypeNameCheck">
<!-- Validates static, final fields against the
expression "^[A-Z][a-zA-Z0-9]*$". -->
<metadata name="altname" value="TypeName"/>
<property name="severity" value="warning"/>
</module>
<module name="ConstantNameCheck">
<!-- Validates non-private, static, final fields against the supplied
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
<metadata name="altname" value="ConstantName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
<message key="name.invalidPattern"
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
<property name="severity" value="warning"/>
</module>
<module name="StaticVariableNameCheck">
<!-- Validates static, non-final fields against the supplied
expression "^[a-z][a-zA-Z0-9]*_?$". -->
<metadata name="altname" value="StaticVariableName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="warning"/>
</module>
<module name="MemberNameCheck">
<!-- Validates non-static members against the supplied expression. -->
<metadata name="altname" value="MemberName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>
<module name="MethodNameCheck">
<!-- Validates identifiers for method names. -->
<metadata name="altname" value="MethodName"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<!-- Validates identifiers for method parameters against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalFinalVariableName">
<!-- Validates identifiers for local final variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableName">
<!-- Validates identifiers for local variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<!--
LENGTH and CODING CHECKS
-->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="warning"/>
</module>
<module name="RightCurly">
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
the same line. e.g., the following example is fine:
<pre>
if {
...
} else
</pre>
-->
<!-- This next example is not fine:
<pre>
if {
...
}
else
</pre>
-->
<property name="option" value="same"/>
<property name="severity" value="warning"/>
</module>
<!-- Checks for braces around if and else blocks -->
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
</module>
<module name="UpperEll">
<!-- Checks that long constants are defined with an upper ell.-->
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<!-- Warn about falling through to the next case statement. Similar to
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
some other variants which we don't publicized to promote consistency).
-->
<property name="reliefPattern"
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
<property name="severity" value="error"/>
</module>
<!--
MODIFIERS CHECKS
-->
<module name="ModifierOrder">
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
8.4.3. The prescribed order is:
public, protected, private, abstract, static, final, transient, volatile,
synchronized, native, strictfp
-->
</module>
<!--
WHITESPACE CHECKS
-->
<module name="WhitespaceAround">
<!-- Checks that various tokens are surrounded by whitespace.
This includes most binary operators and keywords followed
by regular or curly braces.
-->
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="severity" value="error"/>
</module>
<module name="WhitespaceAfter">
<!-- Checks that commas, semicolons and typecasts are followed by
whitespace.
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
UNARY_PLUS"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<!-- Checks that there is no whitespace before various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<!-- Checks that there is no whitespace before close parens or after
open parens.
-->
<property name="severity" value="warning"/>
</module>
</module>
</module>

View file

@ -1,24 +0,0 @@
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>~/.m2/repository</localRepository>
<activeProfiles>
<activeProfile>xbib</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>xbib</id>
<repositories>
<repository>
<id>xbib</id>
<url>http://xbib.org/repository</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>

View file

@ -51,8 +51,8 @@ public final class ASN1BitString extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != BIT_STRING_TAG || berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("ASN.1 BIT STRING: bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != BIT_STRING_TAG || berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("ASN.1 BIT STRING: bad BER: tag=" + berEncoding.getTag() +
" expected " + BIT_STRING_TAG + "\n");
}
if (berEncoding instanceof BERPrimitive) {

View file

@ -48,9 +48,9 @@ public final class ASN1Boolean extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != TAG || berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
if (checkTag && (berEncoding.getTag() != TAG || berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException
("ASN.1 BOOLEAN: bad BER: tag=" + berEncoding.tagGet() +
("ASN.1 BOOLEAN: bad BER: tag=" + berEncoding.getTag() +
" expected " + "TAG\n");
}
if (berEncoding instanceof BERPrimitive) {

View file

@ -13,8 +13,8 @@ public class ASN1Decoder {
}
public static ASN1Any toASN1(BEREncoding ber) throws ASN1Exception {
if (ber.tagTypeGet() == BEREncoding.UNIVERSAL_TAG) {
switch (ber.tagGet()) {
if (ber.getTagType() == BEREncoding.UNIVERSAL_TAG) {
switch (ber.getTag()) {
case ASN1Boolean.TAG:
return new ASN1Boolean(ber, true);
case ASN1Integer.INTEGER_TAG:

View file

@ -52,9 +52,9 @@ public final class ASN1Enumerated extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != ENUMERATED_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != ENUMERATED_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + ENUMERATED_TAG + "\n");
}
if (!(berEncoding instanceof BERPrimitive)) {

View file

@ -76,8 +76,8 @@ public final class ASN1External extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1Exception {
if (checkTag && (berEncoding.tagGet() != EXTERNAL_TAG || berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != EXTERNAL_TAG || berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + EXTERNAL_TAG + "\n");
}
if (berEncoding instanceof BERPrimitive) {
@ -96,31 +96,31 @@ public final class ASN1External extends ASN1Any {
}
int part = 0;
BEREncoding p = ber.elementAt(part);
if (p.tagGet() == ASN1ObjectIdentifier.OBJECT_IDENTIFIER_TAG &&
p.tagTypeGet() == BEREncoding.UNIVERSAL_TAG) {
if (p.getTag() == ASN1ObjectIdentifier.OBJECT_IDENTIFIER_TAG &&
p.getTagType() == BEREncoding.UNIVERSAL_TAG) {
sDirectReference = new ASN1ObjectIdentifier(p, true);
if (numParts <= ++part) {
throw new ASN1EncodingException("incomplete");
}
p = ber.elementAt(part);
}
if (p.tagGet() == ASN1Integer.INTEGER_TAG &&
p.tagTypeGet() == BEREncoding.UNIVERSAL_TAG) {
if (p.getTag() == ASN1Integer.INTEGER_TAG &&
p.getTagType() == BEREncoding.UNIVERSAL_TAG) {
sIndirectReference = new ASN1Integer(p, true);
if (numParts <= ++part) {
throw new ASN1EncodingException("incomplete");
}
p = ber.elementAt(part);
}
if (p.tagGet() == ASN1ObjectDescriptor.OBJECT_DESCRIPTOR_TAG &&
p.tagTypeGet() == BEREncoding.UNIVERSAL_TAG) {
if (p.getTag() == ASN1ObjectDescriptor.OBJECT_DESCRIPTOR_TAG &&
p.getTagType() == BEREncoding.UNIVERSAL_TAG) {
sDataValueDescriptor = new ASN1ObjectDescriptor(p, true);
if (numParts <= ++part) {
throw new ASN1EncodingException("incomplete");
}
p = ber.elementAt(part);
}
switch (p.tagGet()) {
switch (p.getTag()) {
case 0:
if (!(p instanceof BERConstructed)) {
throw new ASN1EncodingException("singleASN1type: bad form, primitive");
@ -132,20 +132,20 @@ public final class ASN1External extends ASN1Any {
break;
case 1:
// octetAligned [1] IMPLICIT OCTET STRING
if (p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("encoding: bad tag type " + p);
}
cOctetAligned = new ASN1OctetString(p, false);
break;
case 2:
// arbitrary [2] IMPLICIT BIT STRING
if (p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("encoding: bad tag type " + p);
}
cArbitrary = new ASN1BitString(p, false);
break;
default:
throw new ASN1EncodingException("encoding: tag = " + p.tagGet());
throw new ASN1EncodingException("encoding: tag = " + p.getTag());
}
if (part != (numParts - 1)) {
throw new ASN1Exception("extra element(s)");

View file

@ -31,8 +31,8 @@ public class ASN1GeneralString extends ASN1OctetString {
public ASN1GeneralString(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != GENERAL_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != GENERAL_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() +
" expected " + GENERAL_STRING_TAG + "\n");
}
}

View file

@ -31,8 +31,8 @@ public final class ASN1GeneralizedTime extends ASN1VisibleString {
public ASN1GeneralizedTime(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != GENERALIZED_TIME_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != GENERALIZED_TIME_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() +
" expected " + GENERALIZED_TIME_TAG + "\n");
}
}

View file

@ -32,8 +32,8 @@ public class ASN1GraphicString extends ASN1OctetString {
*/
public ASN1GraphicString(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != GRAPHIC_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != GRAPHIC_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() +
" expected " + GRAPHIC_STRING_TAG + "\n");
}
}

View file

@ -31,8 +31,8 @@ public final class ASN1IA5String extends ASN1OctetString {
*/
public ASN1IA5String(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != IA5_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != IA5_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() +
" expected " + IA5_STRING_TAG + "\n");
}
}

View file

@ -54,9 +54,9 @@ public final class ASN1Integer extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != INTEGER_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != INTEGER_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + INTEGER_TAG + "\n");
}
if (!(berEncoding instanceof BERPrimitive)) {

View file

@ -40,9 +40,9 @@ public final class ASN1Null extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != NULL_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != NULL_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + NULL_TAG + "\n");
}
if (!(berEncoding instanceof BERPrimitive)) {

View file

@ -31,8 +31,8 @@ public class ASN1NumericString extends ASN1OctetString {
public ASN1NumericString(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != NUMERIC_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != NUMERIC_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() +
" expected " + NUMERIC_STRING_TAG + "\n");
}
}

View file

@ -32,9 +32,9 @@ public final class ASN1ObjectDescriptor extends ASN1GraphicString {
public ASN1ObjectDescriptor(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != OBJECT_DESCRIPTOR_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
if (checkTag && (ber.getTag() != OBJECT_DESCRIPTOR_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException
("ASN.1 ObjectDescriptor: bad BER: tag=" + ber.tagGet() +
("ASN.1 ObjectDescriptor: bad BER: tag=" + ber.getTag() +
" expected " + OBJECT_DESCRIPTOR_TAG + "\n");
}
}

View file

@ -49,9 +49,9 @@ public final class ASN1ObjectIdentifier extends ASN1Any {
*/
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag) throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != OBJECT_IDENTIFIER_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != OBJECT_IDENTIFIER_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + OBJECT_IDENTIFIER_TAG + "\n");
}
if (!(berEncoding instanceof BERPrimitive)) {

View file

@ -68,9 +68,9 @@ public class ASN1OctetString extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1EncodingException {
if (checkTag && (berEncoding.tagGet() != OCTET_STRING_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
if (checkTag && (berEncoding.getTag() != OCTET_STRING_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() +
" expected " + OCTET_STRING_TAG + "\n");
}
if (berEncoding instanceof BERPrimitive) {

View file

@ -49,8 +49,8 @@ public final class ASN1PrintableString extends ASN1OctetString {
public ASN1PrintableString(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != PRINTABLE_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("ASN.1 PrintableString: bad BER: tag=" + ber.tagGet() +
if (checkTag && (ber.getTag() != PRINTABLE_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("ASN.1 PrintableString: bad BER: tag=" + ber.getTag() +
" expected " + PRINTABLE_STRING_TAG + "\n");
}
}

View file

@ -54,9 +54,9 @@ public final class ASN1Sequence extends ASN1Any {
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1Exception {
if (checkTag && (berEncoding.tagGet() != SEQUENCE_TAG || berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
if (checkTag && (berEncoding.getTag() != SEQUENCE_TAG || berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException
("ASN.1 SEQUENCE: bad BER: tag=" + berEncoding.tagGet() +
("ASN.1 SEQUENCE: bad BER: tag=" + berEncoding.getTag() +
" expected " + SEQUENCE_TAG + "\n");
}
if (berEncoding instanceof BERPrimitive) {

View file

@ -53,12 +53,10 @@ public final class ASN1Set extends ASN1Any {
* @throws ASN1Exception If the BER encoding is incorrect.
*/
@Override
public void berDecode(BEREncoding berEncoding, boolean checkTag)
throws ASN1Exception {
if (checkTag && (berEncoding.tagGet() != SET_TAG ||
berEncoding.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.tagGet() +
" expected " + SET_TAG + "\n");
public void berDecode(BEREncoding berEncoding, boolean checkTag) throws ASN1Exception {
if (checkTag && (berEncoding.getTag() != SET_TAG ||
berEncoding.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + berEncoding.getTag() + " expected " + SET_TAG);
}
if (berEncoding instanceof BERPrimitive) {
throw new ASN1EncodingException("bad form, primitive");

View file

@ -35,10 +35,8 @@ public final class ASN1T61String extends ASN1OctetString {
public ASN1T61String(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != T61_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException
("ASN.1 T61String: bad BER: tag=" + ber.tagGet() +
" expected " + T61_STRING_TAG + "\n");
if (checkTag && (ber.getTag() != T61_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("ASN.1 T61String: bad BER: tag=" + ber.getTag() + " expected " + T61_STRING_TAG);
}
}
}

View file

@ -39,13 +39,10 @@ public final class ASN1UTCTime extends ASN1VisibleString {
* @param checkTag If true, it checks the tag. Use false if is implicitly tagged.
* @throws ASN1Exception If the BER encoding is incorrect.
*/
public ASN1UTCTime(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public ASN1UTCTime(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != UTC_TIME_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException
("ASN.1 UTCTime: bad BER: tag=" + ber.tagGet() +
" expected " + UTC_TIME_TAG + "\n");
if (checkTag && (ber.getTag() != UTC_TIME_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected " + UTC_TIME_TAG);
}
}

View file

@ -30,9 +30,8 @@ public class ASN1VideotexString extends ASN1OctetString {
*/
public ASN1VideotexString(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != VIDEOTEX_STRING_TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
" expected " + VIDEOTEX_STRING_TAG + "\n");
if (checkTag && (ber.getTag() != VIDEOTEX_STRING_TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected " + VIDEOTEX_STRING_TAG);
}
}

View file

@ -33,9 +33,8 @@ public class ASN1VisibleString extends ASN1OctetString {
public ASN1VisibleString(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, false);
if (checkTag && (ber.tagGet() != TAG || ber.tagTypeGet() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.tagGet() +
" expected " + TAG + "\n");
if (checkTag && (ber.getTag() != TAG || ber.getTagType() != BEREncoding.UNIVERSAL_TAG)) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected " + TAG);
}
}

View file

@ -29,7 +29,7 @@ public class BERConstructed extends BEREncoding {
throws ASN1Exception {
int contentLength = 0;
for (BEREncoding element : elements) {
contentLength += element.iTotalLength;
contentLength += element.totalLength;
}
init(asn1Class, true, tag, contentLength);
contentElements = elements;
@ -65,7 +65,7 @@ public class BERConstructed extends BEREncoding {
@Override
public String toString() {
StringBuilder str = new StringBuilder("[");
switch (iTagType) {
switch (tagType) {
case BEREncoding.UNIVERSAL_TAG:
str.append("UNIVERSAL ");
break;
@ -81,7 +81,7 @@ public class BERConstructed extends BEREncoding {
default:
break;
}
str.append(String.valueOf(iTag)).append("]{");
str.append(String.valueOf(tag)).append("]{");
for (int x = 0; x < contentElements.length; x++) {
if (x != 0) {
str.append(',');
@ -96,10 +96,10 @@ public class BERConstructed extends BEREncoding {
* This protected method is used to implement the "get_encoding" method.
*/
@Override
protected int iEncodingGet(int offset, byte[] data) {
int i = iGetHead(offset, data);
protected int getEncoding(int offset, byte[] data) {
int i = getHead(offset, data);
for (BEREncoding contentElement : contentElements) {
i = contentElement.iEncodingGet(i, data);
i = contentElement.getEncoding(i, data);
}
return i;
}

View file

@ -50,20 +50,20 @@ public abstract class BEREncoding {
* the same as that encoded in the identiferEncoding.
* This is an internal member. You should not use this.
*/
protected int iTagType;
protected int tagType;
/**
* The tag number of this BER encoded object. This value must be
* the same as that encoded in the identiferEncoding.
* This is an internal member. You should not use this.
*/
protected int iTag;
protected int tag;
/**
* The total length of this BER object (the identifier octets, plus
* length octets, plus content octects). This variable must be
* set up before this object is used (using the init method).
* This is an internal member. You should not use this.
*/
protected int iTotalLength;
protected int totalLength;
/**
* Storage for the identifier octets. This variable is set up by
* calling the make_identifer method.
@ -85,53 +85,28 @@ public abstract class BEREncoding {
return lengthEncoding;
}
public int getITag() {
return iTag;
}
public int getITagType() {
return iTagType;
}
public int getITotalLength() {
return iTotalLength;
}
/**
* Returns the BER encoded object as an array of bytes. This routine
* may be of use if you want to use the encoding rather than sending
* it off. If you want to just output it, it is more efficient to
* use the output method.
* @return byte array
*/
public byte[] encodingGet() {
byte[] result = new byte[iTotalLength];
iEncodingGet(0, result);
return result;
}
/**
* Method to examine the tag type of the BER encoded ASN.1 object.
* @return integer
*/
public int tagTypeGet() {
return iTagType;
public int getTagType() {
return tagType;
}
/**
* Method to examine the tag number of the BER encoded ASN.1 object.
* @return integer
*/
public int tagGet() {
return iTag;
public int getTag() {
return tag;
}
/**
* Returns the total number of bytes the encoding occupies.
* @return integer
*/
public int totalLength() {
return iTotalLength;
public int getTotalLength() {
return totalLength;
}
/**
@ -149,7 +124,7 @@ public abstract class BEREncoding {
throws ASN1Exception {
makeIdentifier(tagType, isConstructed, tag);
makeLength(length);
iTotalLength = identifierEncoding.length + lengthEncoding.length + length;
totalLength = identifierEncoding.length + lengthEncoding.length + length;
}
/*
@ -158,7 +133,7 @@ public abstract class BEREncoding {
* This is used by the superclasses to implement the "encodingGet"
* method.
*/
protected int iGetHead(int offset, byte[] data) {
protected int getHead(int offset, byte[] data) {
for (int anIdentifierEncoding : identifierEncoding) {
data[offset++] = (byte) anIdentifierEncoding;
}
@ -174,7 +149,7 @@ public abstract class BEREncoding {
* array (as bytes), starting at offset into the array. The
* offset of the last element used plus one is returned.
*/
protected abstract int iEncodingGet(int offset, byte[] data);
protected abstract int getEncoding(int offset, byte[] data);
/**
* This private method encodes the identifier octets. When a BER
@ -201,12 +176,12 @@ public abstract class BEREncoding {
if (tag < 0) {
throw new ASN1Exception("ASN.1 tag value is negative");
}
iTagType = tagType & 0xC0;
b = iTagType;
this.tagType = tagType & 0xC0;
b = this.tagType;
if (isConstructed) {
b |= 0x20;
}
iTag = tag;
this.tag = tag;
if (tag <= 30) {
b |= (tag & 0x1F);
identifierEncoding = new int[1];

View file

@ -31,10 +31,18 @@ public class BERPrimitive extends BEREncoding {
* classes. It is not intended that higher level classes create
* BERPrimitives directly.
*
* @param asn1Class ASN.1 class
* @param tag tag
* @param contents contents
*
* @throws ASN1Exception if BER primitive fails
*
* @see org.xbib.asn1.BEREncoding#UNIVERSAL_TAG
* @see org.xbib.asn1.BEREncoding#APPLICATION_TAG
* @see org.xbib.asn1.BEREncoding#CONTEXT_SPECIFIC_TAG
* @see org.xbib.asn1.BEREncoding#PRIVATE_TAG
*
*
*/
public BERPrimitive(int asn1Class, int tag, int[] contents) throws ASN1Exception {
init(asn1Class, false, tag, contents.length);
@ -44,6 +52,7 @@ public class BERPrimitive extends BEREncoding {
/**
* This method allows the content octets to be examined.
* Once again, only the ASN.1 standard objects should be using this.
* @return content octets
*/
public int[] getContentOctets() {
return contentsOctets;
@ -52,11 +61,12 @@ public class BERPrimitive extends BEREncoding {
/**
* Returns a new String object representing this BER encoded
* ASN.1 object's value.
* @return string
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("[");
switch (iTagType) {
switch (tagType) {
case BEREncoding.UNIVERSAL_TAG:
str.append("UNIVERSAL ");
break;
@ -72,7 +82,7 @@ public class BERPrimitive extends BEREncoding {
default:
break;
}
str.append(String.valueOf(iTag)).append("] '");
str.append(String.valueOf(tag)).append("] '");
for (int octet : contentsOctets) {
str.append(hex[(octet >> 4) & 0x0f]);
str.append(hex[octet & 0x0f]);
@ -83,10 +93,12 @@ public class BERPrimitive extends BEREncoding {
/**
* This protected method is used to implement the "get_encoding" method.
*
* @return integer
*/
@Override
protected int iEncodingGet(int offset, byte[] data) {
int i = iGetHead(offset, data);
protected int getEncoding(int offset, byte[] data) {
int i = getHead(offset, data);
for (int contentsOctet : contentsOctets) {
data[i++] = (byte) contentsOctet;
}

View file

@ -147,8 +147,8 @@ public class InputStreamBERReader implements BERReader {
if (chunk == null) {
throw new ASN1EncodingException(ERROR);
}
if (chunk.getITag() == 0 && chunk.getITagType() == BEREncoding.UNIVERSAL_TAG &&
chunk.getITotalLength() == 2) {
if (chunk.getTag() == 0 && chunk.getTagType() == BEREncoding.UNIVERSAL_TAG &&
chunk.getTotalLength() == 2) {
break;
} else {
chunks.add(chunk);

View file

@ -1,4 +1,5 @@
plugins {
id "com.github.spotbugs" version "1.6.2"
id "org.sonarqube" version '2.6.1'
id "io.codearte.nexus-staging" version "0.11.0"
}
@ -17,18 +18,22 @@ printf "Host: %s\nOS: %s %s %s\nJVM: %s %s %s %s\nGradle: %s Groovy: %s Java: %s
GroovySystem.getVersion(),
JavaVersion.current()
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'jacoco'
apply plugin: "com.github.spotbugs"
apply from: "${rootProject.projectDir}/gradle/ext.gradle"
apply from: "${rootProject.projectDir}/gradle/sonarqube.gradle"
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
configurations {
wagon
@ -82,8 +87,6 @@ subprojects {
sign configurations.archives
}
}
apply from: "${rootProject.projectDir}/gradle/ext.gradle"
apply from: "${rootProject.projectDir}/gradle/publish.gradle"
apply from: "${rootProject.projectDir}/gradle/sonarqube.gradle"
}

View file

@ -1,9 +1,11 @@
group = org.xbib
name = z3950
version = 1.2.0
version = 1.2.1
xbib-cql.version = 1.2.0
netty.version = 4.1.29.Final
junit.version = 4.12
wagon.version = 3.0.0
org.gradle.warning.mode = all

View file

@ -1,9 +1,19 @@
tasks.withType(FindBugs) {
spotbugs {
toolVersion = '3.1.3'
sourceSets = [sourceSets.main]
ignoreFailures = true
reports {
effort = "max"
reportLevel = "high"
}
spotbugsMain.reports {
xml.enabled = false
html.enabled = true
}
spotbugsTest.reports {
xml.enabled = false
html.enabled = true
}
tasks.withType(Pmd) {
ignoreFailures = true

View file

@ -1,323 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file.
-->
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="RegexpSingleline">
<!-- Checks that FIXME is not used in comments. TODO is preferred.
-->
<property name="format" value="((//.*)|(\*.*))FIXME" />
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="RegexpSingleline">
<!-- Checks that TODOs are named. (Actually, just that they are followed
by an open paren.)
-->
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="JavadocPackage">
<!-- Checks that each Java package has a Javadoc file used for commenting.
Only allows a package-info.java, not package.html. -->
</module>
<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">
<!--
IMPORT CHECKS
-->
<module name="RedundantImport">
<!-- Checks for redundant import statements. -->
<property name="severity" value="error"/>
</module>
<module name="ImportOrder">
<!-- Checks for out of order import statements. -->
<property name="severity" value="warning"/>
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
</module>
<!--
JAVADOC CHECKS
-->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="warning"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
<module name="JavadocType">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
</module>
<module name="JavadocStyle">
<property name="severity" value="warning"/>
</module>
<!--
NAMING CHECKS
-->
<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- Validates identifiers for package names against the
supplied expression. -->
<!-- Here the default checkstyle rule restricts package name parts to
seven characters, this is not in line with common practice at Google.
-->
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
<property name="severity" value="warning"/>
</module>
<module name="TypeNameCheck">
<!-- Validates static, final fields against the
expression "^[A-Z][a-zA-Z0-9]*$". -->
<metadata name="altname" value="TypeName"/>
<property name="severity" value="warning"/>
</module>
<module name="ConstantNameCheck">
<!-- Validates non-private, static, final fields against the supplied
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
<metadata name="altname" value="ConstantName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
<message key="name.invalidPattern"
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
<property name="severity" value="warning"/>
</module>
<module name="StaticVariableNameCheck">
<!-- Validates static, non-final fields against the supplied
expression "^[a-z][a-zA-Z0-9]*_?$". -->
<metadata name="altname" value="StaticVariableName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="warning"/>
</module>
<module name="MemberNameCheck">
<!-- Validates non-static members against the supplied expression. -->
<metadata name="altname" value="MemberName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>
<module name="MethodNameCheck">
<!-- Validates identifiers for method names. -->
<metadata name="altname" value="MethodName"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<!-- Validates identifiers for method parameters against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalFinalVariableName">
<!-- Validates identifiers for local final variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableName">
<!-- Validates identifiers for local variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<!--
LENGTH and CODING CHECKS
-->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="warning"/>
</module>
<module name="RightCurly">
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
the same line. e.g., the following example is fine:
<pre>
if {
...
} else
</pre>
-->
<!-- This next example is not fine:
<pre>
if {
...
}
else
</pre>
-->
<property name="option" value="same"/>
<property name="severity" value="warning"/>
</module>
<!-- Checks for braces around if and else blocks -->
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
</module>
<module name="UpperEll">
<!-- Checks that long constants are defined with an upper ell.-->
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<!-- Warn about falling through to the next case statement. Similar to
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
some other variants which we don't publicized to promote consistency).
-->
<property name="reliefPattern"
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
<property name="severity" value="error"/>
</module>
<!--
MODIFIERS CHECKS
-->
<module name="ModifierOrder">
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
8.4.3. The prescribed order is:
public, protected, private, abstract, static, final, transient, volatile,
synchronized, native, strictfp
-->
</module>
<!--
WHITESPACE CHECKS
-->
<module name="WhitespaceAround">
<!-- Checks that various tokens are surrounded by whitespace.
This includes most binary operators and keywords followed
by regular or curly braces.
-->
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="severity" value="error"/>
</module>
<module name="WhitespaceAfter">
<!-- Checks that commas, semicolons and typecasts are followed by
whitespace.
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
UNARY_PLUS"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<!-- Checks that there is no whitespace before various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<!-- Checks that there is no whitespace before close parens or after
open parens.
-->
<property name="severity" value="warning"/>
</module>
</module>
</module>

View file

@ -1,24 +0,0 @@
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>~/.m2/repository</localRepository>
<activeProfiles>
<activeProfile>xbib</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>xbib</id>
<repositories>
<repository>
<id>xbib</id>
<url>http://xbib.org/repository</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>

View file

@ -0,0 +1,12 @@
package org.xbib.io.iso23950;
import org.xbib.asn1.BEREncoding;
/**
*
*/
@FunctionalInterface
public interface ScanListener {
void onScan(BEREncoding result);
}

View file

@ -6,7 +6,7 @@ import java.io.IOException;
*
*/
@FunctionalInterface
public interface ResponseListener {
public interface SearchListener {
void onResponse(int status, int total, int returned, long elapsedMillis) throws IOException;
}

View file

@ -1,27 +1,18 @@
package org.xbib.io.iso23950;
import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.io.InputStreamBERReader;
import org.xbib.asn1.io.OutputStreamBERWriter;
import org.xbib.cql.CQLParser;
import org.xbib.io.iso23950.cql.CQLRPNGenerator;
import org.xbib.io.iso23950.operations.CloseOperation;
import org.xbib.io.iso23950.operations.InitOperation;
import org.xbib.io.iso23950.operations.PresentOperation;
import org.xbib.io.iso23950.operations.ScanOperation;
import org.xbib.io.iso23950.operations.SearchOperation;
import org.xbib.io.iso23950.pqf.PQFParser;
import org.xbib.io.iso23950.pqf.PQFRPNGenerator;
import org.xbib.io.iso23950.v3.Close;
import org.xbib.io.iso23950.v3.CloseReason;
import org.xbib.io.iso23950.v3.PDU;
import org.xbib.io.iso23950.v3.RPNQuery;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.text.MessageFormat;
@ -136,8 +127,8 @@ public class ZClient implements AutoCloseable {
}
}
public int executeCQL(String query, int offset, int length,
ResponseListener responseListener,
public int searchCQL(String query, int offset, int length,
SearchListener searchListener,
RecordListener recordListener) throws IOException {
if (query == null) {
throw new IllegalArgumentException("no query");
@ -146,12 +137,12 @@ public class ZClient implements AutoCloseable {
try {
lock.lock();
SearchOperation searchOperation = new SearchOperation(berReader, berWriter, resultSetName, databases, host);
boolean success = searchOperation.execute(createRPNQueryFromCQL(query));
boolean success = searchOperation.executeCQL(query);
if (!success) {
logger.log(Level.WARNING, MessageFormat.format("search was not a success [{0}]", query));
} else {
if (responseListener == null) {
responseListener = (status, total, returned, elapsedMillis) -> {
if (searchListener == null) {
searchListener = (status, total, returned, elapsedMillis) -> {
logger.log(Level.INFO, MessageFormat.format("[{0}ms] [{1}] [{2}] [{3}]",
elapsedMillis, total, returned, query));
};
@ -167,7 +158,7 @@ public class ZClient implements AutoCloseable {
// avoid condition 13 "Present request out-of-range"
length = searchOperation.getCount();
}
present.execute(offset, length, searchOperation.getCount(), responseListener, recordListener);
present.execute(offset, length, searchOperation.getCount(), searchListener, recordListener);
}
}
return searchOperation.getCount();
@ -176,8 +167,8 @@ public class ZClient implements AutoCloseable {
}
}
public int executePQF(String query, int offset, int length,
ResponseListener responseListener,
public int searchPQF(String query, int offset, int length,
SearchListener searchListener,
RecordListener recordListener) throws IOException {
if (query == null) {
throw new IllegalArgumentException("no query");
@ -186,18 +177,18 @@ public class ZClient implements AutoCloseable {
try {
lock.lock();
SearchOperation search = new SearchOperation(berReader, berWriter, resultSetName, databases, host);
search.execute(createRPNQueryFromPQF(query));
search.executePQF(query);
if (!search.isSuccess()) {
logger.log(Level.WARNING, MessageFormat.format("search was not a success [{0}]", query));
} else {
if (responseListener == null) {
responseListener = (status, total, returned, elapsedMillis) -> {
if (searchListener == null) {
searchListener = (status, total, returned, elapsedMillis) -> {
logger.log(Level.INFO, MessageFormat.format("[{0}ms] [{1}] [{2}] [{3}]",
elapsedMillis, total, returned, query));
};
}
if (search.getCount() > 0) {
logger.log(Level.INFO, "search returned " + search.getCount());
logger.log(Level.FINE, "search returned " + search.getCount());
PresentOperation present = new PresentOperation(berReader, berWriter,
resultSetName, elementSetName, preferredRecordSyntax);
if (offset < 1) {
@ -208,7 +199,7 @@ public class ZClient implements AutoCloseable {
// avoid condition 13 "Present request out-of-range"
length = search.getCount();
}
present.execute(offset, length, search.getCount(), responseListener, recordListener);
present.execute(offset, length, search.getCount(), searchListener, recordListener);
}
}
return search.getCount();
@ -217,6 +208,18 @@ public class ZClient implements AutoCloseable {
}
}
public void scanPQF(String query, int nTerms, int step, int position,
ScanListener scanListener) throws IOException {
ensureConnected();
try {
lock.lock();
ScanOperation scanOperation = new ScanOperation(berReader, berWriter, databases);
scanOperation.executePQF(nTerms, step, position, query, scanListener);
} finally {
lock.unlock();
}
}
public String getHost() {
return host;
}
@ -265,56 +268,6 @@ public class ZClient implements AutoCloseable {
return databases;
}
private RPNQuery createRPNQueryFromCQL(String query) {
CQLRPNGenerator generator = new CQLRPNGenerator();
CQLParser parser = new CQLParser(query);
parser.parse();
parser.getCQLQuery().accept(generator);
return generator.getQueryResult();
}
private RPNQuery createRPNQueryFromPQF(String query) {
PQFRPNGenerator generator = new PQFRPNGenerator();
PQFParser parser = new PQFParser(new StringReader(query));
parser.parse();
parser.getResult().accept(generator);
return generator.getResult();
}
/**
* Send a close request to the server.
*
* @param reason reason Reason codes are:
* 0=finished 1=shutdown 2=system problem 3=cost limits
* 4=resources 5=security violation 6=protocol error 7=lack of activity
* 8=peer abort 9=unspecified
* @throws IOException if close fails
*/
private void sendClose(int reason) throws IOException {
if (!isConnected()) {
return;
}
try {
lock.lock();
PDU pdu = new PDU();
pdu.c_close = new Close();
pdu.c_close.sCloseReason = new CloseReason();
pdu.c_close.sCloseReason.value = new ASN1Integer(reason);
pdu.c_close.sReferenceId = null;
try {
berWriter.write(pdu.berEncode());
} catch (ASN1Exception ex) {
throw new IOException(ex);
}
// do not wait, it may hang
//waitClosePDU();
} finally {
lock.unlock();
}
}
private void connect() throws IOException {
try {
lock.lock();
@ -330,6 +283,7 @@ public class ZClient implements AutoCloseable {
if (initOperation.execute(preferredMessageSize, initListener)) {
throw new IOException("could not initiate connection");
}
logger.log(Level.INFO, initOperation.getTargetInfo());
} finally {
lock.unlock();
}
@ -349,6 +303,28 @@ public class ZClient implements AutoCloseable {
return new Builder();
}
/**
* Send a close request to the server.
*
* @param reason reason Reason codes are:
* 0=finished 1=shutdown 2=system problem 3=cost limits
* 4=resources 5=security violation 6=protocol error 7=lack of activity
* 8=peer abort 9=unspecified
* @throws IOException if close fails
*/
private void sendClose(int reason) throws IOException {
if (!isConnected()) {
return;
}
try {
lock.lock();
CloseOperation closeOperation = new CloseOperation(berReader, berWriter);
closeOperation.execute(reason);
} finally {
lock.unlock();
}
}
/**
*
*/

View file

@ -46,27 +46,15 @@ import java.util.Stack;
*/
public final class CQLRPNGenerator implements Visitor {
/**
* BIB-1 Use attributes resource bundle.
*/
private static final ResourceBundle bib =
ResourceBundle.getBundle("org.xbib.io.iso23950.cql.bib-1");
/**
* Dublin Core Use attributes resource bundle.
*/
private static final ResourceBundle dc =
ResourceBundle.getBundle("org.xbib.io.iso23950.cql.dc");
/**
* Context map.
*/
private final Map<String, ResourceBundle> contexts = new HashMap<String, ResourceBundle>() {
private static final long serialVersionUID = 8199395368653216950L;
{
put("bib", bib);
put("dc", dc);
put("bib", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.bib-1"));
put("dc", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.dc"));
put("gbv", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.gbv"));
}
};
private Stack<ASN1Any> result;
@ -90,10 +78,10 @@ public final class CQLRPNGenerator implements Visitor {
}
if (!result.isEmpty()) {
this.rpnQuery = new RPNQuery();
rpnQuery.s_rpn = (RPNStructure) result.pop();
rpnQuery.rpn = (RPNStructure) result.pop();
// Z39.50 BIB-1: urn:oid:1.2.840.10003.3.1
rpnQuery.s_attributeSet = new AttributeSetId();
rpnQuery.s_attributeSet.value = new ASN1ObjectIdentifier(new int[]{1, 2, 840, 10003, 3, 1});
rpnQuery.attributeSet = new AttributeSetId();
rpnQuery.attributeSet.value = new ASN1ObjectIdentifier(new int[]{1, 2, 840, 10003, 3, 1});
} else {
throw new SyntaxException("unable to generate RPN from CQL");
}
@ -154,13 +142,13 @@ public final class CQLRPNGenerator implements Visitor {
BooleanOperator op = node.getBooleanGroup().getOperator();
switch (op) {
case AND:
rpn.c_rpnRpnOp.s_op.c_and = new ASN1Null();
rpn.c_rpnRpnOp.s_op.andOp = new ASN1Null();
break;
case OR:
rpn.c_rpnRpnOp.s_op.c_or = new ASN1Null();
rpn.c_rpnRpnOp.s_op.orOp = new ASN1Null();
break;
case NOT:
rpn.c_rpnRpnOp.s_op.c_and_not = new ASN1Null();
rpn.c_rpnRpnOp.s_op.andNotOp = new ASN1Null();
break;
default:
break;
@ -193,17 +181,17 @@ public final class CQLRPNGenerator implements Visitor {
node.getRelation().accept(this);
}
Operand operand = new Operand();
operand.c_attrTerm = new AttributesPlusTerm();
operand.c_attrTerm.sTerm = new org.xbib.io.iso23950.v3.Term();
operand.c_attrTerm.sTerm.c_general = new ASN1OctetString(node.getTerm().getValue());
operand.attrTerm = new AttributesPlusTerm();
operand.attrTerm.term = new org.xbib.io.iso23950.v3.Term();
operand.attrTerm.term.c_general = new ASN1OctetString(node.getTerm().getValue());
Stack<AttributeElement> attrs = new Stack<>();
ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;
while (any != null) {
attrs.push((AttributeElement) any);
any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;
}
operand.c_attrTerm.sAttributes = new AttributeList();
operand.c_attrTerm.sAttributes.value = attrs.toArray(new AttributeElement[attrs.size()]);
operand.attrTerm.attributes = new AttributeList();
operand.attrTerm.attributes.value = attrs.toArray(new AttributeElement[attrs.size()]);
RPNStructure rpn = new RPNStructure();
rpn.c_op = operand;
result.push(rpn);
@ -248,9 +236,9 @@ public final class CQLRPNGenerator implements Visitor {
}
if (n != 3) {
AttributeElement ae = new AttributeElement();
ae.sAttributeType = new ASN1Integer(t);
ae.attributeType = new ASN1Integer(t);
ae.attributeValue = new AttributeElementAttributeValue();
ae.attributeValue.cNumeric = new ASN1Integer(n);
ae.attributeValue.numeric = new ASN1Integer(n);
result.push(ae);
}
}
@ -289,9 +277,9 @@ public final class CQLRPNGenerator implements Visitor {
}
if (n != 100) {
AttributeElement ae = new AttributeElement();
ae.sAttributeType = new ASN1Integer(t);
ae.attributeType = new ASN1Integer(t);
ae.attributeValue = new AttributeElementAttributeValue();
ae.attributeValue.cNumeric = new ASN1Integer(n);
ae.attributeValue.numeric = new ASN1Integer(n);
result.push(ae);
v = v.replaceAll("\\*", "");
}
@ -318,9 +306,9 @@ public final class CQLRPNGenerator implements Visitor {
int t = 1;
int n = getUseAttr(context, node.getName());
AttributeElement ae = new AttributeElement();
ae.sAttributeType = new ASN1Integer(t);
ae.attributeType = new ASN1Integer(t);
ae.attributeValue = new AttributeElementAttributeValue();
ae.attributeValue.cNumeric = new ASN1Integer(n);
ae.attributeValue.numeric = new ASN1Integer(n);
result.push(ae);
}

View file

@ -1,6 +1,7 @@
package org.xbib.io.iso23950.netty;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
@ -11,17 +12,18 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.CharsetUtil;
import org.xbib.io.iso23950.v3.PDU;
import java.io.IOException;
import java.net.InetSocketAddress;
public class Client {
/**
*
*/
public class NettyZClient {
private final EventLoopGroup group;
private final Bootstrap clientBootstrap;
public Client() {
public NettyZClient() {
this.group = new NioEventLoopGroup();
clientBootstrap = new Bootstrap();
clientBootstrap.group(group);
@ -40,15 +42,12 @@ public class Client {
}
public void writePDU(PDU pdu) throws IOException {
}
public void shutdown() throws InterruptedException {
group.shutdownGracefully().sync();
}
class Handler extends SimpleChannelInboundHandler {
class Handler extends SimpleChannelInboundHandler<ByteBuf> {
@Override
public void channelActive(ChannelHandlerContext channelHandlerContext){
@ -62,7 +61,7 @@ public class Client {
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
}
}

View file

@ -1,14 +1,57 @@
package org.xbib.io.iso23950.operations;
import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BEREncoding;
import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.v3.PDU;
import org.xbib.io.iso23950.v3.Close;
import org.xbib.io.iso23950.v3.InitializeRequest;
import org.xbib.io.iso23950.v3.InitializeResponse;
import org.xbib.io.iso23950.v3.PresentRequest;
import org.xbib.io.iso23950.v3.PresentResponse;
import org.xbib.io.iso23950.v3.ScanRequest;
import org.xbib.io.iso23950.v3.ScanResponse;
import org.xbib.io.iso23950.v3.SearchRequest;
import org.xbib.io.iso23950.v3.SearchResponse;
import java.io.IOException;
public class AbstractOperation {
/**
* Class for representing a <code>PDU</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
* PDU ::=
* CHOICE {
* initRequest [20] IMPLICIT InitializeRequest
* initResponse [21] IMPLICIT InitializeResponse
* searchRequest [22] IMPLICIT SearchRequest
* searchResponse [23] IMPLICIT SearchResponse
* presentRequest [24] IMPLICIT PresentRequest
* presentResponse [25] IMPLICIT PresentResponse
* deleteResultSetRequest [26] IMPLICIT DeleteResultSetRequest
* deleteResultSetResponse [27] IMPLICIT DeleteResultSetResponse
* accessControlRequest [28] IMPLICIT AccessControlRequest
* accessControlResponse [29] IMPLICIT AccessControlResponse
* resourceControlRequest [30] IMPLICIT ResourceControlRequest
* resourceControlResponse [31] IMPLICIT ResourceControlResponse
* triggerResourceControlRequest [32] IMPLICIT TriggerResourceControlRequest
* resourceReportRequest [33] IMPLICIT ResourceReportRequest
* resourceReportResponse [34] IMPLICIT ResourceReportResponse
* scanRequest [35] IMPLICIT ScanRequest
* scanResponse [36] IMPLICIT ScanResponse
* sortRequest [43] IMPLICIT SortRequest
* sortResponse [44] IMPLICIT SortResponse
* segmentRequest [45] IMPLICIT Segment
* extendedServicesRequest [46] IMPLICIT ExtendedServicesRequest
* extendedServicesResponse [47] IMPLICIT ExtendedServicesResponse
* close [48] IMPLICIT Close
* }
* </pre>
*
* @param <IN> input parameter
* @param <OUT> output parameter
*/
public class AbstractOperation<IN extends ASN1Any, OUT extends ASN1Any> {
protected final BERReader reader;
@ -19,21 +62,21 @@ public class AbstractOperation {
this.writer = writer;
}
protected void writePDU(PDU pdu) throws IOException {
protected void write(OUT protocolDataUnit) throws IOException {
try {
writer.write(pdu.berEncode());
writer.write(encode(protocolDataUnit));
} catch (ASN1Exception ex) {
throw new IOException(ex);
}
}
protected PDU readPDU() throws IOException {
protected IN read() throws IOException {
try {
BEREncoding ber = reader.read();
if (ber == null) {
throw new IOException("read PDU error");
}
return new PDU(ber, true);
return decode(ber);
} catch (ASN1Exception ex) {
throw new IOException(ex);
} catch (NullPointerException ex) {
@ -41,4 +84,77 @@ public class AbstractOperation {
}
}
private BEREncoding encode(OUT data) throws ASN1Exception {
if (data instanceof InitializeRequest) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 20);
}
if (data instanceof InitializeResponse) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 21);
}
if (data instanceof SearchRequest) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 22);
}
if (data instanceof SearchResponse) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 23);
}
if (data instanceof PresentRequest) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 24);
}
if (data instanceof PresentResponse) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 25);
}
if (data instanceof ScanRequest) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 35);
}
if (data instanceof ScanResponse) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 36);
}
if (data instanceof Close) {
return data.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 48);
}
throw new ASN1Exception("bad PDU to write");
}
@SuppressWarnings("unchecked")
private IN decode(BEREncoding ber) throws ASN1Exception {
if (ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1Exception("bad BER encoding: choice not matched");
}
switch (ber.getTag()) {
case 20:
return (IN)new InitializeRequest(ber, false);
case 21:
return (IN)new InitializeResponse(ber, false);
case 22:
return (IN)new SearchRequest(ber, false);
case 23:
return (IN)new SearchResponse(ber, false);
case 24:
return (IN)new PresentRequest(ber, false);
case 25:
return (IN)new PresentResponse(ber, false);
// 26 new DeleteResultSetRequest(ber, false);
// 27 new DeleteResultSetResponse(ber, false);
// 28 new AccessControlRequest(ber, false);
// 29 new AccessControlResponse(ber, false);
// 30 new ResourceControlRequest(ber, false);
// 31 new ResourceControlResponse(ber, false);
// 32 new TriggerResourceControlRequest(ber, false);
// 33 new ResourceReportRequest(ber, false);
// 34 new ResourceReportResponse(ber, false);
case 35:
return (IN) new ScanRequest(ber, false);
case 36:
return (IN) new ScanResponse(ber, false);
// 43 new SortRequest(ber, false);
// 44 new SortResponse(ber, false);
// 45 new Segment(ber, false);
// 46 new ExtendedServicesRequest(ber, false);
// 47 new ExtendedServicesResponse(ber, false);
case 48:
return (IN) new Close(ber, false);
}
throw new ASN1Exception("bad BER encoding: choice not matched");
}
}

View file

@ -0,0 +1,26 @@
package org.xbib.io.iso23950.operations;
import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.v3.Close;
import org.xbib.io.iso23950.v3.CloseReason;
import java.io.IOException;
public class CloseOperation extends AbstractOperation<Close, Close> {
public CloseOperation(BERReader reader, BERWriter writer) {
super(reader, writer);
}
public void execute(int reason) throws IOException {
Close close = new Close();
close.closeReason = new CloseReason();
close.closeReason.value = new ASN1Integer(reason);
close.referenceId = null;
write(close);
// do not wait, it may hang
//waitClosePDU();
}
}

View file

@ -12,39 +12,42 @@ import org.xbib.io.iso23950.v3.InitializeRequest;
import org.xbib.io.iso23950.v3.InitializeResponse;
import org.xbib.io.iso23950.v3.InternationalString;
import org.xbib.io.iso23950.v3.Options;
import org.xbib.io.iso23950.v3.PDU;
import org.xbib.io.iso23950.v3.ProtocolVersion;
import java.io.IOException;
import java.util.logging.Logger;
/**
* A Z39.50 Init operation.
*/
public class InitOperation extends AbstractOperation {
public class InitOperation extends AbstractOperation<InitializeResponse, InitializeRequest> {
private static final Logger logger = Logger.getLogger(InitOperation.class.getName());
private final String user;
private final String pass;
private String targetInfo;
public InitOperation(BERReader reader, BERWriter writer, String user, String pass) {
super(reader, writer);
this.user = user;
this.pass = pass;
}
public boolean execute(Integer preferredMessageSize,
InitListener initListener) throws IOException {
public boolean execute(Integer preferredMessageSize, InitListener initListener) throws IOException {
InitializeRequest init = new InitializeRequest();
boolean[] version = new boolean[3];
version[0] = true; // any version, should alwasy be true
version[1] = true; // Z39.50 version 2
version[2] = true; // Z39.50 version 3
init.s_protocolVersion = new ProtocolVersion();
init.s_protocolVersion.value = new ASN1BitString(version);
init.protocolVersion = new ProtocolVersion();
init.protocolVersion.value = new ASN1BitString(version);
boolean[] options = new boolean[15];
options[0] = true; // search
options[1] = true; // present
options[2] = true; // delete set
options[2] = false; // delete set
options[3] = false; // resource-report
options[4] = false; // trigger resource control
options[5] = false; // resource control
@ -57,48 +60,44 @@ public class InitOperation extends AbstractOperation {
options[12] = false; // level 2 segmentation
options[13] = false; // concurrent operations
options[14] = true; // named result sets
init.s_options = new Options();
init.s_options.value = new ASN1BitString(options);
init.s_preferredMessageSize = new ASN1Integer(preferredMessageSize);
init.s_exceptionalRecordSize = new ASN1Integer(preferredMessageSize * 2);
init.s_implementationId = new InternationalString();
init.s_implementationId.value = new ASN1GeneralString("1");
init.s_implementationName = new InternationalString();
init.s_implementationName.value = new ASN1GeneralString("Java ZClient");
init.s_implementationVersion = new InternationalString();
init.s_implementationVersion.value = new ASN1GeneralString("1.00");
init.options = new Options();
init.options.value = new ASN1BitString(options);
init.preferredMessageSize = new ASN1Integer(preferredMessageSize);
init.exceptionalRecordSize = new ASN1Integer(preferredMessageSize * 2);
init.implementationId = new InternationalString();
init.implementationId.value = new ASN1GeneralString("1");
init.implementationName = new InternationalString();
init.implementationName.value = new ASN1GeneralString("Java ZClient");
init.implementationVersion = new InternationalString();
init.implementationVersion.value = new ASN1GeneralString("1.00");
if (user != null) {
init.s_idAuthentication = new IdAuthentication();
init.s_idAuthentication.c_idPass = new IdAuthenticationIdPass();
init.s_idAuthentication.c_idPass.s_userId = new InternationalString();
init.s_idAuthentication.c_idPass.s_userId.value = new ASN1GeneralString(user);
init.idAuthentication = new IdAuthentication();
init.idAuthentication.idPass = new IdAuthenticationIdPass();
init.idAuthentication.idPass.s_userId = new InternationalString();
init.idAuthentication.idPass.s_userId.value = new ASN1GeneralString(user);
if (pass != null) {
init.s_idAuthentication.c_idPass.s_password = new InternationalString();
init.s_idAuthentication.c_idPass.s_password.value = new ASN1GeneralString(pass);
init.idAuthentication.idPass.s_password = new InternationalString();
init.idAuthentication.idPass.s_password.value = new ASN1GeneralString(pass);
}
/*if (group != null) {
init.s_idAuthentication.c_idPass.s_groupId = new InternationalString();
init.s_idAuthentication.c_idPass.s_groupId.value = new ASN1GeneralString(group);
}*/
}
PDU pduOut = new PDU();
pduOut.c_initRequest = init;
writePDU(pduOut);
PDU pduIn = readPDU();
InitializeResponse initResp = pduIn.c_initResponse;
String targetInfo;
if (initResp.s_implementationName != null) {
targetInfo = initResp.s_implementationName.toString();
if (initResp.s_implementationVersion != null) {
targetInfo += " - " + initResp.s_implementationVersion.toString();
write(init);
InitializeResponse initResp = read();
if (initResp.implementationName != null) {
targetInfo = initResp.implementationName.toString();
if (initResp.implementationVersion != null) {
targetInfo += " - " + initResp.implementationVersion.toString();
}
} else {
targetInfo = "server";
}
int targetVersion = 0;
if (initResp.s_protocolVersion != null) {
for (int n = 0; n < initResp.s_protocolVersion.value.get().length; n++) {
if (initResp.s_protocolVersion.value.get()[n]) {
if (initResp.protocolVersion != null) {
for (int n = 0; n < initResp.protocolVersion.value.get().length; n++) {
if (initResp.protocolVersion.value.get()[n]) {
targetVersion = n + 1;
}
}
@ -108,18 +107,20 @@ public class InitOperation extends AbstractOperation {
} else {
targetInfo += " (Version unknown)";
}
if (initResp.s_userInformationField != null) {
if (initResp.s_userInformationField.getSingleASN1Type() != null) {
targetInfo += "\n" + initResp.s_userInformationField.getSingleASN1Type().toString();
if (initResp.userInformationField != null && initResp.userInformationField.getSingleASN1Type() != null) {
targetInfo += "\n" + initResp.userInformationField.getSingleASN1Type().toString();
}
}
if (initResp.s_otherInfo != null) {
targetInfo += "\n" + initResp.s_otherInfo.toString();
if (initResp.otherInfo != null) {
targetInfo += "\n" + initResp.otherInfo.toString();
}
targetInfo = targetInfo.replaceAll("\"", "");
if (initListener != null) {
initListener.onInit(targetVersion, targetInfo);
}
return !initResp.s_result.get();
return !initResp.result.get();
}
public String getTargetInfo() {
return targetInfo;
}
}

View file

@ -7,19 +7,20 @@ import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1ObjectIdentifier;
import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.Diagnostics;
import org.xbib.io.iso23950.ErrorRecord;
import org.xbib.io.iso23950.Record;
import org.xbib.io.iso23950.RecordListener;
import org.xbib.io.iso23950.ResponseListener;
import org.xbib.io.iso23950.SearchListener;
import org.xbib.io.iso23950.exceptions.MessageSizeTooSmallException;
import org.xbib.io.iso23950.exceptions.NoRecordsReturnedException;
import org.xbib.io.iso23950.exceptions.RequestTerminatedByAccessControlException;
import org.xbib.io.iso23950.exceptions.RequestTerminatedException;
import org.xbib.io.iso23950.exceptions.ZException;
import org.xbib.io.iso23950.v3.DefaultDiagFormat;
import org.xbib.io.iso23950.v3.ElementSetNames;
import org.xbib.io.iso23950.v3.InternationalString;
import org.xbib.io.iso23950.v3.NamePlusRecord;
import org.xbib.io.iso23950.v3.PDU;
import org.xbib.io.iso23950.v3.PresentRequest;
import org.xbib.io.iso23950.v3.PresentRequestRecordComposition;
import org.xbib.io.iso23950.v3.PresentResponse;
@ -27,11 +28,16 @@ import org.xbib.io.iso23950.v3.PresentStatus;
import org.xbib.io.iso23950.v3.ResultSetId;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Present operation for Z39.50.
*/
public class PresentOperation extends AbstractOperation {
public class PresentOperation extends AbstractOperation<PresentResponse, PresentRequest> {
private static final Logger logger = Logger.getLogger(PresentOperation.class.getName());
private final String resultSetName;
@ -50,49 +56,55 @@ public class PresentOperation extends AbstractOperation {
}
public void execute(int offset, int length, int total,
ResponseListener responseListener, RecordListener recordListener) throws IOException {
PresentRequest pr = new PresentRequest();
pr.s_resultSetId = new ResultSetId();
pr.s_resultSetId.value = new InternationalString();
pr.s_resultSetId.value.value = new ASN1GeneralString(resultSetName);
pr.s_resultSetStartPoint = new ASN1Integer(offset);
pr.s_numberOfRecordsRequested = new ASN1Integer(length);
pr.s_recordComposition = new PresentRequestRecordComposition();
pr.s_recordComposition.c_simple = new ElementSetNames();
pr.s_recordComposition.c_simple.cGenericElementSetName = new InternationalString();
pr.s_recordComposition.c_simple.cGenericElementSetName.value = new ASN1GeneralString(elementSetName);
pr.s_preferredRecordSyntax = new ASN1ObjectIdentifier(makeOID(preferredRecordSyntax));
PDU pdu = new PDU();
pdu.c_presentRequest = pr;
SearchListener searchListener, RecordListener recordListener) throws IOException {
PresentRequest presentRequest = new PresentRequest();
presentRequest.resultSetId = new ResultSetId();
presentRequest.resultSetId.value = new InternationalString();
presentRequest.resultSetId.value.value = new ASN1GeneralString(resultSetName);
presentRequest.resultSetStartPoint = new ASN1Integer(offset);
presentRequest.numberOfRecordsRequested = new ASN1Integer(length);
presentRequest.recordComposition = new PresentRequestRecordComposition();
presentRequest.recordComposition.simple = new ElementSetNames();
presentRequest.recordComposition.simple.cGenericElementSetName = new InternationalString();
presentRequest.recordComposition.simple.cGenericElementSetName.value = new ASN1GeneralString(elementSetName);
presentRequest.preferredRecordSyntax = new ASN1ObjectIdentifier(makeOID(preferredRecordSyntax));
long millis = System.currentTimeMillis();
writePDU(pdu);
pdu = readPDU();
PresentResponse response = pdu.c_presentResponse;
int nReturned = response.s_numberOfRecordsReturned != null ? response.s_numberOfRecordsReturned.get() : 0;
int status = response.s_presentStatus.value != null ? response.s_presentStatus.value.get() : 0;
if (responseListener != null) {
responseListener.onResponse(status, total, nReturned, System.currentTimeMillis() - millis);
write(presentRequest);
PresentResponse response = read();
int nReturned = response.numberOfRecordsReturned != null ? response.numberOfRecordsReturned.get() : 0;
int status = response.presentStatus.value != null ? response.presentStatus.value.get() : 0;
if (searchListener != null) {
searchListener.onResponse(status, total, nReturned, System.currentTimeMillis() - millis);
}
if (status == PresentStatus.E_success) {
for (int n = 0; n < nReturned; n++) {
NamePlusRecord nr = response.s_records.c_responseRecords[n];
NamePlusRecord nr = response.records.c_responseRecords[n];
try {
if (nr.s_record.c_retrievalRecord != null) {
ASN1External asn1External = new ASN1External(nr.s_record.c_retrievalRecord.berEncode(), true);
if (nr.record.retrievalRecord != null) {
ASN1External asn1External = new ASN1External(nr.record.retrievalRecord.berEncode(), true);
Record record = new Record(offset + n, asn1External.getcOctetAligned().getBytes());
if (recordListener != null) {
recordListener.onRecord(record);
}
} else if (nr.s_record.c_surrogateDiagnostic != null) {
ASN1External asn1External =
new ASN1External(nr.s_record.c_surrogateDiagnostic.cDefaultFormat.berEncode(), true);
} else if (nr.record.surrogateDiagnostic != null) {
DefaultDiagFormat diagFormat = nr.record.surrogateDiagnostic.defaultFormat;
if (diagFormat != null) {
logger.log(Level.WARNING, diagFormat.toString());
}
ASN1External asn1External = nr.record.surrogateDiagnostic.externallyDefined;
if (asn1External != null) {
ErrorRecord record = new ErrorRecord(offset + n, asn1External.getcOctetAligned().getBytes());
if (recordListener != null) {
recordListener.onRecord(record);
}
}
}
} catch (ASN1Exception e) {
throw new IOException("Present error: " + e.getMessage());
logger.log(Level.WARNING, e.getMessage(), e);
if (recordListener != null) {
ErrorRecord record = new ErrorRecord(offset + n, e.getMessage().getBytes(StandardCharsets.UTF_8));
recordListener.onRecord(record);
}
}
}
} else {

View file

@ -0,0 +1,75 @@
package org.xbib.io.iso23950.operations;
import org.xbib.asn1.ASN1GeneralString;
import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1ObjectIdentifier;
import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.ScanListener;
import org.xbib.io.iso23950.pqf.PQFParser;
import org.xbib.io.iso23950.pqf.PQFRPNGenerator;
import org.xbib.io.iso23950.v3.AttributeSetId;
import org.xbib.io.iso23950.v3.AttributesPlusTerm;
import org.xbib.io.iso23950.v3.DatabaseName;
import org.xbib.io.iso23950.v3.InternationalString;
import org.xbib.io.iso23950.v3.RPNQuery;
import org.xbib.io.iso23950.v3.ScanRequest;
import org.xbib.io.iso23950.v3.ScanResponse;
import java.io.IOException;
import java.io.StringReader;
import java.util.List;
public class ScanOperation extends AbstractOperation<ScanResponse, ScanRequest> {
private final List<String> databases;
public ScanOperation(BERReader reader, BERWriter writer,
List<String> databases) {
super(reader, writer);
this.databases = databases;
}
public void executePQF(int nTerms, int step, int position, String pqf, ScanListener listener) throws IOException {
execute(nTerms, step, position, createRPNQueryFromPQF(pqf).rpn.c_op.attrTerm, listener);
}
public void execute(int nTerms, int step, int position, AttributesPlusTerm term, ScanListener listener) throws IOException {
ScanRequest scanRequest = new ScanRequest();
scanRequest.attributeSet = new AttributeSetId();
// Z39.50 BIB-1: urn:oid:1.2.840.10003.3.1
scanRequest.attributeSet.value =
new ASN1ObjectIdentifier(new int[]{1, 2, 840, 10003, 3, 1});
DatabaseName[] databaseNames = new DatabaseName[databases.size()];
for (int n = 0; n < databases.size(); n++) {
databaseNames[n] = new DatabaseName();
databaseNames[n].value = new InternationalString();
databaseNames[n].value.value = new ASN1GeneralString(databases.get(n));
}
scanRequest.databaseNames = databaseNames;
scanRequest.numberOfTermsRequested = new ASN1Integer(nTerms);
scanRequest.stepSize = new ASN1Integer(step);
scanRequest.preferredPositionInResponse = new ASN1Integer(position);
scanRequest.termListAndStartPoint = term;
write(scanRequest);
ScanResponse scanResponse = read();
if (scanResponse != null) {
if (scanResponse.scanStatus.get() == 0) {
for (int n = 0; n < scanResponse.entries.s_entries.length; n++) {
if (listener != null) {
listener.onScan(scanResponse.entries.s_entries[n].cTermInfo.berEncode());
}
}
}
}
}
private RPNQuery createRPNQueryFromPQF(String query) {
PQFRPNGenerator generator = new PQFRPNGenerator();
PQFParser parser = new PQFParser(new StringReader(query));
parser.parse();
parser.getResult().accept(generator);
return generator.getResult();
}
}

View file

@ -8,10 +8,14 @@ import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1Sequence;
import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter;
import org.xbib.cql.CQLParser;
import org.xbib.io.iso23950.Diagnostics;
import org.xbib.io.iso23950.cql.CQLRPNGenerator;
import org.xbib.io.iso23950.pqf.PQFParser;
import org.xbib.io.iso23950.pqf.PQFRPNGenerator;
import org.xbib.io.iso23950.v3.DatabaseName;
import org.xbib.io.iso23950.v3.InternationalString;
import org.xbib.io.iso23950.v3.OtherInformation1;
import org.xbib.io.iso23950.v3.PDU;
import org.xbib.io.iso23950.v3.PresentStatus;
import org.xbib.io.iso23950.v3.Query;
import org.xbib.io.iso23950.v3.RPNQuery;
@ -19,15 +23,19 @@ import org.xbib.io.iso23950.v3.SearchRequest;
import org.xbib.io.iso23950.v3.SearchResponse;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Base class for Z39.50 Search operation.
*/
public class SearchOperation extends AbstractOperation {
public class SearchOperation extends AbstractOperation<SearchResponse, SearchRequest> {
private static final Logger logger = Logger.getLogger(SearchOperation.class.getName());
private int count = -1;
@ -52,43 +60,48 @@ public class SearchOperation extends AbstractOperation {
this.results = new HashMap<>();
}
public boolean executePQF(String pqf) throws IOException {
return execute(createRPNQueryFromPQF(pqf));
}
public boolean executeCQL(String cql) throws IOException {
return execute(createRPNQueryFromCQL(cql));
}
public boolean execute(RPNQuery rpn) throws IOException {
try {
SearchRequest search = new SearchRequest();
search.s_query = new Query();
search.s_query.c_type_1 = rpn;
search.s_smallSetUpperBound = new ASN1Integer(0);
search.s_largeSetLowerBound = new ASN1Integer(1);
search.s_mediumSetPresentNumber = new ASN1Integer(0);
search.s_replaceIndicator = new ASN1Boolean(true);
search.s_resultSetName = new InternationalString();
search.s_resultSetName.value = new ASN1GeneralString(resultSetName);
search.query = new Query();
search.query.c_type_1 = rpn;
search.smallSetUpperBound = new ASN1Integer(0);
search.largeSetLowerBound = new ASN1Integer(1);
search.mediumSetPresentNumber = new ASN1Integer(0);
search.replaceIndicator = new ASN1Boolean(true);
search.resultSetName = new InternationalString();
search.resultSetName.value = new ASN1GeneralString(resultSetName);
DatabaseName dbs[] = new DatabaseName[databases.size()];
for (int n = 0; n < databases.size(); n++) {
dbs[n] = new DatabaseName();
dbs[n].value = new InternationalString();
dbs[n].value.value = new ASN1GeneralString(databases.get(n));
}
search.s_databaseNames = dbs;
PDU pduRequest = new PDU();
pduRequest.c_searchRequest = search;
writePDU(pduRequest);
PDU pduResponse = readPDU();
SearchResponse response = pduResponse.c_searchResponse;
count = response.s_resultCount.get();
search.databaseNames = dbs;
write(search);
SearchResponse response = read();
if (response != null) {
if (response.resultCount != null) {
count = response.resultCount.get();
}
ASN1Boolean b = response.s_searchStatus;
status = b != null && b.get();
if (!status) {
String message = "no message";
if (response.s_records != null && response.s_records.c_nonSurrogateDiagnostic != null) {
try {
message = "ASN error, non-surrogate diagnostics: " +
response.s_records.c_nonSurrogateDiagnostic.berEncode();
} catch (ASN1Exception e) {
//
int code = response.s_records.c_nonSurrogateDiagnostic.condition.get();
String addInfo = response.s_records.c_nonSurrogateDiagnostic.addinfo.v2Addinfo.get();
throw new Diagnostics(code, addInfo);
}
}
throw new IOException(host + ": " + message);
throw new IOException(host + ": error, without diagnostic");
}
PresentStatus presentStatus = response.s_presentStatus;
if (presentStatus != null && presentStatus.value != null && presentStatus.value.get() == 5) {
@ -96,7 +109,7 @@ public class SearchOperation extends AbstractOperation {
}
if (response.s_additionalSearchInfo != null && response.s_additionalSearchInfo.value[0] != null) {
OtherInformation1 info = response.s_additionalSearchInfo.value[0];
ASN1Sequence targetSeq = (ASN1Sequence) info.s_information.c_externallyDefinedInfo.getSingleASN1Type();
ASN1Sequence targetSeq = (ASN1Sequence) info.information.c_externallyDefinedInfo.getSingleASN1Type();
ASN1Any[] targets = targetSeq.get();
DatabaseName dbName;
for (int i = 0; i < targets.length; i++) {
@ -112,13 +125,16 @@ public class SearchOperation extends AbstractOperation {
ASN1Integer res = (ASN1Integer) details[1];
results.put(target, res.get());
} catch (ASN1Exception ex) {
// non-fatal String message = "Error in accessing additional search info.";
logger.log(Level.WARNING, ex.getMessage(), ex);
// non-fatal, e.g. String message = "Error in accessing additional search info.";
results.put(target, -1);
}
}
}
} catch (SocketTimeoutException e) {
throw new IOException(host + ": timeout", e);
}
} catch (IOException e) {
// set host in IOException message
throw new IOException(host + ": " + e.getMessage(), e);
}
return status;
}
@ -135,4 +151,19 @@ public class SearchOperation extends AbstractOperation {
return results;
}
private RPNQuery createRPNQueryFromCQL(String query) {
CQLRPNGenerator generator = new CQLRPNGenerator();
CQLParser parser = new CQLParser(query);
parser.parse();
parser.getCQLQuery().accept(generator);
return generator.getQueryResult();
}
private RPNQuery createRPNQueryFromPQF(String query) {
PQFRPNGenerator generator = new PQFRPNGenerator();
PQFParser parser = new PQFParser(new StringReader(query));
parser.parse();
parser.getResult().accept(generator);
return generator.getResult();
}
}

View file

@ -39,11 +39,11 @@ public class PQFRPNGenerator implements Visitor {
public void visit(PQF pqf) {
if (!result.isEmpty()) {
this.rpnQuery = new RPNQuery();
rpnQuery.s_rpn = (RPNStructure) result.pop();
rpnQuery.rpn = (RPNStructure) result.pop();
if (pqf.getAttrSet() == null) {
// Z39.50 BIB-1: urn:oid:1.2.840.10003.3.1
rpnQuery.s_attributeSet = new AttributeSetId();
rpnQuery.s_attributeSet.value = new ASN1ObjectIdentifier(new int[]{1, 2, 840, 10003, 3, 1});
rpnQuery.attributeSet = new AttributeSetId();
rpnQuery.attributeSet.value = new ASN1ObjectIdentifier(new int[]{1, 2, 840, 10003, 3, 1});
}
} else {
throw new SyntaxException("no valid PQF found");
@ -53,17 +53,17 @@ public class PQFRPNGenerator implements Visitor {
@Override
public void visit(Query query) {
Operand operand = new Operand();
operand.c_attrTerm = new AttributesPlusTerm();
operand.c_attrTerm.sTerm = new org.xbib.io.iso23950.v3.Term();
operand.c_attrTerm.sTerm.c_general = new ASN1OctetString(query.getTerm().getValue());
operand.attrTerm = new AttributesPlusTerm();
operand.attrTerm.term = new org.xbib.io.iso23950.v3.Term();
operand.attrTerm.term.c_general = new ASN1OctetString(query.getTerm().getValue());
Stack<AttributeElement> attrs = new Stack<>();
ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;
while (any != null) {
attrs.push((AttributeElement) any);
any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;
}
operand.c_attrTerm.sAttributes = new AttributeList();
operand.c_attrTerm.sAttributes.value = attrs.toArray(new AttributeElement[attrs.size()]);
operand.attrTerm.attributes = new AttributeList();
operand.attrTerm.attributes.value = attrs.toArray(new AttributeElement[attrs.size()]);
RPNStructure rpn = new RPNStructure();
rpn.c_op = operand;
if (attrs.size() > 0) {
@ -78,13 +78,13 @@ public class PQFRPNGenerator implements Visitor {
rpn.c_rpnRpnOp = new RPNStructureRpnRpnOp();
rpn.c_rpnRpnOp.s_op = new Operator();
if ("@and".equals(op)) {
rpn.c_rpnRpnOp.s_op.c_and = new ASN1Null();
rpn.c_rpnRpnOp.s_op.andOp = new ASN1Null();
}
if ("@or".equals(op)) {
rpn.c_rpnRpnOp.s_op.c_or = new ASN1Null();
rpn.c_rpnRpnOp.s_op.orOp = new ASN1Null();
}
if ("@not".equals(op)) {
rpn.c_rpnRpnOp.s_op.c_and_not = new ASN1Null();
rpn.c_rpnRpnOp.s_op.andNotOp = new ASN1Null();
}
rpn.c_rpnRpnOp.s_rpn1 = (RPNStructure) result.pop();
rpn.c_rpnRpnOp.s_rpn2 = (RPNStructure) result.pop();
@ -94,9 +94,9 @@ public class PQFRPNGenerator implements Visitor {
@Override
public void visit(AttrStr attrspec) {
AttributeElement ae = new AttributeElement();
ae.sAttributeType = (ASN1Integer) result.pop();
ae.attributeType = (ASN1Integer) result.pop();
ae.attributeValue = new AttributeElementAttributeValue();
ae.attributeValue.cNumeric = (ASN1Integer) result.pop();
ae.attributeValue.numeric = (ASN1Integer) result.pop();
result.push(ae);
}

View file

@ -52,13 +52,13 @@ public final class AccessControlRequestSecurityChallenge extends ASN1Any {
BERConstructed tagwrapper;
cSimpleForm = null;
cExternallyDefined = null;
if (ber.tagGet() == 37 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 37 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
cSimpleForm = new ASN1OctetString(ber, false);
return;
}
if (ber.tagGet() == 0 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 0 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {

View file

@ -92,8 +92,8 @@ public final class AccessControlResponse extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 223 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 223 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {

View file

@ -54,13 +54,13 @@ public final class AccessControlResponseSecurityChallengeResponse extends ASN1An
BERConstructed tagwrapper;
cSimpleForm = null;
cExternallyDefined = null;
if (ber.tagGet() == 38 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 38 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
cSimpleForm = new ASN1OctetString(ber, false);
return;
}
if (ber.tagGet() == 0 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 0 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {

View file

@ -23,14 +23,13 @@ public final class AttributeElement extends ASN1Any {
public AttributeSetId attributeSetId; // optional
public ASN1Integer sAttributeType;
public ASN1Integer attributeType;
public AttributeElementAttributeValue attributeValue;
/**
* Default constructor for a AttributeElement.
*/
public AttributeElement() {
}
@ -56,6 +55,7 @@ public final class AttributeElement extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -70,8 +70,8 @@ public final class AttributeElement extends ASN1Any {
throw new ASN1Exception("AttributeElement: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
attributeSetId = new AttributeSetId(p, false);
part++;
}
@ -79,11 +79,11 @@ public final class AttributeElement extends ASN1Any {
throw new ASN1Exception("AttributeElement: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 120 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 120 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("AttributeElement: bad tag in s_attributeType\n");
}
sAttributeType = new ASN1Integer(p, false);
attributeType = new ASN1Integer(p, false);
part++;
if (numParts <= part) {
throw new ASN1Exception("AttributeElement: incomplete");
@ -102,6 +102,7 @@ public final class AttributeElement extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -118,6 +119,7 @@ public final class AttributeElement extends ASN1Any {
* @see org.xbib.asn1.BEREncoding#CONTEXT_SPECIFIC_TAG
* @see org.xbib.asn1.BEREncoding#PRIVATE_TAG
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 2;
if (attributeSetId != null) {
@ -128,7 +130,7 @@ public final class AttributeElement extends ASN1Any {
if (attributeSetId != null) {
fields[x++] = attributeSetId.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
}
fields[x++] = sAttributeType.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 120);
fields[x++] = attributeType.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 120);
fields[x] = attributeValue.berEncode();
return new BERConstructed(tagType, tag, fields);
}
@ -137,6 +139,7 @@ public final class AttributeElement extends ASN1Any {
* Returns a new String object containing a text representing
* of the AttributeElement.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
@ -149,7 +152,7 @@ public final class AttributeElement extends ASN1Any {
str.append(", ");
}
str.append("attributeType ");
str.append(sAttributeType);
str.append(attributeType);
outputted++;
if (0 < outputted) {
str.append(", ");

View file

@ -18,9 +18,9 @@ import org.xbib.asn1.BEREncoding;
*/
public final class AttributeElementAttributeValue extends ASN1Any {
public ASN1Integer cNumeric;
public ASN1Integer numeric;
public AttributeElementAttributeValueComplex attributeValueComplex;
public AttributeElementAttributeValueComplex complex;
/**
* Default constructor for a AttributeElement_attributeValue.
@ -52,16 +52,16 @@ public final class AttributeElementAttributeValue extends ASN1Any {
* @throws ASN1Exception if the BER encoding is bad.
*/
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
cNumeric = null;
attributeValueComplex = null;
if (ber.tagGet() == 121 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
cNumeric = new ASN1Integer(ber, false);
numeric = null;
complex = null;
if (ber.getTag() == 121 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
numeric = new ASN1Integer(ber, false);
return;
}
if (ber.tagGet() == 224 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
attributeValueComplex = new AttributeElementAttributeValueComplex(ber, false);
if (ber.getTag() == 224 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
complex = new AttributeElementAttributeValueComplex(ber, false);
return;
}
throw new ASN1Exception("AttributeElement_attributeValue: bad BER encoding: choice not matched");
@ -75,14 +75,14 @@ public final class AttributeElementAttributeValue extends ASN1Any {
*/
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
if (cNumeric != null) {
chosen = cNumeric.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 121);
if (numeric != null) {
chosen = numeric.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 121);
}
if (attributeValueComplex != null) {
if (complex != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = attributeValueComplex.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 224);
chosen = complex.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 224);
}
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
@ -101,17 +101,17 @@ public final class AttributeElementAttributeValue extends ASN1Any {
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (cNumeric != null) {
if (numeric != null) {
found = true;
str.append("numeric ");
str.append(cNumeric);
str.append(numeric);
}
if (attributeValueComplex != null) {
if (complex != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: complex> ");
}
str.append("complex ");
str.append(attributeValueComplex);
str.append(complex);
}
str.append("}");
return str.toString();

View file

@ -20,8 +20,8 @@ import org.xbib.asn1.BEREncoding;
*/
public final class AttributeElementAttributeValueComplex extends ASN1Any {
public StringOrNumeric[] sList;
public ASN1Integer[] sSemanticAction; // optional
public StringOrNumeric[] list;
public ASN1Integer[] semanticAction; // optional
/**
* Constructor for a AttributeElement_attributeValue_complex from a BER encoding.
@ -32,8 +32,7 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public AttributeElementAttributeValueComplex(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public AttributeElementAttributeValueComplex(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -46,6 +45,7 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -60,36 +60,36 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
throw new ASN1Exception("AttributeElement_attributeValue_complex: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("AttributeElement_attributeValue_complex: bad tag in s_list\n");
}
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
sList = new StringOrNumeric[parts];
list = new StringOrNumeric[parts];
int n;
for (n = 0; n < parts; n++) {
sList[n] = new StringOrNumeric(cons.elementAt(n), true);
list[n] = new StringOrNumeric(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
}
part++;
sSemanticAction = null;
semanticAction = null;
if (numParts <= part) {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 2 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 2 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
sSemanticAction = new ASN1Integer[parts];
semanticAction = new ASN1Integer[parts];
int n;
for (n = 0; n < parts; n++) {
sSemanticAction[n] = new ASN1Integer(cons.elementAt(n), true);
semanticAction[n] = new ASN1Integer(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
@ -108,6 +108,7 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -120,24 +121,25 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (sSemanticAction != null) {
if (semanticAction != null) {
numFields++;
}
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
BEREncoding f2[];
int p;
f2 = new BEREncoding[sList.length];
for (p = 0; p < sList.length; p++) {
f2[p] = sList[p].berEncode();
f2 = new BEREncoding[list.length];
for (p = 0; p < list.length; p++) {
f2[p] = list[p].berEncode();
}
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 1, f2);
if (sSemanticAction != null) {
f2 = new BEREncoding[sSemanticAction.length];
for (p = 0; p < sSemanticAction.length; p++) {
f2[p] = sSemanticAction[p].berEncode();
if (semanticAction != null) {
f2 = new BEREncoding[semanticAction.length];
for (p = 0; p < semanticAction.length; p++) {
f2[p] = semanticAction[p].berEncode();
}
fields[x] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 2, f2);
}
@ -148,31 +150,32 @@ public final class AttributeElementAttributeValueComplex extends ASN1Any {
* Returns a new String object containing a text representing
* of the AttributeElement_attributeValue_complex.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("list ");
str.append("{");
for (p = 0; p < sList.length; p++) {
for (p = 0; p < list.length; p++) {
if (p != 0) {
str.append(", ");
}
str.append(sList[p]);
str.append(list[p]);
}
str.append("}");
outputted++;
if (sSemanticAction != null) {
if (semanticAction != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("semanticAction ");
str.append("{");
for (p = 0; p < sSemanticAction.length; p++) {
for (p = 0; p < semanticAction.length; p++) {
if (p != 0) {
str.append(", ");
}
str.append(sSemanticAction[p]);
str.append(semanticAction[p]);
}
str.append("}");
}

View file

@ -46,11 +46,12 @@ public final class AttributeList extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
if (checkTag) {
if (ber.tagGet() != 44 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("AttributeList: bad BER: tag=" + ber.tagGet() + " expected 44\n");
if (ber.getTag() != 44 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("AttributeList: bad BER: tag=" + ber.getTag() + " expected 44\n");
}
}
BERConstructed berConstructed;
@ -73,6 +74,7 @@ public final class AttributeList extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 44);
}
@ -85,6 +87,7 @@ public final class AttributeList extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding fields[] = new BERConstructed[value.length];
int p;
@ -98,6 +101,7 @@ public final class AttributeList extends ASN1Any {
* Returns a new String object containing a text representing
* of the AttributeList.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int p;

View file

@ -45,6 +45,7 @@ public final class AttributeSetId extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
value = new ASN1ObjectIdentifier(ber, checkTag);
}
@ -55,6 +56,7 @@ public final class AttributeSetId extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return value.berEncode();
}
@ -67,6 +69,7 @@ public final class AttributeSetId extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -75,6 +78,7 @@ public final class AttributeSetId extends ASN1Any {
* Returns a new String object containing a text representing
* of the AttributeSetId.
*/
@Override
public String toString() {
return value.toString();
}

View file

@ -18,14 +18,13 @@ import org.xbib.asn1.BEREncoding;
*/
public final class AttributesPlusTerm extends ASN1Any {
public AttributeList sAttributes;
public AttributeList attributes;
public Term sTerm;
public Term term;
/**
* Default constructor for a AttributesPlusTerm.
*/
public AttributesPlusTerm() {
}
@ -38,9 +37,7 @@ public final class AttributesPlusTerm extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public AttributesPlusTerm(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public AttributesPlusTerm(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -53,38 +50,37 @@ public final class AttributesPlusTerm extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
if (checkTag) {
if (ber.tagGet() != 102 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("AttributesPlusTerm: bad BER: tag=" + ber.tagGet() + " expected 102\n");
if (ber.getTag() != 102 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 102");
}
}
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("AttributesPlusTerm: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
throw new ASN1Exception("AttributesPlusTerm: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sAttributes = new AttributeList(p, true);
attributes = new AttributeList(p, true);
part++;
if (numParts <= part) {
throw new ASN1Exception("AttributesPlusTerm: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sTerm = new Term(p, true);
term = new Term(p, true);
part++;
if (part < numParts) {
throw new ASN1Exception("AttributesPlusTerm: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -94,6 +90,7 @@ public final class AttributesPlusTerm extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 102);
}
@ -106,12 +103,13 @@ public final class AttributesPlusTerm extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 2;
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
fields[x++] = sAttributes.berEncode();
fields[x] = sTerm.berEncode();
fields[x++] = attributes.berEncode();
fields[x] = term.berEncode();
return new BERConstructed(tagType, tag, fields);
}
@ -119,17 +117,18 @@ public final class AttributesPlusTerm extends ASN1Any {
* Returns a new String object containing a text representing
* of the AttributesPlusTerm.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("attributes ");
str.append(sAttributes);
str.append(attributes);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("term ");
str.append(sTerm);
str.append(term);
str.append("}");
return str.toString();
}

View file

@ -25,17 +25,17 @@ import org.xbib.asn1.BEREncoding;
public final class Close extends ASN1Any {
public ReferenceId sReferenceId; // optional
public ReferenceId referenceId; // optional
public CloseReason sCloseReason;
public CloseReason closeReason;
public InternationalString sDiagnosticInformation; // optional
public InternationalString diagnosticInformation; // optional
public ResourceReportId sResourceReportFormat; // optional
public ResourceReportId resourceReportFormat; // optional
public ResourceReport sResourceReport; // optional
public ResourceReport resourceReport; // optional
public OtherInformation sOtherInfo; // optional
public OtherInformation otherInformation; // optional
/**
* Default constructor for a Close.
@ -66,6 +66,7 @@ public final class Close extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -82,45 +83,45 @@ public final class Close extends ASN1Any {
}
p = berConstructed.elementAt(part);
try {
sReferenceId = new ReferenceId(p, true);
referenceId = new ReferenceId(p, true);
part++;
} catch (ASN1Exception e) {
sReferenceId = null;
referenceId = null;
}
if (numParts <= part) {
throw new ASN1Exception("Close: incomplete");
}
p = berConstructed.elementAt(part);
sCloseReason = new CloseReason(p, true);
closeReason = new CloseReason(p, true);
part++;
sDiagnosticInformation = null;
sResourceReportFormat = null;
sResourceReport = null;
sOtherInfo = null;
diagnosticInformation = null;
resourceReportFormat = null;
resourceReport = null;
otherInformation = null;
if (numParts <= part) {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 3 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sDiagnosticInformation = new InternationalString(p, false);
if (p.getTag() == 3 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
diagnosticInformation = new InternationalString(p, false);
part++;
}
if (numParts <= part) {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 4 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sResourceReportFormat = new ResourceReportId(p, false);
if (p.getTag() == 4 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
resourceReportFormat = new ResourceReportId(p, false);
part++;
}
if (numParts <= part) {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 5 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 5 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {
@ -129,7 +130,7 @@ public final class Close extends ASN1Any {
if (tagged.numberComponents() != 1) {
throw new ASN1EncodingException("Close: bad BER encoding: s_resourceReport tag bad");
}
sResourceReport = new ResourceReport(tagged.elementAt(0), true);
resourceReport = new ResourceReport(tagged.elementAt(0), true);
part++;
}
if (numParts <= part) {
@ -137,10 +138,10 @@ public final class Close extends ASN1Any {
}
p = berConstructed.elementAt(part);
try {
sOtherInfo = new OtherInformation(p, true);
otherInformation = new OtherInformation(p, true);
part++;
} catch (ASN1Exception e) {
sOtherInfo = null;
otherInformation = null;
}
if (part < numParts) {
throw new ASN1Exception("Close: bad BER: extra data " + part + "/" + numParts + " processed");
@ -153,6 +154,7 @@ public final class Close extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -165,43 +167,44 @@ public final class Close extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (sReferenceId != null) {
if (referenceId != null) {
numFields++;
}
if (sDiagnosticInformation != null) {
if (diagnosticInformation != null) {
numFields++;
}
if (sResourceReportFormat != null) {
if (resourceReportFormat != null) {
numFields++;
}
if (sResourceReport != null) {
if (resourceReport != null) {
numFields++;
}
if (sOtherInfo != null) {
if (otherInformation != null) {
numFields++;
}
BEREncoding[] fields = new BEREncoding[numFields];
int x = 0;
BEREncoding[] enc;
if (sReferenceId != null) {
fields[x++] = sReferenceId.berEncode();
if (referenceId != null) {
fields[x++] = referenceId.berEncode();
}
fields[x++] = sCloseReason.berEncode();
if (sDiagnosticInformation != null) {
fields[x++] = sDiagnosticInformation.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 3);
fields[x++] = closeReason.berEncode();
if (diagnosticInformation != null) {
fields[x++] = diagnosticInformation.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 3);
}
if (sResourceReportFormat != null) {
fields[x++] = sResourceReportFormat.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 4);
if (resourceReportFormat != null) {
fields[x++] = resourceReportFormat.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 4);
}
if (sResourceReport != null) {
if (resourceReport != null) {
enc = new BEREncoding[1];
enc[0] = sResourceReport.berEncode();
enc[0] = resourceReport.berEncode();
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 5, enc);
}
if (sOtherInfo != null) {
fields[x] = sOtherInfo.berEncode();
if (otherInformation != null) {
fields[x] = otherInformation.berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -210,50 +213,51 @@ public final class Close extends ASN1Any {
* Returns a new String object containing a text representing
* of the Close.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (sReferenceId != null) {
if (referenceId != null) {
str.append("referenceId ");
str.append(sReferenceId);
str.append(referenceId);
outputted++;
}
if (0 < outputted) {
str.append(", ");
}
str.append("closeReason ");
str.append(sCloseReason);
str.append(closeReason);
outputted++;
if (sDiagnosticInformation != null) {
if (diagnosticInformation != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("diagnosticInformation ");
str.append(sDiagnosticInformation);
str.append(diagnosticInformation);
outputted++;
}
if (sResourceReportFormat != null) {
if (resourceReportFormat != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("resourceReportFormat ");
str.append(sResourceReportFormat);
str.append(resourceReportFormat);
outputted++;
}
if (sResourceReport != null) {
if (resourceReport != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("resourceReport ");
str.append(sResourceReport);
str.append(resourceReport);
outputted++;
}
if (sOtherInfo != null) {
if (otherInformation != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("otherInfo ");
str.append(sOtherInfo);
str.append(otherInformation);
}
str.append("}");
return str.toString();

View file

@ -55,11 +55,12 @@ public final class CloseReason extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
if (checkTag) {
if (ber.tagGet() != 211 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("CloseReason: bad BER: tag=" + ber.tagGet() + " expected 211");
if (ber.getTag() != 211 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("CloseReason: bad BER: tag=" + ber.getTag() + " expected 211");
}
}
value = new ASN1Integer(ber, false);
@ -71,6 +72,7 @@ public final class CloseReason extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 211);
}
@ -83,6 +85,7 @@ public final class CloseReason extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -91,6 +94,7 @@ public final class CloseReason extends ASN1Any {
* Returns a new String object containing a text representing
* of the CloseReason.
*/
@Override
public String toString() {
return value.toString();
}

View file

@ -23,18 +23,14 @@ import org.xbib.asn1.BEREncoding;
*/
public final class CompSpec extends ASN1Any {
public ASN1Boolean sSelectAlternativeSyntax;
public ASN1Boolean selectAlternativeSyntax;
public Specification sGeneric; // optional
public CompSpecDbSpecific[] dbSpecifics; // optional
public ASN1ObjectIdentifier[] objectIdentifiers; // optional
public ASN1ObjectIdentifier[] recordSyntax; // optional
/**
* Default constructor for a CompSpec.
*/
public CompSpec() {
}
@ -60,6 +56,7 @@ public final class CompSpec extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -74,21 +71,21 @@ public final class CompSpec extends ASN1Any {
throw new ASN1Exception("CompSpec: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("CompSpec: bad tag in s_selectAlternativeSyntax\n");
}
sSelectAlternativeSyntax = new ASN1Boolean(p, false);
selectAlternativeSyntax = new ASN1Boolean(p, false);
part++;
sGeneric = null;
dbSpecifics = null;
objectIdentifiers = null;
recordSyntax = null;
if (numParts <= part) {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 2 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 2 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sGeneric = new Specification(p, false);
part++;
}
@ -96,8 +93,8 @@ public final class CompSpec extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 3 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 3 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
@ -115,15 +112,15 @@ public final class CompSpec extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 4 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 4 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
objectIdentifiers = new ASN1ObjectIdentifier[parts];
recordSyntax = new ASN1ObjectIdentifier[parts];
int n;
for (n = 0; n < parts; n++) {
objectIdentifiers[n] = new ASN1ObjectIdentifier(cons.elementAt(n), true);
recordSyntax[n] = new ASN1ObjectIdentifier(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
@ -141,6 +138,7 @@ public final class CompSpec extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -153,6 +151,7 @@ public final class CompSpec extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (sGeneric != null) {
@ -161,14 +160,14 @@ public final class CompSpec extends ASN1Any {
if (dbSpecifics != null) {
numFields++;
}
if (objectIdentifiers != null) {
if (recordSyntax != null) {
numFields++;
}
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
BEREncoding f2[];
int p;
fields[x++] = sSelectAlternativeSyntax.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
fields[x++] = selectAlternativeSyntax.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
if (sGeneric != null) {
fields[x++] = sGeneric.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 2);
}
@ -179,10 +178,10 @@ public final class CompSpec extends ASN1Any {
}
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 3, f2);
}
if (objectIdentifiers != null) {
f2 = new BEREncoding[objectIdentifiers.length];
for (p = 0; p < objectIdentifiers.length; p++) {
f2[p] = objectIdentifiers[p].berEncode();
if (recordSyntax != null) {
f2 = new BEREncoding[recordSyntax.length];
for (p = 0; p < recordSyntax.length; p++) {
f2[p] = recordSyntax[p].berEncode();
}
fields[x] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 4, f2);
}
@ -193,12 +192,13 @@ public final class CompSpec extends ASN1Any {
* Returns a new String object containing a text representing
* of the CompSpec.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("selectAlternativeSyntax ");
str.append(sSelectAlternativeSyntax);
str.append(selectAlternativeSyntax);
outputted++;
if (sGeneric != null) {
if (0 < outputted) {
@ -223,17 +223,17 @@ public final class CompSpec extends ASN1Any {
str.append("}");
outputted++;
}
if (objectIdentifiers != null) {
if (recordSyntax != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("recordSyntax ");
str.append("{");
for (p = 0; p < objectIdentifiers.length; p++) {
for (p = 0; p < recordSyntax.length; p++) {
if (p != 0) {
str.append(", ");
}
str.append(objectIdentifiers[p]);
str.append(recordSyntax[p]);
}
str.append("}");
}

View file

@ -45,6 +45,7 @@ public final class CompSpecDbSpecific extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -60,8 +61,8 @@ public final class CompSpecDbSpecific extends ASN1Any {
throw new ASN1Exception("CompSpec_dbSpecific: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("CompSpec_dbSpecific: bad tag in s_db\n");
}
@ -81,8 +82,8 @@ public final class CompSpecDbSpecific extends ASN1Any {
throw new ASN1Exception("CompSpec_dbSpecific: incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 2 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 2 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("CompSpec_dbSpecific: bad tag in s_spec\n");
}
@ -99,6 +100,7 @@ public final class CompSpecDbSpecific extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -111,6 +113,7 @@ public final class CompSpecDbSpecific extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 2;
BEREncoding fields[] = new BEREncoding[numFields];
@ -127,6 +130,7 @@ public final class CompSpecDbSpecific extends ASN1Any {
* Returns a new String object containing a text representing
* of the CompSpec_dbSpecific.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -45,16 +45,15 @@ public final class DatabaseName extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Check tag matches
if (checkTag) {
if (ber.tagGet() != 105 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("DatabaseName: bad BER: tag=" + ber.tagGet() + " expected 105\n");
if (ber.getTag() != 105 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("DatabaseName: bad BER: tag=" + ber.getTag() + " expected 105\n");
}
}
value = new InternationalString(ber, false);
}
@ -64,6 +63,7 @@ public final class DatabaseName extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 105);
}
@ -76,6 +76,7 @@ public final class DatabaseName extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -84,7 +85,7 @@ public final class DatabaseName extends ASN1Any {
* Returns a new String object containing a text representing
* of the DatabaseName.
*/
@Override
public String toString() {
return value.toString();
}

View file

@ -22,9 +22,9 @@ import org.xbib.asn1.BEREncoding;
*/
public final class DefaultDiagFormat extends ASN1Any {
public ASN1ObjectIdentifier sDiagnosticSetId;
public ASN1Integer sCondition;
public DefaultDiagFormatAddinfo sAddinfo;
public ASN1ObjectIdentifier diagnosticSetId;
public ASN1Integer condition;
public DefaultDiagFormatAddinfo addinfo;
/**
* Constructor for a DefaultDiagFormat from a BER encoding.
@ -35,7 +35,6 @@ public final class DefaultDiagFormat extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public DefaultDiagFormat(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -49,36 +48,37 @@ public final class DefaultDiagFormat extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("DefaultDiagFormat: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
throw new ASN1Exception("DefaultDiagFormat: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sDiagnosticSetId = new ASN1ObjectIdentifier(p, true);
diagnosticSetId = new ASN1ObjectIdentifier(p, true);
part++;
if (numParts <= part) {
throw new ASN1Exception("DefaultDiagFormat: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sCondition = new ASN1Integer(p, true);
condition = new ASN1Integer(p, true);
part++;
if (numParts <= part) {
throw new ASN1Exception("DefaultDiagFormat: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sAddinfo = new DefaultDiagFormatAddinfo(p, true);
addinfo = new DefaultDiagFormatAddinfo(p, true);
part++;
if (part < numParts) {
throw new ASN1Exception("DefaultDiagFormat: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -88,6 +88,7 @@ public final class DefaultDiagFormat extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -100,13 +101,14 @@ public final class DefaultDiagFormat extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 3; // number of mandatories
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
fields[x++] = sDiagnosticSetId.berEncode();
fields[x++] = sCondition.berEncode();
fields[x] = sAddinfo.berEncode();
fields[x++] = diagnosticSetId.berEncode();
fields[x++] = condition.berEncode();
fields[x] = addinfo.berEncode();
return new BERConstructed(tagType, tag, fields);
}
@ -114,23 +116,24 @@ public final class DefaultDiagFormat extends ASN1Any {
* Returns a new String object containing a text representing
* of the DefaultDiagFormat.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("diagnosticSetId ");
str.append(sDiagnosticSetId);
str.append(diagnosticSetId);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("condition ");
str.append(sCondition);
str.append(condition);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("addinfo ");
str.append(sAddinfo);
str.append(addinfo);
str.append("}");
return str.toString();
}

View file

@ -18,8 +18,8 @@ import org.xbib.asn1.BEREncoding;
*/
public final class DefaultDiagFormatAddinfo extends ASN1Any {
public ASN1VisibleString cV2Addinfo;
public InternationalString cV3Addinfo;
public ASN1VisibleString v2Addinfo;
public InternationalString v3Addinfo;
/**
* Constructor for a DefaultDiagFormat_addinfo from a BER encoding.
@ -43,22 +43,23 @@ public final class DefaultDiagFormatAddinfo extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
cV2Addinfo = null;
cV3Addinfo = null;
v2Addinfo = null;
v3Addinfo = null;
try {
cV2Addinfo = new ASN1VisibleString(ber, checkTag);
v2Addinfo = new ASN1VisibleString(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
try {
cV3Addinfo = new InternationalString(ber, checkTag);
v3Addinfo = new InternationalString(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
throw new ASN1Exception("DefaultDiagFormat_addinfo: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -67,16 +68,17 @@ public final class DefaultDiagFormatAddinfo extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
if (cV2Addinfo != null) {
chosen = cV2Addinfo.berEncode();
if (v2Addinfo != null) {
chosen = v2Addinfo.berEncode();
}
if (cV3Addinfo != null) {
if (v3Addinfo != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = cV3Addinfo.berEncode();
chosen = v3Addinfo.berEncode();
}
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
@ -84,28 +86,30 @@ public final class DefaultDiagFormatAddinfo extends ASN1Any {
return chosen;
}
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
throw new ASN1EncodingException("DefaultDiagFormat_addinfo: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the DefaultDiagFormat_addinfo.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (cV2Addinfo != null) {
if (v2Addinfo != null) {
found = true;
str.append("v2Addinfo ");
str.append(cV2Addinfo);
str.append(v2Addinfo);
}
if (cV3Addinfo != null) {
if (v3Addinfo != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: v3Addinfo> ");
}
str.append("v3Addinfo ");
str.append(cV3Addinfo);
str.append(v3Addinfo);
}
str.append("}");
return str.toString();

View file

@ -53,18 +53,19 @@ public final class DeleteResultSetRequest extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("DeleteResultSetRequest: bad BER form");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
throw new ASN1Exception("DeleteResultSetRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
@ -74,12 +75,12 @@ public final class DeleteResultSetRequest extends ASN1Any {
referenceId = null;
}
if (numParts <= part) {
throw new ASN1Exception("DeleteResultSetRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 32 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("DeleteResultSetRequest: bad tag in s_deleteFunction");
if (p.getTag() != 32 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in s_deleteFunction");
}
sDeleteFunction = new ASN1Integer(p, false);
part++;
@ -99,7 +100,7 @@ public final class DeleteResultSetRequest extends ASN1Any {
sResultSetList[n] = new ResultSetId(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
throw new ASN1EncodingException("bad BER");
}
part++;
} catch (ASN1Exception e) {
@ -116,7 +117,7 @@ public final class DeleteResultSetRequest extends ASN1Any {
sOtherInfo = null; // no, not present
}
if (part < numParts) {
throw new ASN1Exception("DeleteResultSetRequest: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -126,6 +127,7 @@ public final class DeleteResultSetRequest extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -138,6 +140,7 @@ public final class DeleteResultSetRequest extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (referenceId != null) {
@ -174,6 +177,7 @@ public final class DeleteResultSetRequest extends ASN1Any {
* Returns a new String object containing a text representing
* of the DeleteResultSetRequest.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
@ -214,5 +218,4 @@ public final class DeleteResultSetRequest extends ASN1Any {
str.append("}");
return str.toString();
}
}

View file

@ -56,6 +56,7 @@ public final class DeleteResultSetResponse extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
@ -81,8 +82,8 @@ public final class DeleteResultSetResponse extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 0 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 0 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("DeleteResultSetResponse: bad tag in s_deleteOperationStatus\n");
}
sDeleteOperationStatus = new DeleteSetStatus(p, false);
@ -96,8 +97,8 @@ public final class DeleteResultSetResponse extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sDeleteListStatuses = new ListStatuses(p, false);
part++;
}
@ -105,8 +106,8 @@ public final class DeleteResultSetResponse extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 34 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 34 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sNumberNotDeleted = new ASN1Integer(p, false);
part++;
}
@ -114,8 +115,8 @@ public final class DeleteResultSetResponse extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 35 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 35 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sBulkStatuses = new ListStatuses(p, false);
part++;
}
@ -123,8 +124,8 @@ public final class DeleteResultSetResponse extends ASN1Any {
return;
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 36 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 36 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sDeleteMessage = new InternationalString(p, false);
part++;
}
@ -149,6 +150,7 @@ public final class DeleteResultSetResponse extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -161,6 +163,7 @@ public final class DeleteResultSetResponse extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (sReferenceId != null) {
@ -209,6 +212,7 @@ public final class DeleteResultSetResponse extends ASN1Any {
* Returns a new String object containing a text representing
* of the DeleteResultSetResponse.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -28,6 +28,7 @@ public final class DeleteSetStatus extends ASN1Any {
public static final int E_NOT_ALL_REQUESTED_RESULT_SETS_DELETED = 9;
public static final int E_RESULT_SET_IN_USE = 10;
public ASN1Integer value;
/**
* Constructor for a DeleteSetStatus from a BER encoding.
*
@ -37,7 +38,6 @@ public final class DeleteSetStatus extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public DeleteSetStatus(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -51,11 +51,12 @@ public final class DeleteSetStatus extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
if (checkTag) {
if (ber.tagGet() != 33 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("DeleteSetStatus: bad BER: tag=" + ber.tagGet() + " expected 33\n");
if (ber.getTag() != 33 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 33");
}
}
value = new ASN1Integer(ber, false);
@ -67,7 +68,7 @@ public final class DeleteSetStatus extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 33);
}
@ -80,6 +81,7 @@ public final class DeleteSetStatus extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -88,10 +90,8 @@ public final class DeleteSetStatus extends ASN1Any {
* Returns a new String object containing a text representing
* of the DeleteSetStatus.
*/
public String
toString() {
@Override
public String toString() {
return value.toString();
}
}

View file

@ -19,8 +19,8 @@ import org.xbib.asn1.BEREncoding;
public final class DiagRec extends ASN1Any {
public DefaultDiagFormat cDefaultFormat;
public ASN1External cExternallyDefined;
public DefaultDiagFormat defaultFormat;
public ASN1External externallyDefined;
/**
* Constructor for a DiagRec from a BER encoding.
@ -44,22 +44,23 @@ public final class DiagRec extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
cDefaultFormat = null;
cExternallyDefined = null;
defaultFormat = null;
externallyDefined = null;
try {
cDefaultFormat = new DefaultDiagFormat(ber, checkTag);
defaultFormat = new DefaultDiagFormat(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
try {
cExternallyDefined = new ASN1External(ber, checkTag);
externallyDefined = new ASN1External(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
throw new ASN1Exception("DiagRec: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -68,16 +69,17 @@ public final class DiagRec extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
if (cDefaultFormat != null) {
chosen = cDefaultFormat.berEncode();
if (defaultFormat != null) {
chosen = defaultFormat.berEncode();
}
if (cExternallyDefined != null) {
if (externallyDefined != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = cExternallyDefined.berEncode();
chosen = externallyDefined.berEncode();
}
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
@ -85,28 +87,30 @@ public final class DiagRec extends ASN1Any {
return chosen;
}
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
throw new ASN1EncodingException("DiagRec: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the DiagRec.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (cDefaultFormat != null) {
if (defaultFormat != null) {
found = true;
str.append("defaultFormat ");
str.append(cDefaultFormat);
str.append(defaultFormat);
}
if (cExternallyDefined != null) {
if (externallyDefined != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: externallyDefined> ");
}
str.append("externallyDefined ");
str.append(cExternallyDefined);
str.append(externallyDefined);
}
str.append("}");
return str.toString();

View file

@ -25,9 +25,7 @@ public final class ElementSetName extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ElementSetName(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public ElementSetName(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -40,16 +38,15 @@ public final class ElementSetName extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Check tag matches
if (checkTag) {
if (ber.tagGet() != 103 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("ElementSetName: bad BER: tag=" + ber.tagGet() + " expected 103\n");
if (ber.getTag() != 103 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 103");
}
}
value = new InternationalString(ber, false);
}
@ -59,6 +56,7 @@ public final class ElementSetName extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 103);
}
@ -71,6 +69,7 @@ public final class ElementSetName extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -79,9 +78,8 @@ public final class ElementSetName extends ASN1Any {
* Returns a new String object containing a text representing
* of the ElementSetName.
*/
@Override
public String toString() {
return value.toString();
}
}

View file

@ -19,12 +19,12 @@ import org.xbib.asn1.BEREncoding;
public final class ElementSetNames extends ASN1Any {
public InternationalString cGenericElementSetName;
public ElementSetNamesDatabaseSpecific[] cDatabaseSpecific;
/**
* Default constructor for a ElementSetNames.
*/
public ElementSetNames() {
}
@ -37,7 +37,6 @@ public final class ElementSetNames extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ElementSetNames(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -51,23 +50,24 @@ public final class ElementSetNames extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
cGenericElementSetName = null;
cDatabaseSpecific = null;
if (ber.tagGet() == 0 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 0 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
cGenericElementSetName = new InternationalString(ber, false);
return;
}
if (ber.tagGet() == 1 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 1 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
BEREncoding berData;
berData = ber;
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) berData;
} catch (ClassCastException e) {
throw new ASN1EncodingException("ElementSetNames: bad BER form");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int p;
@ -77,7 +77,7 @@ public final class ElementSetNames extends ASN1Any {
}
return;
}
throw new ASN1Exception("ElementSetNames: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -86,6 +86,7 @@ public final class ElementSetNames extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
BEREncoding[] f2;
@ -109,14 +110,16 @@ public final class ElementSetNames extends ASN1Any {
return chosen;
}
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
throw new ASN1EncodingException("ElementSetNames: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the ElementSetNames.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");

View file

@ -20,13 +20,12 @@ import org.xbib.asn1.BEREncoding;
public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
public DatabaseName sDbName;
public DatabaseName dbName;
public ElementSetName elementSetName;
/**
* Default constructor for a ElementSetNames_databaseSpecific.
*/
public ElementSetNamesDatabaseSpecific() {
}
@ -39,7 +38,6 @@ public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ElementSetNamesDatabaseSpecific(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -53,32 +51,31 @@ public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("ElementSetNames_databaseSpecific: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
throw new ASN1Exception("ElementSetNames_databaseSpecific: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
sDbName = new DatabaseName(p, true);
dbName = new DatabaseName(p, true);
part++;
if (numParts <= part) {
throw new ASN1Exception("ElementSetNames_databaseSpecific: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
elementSetName = new ElementSetName(p, true);
part++;
if (part < numParts) {
throw new ASN1Exception("ElementSetNames_databaseSpecific: bad BER: extra data "
throw new ASN1Exception("bad BER: extra data "
+ part + "/" + numParts + " processed");
}
}
@ -89,6 +86,7 @@ public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -101,11 +99,12 @@ public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 2;
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
fields[x++] = sDbName.berEncode();
fields[x++] = dbName.berEncode();
fields[x] = elementSetName.berEncode();
return new BERConstructed(tagType, tag, fields);
}
@ -114,11 +113,12 @@ public final class ElementSetNamesDatabaseSpecific extends ASN1Any {
* Returns a new String object containing a text representing
* of the ElementSetNames_databaseSpecific.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("dbName ");
str.append(sDbName);
str.append(dbName);
outputted++;
if (0 < outputted) {
str.append(", ");

View file

@ -30,9 +30,7 @@ public final class Entry extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Entry(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Entry(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -45,31 +43,30 @@ public final class Entry extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed tagwrapper;
cTermInfo = null;
cSurrogateDiagnostic = null;
if (ber.tagGet() == 1 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 1 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
cTermInfo = new TermInfo(ber, false);
return;
}
if (ber.tagGet() == 2 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 2 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("Entry: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("Entry: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
cSurrogateDiagnostic = new DiagRec(tagwrapper.elementAt(0), true);
return;
}
throw new ASN1Exception("Entry: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -78,6 +75,7 @@ public final class Entry extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
BEREncoding[] enc;
@ -98,14 +96,16 @@ public final class Entry extends ASN1Any {
return chosen;
}
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
throw new ASN1EncodingException("Entry: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the Entry.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;

View file

@ -62,7 +62,6 @@ public final class ExtendedServicesRequest extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ExtendedServicesRequest(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -76,19 +75,19 @@ public final class ExtendedServicesRequest extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("ExtendedServicesRequest: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
@ -99,88 +98,86 @@ public final class ExtendedServicesRequest extends ASN1Any {
}
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 3 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("ExtendedServicesRequest: bad tag in s_function\n");
if (p.getTag() != 3 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in s_function");
}
sFunction = new ASN1Integer(p, false);
part++;
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 4 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("ExtendedServicesRequest: bad tag in s_packageType\n");
if (p.getTag() != 4 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in s_packageType");
}
sPackageType = new ASN1ObjectIdentifier(p, false);
part++;
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 5 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 5 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sPackageName = new InternationalString(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 6 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 6 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sUserId = new InternationalString(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 7 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 7 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sRetentionTime = new IntUnit(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 8 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 8 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sPermissions = new Permissions(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 9 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 9 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sDescription = new InternationalString(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 10 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 10 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sTaskSpecificParameters = new ASN1External(p, false);
part++;
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 11 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("ExtendedServicesRequest: bad tag in s_waitAction\n");
if (p.getTag() != 11 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in waitAction");
}
sWaitAction = new ASN1Integer(p, false);
part++;
@ -207,7 +204,7 @@ public final class ExtendedServicesRequest extends ASN1Any {
sOtherInfo = null; // no, not present
}
if (part < numParts) {
throw new ASN1Exception("ExtendedServicesRequest: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -217,6 +214,7 @@ public final class ExtendedServicesRequest extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -229,6 +227,7 @@ public final class ExtendedServicesRequest extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 3;
if (sReferenceId != null) {
@ -297,6 +296,7 @@ public final class ExtendedServicesRequest extends ASN1Any {
* Returns a new String object containing a text representing
* of the ExtendedServicesRequest.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -42,7 +42,6 @@ public final class ExtendedServicesResponse extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ExtendedServicesResponse(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -57,19 +56,20 @@ public final class ExtendedServicesResponse extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("ExtendedServicesResponse: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("ExtendedServicesResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
@ -79,12 +79,12 @@ public final class ExtendedServicesResponse extends ASN1Any {
sReferenceId = null; // no, not present
}
if (numParts <= part) {
throw new ASN1Exception("ExtendedServicesResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 3 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("ExtendedServicesResponse: bad tag in s_operationStatus\n");
if (p.getTag() != 3 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in operationStatus");
}
sOperationStatus = new ASN1Integer(p, false);
part++;
@ -95,8 +95,8 @@ public final class ExtendedServicesResponse extends ASN1Any {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 4 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 4 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
@ -114,8 +114,8 @@ public final class ExtendedServicesResponse extends ASN1Any {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 5 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 5 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
sTaskPackage = new ASN1External(p, false);
part++;
}
@ -130,7 +130,7 @@ public final class ExtendedServicesResponse extends ASN1Any {
sOtherInfo = null; // no, not present
}
if (part < numParts) {
throw new ASN1Exception("ExtendedServicesResponse: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -140,6 +140,7 @@ public final class ExtendedServicesResponse extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -152,6 +153,7 @@ public final class ExtendedServicesResponse extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
int numFields = 1;
if (sReferenceId != null) {
@ -194,7 +196,7 @@ public final class ExtendedServicesResponse extends ASN1Any {
* Returns a new String object containing a text representing
* of the ExtendedServicesResponse.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");

View file

@ -44,7 +44,7 @@ public final class FragmentSyntax extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
c_externallyTagged = null;
c_notExternallyTagged = null;
@ -69,6 +69,7 @@ public final class FragmentSyntax extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
if (c_externallyTagged != null) {
@ -100,7 +101,7 @@ public final class FragmentSyntax extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
@ -109,17 +110,15 @@ public final class FragmentSyntax extends ASN1Any {
// permitted to allow something else to apply an implicit
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("FragmentSyntax: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the FragmentSyntax.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_externallyTagged != null) {
@ -137,5 +136,4 @@ public final class FragmentSyntax extends ASN1Any {
str.append("}");
return str.toString();
}
}

View file

@ -23,15 +23,14 @@ import org.xbib.asn1.BEREncoding;
public final class IdAuthentication extends ASN1Any {
public ASN1VisibleString c_open;
public IdAuthenticationIdPass c_idPass;
public ASN1Null c_anonymous;
public ASN1External c_other;
public ASN1VisibleString open;
public IdAuthenticationIdPass idPass;
public ASN1Null anonymous;
public ASN1External other;
/**
* Default constructor for a IdAuthentication.
*/
public IdAuthentication() {
}
@ -44,7 +43,6 @@ public final class IdAuthentication extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public IdAuthentication(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -59,20 +57,18 @@ public final class IdAuthentication extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Null out all choices
c_open = null;
c_idPass = null;
c_anonymous = null;
c_other = null;
open = null;
idPass = null;
anonymous = null;
other = null;
// Try choice open
try {
c_open = new ASN1VisibleString(ber, checkTag);
open = new ASN1VisibleString(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
@ -80,7 +76,7 @@ public final class IdAuthentication extends ASN1Any {
// Try choice idPass
try {
c_idPass = new IdAuthenticationIdPass(ber, checkTag);
idPass = new IdAuthenticationIdPass(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
@ -88,7 +84,7 @@ public final class IdAuthentication extends ASN1Any {
// Try choice anonymous
try {
c_anonymous = new ASN1Null(ber, checkTag);
anonymous = new ASN1Null(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
@ -96,13 +92,13 @@ public final class IdAuthentication extends ASN1Any {
// Try choice other
try {
c_other = new ASN1External(ber, checkTag);
other = new ASN1External(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
throw new ASN1Exception("IdAuthentication: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -111,46 +107,43 @@ public final class IdAuthentication extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
// Encoding choice: c_open
if (c_open != null) {
chosen = c_open.berEncode();
if (open != null) {
chosen = open.berEncode();
}
// Encoding choice: c_idPass
if (c_idPass != null) {
if (idPass != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_idPass.berEncode();
chosen = idPass.berEncode();
}
// Encoding choice: c_anonymous
if (c_anonymous != null) {
if (anonymous != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_anonymous.berEncode();
chosen = anonymous.berEncode();
}
// Encoding choice: c_other
if (c_other != null) {
if (other != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_other.berEncode();
chosen = other.berEncode();
}
// Check for error of having none of the choices set
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
}
return chosen;
}
@ -168,10 +161,8 @@ public final class IdAuthentication extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
// Method is not available because this is a basic CHOICE
@ -179,56 +170,52 @@ public final class IdAuthentication extends ASN1Any {
// permitted to allow something else to apply an implicit
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("IdAuthentication: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the IdAuthentication.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_open != null) {
if (open != null) {
found = true;
str.append("open ");
str.append(c_open);
str.append(open);
}
if (c_idPass != null) {
if (idPass != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: idPass> ");
}
found = true;
str.append("idPass ");
str.append(c_idPass);
str.append(idPass);
}
if (c_anonymous != null) {
if (anonymous != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: anonymous> ");
}
found = true;
str.append("anonymous ");
str.append(c_anonymous);
str.append(anonymous);
}
if (c_other != null) {
if (other != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: other> ");
}
str.append("other ");
str.append(c_other);
str.append(other);
}
str.append("}");
return str.toString();
}
}

View file

@ -27,7 +27,6 @@ public final class IdAuthenticationIdPass extends ASN1Any {
/**
* Default constructor for a IdAuthentication_idPass.
*/
public IdAuthenticationIdPass() {
}
@ -40,9 +39,7 @@ public final class IdAuthenticationIdPass extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public IdAuthenticationIdPass(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public IdAuthenticationIdPass(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -55,10 +52,8 @@ public final class IdAuthenticationIdPass extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// IdAuthentication_idPass should be encoded by a constructed BER
BERConstructed berConstructed;
@ -88,8 +83,8 @@ public final class IdAuthenticationIdPass extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 0 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 0 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_groupId = new InternationalString(p, false);
part++;
}
@ -101,8 +96,8 @@ public final class IdAuthenticationIdPass extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_userId = new InternationalString(p, false);
part++;
}
@ -114,8 +109,8 @@ public final class IdAuthenticationIdPass extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 2 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 2 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_password = new InternationalString(p, false);
part++;
}
@ -133,6 +128,7 @@ public final class IdAuthenticationIdPass extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -145,6 +141,7 @@ public final class IdAuthenticationIdPass extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
@ -189,12 +186,10 @@ public final class IdAuthenticationIdPass extends ASN1Any {
* Returns a new String object containing a text representing
* of the IdAuthentication_idPass.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_groupId != null) {
str.append("groupId ");
str.append(s_groupId);

View file

@ -33,7 +33,6 @@ public final class InfoCategory extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public InfoCategory(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -71,8 +70,8 @@ public final class InfoCategory extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_categoryTypeId = new ASN1ObjectIdentifier(p, false);
part++;
}
@ -85,8 +84,8 @@ public final class InfoCategory extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 2 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 2 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("InfoCategory: bad tag in s_categoryValue\n");
}
@ -106,6 +105,7 @@ public final class InfoCategory extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -118,10 +118,8 @@ public final class InfoCategory extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 1; // number of mandatories
@ -151,9 +149,8 @@ public final class InfoCategory extends ASN1Any {
* Returns a new String object containing a text representing
* of the InfoCategory.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -30,22 +30,24 @@ import org.xbib.asn1.BEREncoding;
*/
public final class InitializeRequest extends ASN1Any {
public ReferenceId s_referenceId; // optional
public ProtocolVersion s_protocolVersion;
public Options s_options;
public ASN1Integer s_preferredMessageSize;
public ASN1Integer s_exceptionalRecordSize;
public IdAuthentication s_idAuthentication; // optional
public InternationalString s_implementationId; // optional
public InternationalString s_implementationName; // optional
public InternationalString s_implementationVersion; // optional
public ASN1External s_userInformationField; // optional
public OtherInformation s_otherInfo; // optional
public ReferenceId referenceId; // optional
public ProtocolVersion protocolVersion;
public Options options;
public ASN1Integer preferredMessageSize;
public ASN1Integer exceptionalRecordSize;
public IdAuthentication idAuthentication; // optional
public InternationalString implementationId; // optional
public InternationalString implementationName; // optional
public InternationalString implementationVersion; // optional
public ASN1External userInformationField; // optional
public OtherInformation otherInfo; // optional
/**
* Default constructor for a InitializeRequest.
*/
public InitializeRequest() {
}
/**
* Constructor for a InitializeRequest from a BER encoding.
*
@ -55,9 +57,7 @@ public final class InitializeRequest extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public InitializeRequest(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public InitializeRequest(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -70,17 +70,14 @@ public final class InitializeRequest extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// InitializeRequest should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("InitializeRequest: bad BER form");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -94,80 +91,80 @@ public final class InitializeRequest extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
s_referenceId = new ReferenceId(p, true);
referenceId = new ReferenceId(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_referenceId = null; // no, not present
referenceId = null; // no, not present
}
// Decoding: protocolVersion ProtocolVersion
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
s_protocolVersion = new ProtocolVersion(p, true);
protocolVersion = new ProtocolVersion(p, true);
part++;
// Decoding: options Options
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
s_options = new Options(p, true);
options = new Options(p, true);
part++;
// Decoding: preferredMessageSize [5] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 5 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("InitializeRequest: bad tag in s_preferredMessageSize");
if (p.getTag() != 5 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in preferredMessageSize");
}
s_preferredMessageSize = new ASN1Integer(p, false);
preferredMessageSize = new ASN1Integer(p, false);
part++;
// Decoding: exceptionalRecordSize [6] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 6 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("InitializeRequest: bad tag in s_exceptionalRecordSize");
if (p.getTag() != 6 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in exceptionalRecordSize");
}
s_exceptionalRecordSize = new ASN1Integer(p, false);
exceptionalRecordSize = new ASN1Integer(p, false);
part++;
// Remaining elements are optional, set variables
// to null (not present) so can return at endStream of BER
s_idAuthentication = null;
s_implementationId = null;
s_implementationName = null;
s_implementationVersion = null;
s_userInformationField = null;
s_otherInfo = null;
idAuthentication = null;
implementationId = null;
implementationName = null;
implementationVersion = null;
userInformationField = null;
otherInfo = null;
// Decoding: idAuthentication [7] EXPLICIT IdAuthentication OPTIONAL
@ -176,44 +173,38 @@ public final class InitializeRequest extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 7 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 7 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {
throw new ASN1EncodingException("InitializeRequest: bad BER encoding: s_idAuthentication tag bad");
throw new ASN1EncodingException("bad BER encoding: idAuthentication tag bad");
}
if (tagged.numberComponents() != 1) {
throw new ASN1EncodingException("InitializeRequest: bad BER encoding: s_idAuthentication tag bad");
throw new ASN1EncodingException("bad BER encoding: idAuthentication tag bad");
}
s_idAuthentication = new IdAuthentication(tagged.elementAt(0), true);
idAuthentication = new IdAuthentication(tagged.elementAt(0), true);
part++;
}
// Decoding: implementationId [110] IMPLICIT InternationalString OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 110 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationId = new InternationalString(p, false);
if (p.getTag() == 110 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationId = new InternationalString(p, false);
part++;
}
// Decoding: implementationName [111] IMPLICIT InternationalString OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 111 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationName = new InternationalString(p, false);
if (p.getTag() == 111 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationName = new InternationalString(p, false);
part++;
}
@ -224,9 +215,9 @@ public final class InitializeRequest extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 112 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationVersion = new InternationalString(p, false);
if (p.getTag() == 112 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationVersion = new InternationalString(p, false);
part++;
}
@ -237,18 +228,17 @@ public final class InitializeRequest extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 11 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 11 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {
throw new ASN1EncodingException("InitializeRequest: bad BER encoding: s_userInformationField tag bad");
throw new ASN1EncodingException("bad BER encoding: s_userInformationField tag bad");
}
if (tagged.numberComponents() != 1) {
throw new ASN1EncodingException("InitializeRequest: bad BER encoding: s_userInformationField tag bad");
throw new ASN1EncodingException("bad BER encoding: s_userInformationField tag bad");
}
s_userInformationField = new ASN1External(tagged.elementAt(0), true);
userInformationField = new ASN1External(tagged.elementAt(0), true);
part++;
}
@ -260,16 +250,14 @@ public final class InitializeRequest extends ASN1Any {
p = berConstructed.elementAt(part);
try {
s_otherInfo = new OtherInformation(p, true);
otherInfo = new OtherInformation(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_otherInfo = null; // no, not present
otherInfo = null; // no, not present
}
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("InitializeRequest: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -279,10 +267,8 @@ public final class InitializeRequest extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -299,102 +285,76 @@ public final class InitializeRequest extends ASN1Any {
* @see org.xbib.asn1.BEREncoding#PRIVATE_TAG
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 4; // number of mandatories
if (s_referenceId != null) {
if (referenceId != null) {
numFields++;
}
if (s_idAuthentication != null) {
if (idAuthentication != null) {
numFields++;
}
if (s_implementationId != null) {
if (implementationId != null) {
numFields++;
}
if (s_implementationName != null) {
if (implementationName != null) {
numFields++;
}
if (s_implementationVersion != null) {
if (implementationVersion != null) {
numFields++;
}
if (s_userInformationField != null) {
if (userInformationField != null) {
numFields++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
numFields++;
}
// Encode it
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
BEREncoding enc[];
// Encoding s_referenceId: ReferenceId OPTIONAL
if (s_referenceId != null) {
fields[x++] = s_referenceId.berEncode();
if (referenceId != null) {
fields[x++] = referenceId.berEncode();
}
// Encoding s_protocolVersion: ProtocolVersion
fields[x++] = s_protocolVersion.berEncode();
fields[x++] = protocolVersion.berEncode();
// Encoding s_options: Options
fields[x++] = s_options.berEncode();
fields[x++] = options.berEncode();
// Encoding s_preferredMessageSize: INTEGER
fields[x++] = s_preferredMessageSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 5);
fields[x++] = preferredMessageSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 5);
// Encoding s_exceptionalRecordSize: INTEGER
fields[x++] = s_exceptionalRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 6);
fields[x++] = exceptionalRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 6);
// Encoding s_idAuthentication: IdAuthentication OPTIONAL
if (s_idAuthentication != null) {
if (idAuthentication != null) {
enc = new BEREncoding[1];
enc[0] = s_idAuthentication.berEncode();
enc[0] = idAuthentication.berEncode();
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 7, enc);
}
// Encoding s_implementationId: InternationalString OPTIONAL
if (s_implementationId != null) {
fields[x++] = s_implementationId.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 110);
if (implementationId != null) {
fields[x++] = implementationId.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 110);
}
// Encoding s_implementationName: InternationalString OPTIONAL
if (s_implementationName != null) {
fields[x++] = s_implementationName.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 111);
if (implementationName != null) {
fields[x++] = implementationName.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 111);
}
// Encoding s_implementationVersion: InternationalString OPTIONAL
if (s_implementationVersion != null) {
fields[x++] = s_implementationVersion.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 112);
if (implementationVersion != null) {
fields[x++] = implementationVersion.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 112);
}
// Encoding s_userInformationField: EXTERNAL OPTIONAL
if (s_userInformationField != null) {
if (userInformationField != null) {
enc = new BEREncoding[1];
enc[0] = s_userInformationField.berEncode();
enc[0] = userInformationField.berEncode();
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 11, enc);
}
// Encoding s_otherInfo: OtherInformation OPTIONAL
if (s_otherInfo != null) {
fields[x++] = s_otherInfo.berEncode();
if (otherInfo != null) {
fields[x] = otherInfo.berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -402,100 +362,87 @@ public final class InitializeRequest extends ASN1Any {
* Returns a new String object containing a text representing
* of the InitializeRequest.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_referenceId != null) {
if (referenceId != null) {
str.append("referenceId ");
str.append(s_referenceId);
str.append(referenceId);
outputted++;
}
if (0 < outputted) {
str.append(", ");
}
str.append("protocolVersion ");
str.append(s_protocolVersion);
str.append(protocolVersion);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("options ");
str.append(s_options);
str.append(options);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("preferredMessageSize ");
str.append(s_preferredMessageSize);
str.append(preferredMessageSize);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("exceptionalRecordSize ");
str.append(s_exceptionalRecordSize);
str.append(exceptionalRecordSize);
outputted++;
if (s_idAuthentication != null) {
if (idAuthentication != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("idAuthentication ");
str.append(s_idAuthentication);
str.append(idAuthentication);
outputted++;
}
if (s_implementationId != null) {
if (implementationId != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationId ");
str.append(s_implementationId);
str.append(implementationId);
outputted++;
}
if (s_implementationName != null) {
if (implementationName != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationName ");
str.append(s_implementationName);
str.append(implementationName);
outputted++;
}
if (s_implementationVersion != null) {
if (implementationVersion != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationVersion ");
str.append(s_implementationVersion);
str.append(implementationVersion);
outputted++;
}
if (s_userInformationField != null) {
if (userInformationField != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("userInformationField ");
str.append(s_userInformationField);
str.append(userInformationField);
outputted++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("otherInfo ");
str.append(s_otherInfo);
str.append(otherInfo);
}
str.append("}");
return str.toString();
}
}

View file

@ -32,17 +32,18 @@ import org.xbib.asn1.BEREncoding;
*/
public final class InitializeResponse extends ASN1Any {
public ReferenceId s_referenceId; // optional
public ProtocolVersion s_protocolVersion;
public Options s_options;
public ASN1Integer s_preferredMessageSize;
public ASN1Integer s_exceptionalRecordSize;
public ASN1Boolean s_result;
public InternationalString s_implementationId; // optional
public InternationalString s_implementationName; // optional
public InternationalString s_implementationVersion; // optional
public ASN1External s_userInformationField; // optional
public OtherInformation s_otherInfo; // optional
public ReferenceId referenceId; // optional
public ProtocolVersion protocolVersion;
public Options options;
public ASN1Integer preferredMessageSize;
public ASN1Integer exceptionalRecordSize;
public ASN1Boolean result;
public InternationalString implementationId; // optional
public InternationalString implementationName; // optional
public InternationalString implementationVersion; // optional
public ASN1External userInformationField; // optional
public OtherInformation otherInfo; // optional
/**
* Constructor for a InitializeResponse from a BER encoding.
*
@ -52,7 +53,6 @@ public final class InitializeResponse extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public InitializeResponse(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -66,204 +66,154 @@ public final class InitializeResponse extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// InitializeResponse should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("InitializeResponse: bad BER form\n");
throw new ASN1EncodingException("bad BER form\n");
}
// Prepare to decode the components
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
BERConstructed tagged;
// Decoding: referenceId ReferenceId OPTIONAL
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
s_referenceId = new ReferenceId(p, true);
referenceId = new ReferenceId(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_referenceId = null; // no, not present
referenceId = null; // no, not present
}
// Decoding: protocolVersion ProtocolVersion
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
s_protocolVersion = new ProtocolVersion(p, true);
protocolVersion = new ProtocolVersion(p, true);
part++;
// Decoding: options Options
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
s_options = new Options(p, true);
options = new Options(p, true);
part++;
// Decoding: preferredMessageSize [5] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 5 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("InitializeResponse: bad tag in s_preferredMessageSize\n");
if (p.getTag() != 5 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in preferredMessageSize");
}
s_preferredMessageSize = new ASN1Integer(p, false);
preferredMessageSize = new ASN1Integer(p, false);
part++;
// Decoding: exceptionalRecordSize [6] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 6 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("InitializeResponse: bad tag in s_exceptionalRecordSize\n");
if (p.getTag() != 6 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in exceptionalRecordSize");
}
s_exceptionalRecordSize = new ASN1Integer(p, false);
exceptionalRecordSize = new ASN1Integer(p, false);
part++;
// Decoding: result [12] IMPLICIT BOOLEAN
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("InitializeResponse: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 12 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("InitializeResponse: bad tag in s_result\n");
if (p.getTag() != 12 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in result");
}
s_result = new ASN1Boolean(p, false);
result = new ASN1Boolean(p, false);
part++;
// Remaining elements are optional, set variables
// to null (not present) so can return at endStream of BER
s_implementationId = null;
s_implementationName = null;
s_implementationVersion = null;
s_userInformationField = null;
s_otherInfo = null;
implementationId = null;
implementationName = null;
implementationVersion = null;
userInformationField = null;
otherInfo = null;
// Decoding: implementationId [110] IMPLICIT InternationalString OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 110 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationId = new InternationalString(p, false);
if (p.getTag() == 110 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationId = new InternationalString(p, false);
part++;
}
// Decoding: implementationName [111] IMPLICIT InternationalString OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 111 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationName = new InternationalString(p, false);
if (p.getTag() == 111 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationName = new InternationalString(p, false);
part++;
}
// Decoding: implementationVersion [112] IMPLICIT InternationalString OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 112 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_implementationVersion = new InternationalString(p, false);
if (p.getTag() == 112 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
implementationVersion = new InternationalString(p, false);
part++;
}
// Decoding: userInformationField [11] EXPLICIT EXTERNAL OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 11 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 11 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("InitializeResponse: bad BER encoding: s_userInformationField tag bad\n");
throw new ASN1EncodingException("bad BER encoding: userInformationField tag bad");
}
if (tagged.numberComponents() != 1) {
throw new ASN1EncodingException
("InitializeResponse: bad BER encoding: s_userInformationField tag bad\n");
throw new ASN1EncodingException("bad BER encoding: s_userInformationField tag bad");
}
s_userInformationField = new ASN1External(tagged.elementAt(0), true);
userInformationField = new ASN1External(tagged.elementAt(0), true);
part++;
}
// Decoding: otherInfo OtherInformation OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
try {
s_otherInfo = new OtherInformation(p, true);
otherInfo = new OtherInformation(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_otherInfo = null; // no, not present
otherInfo = null; // no, not present
}
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("InitializeResponse: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -273,10 +223,8 @@ public final class InitializeResponse extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -288,96 +236,68 @@ public final class InitializeResponse extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 5; // number of mandatories
if (s_referenceId != null) {
if (referenceId != null) {
numFields++;
}
if (s_implementationId != null) {
if (implementationId != null) {
numFields++;
}
if (s_implementationName != null) {
if (implementationName != null) {
numFields++;
}
if (s_implementationVersion != null) {
if (implementationVersion != null) {
numFields++;
}
if (s_userInformationField != null) {
if (userInformationField != null) {
numFields++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
numFields++;
}
// Encode it
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
BEREncoding enc[];
// Encoding s_referenceId: ReferenceId OPTIONAL
if (s_referenceId != null) {
fields[x++] = s_referenceId.berEncode();
if (referenceId != null) {
fields[x++] = referenceId.berEncode();
}
// Encoding s_protocolVersion: ProtocolVersion
fields[x++] = s_protocolVersion.berEncode();
fields[x++] = protocolVersion.berEncode();
// Encoding s_options: Options
fields[x++] = s_options.berEncode();
fields[x++] = options.berEncode();
// Encoding s_preferredMessageSize: INTEGER
fields[x++] = s_preferredMessageSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 5);
fields[x++] = preferredMessageSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 5);
// Encoding s_exceptionalRecordSize: INTEGER
fields[x++] = s_exceptionalRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 6);
fields[x++] = exceptionalRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 6);
// Encoding s_result: BOOLEAN
fields[x++] = s_result.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 12);
fields[x++] = result.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 12);
// Encoding s_implementationId: InternationalString OPTIONAL
if (s_implementationId != null) {
fields[x++] = s_implementationId.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 110);
if (implementationId != null) {
fields[x++] = implementationId.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 110);
}
// Encoding s_implementationName: InternationalString OPTIONAL
if (s_implementationName != null) {
fields[x++] = s_implementationName.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 111);
if (implementationName != null) {
fields[x++] = implementationName.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 111);
}
// Encoding s_implementationVersion: InternationalString OPTIONAL
if (s_implementationVersion != null) {
fields[x++] = s_implementationVersion.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 112);
if (implementationVersion != null) {
fields[x++] = implementationVersion.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 112);
}
// Encoding s_userInformationField: EXTERNAL OPTIONAL
if (s_userInformationField != null) {
if (userInformationField != null) {
enc = new BEREncoding[1];
enc[0] = s_userInformationField.berEncode();
enc[0] = userInformationField.berEncode();
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 11, enc);
}
// Encoding s_otherInfo: OtherInformation OPTIONAL
if (s_otherInfo != null) {
fields[x] = s_otherInfo.berEncode();
if (otherInfo != null) {
fields[x] = otherInfo.berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -385,100 +305,85 @@ public final class InitializeResponse extends ASN1Any {
* Returns a new String object containing a text representing
* of the InitializeResponse.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_referenceId != null) {
if (referenceId != null) {
str.append("referenceId ");
str.append(s_referenceId);
str.append(referenceId);
outputted++;
}
if (0 < outputted) {
str.append(", ");
}
str.append("protocolVersion ");
str.append(s_protocolVersion);
str.append(protocolVersion);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("options ");
str.append(s_options);
str.append(options);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("preferredMessageSize ");
str.append(s_preferredMessageSize);
str.append(preferredMessageSize);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("exceptionalRecordSize ");
str.append(s_exceptionalRecordSize);
str.append(exceptionalRecordSize);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("result ");
str.append(s_result);
str.append(result);
outputted++;
if (s_implementationId != null) {
if (implementationId != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationId ");
str.append(s_implementationId);
str.append(implementationId);
outputted++;
}
if (s_implementationName != null) {
if (implementationName != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationName ");
str.append(s_implementationName);
str.append(implementationName);
outputted++;
}
if (s_implementationVersion != null) {
if (implementationVersion != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("implementationVersion ");
str.append(s_implementationVersion);
str.append(implementationVersion);
outputted++;
}
if (s_userInformationField != null) {
if (userInformationField != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("userInformationField ");
str.append(s_userInformationField);
str.append(userInformationField);
outputted++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("otherInfo ");
str.append(s_otherInfo);
str.append(otherInfo);
}
str.append("}");
return str.toString();
}
}

View file

@ -33,9 +33,7 @@ public final class IntUnit extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public IntUnit(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public IntUnit(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -48,10 +46,8 @@ public final class IntUnit extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// IntUnit should be encoded by a constructed BER
BERConstructed berConstructed;
@ -75,8 +71,8 @@ public final class IntUnit extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("IntUnit: bad tag in s_value\n");
}
@ -91,8 +87,8 @@ public final class IntUnit extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 2 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 2 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("IntUnit: bad tag in s_unitUsed\n");
}
@ -112,10 +108,8 @@ public final class IntUnit extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -127,10 +121,8 @@ public final class IntUnit extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 2; // number of mandatories
@ -155,9 +147,8 @@ public final class IntUnit extends ASN1Any {
* Returns a new String object containing a text representing
* of the IntUnit.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
str.append("value ");
@ -171,5 +162,4 @@ public final class IntUnit extends ASN1Any {
str.append("}");
return str.toString();
}
}

View file

@ -52,6 +52,7 @@ public final class InternationalString extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return value.berEncode();
}
@ -64,10 +65,8 @@ public final class InternationalString extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -75,9 +74,8 @@ public final class InternationalString extends ASN1Any {
* Returns a new String object containing a text representing
* of the InternationalString.
*/
@Override
public String toString() {
return value.toString();
}
}

View file

@ -36,7 +36,6 @@ public final class KnownProximityUnit extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public KnownProximityUnit(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -51,10 +50,8 @@ public final class KnownProximityUnit extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
value = new ASN1Integer(ber, checkTag);
}
@ -64,10 +61,8 @@ public final class KnownProximityUnit extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return value.berEncode();
}
@ -79,6 +74,7 @@ public final class KnownProximityUnit extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -87,6 +83,7 @@ public final class KnownProximityUnit extends ASN1Any {
* Returns a new String object containing a text representing
* of the KnownProximityUnit.
*/
@Override
public String toString() {
return value.toString();
}

View file

@ -20,9 +20,8 @@ import org.xbib.asn1.BEREncoding;
*/
public final class ListEntries extends ASN1Any {
public Entry s_entries[]; // optional
public DiagRec s_nonsurrogateDiagnostics[]; // optional
public Entry[] s_entries; // optional
public DiagRec[] s_nonsurrogateDiagnostics; // optional
/**
* Constructor for a ListEntries from a BER encoding.
@ -46,17 +45,14 @@ public final class ListEntries extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// ListEntries should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("ListEntries: bad BER form\n");
} catch (ClassCastException e) { throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -78,8 +74,8 @@ public final class ListEntries extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
@ -89,7 +85,7 @@ public final class ListEntries extends ASN1Any {
s_entries[n] = new Entry(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
throw new ASN1EncodingException("bad BER");
}
part++;
}
@ -101,8 +97,8 @@ public final class ListEntries extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 2 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 2 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
@ -112,7 +108,7 @@ public final class ListEntries extends ASN1Any {
s_nonsurrogateDiagnostics[n] = new DiagRec(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
throw new ASN1EncodingException("bad BER");
}
part++;
}
@ -120,7 +116,7 @@ public final class ListEntries extends ASN1Any {
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("ListEntries: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -130,10 +126,8 @@ public final class ListEntries extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -145,6 +139,7 @@ public final class ListEntries extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
@ -193,6 +188,7 @@ public final class ListEntries extends ASN1Any {
* Returns a new String object containing a text representing
* of the ListEntries.
*/
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");

View file

@ -29,7 +29,6 @@ public final class ListStatuses extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ListStatuses(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -44,6 +43,7 @@ public final class ListStatuses extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// ListStatuses should be encoded by a constructed BER
@ -71,6 +71,7 @@ public final class ListStatuses extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -83,6 +84,7 @@ public final class ListStatuses extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding fields[] = new BERConstructed[value.length];
int p;
@ -98,7 +100,7 @@ public final class ListStatuses extends ASN1Any {
* Returns a new String object containing a text representing
* of the ListStatuses.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int p;

View file

@ -33,7 +33,6 @@ public final class ListStatuses1 extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public ListStatuses1(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -48,10 +47,8 @@ public final class ListStatuses1 extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// ListStatuses1 should be encoded by a constructed BER
BERConstructed berConstructed;
@ -103,10 +100,8 @@ public final class ListStatuses1 extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -118,10 +113,8 @@ public final class ListStatuses1 extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 2; // number of mandatories
@ -146,6 +139,7 @@ public final class ListStatuses1 extends ASN1Any {
* Returns a new String object containing a text representing
* of the ListStatuses1.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -20,13 +20,12 @@ import org.xbib.asn1.BEREncoding;
public final class NamePlusRecord extends ASN1Any {
public DatabaseName s_name; // optional
public NamePlusRecordRecord s_record;
public DatabaseName name; // optional
public NamePlusRecordRecord record;
/**
* Default constructor for a NamePlusRecord.
*/
public NamePlusRecord() {
}
@ -39,9 +38,7 @@ public final class NamePlusRecord extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public NamePlusRecord(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public NamePlusRecord(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -54,17 +51,15 @@ public final class NamePlusRecord extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// NamePlusRecord should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("NamePlusRecord: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -78,13 +73,13 @@ public final class NamePlusRecord extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("NamePlusRecord: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 0 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_name = new DatabaseName(p, false);
if (p.getTag() == 0 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
name = new DatabaseName(p, false);
part++;
}
@ -92,31 +87,31 @@ public final class NamePlusRecord extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("NamePlusRecord: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("NamePlusRecord: bad tag in s_record\n");
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in record");
}
try {
tagged = (BERConstructed) p;
} catch (ClassCastException e) {
throw new ASN1EncodingException("NamePlusRecord: bad BER encoding: s_record tag bad\n");
throw new ASN1EncodingException("bad BER encoding: record tag bad");
}
if (tagged.numberComponents() != 1) {
throw new ASN1EncodingException("NamePlusRecord: bad BER encoding: s_record tag bad\n");
throw new ASN1EncodingException("bad BER encoding: record tag bad");
}
s_record = new NamePlusRecordRecord(tagged.elementAt(0), true);
record = new NamePlusRecordRecord(tagged.elementAt(0), true);
part++;
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("NamePlusRecord: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -126,10 +121,8 @@ public final class NamePlusRecord extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -141,14 +134,12 @@ public final class NamePlusRecord extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 1; // number of mandatories
if (s_name != null) {
if (name != null) {
numFields++;
}
@ -160,14 +151,14 @@ public final class NamePlusRecord extends ASN1Any {
// Encoding s_name: DatabaseName OPTIONAL
if (s_name != null) {
fields[x++] = s_name.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 0);
if (name != null) {
fields[x++] = name.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 0);
}
// Encoding s_record: NamePlusRecord_record
enc = new BEREncoding[1];
enc[0] = s_record.berEncode();
enc[0] = record.berEncode();
fields[x] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 1, enc);
return new BERConstructed(tagType, tag, fields);
}
@ -176,15 +167,14 @@ public final class NamePlusRecord extends ASN1Any {
* Returns a new String object containing a text representing
* of the NamePlusRecord.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_name != null) {
if (name != null) {
str.append("name ");
str.append(s_name);
str.append(name);
outputted++;
}
@ -192,11 +182,10 @@ public final class NamePlusRecord extends ASN1Any {
str.append(", ");
}
str.append("record ");
str.append(s_record);
str.append(record);
str.append("}");
return str.toString();
}
}

View file

@ -22,11 +22,11 @@ import org.xbib.asn1.BEREncoding;
*/
public final class NamePlusRecordRecord extends ASN1Any {
public ASN1External c_retrievalRecord;
public DiagRec c_surrogateDiagnostic;
public FragmentSyntax c_startingFragment;
public FragmentSyntax c_intermediateFragment;
public FragmentSyntax c_finalFragment;
public ASN1External retrievalRecord;
public DiagRec surrogateDiagnostic;
public FragmentSyntax startingFragment;
public FragmentSyntax intermediateFragment;
public FragmentSyntax finalFragment;
/**
* Constructor for a NamePlusRecord_record from a BER encoding.
@ -37,9 +37,7 @@ public final class NamePlusRecordRecord extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public NamePlusRecordRecord(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public NamePlusRecordRecord(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -52,106 +50,93 @@ public final class NamePlusRecordRecord extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed tagwrapper;
// Null out all choices
c_retrievalRecord = null;
c_surrogateDiagnostic = null;
c_startingFragment = null;
c_intermediateFragment = null;
c_finalFragment = null;
retrievalRecord = null;
surrogateDiagnostic = null;
startingFragment = null;
intermediateFragment = null;
finalFragment = null;
// Try choice retrievalRecord
if (ber.tagGet() == 1 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 1 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_retrievalRecord = new ASN1External(tagwrapper.elementAt(0), true);
retrievalRecord = new ASN1External(tagwrapper.elementAt(0), true);
return;
}
// Try choice surrogateDiagnostic
if (ber.tagGet() == 2 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 2 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_surrogateDiagnostic = new DiagRec(tagwrapper.elementAt(0), true);
surrogateDiagnostic = new DiagRec(tagwrapper.elementAt(0), true);
return;
}
// Try choice startingFragment
if (ber.tagGet() == 3 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 3 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_startingFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
startingFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
return;
}
// Try choice intermediateFragment
if (ber.tagGet() == 4 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 4 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_intermediateFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
intermediateFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
return;
}
// Try choice finalFragment
if (ber.tagGet() == 5 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 5 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("NamePlusRecord_record: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_finalFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
finalFragment = new FragmentSyntax(tagwrapper.elementAt(0), true);
return;
}
throw new ASN1Exception("NamePlusRecord_record: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -160,58 +145,56 @@ public final class NamePlusRecordRecord extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
BEREncoding enc[];
// Encoding choice: c_retrievalRecord
if (c_retrievalRecord != null) {
if (retrievalRecord != null) {
enc = new BEREncoding[1];
enc[0] = c_retrievalRecord.berEncode();
enc[0] = retrievalRecord.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 1, enc);
}
// Encoding choice: c_surrogateDiagnostic
if (c_surrogateDiagnostic != null) {
if (surrogateDiagnostic != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
enc = new BEREncoding[1];
enc[0] = c_surrogateDiagnostic.berEncode();
enc[0] = surrogateDiagnostic.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 2, enc);
}
// Encoding choice: c_startingFragment
if (c_startingFragment != null) {
if (startingFragment != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
enc = new BEREncoding[1];
enc[0] = c_startingFragment.berEncode();
enc[0] = startingFragment.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 3, enc);
}
// Encoding choice: c_intermediateFragment
if (c_intermediateFragment != null) {
if (intermediateFragment != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
enc = new BEREncoding[1];
enc[0] = c_intermediateFragment.berEncode();
enc[0] = intermediateFragment.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 4, enc);
}
// Encoding choice: c_finalFragment
if (c_finalFragment != null) {
if (finalFragment != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
enc = new BEREncoding[1];
enc[0] = c_finalFragment.berEncode();
enc[0] = finalFragment.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 5, enc);
}
@ -237,10 +220,8 @@ public final class NamePlusRecordRecord extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
// Method is not available because this is a basic CHOICE
@ -249,64 +230,62 @@ public final class NamePlusRecordRecord extends ASN1Any {
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("NamePlusRecord_record: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the NamePlusRecord_record.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_retrievalRecord != null) {
if (retrievalRecord != null) {
found = true;
str.append("retrievalRecord ");
str.append(c_retrievalRecord);
str.append(retrievalRecord);
}
if (c_surrogateDiagnostic != null) {
if (surrogateDiagnostic != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: surrogateDiagnostic> ");
}
found = true;
str.append("surrogateDiagnostic ");
str.append(c_surrogateDiagnostic);
str.append(surrogateDiagnostic);
}
if (c_startingFragment != null) {
if (startingFragment != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: startingFragment> ");
}
found = true;
str.append("startingFragment ");
str.append(c_startingFragment);
str.append(startingFragment);
}
if (c_intermediateFragment != null) {
if (intermediateFragment != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: intermediateFragment> ");
}
found = true;
str.append("intermediateFragment ");
str.append(c_intermediateFragment);
str.append(intermediateFragment);
}
if (c_finalFragment != null) {
if (finalFragment != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: finalFragment> ");
}
str.append("finalFragment ");
str.append(c_finalFragment);
str.append(finalFragment);
}
str.append("}");
return str.toString();
}
}

View file

@ -18,7 +18,6 @@ import org.xbib.asn1.BEREncoding;
public final class OccurrenceByAttributes extends ASN1Any {
public OccurrenceByAttributes1 value[];
/**
* Constructor for a OccurrenceByAttributes from a BER encoding.
*
@ -28,7 +27,6 @@ public final class OccurrenceByAttributes extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OccurrenceByAttributes(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -43,10 +41,8 @@ public final class OccurrenceByAttributes extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// OccurrenceByAttributes should be encoded by a constructed BER
BERConstructed berConstructed;
@ -72,10 +68,8 @@ public final class OccurrenceByAttributes extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -87,17 +81,13 @@ public final class OccurrenceByAttributes extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding fields[] = new BERConstructed[value.length];
int p;
for (p = 0; p < value.length; p++) {
fields[p] = value[p].berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -105,19 +95,14 @@ public final class OccurrenceByAttributes extends ASN1Any {
* Returns a new String object containing a text representing
* of the OccurrenceByAttributes.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int p;
for (p = 0; p < value.length; p++) {
str.append(value[p]);
}
str.append("}");
return str.toString();
}
}

View file

@ -34,7 +34,6 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OccurrenceByAttributes1(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -49,10 +48,8 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// OccurrenceByAttributes1 should be encoded by a constructed BER
BERConstructed berConstructed;
@ -78,8 +75,8 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("OccurrenceByAttributes1: bad tag in s_attributes\n");
}
@ -145,10 +142,8 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -160,7 +155,7 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
@ -203,9 +198,8 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
* Returns a new String object containing a text representing
* of the OccurrenceByAttributes1.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
@ -229,10 +223,7 @@ public final class OccurrenceByAttributes1 extends ASN1Any {
str.append("otherOccurInfo ");
str.append(s_otherOccurInfo);
}
str.append("}");
return str.toString();
}
}

View file

@ -7,7 +7,6 @@ import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.BERConstructed;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>OccurrenceByAttributes_occurrences</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -33,7 +32,6 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OccurrenceByAttributesOccurrences(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
@ -48,39 +46,35 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed tagwrapper;
c_global = null;
c_byDatabase = null;
if (ber.tagGet() == 2 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 2 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("OccurrenceByAttributes_occurrences: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("OccurrenceByAttributes_occurrences: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
c_global = new ASN1Integer(tagwrapper.elementAt(0), true);
return;
}
// Try choice byDatabase
if (ber.tagGet() == 3 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 3 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
BEREncoding ber_data;
ber_data = ber;
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber_data;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("OccurrenceByAttributes_occurrences: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
@ -94,7 +88,7 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
return;
}
throw new ASN1Exception("OccurrenceByAttributes_occurrences: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -103,10 +97,8 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
BEREncoding f2[];
@ -156,7 +148,7 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
@ -166,16 +158,15 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("OccurrenceByAttributes_occurrences: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the OccurrenceByAttributes_occurrences.
*/
public String
toString() {
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
@ -203,5 +194,4 @@ public final class OccurrenceByAttributesOccurrences extends ASN1Any {
return str.toString();
}
}

View file

@ -49,18 +49,15 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// OccurrenceByAttributes_occurrences_byDatabase should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("OccurrenceByAttributes_occurrences_byDatabase: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -73,7 +70,7 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("OccurrenceByAttributes_occurrences_byDatabase: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
@ -93,8 +90,8 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_num = new ASN1Integer(p, false);
part++;
}
@ -116,7 +113,7 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("OccurrenceByAttributes_occurrences_byDatabase: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -126,10 +123,8 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -141,7 +136,7 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
@ -181,9 +176,8 @@ public final class OccurrenceByAttributesOccurrencesByDatabase extends ASN1Any {
* Returns a new String object containing a text representing
* of the OccurrenceByAttributes_occurrences_byDatabase.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;

View file

@ -5,7 +5,6 @@ import org.xbib.asn1.ASN1EncodingException;
import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>Operand</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -19,15 +18,13 @@ import org.xbib.asn1.BEREncoding;
*/
public final class Operand extends ASN1Any {
public AttributesPlusTerm c_attrTerm;
public ResultSetId c_resultSet;
public ResultSetPlusAttributes c_resultAttr;
public AttributesPlusTerm attrTerm;
public ResultSetId resultSet;
public ResultSetPlusAttributes resultAttr;
public Operand() {
}
/**
* Constructor for a Operand from a BER encoding.
*
@ -37,9 +34,7 @@ public final class Operand extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Operand(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Operand(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -52,19 +47,17 @@ public final class Operand extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Null out all choices
c_attrTerm = null;
c_resultSet = null;
c_resultAttr = null;
attrTerm = null;
resultSet = null;
resultAttr = null;
// Try choice attrTerm
try {
c_attrTerm = new AttributesPlusTerm(ber, checkTag);
attrTerm = new AttributesPlusTerm(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
@ -72,7 +65,7 @@ public final class Operand extends ASN1Any {
// Try choice resultSet
try {
c_resultSet = new ResultSetId(ber, checkTag);
resultSet = new ResultSetId(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
@ -80,13 +73,13 @@ public final class Operand extends ASN1Any {
// Try choice resultAttr
try {
c_resultAttr = new ResultSetPlusAttributes(ber, checkTag);
resultAttr = new ResultSetPlusAttributes(ber, checkTag);
return;
} catch (ASN1Exception e) {
// failed to decode, continue on
}
throw new ASN1Exception("Operand: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -95,31 +88,29 @@ public final class Operand extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
// Encoding choice: c_attrTerm
if (c_attrTerm != null) {
chosen = c_attrTerm.berEncode();
if (attrTerm != null) {
chosen = attrTerm.berEncode();
}
// Encoding choice: c_resultSet
if (c_resultSet != null) {
if (resultSet != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resultSet.berEncode();
chosen = resultSet.berEncode();
}
// Encoding choice: c_resultAttr
if (c_resultAttr != null) {
if (resultAttr != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resultAttr.berEncode();
chosen = resultAttr.berEncode();
}
// Check for error of having none of the choices set
@ -144,6 +135,7 @@ public final class Operand extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
@ -153,46 +145,44 @@ public final class Operand extends ASN1Any {
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("Operand: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the Operand.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_attrTerm != null) {
if (attrTerm != null) {
found = true;
str.append("attrTerm ");
str.append(c_attrTerm);
str.append(attrTerm);
}
if (c_resultSet != null) {
if (resultSet != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resultSet> ");
}
found = true;
str.append("resultSet ");
str.append(c_resultSet);
str.append(resultSet);
}
if (c_resultAttr != null) {
if (resultAttr != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resultAttr> ");
}
str.append("resultAttr ");
str.append(c_resultAttr);
str.append(resultAttr);
}
str.append("}");
return str.toString();
}
}

View file

@ -7,7 +7,6 @@ import org.xbib.asn1.ASN1Null;
import org.xbib.asn1.BERConstructed;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>Operator</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -22,16 +21,14 @@ import org.xbib.asn1.BEREncoding;
*/
public final class Operator extends ASN1Any {
public ASN1Null c_and;
public ASN1Null c_or;
public ASN1Null c_and_not;
public ProximityOperator c_prox;
public ASN1Null andOp;
public ASN1Null orOp;
public ASN1Null andNotOp;
public ProximityOperator proxOp;
public Operator() {
}
/**
* Constructor for a Operator from a BER encoding.
*
@ -41,9 +38,7 @@ public final class Operator extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Operator(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Operator(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -56,16 +51,14 @@ public final class Operator extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Check tag matches
if (checkTag) {
if (ber.tagGet() != 46 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("Operator: bad BER: tag=" + ber.tagGet() + " expected 46\n");
if (ber.getTag() != 46 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 46");
}
}
@ -75,51 +68,48 @@ public final class Operator extends ASN1Any {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("Operator: bad BER tag form\n");
throw new ASN1EncodingException("bad BER tag form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException
("Operator: bad BER tag form\n");
throw new ASN1EncodingException("bad BER tag form");
}
ber = tagwrapper.elementAt(0);
// Null out all choices
c_and = null;
c_or = null;
c_and_not = null;
c_prox = null;
andOp = null;
orOp = null;
andNotOp = null;
proxOp = null;
// Try choice and
if (ber.tagGet() == 0 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_and = new ASN1Null(ber, false);
if (ber.getTag() == 0 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
andOp = new ASN1Null(ber, false);
return;
}
// Try choice or
if (ber.tagGet() == 1 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_or = new ASN1Null(ber, false);
if (ber.getTag() == 1 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
orOp = new ASN1Null(ber, false);
return;
}
// Try choice and-not
if (ber.tagGet() == 2 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_and_not = new ASN1Null(ber, false);
if (ber.getTag() == 2 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
andNotOp = new ASN1Null(ber, false);
return;
}
// Try choice prox
if (ber.tagGet() == 3 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_prox = new ProximityOperator(ber, false);
if (ber.getTag() == 3 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
proxOp = new ProximityOperator(ber, false);
return;
}
throw new ASN1Exception("Operator: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -128,10 +118,8 @@ public final class Operator extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 46);
}
@ -141,39 +129,37 @@ public final class Operator extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding chosen = null;
// Encoding choice: c_and
if (c_and != null) {
chosen = c_and.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 0);
if (andOp != null) {
chosen = andOp.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 0);
}
// Encoding choice: c_or
if (c_or != null) {
if (orOp != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_or.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
chosen = orOp.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
}
// Encoding choice: c_and_not
if (c_and_not != null) {
if (andNotOp != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_and_not.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 2);
chosen = andNotOp.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 2);
}
// Encoding choice: c_prox
if (c_prox != null) {
if (proxOp != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_prox.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 3);
chosen = proxOp.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 3);
}
// Check for error of having none of the choices set
@ -192,49 +178,46 @@ public final class Operator extends ASN1Any {
* Returns a new String object containing a text representing
* of the Operator.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_and != null) {
if (andOp != null) {
found = true;
str.append("and ");
str.append(c_and);
str.append(andOp);
}
if (c_or != null) {
if (orOp != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: or> ");
}
found = true;
str.append("or ");
str.append(c_or);
str.append(orOp);
}
if (c_and_not != null) {
if (andNotOp != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: and-not> ");
}
found = true;
str.append("and-not ");
str.append(c_and_not);
str.append(andNotOp);
}
if (c_prox != null) {
if (proxOp != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: prox> ");
}
found = true;
str.append("prox ");
str.append(c_prox);
str.append(proxOp);
}
str.append("}");
return str.toString();
}
}

View file

@ -6,7 +6,6 @@ import org.xbib.asn1.ASN1EncodingException;
import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>Options</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -15,6 +14,7 @@ import org.xbib.asn1.BEREncoding;
* </pre>
*/
public final class Options extends ASN1Any {
public ASN1BitString value;
/**
@ -23,7 +23,6 @@ public final class Options extends ASN1Any {
public Options() {
}
/**
* Constructor for a Options from a BER encoding.
*
@ -33,9 +32,7 @@ public final class Options extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Options(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Options(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -48,16 +45,14 @@ public final class Options extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Check tag matches
if (checkTag) {
if (ber.tagGet() != 4 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("Options: bad BER: tag=" + ber.tagGet() + " expected 4\n");
if (ber.getTag() != 4 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 4");
}
}
@ -70,6 +65,7 @@ public final class Options extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 4);
}
@ -82,6 +78,7 @@ public final class Options extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
return value.berEncode(tagType, tag);
}
@ -90,8 +87,8 @@ public final class Options extends ASN1Any {
* Returns a new String object containing a text representing
* of the Options.
*/
@Override
public String toString() {
return value.toString();
}
}

View file

@ -6,7 +6,6 @@ import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BERConstructed;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>OtherInformation</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -15,8 +14,8 @@ import org.xbib.asn1.BEREncoding;
* </pre>
*/
public final class OtherInformation extends ASN1Any {
public OtherInformation1 value[];
public OtherInformation1[] value;
/**
* Default constructor for a OtherInformation.
@ -25,7 +24,6 @@ public final class OtherInformation extends ASN1Any {
public OtherInformation() {
}
/**
* Constructor for a OtherInformation from a BER encoding.
*
@ -35,9 +33,7 @@ public final class OtherInformation extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OtherInformation(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public OtherInformation(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -50,16 +46,14 @@ public final class OtherInformation extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Check tag matches
if (checkTag) {
if (ber.tagGet() != 201 ||
ber.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("OtherInformation: bad BER: tag=" + ber.tagGet() + " expected 201\n");
if (ber.getTag() != 201 ||
ber.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad BER: tag=" + ber.getTag() + " expected 201");
}
}
@ -69,7 +63,7 @@ public final class OtherInformation extends ASN1Any {
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("OtherInformation: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -88,10 +82,8 @@ public final class OtherInformation extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 201);
}
@ -103,10 +95,8 @@ public final class OtherInformation extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding fields[] = new BERConstructed[value.length];
int p;
@ -121,9 +111,8 @@ public final class OtherInformation extends ASN1Any {
* Returns a new String object containing a text representing
* of the OtherInformation.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int p;
@ -135,5 +124,4 @@ public final class OtherInformation extends ASN1Any {
return str.toString();
}
}

View file

@ -19,8 +19,8 @@ import org.xbib.asn1.BEREncoding;
*/
public final class OtherInformation1 extends ASN1Any {
public InfoCategory s_category; // optional
public OtherInformationInformation s_information;
public InfoCategory category; // optional
public OtherInformationInformation information;
/**
* Constructor for a OtherInformation1 from a BER encoding.
@ -31,9 +31,7 @@ public final class OtherInformation1 extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OtherInformation1(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public OtherInformation1(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -46,10 +44,8 @@ public final class OtherInformation1 extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// OtherInformation1 should be encoded by a constructed BER
BERConstructed berConstructed;
@ -73,9 +69,9 @@ public final class OtherInformation1 extends ASN1Any {
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 1 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_category = new InfoCategory(p, false);
if (p.getTag() == 1 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
category = new InfoCategory(p, false);
part++;
}
@ -87,7 +83,7 @@ public final class OtherInformation1 extends ASN1Any {
}
p = berConstructed.elementAt(part);
s_information = new OtherInformationInformation(p, true);
information = new OtherInformationInformation(p, true);
part++;
// Should not be any more parts
@ -103,10 +99,8 @@ public final class OtherInformation1 extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -118,14 +112,12 @@ public final class OtherInformation1 extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 1; // number of mandatories
if (s_category != null) {
if (category != null) {
numFields++;
}
@ -136,13 +128,13 @@ public final class OtherInformation1 extends ASN1Any {
// Encoding s_category: InfoCategory OPTIONAL
if (s_category != null) {
fields[x++] = s_category.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
if (category != null) {
fields[x++] = category.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 1);
}
// Encoding s_information: OtherInformation_information
fields[x] = s_information.berEncode();
fields[x] = information.berEncode();
return new BERConstructed(tagType, tag, fields);
}
@ -151,29 +143,22 @@ public final class OtherInformation1 extends ASN1Any {
* Returns a new String object containing a text representing
* of the OtherInformation1.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_category != null) {
if (category != null) {
str.append("category ");
str.append(s_category);
str.append(category);
outputted++;
}
if (0 < outputted) {
str.append(", ");
}
str.append("information ");
str.append(s_information);
str.append(information);
str.append("}");
return str.toString();
}
}

View file

@ -37,9 +37,7 @@ public final class OtherInformationInformation extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public OtherInformationInformation(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public OtherInformationInformation(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -52,10 +50,8 @@ public final class OtherInformationInformation extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Null out all choices
c_characterInfo = null;
@ -64,34 +60,34 @@ public final class OtherInformationInformation extends ASN1Any {
c_oid = null;
// Try choice characterInfo
if (ber.tagGet() == 2 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 2 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_characterInfo = new InternationalString(ber, false);
return;
}
// Try choice binaryInfo
if (ber.tagGet() == 3 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 3 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_binaryInfo = new ASN1OctetString(ber, false);
return;
}
// Try choice externallyDefinedInfo
if (ber.tagGet() == 4 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 4 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_externallyDefinedInfo = new ASN1External(ber, false);
return;
}
// Try choice oid
if (ber.tagGet() == 5 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (ber.getTag() == 5 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_oid = new ASN1ObjectIdentifier(ber, false);
return;
}
throw new ASN1Exception("OtherInformation_information: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -100,10 +96,8 @@ public final class OtherInformationInformation extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
// Encoding choice: c_characterInfo
@ -156,10 +150,8 @@ public final class OtherInformationInformation extends ASN1Any {
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
// Method is not available because this is a basic CHOICE
@ -168,18 +160,17 @@ public final class OtherInformationInformation extends ASN1Any {
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("OtherInformation_information: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the OtherInformation_information.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_characterInfo != null) {
found = true;
str.append("characterInfo ");
@ -212,10 +203,7 @@ public final class OtherInformationInformation extends ASN1Any {
str.append("oid ");
str.append(c_oid);
}
str.append("}");
return str.toString();
}
}

View file

@ -1,722 +0,0 @@
package org.xbib.io.iso23950.v3;
import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException;
import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>PDU</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
* PDU ::=
* CHOICE {
* initRequest [20] IMPLICIT InitializeRequest
* initResponse [21] IMPLICIT InitializeResponse
* searchRequest [22] IMPLICIT SearchRequest
* searchResponse [23] IMPLICIT SearchResponse
* presentRequest [24] IMPLICIT PresentRequest
* presentResponse [25] IMPLICIT PresentResponse
* deleteResultSetRequest [26] IMPLICIT DeleteResultSetRequest
* deleteResultSetResponse [27] IMPLICIT DeleteResultSetResponse
* accessControlRequest [28] IMPLICIT AccessControlRequest
* accessControlResponse [29] IMPLICIT AccessControlResponse
* resourceControlRequest [30] IMPLICIT ResourceControlRequest
* resourceControlResponse [31] IMPLICIT ResourceControlResponse
* triggerResourceControlRequest [32] IMPLICIT TriggerResourceControlRequest
* resourceReportRequest [33] IMPLICIT ResourceReportRequest
* resourceReportResponse [34] IMPLICIT ResourceReportResponse
* scanRequest [35] IMPLICIT ScanRequest
* scanResponse [36] IMPLICIT ScanResponse
* sortRequest [43] IMPLICIT SortRequest
* sortResponse [44] IMPLICIT SortResponse
* segmentRequest [45] IMPLICIT Segment
* extendedServicesRequest [46] IMPLICIT ExtendedServicesRequest
* extendedServicesResponse [47] IMPLICIT ExtendedServicesResponse
* close [48] IMPLICIT Close
* }
* </pre>
*/
public final class PDU extends ASN1Any {
public InitializeRequest c_initRequest;
public InitializeResponse c_initResponse;
public SearchRequest c_searchRequest;
public SearchResponse c_searchResponse;
public PresentRequest c_presentRequest;
public PresentResponse c_presentResponse;
public DeleteResultSetRequest c_deleteResultSetRequest;
public DeleteResultSetResponse c_deleteResultSetResponse;
public AccessControlRequest c_accessControlRequest;
public AccessControlResponse c_accessControlResponse;
public ResourceControlRequest c_resourceControlRequest;
public ResourceControlResponse c_resourceControlResponse;
public TriggerResourceControlRequest c_triggerResourceControlRequest;
public ResourceReportRequest c_resourceReportRequest;
public ResourceReportResponse c_resourceReportResponse;
public ScanRequest c_scanRequest;
public ScanResponse c_scanResponse;
public SortRequest c_sortRequest;
public SortResponse c_sortResponse;
public Segment c_segmentRequest;
public ExtendedServicesRequest c_extendedServicesRequest;
public ExtendedServicesResponse c_extendedServicesResponse;
public Close c_close;
/**
* Default constructor for a PDU.
*/
public PDU() {
}
/**
* Constructor for a PDU from a BER encoding.
*
* @param ber the BER encoding.
* @param checkTag will check tag if true, use false
* if the BER has been implicitly tagged. You should
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public PDU(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
super(ber, checkTag);
}
/**
* Initializing object from a BER encoding.
* This method is for internal use only. You should use
* the constructor that takes a BEREncoding.
*
* @param ber the BER to decode.
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
c_initRequest = null;
c_initResponse = null;
c_searchRequest = null;
c_searchResponse = null;
c_presentRequest = null;
c_presentResponse = null;
c_deleteResultSetRequest = null;
c_deleteResultSetResponse = null;
c_accessControlRequest = null;
c_accessControlResponse = null;
c_resourceControlRequest = null;
c_resourceControlResponse = null;
c_triggerResourceControlRequest = null;
c_resourceReportRequest = null;
c_resourceReportResponse = null;
c_scanRequest = null;
c_scanResponse = null;
c_sortRequest = null;
c_sortResponse = null;
c_segmentRequest = null;
c_extendedServicesRequest = null;
c_extendedServicesResponse = null;
c_close = null;
// Try choice initRequest
if (ber.tagGet() == 20 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_initRequest = new InitializeRequest(ber, false);
return;
}
// Try choice initResponse
if (ber.tagGet() == 21 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_initResponse = new InitializeResponse(ber, false);
return;
}
// Try choice searchRequest
if (ber.tagGet() == 22 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_searchRequest = new SearchRequest(ber, false);
return;
}
// Try choice searchResponse
if (ber.tagGet() == 23 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_searchResponse = new SearchResponse(ber, false);
return;
}
// Try choice presentRequest
if (ber.tagGet() == 24 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_presentRequest = new PresentRequest(ber, false);
return;
}
// Try choice presentResponse
if (ber.tagGet() == 25 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_presentResponse = new PresentResponse(ber, false);
return;
}
// Try choice deleteResultSetRequest
if (ber.tagGet() == 26 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_deleteResultSetRequest = new DeleteResultSetRequest(ber, false);
return;
}
// Try choice deleteResultSetResponse
if (ber.tagGet() == 27 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_deleteResultSetResponse = new DeleteResultSetResponse(ber, false);
return;
}
// Try choice accessControlRequest
if (ber.tagGet() == 28 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_accessControlRequest = new AccessControlRequest(ber, false);
return;
}
// Try choice accessControlResponse
if (ber.tagGet() == 29 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_accessControlResponse = new AccessControlResponse(ber, false);
return;
}
// Try choice resourceControlRequest
if (ber.tagGet() == 30 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_resourceControlRequest = new ResourceControlRequest(ber, false);
return;
}
// Try choice resourceControlResponse
if (ber.tagGet() == 31 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_resourceControlResponse = new ResourceControlResponse(ber, false);
return;
}
// Try choice triggerResourceControlRequest
if (ber.tagGet() == 32 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_triggerResourceControlRequest = new TriggerResourceControlRequest(ber, false);
return;
}
// Try choice resourceReportRequest
if (ber.tagGet() == 33 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_resourceReportRequest = new ResourceReportRequest(ber, false);
return;
}
// Try choice resourceReportResponse
if (ber.tagGet() == 34 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_resourceReportResponse = new ResourceReportResponse(ber, false);
return;
}
// Try choice scanRequest
if (ber.tagGet() == 35 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_scanRequest = new ScanRequest(ber, false);
return;
}
// Try choice scanResponse
if (ber.tagGet() == 36 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_scanResponse = new ScanResponse(ber, false);
return;
}
// Try choice sortRequest
if (ber.tagGet() == 43 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_sortRequest = new SortRequest(ber, false);
return;
}
// Try choice sortResponse
if (ber.tagGet() == 44 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_sortResponse = new SortResponse(ber, false);
return;
}
// Try choice segmentRequest
if (ber.tagGet() == 45 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_segmentRequest = new Segment(ber, false);
return;
}
// Try choice extendedServicesRequest
if (ber.tagGet() == 46 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_extendedServicesRequest = new ExtendedServicesRequest(ber, false);
return;
}
// Try choice extendedServicesResponse
if (ber.tagGet() == 47 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_extendedServicesResponse = new ExtendedServicesResponse(ber, false);
return;
}
// Try choice close
if (ber.tagGet() == 48 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_close = new Close(ber, false);
return;
}
throw new ASN1Exception("PDU: bad BER encoding: choice not matched");
}
/**
* Returns a BER encoding of PDU.
*
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
// Encoding choice: c_initRequest
if (c_initRequest != null) {
chosen = c_initRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 20);
}
// Encoding choice: c_initResponse
if (c_initResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_initResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 21);
}
// Encoding choice: c_searchRequest
if (c_searchRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_searchRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 22);
}
// Encoding choice: c_searchResponse
if (c_searchResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_searchResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 23);
}
// Encoding choice: c_presentRequest
if (c_presentRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_presentRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 24);
}
// Encoding choice: c_presentResponse
if (c_presentResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_presentResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 25);
}
// Encoding choice: c_deleteResultSetRequest
if (c_deleteResultSetRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_deleteResultSetRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 26);
}
// Encoding choice: c_deleteResultSetResponse
if (c_deleteResultSetResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_deleteResultSetResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 27);
}
// Encoding choice: c_accessControlRequest
if (c_accessControlRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_accessControlRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 28);
}
// Encoding choice: c_accessControlResponse
if (c_accessControlResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_accessControlResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 29);
}
// Encoding choice: c_resourceControlRequest
if (c_resourceControlRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resourceControlRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 30);
}
// Encoding choice: c_resourceControlResponse
if (c_resourceControlResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resourceControlResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 31);
}
// Encoding choice: c_triggerResourceControlRequest
if (c_triggerResourceControlRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_triggerResourceControlRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 32);
}
// Encoding choice: c_resourceReportRequest
if (c_resourceReportRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resourceReportRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 33);
}
// Encoding choice: c_resourceReportResponse
if (c_resourceReportResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_resourceReportResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 34);
}
// Encoding choice: c_scanRequest
if (c_scanRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_scanRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 35);
}
// Encoding choice: c_scanResponse
if (c_scanResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_scanResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 36);
}
// Encoding choice: c_sortRequest
if (c_sortRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_sortRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 43);
}
// Encoding choice: c_sortResponse
if (c_sortResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_sortResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 44);
}
// Encoding choice: c_segmentRequest
if (c_segmentRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_segmentRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 45);
}
// Encoding choice: c_extendedServicesRequest
if (c_extendedServicesRequest != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_extendedServicesRequest.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 46);
}
// Encoding choice: c_extendedServicesResponse
if (c_extendedServicesResponse != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_extendedServicesResponse.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 47);
}
// Encoding choice: c_close
if (c_close != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_close.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 48);
}
// Check for error of having none of the choices set
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
}
return chosen;
}
/**
* Generating a BER encoding of the object
* and implicitly tagging it.
* This method is for internal use only. You should use
* the berEncode method that does not take a parameter.
* This function should never be used, because this
* production is a CHOICE.
* It must never have an implicit tag.
* An exception will be thrown if it is called.
*
* @param tagType the type of the tag.
* @param tag the tag.
* @throws ASN1Exception if it cannot be BER encoded.
*/
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// This method must not be called!
// Method is not available because this is a basic CHOICE
// which does not have an explicit tag on it. So it is not
// permitted to allow something else to apply an implicit
// tag on it, otherwise the tag identifying which CHOICE
// it is will be overwritten and lost.
throw new ASN1EncodingException("PDU: cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the PDU.
*/
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_initRequest != null) {
found = true;
str.append("initRequest ");
str.append(c_initRequest);
}
if (c_initResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: initResponse> ");
}
found = true;
str.append("initResponse ");
str.append(c_initResponse);
}
if (c_searchRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: searchRequest> ");
}
found = true;
str.append("searchRequest ");
str.append(c_searchRequest);
}
if (c_searchResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: searchResponse> ");
}
found = true;
str.append("searchResponse ");
str.append(c_searchResponse);
}
if (c_presentRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: presentRequest> ");
}
found = true;
str.append("presentRequest ");
str.append(c_presentRequest);
}
if (c_presentResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: presentResponse> ");
}
found = true;
str.append("presentResponse ");
str.append(c_presentResponse);
}
if (c_deleteResultSetRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: deleteResultSetRequest> ");
}
found = true;
str.append("deleteResultSetRequest ");
str.append(c_deleteResultSetRequest);
}
if (c_deleteResultSetResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: deleteResultSetResponse> ");
}
found = true;
str.append("deleteResultSetResponse ");
str.append(c_deleteResultSetResponse);
}
if (c_accessControlRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: accessControlRequest> ");
}
found = true;
str.append("accessControlRequest ");
str.append(c_accessControlRequest);
}
if (c_accessControlResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: accessControlResponse> ");
}
found = true;
str.append("accessControlResponse ");
str.append(c_accessControlResponse);
}
if (c_resourceControlRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resourceControlRequest> ");
}
found = true;
str.append("resourceControlRequest ");
str.append(c_resourceControlRequest);
}
if (c_resourceControlResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resourceControlResponse> ");
}
found = true;
str.append("resourceControlResponse ");
str.append(c_resourceControlResponse);
}
if (c_triggerResourceControlRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: triggerResourceControlRequest> ");
}
found = true;
str.append("triggerResourceControlRequest ");
str.append(c_triggerResourceControlRequest);
}
if (c_resourceReportRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resourceReportRequest> ");
}
found = true;
str.append("resourceReportRequest ");
str.append(c_resourceReportRequest);
}
if (c_resourceReportResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: resourceReportResponse> ");
}
found = true;
str.append("resourceReportResponse ");
str.append(c_resourceReportResponse);
}
if (c_scanRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: scanRequest> ");
}
found = true;
str.append("scanRequest ");
str.append(c_scanRequest);
}
if (c_scanResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: scanResponse> ");
}
found = true;
str.append("scanResponse ");
str.append(c_scanResponse);
}
if (c_sortRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: sortRequest> ");
}
found = true;
str.append("sortRequest ");
str.append(c_sortRequest);
}
if (c_sortResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: sortResponse> ");
}
found = true;
str.append("sortResponse ");
str.append(c_sortResponse);
}
if (c_segmentRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: segmentRequest> ");
}
found = true;
str.append("segmentRequest ");
str.append(c_segmentRequest);
}
if (c_extendedServicesRequest != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: extendedServicesRequest> ");
}
found = true;
str.append("extendedServicesRequest ");
str.append(c_extendedServicesRequest);
}
if (c_extendedServicesResponse != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: extendedServicesResponse> ");
}
found = true;
str.append("extendedServicesResponse ");
str.append(c_extendedServicesResponse);
}
if (c_close != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: close> ");
}
str.append("close ");
str.append(c_close);
}
str.append("}");
return str.toString();
}
}

View file

@ -17,7 +17,7 @@ import org.xbib.asn1.BEREncoding;
*/
public final class Permissions extends ASN1Any {
public Permissions1 value[];
public Permissions1[] value;
/**
* Constructor for a Permissions from a BER encoding.
@ -28,9 +28,7 @@ public final class Permissions extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Permissions(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Permissions(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -43,17 +41,15 @@ public final class Permissions extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Permissions should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("Permissions: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
int numParts = berConstructed.numberComponents();
value = new Permissions1[numParts];
@ -69,10 +65,8 @@ public final class Permissions extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -84,17 +78,13 @@ public final class Permissions extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
BEREncoding fields[] = new BERConstructed[value.length];
int p;
for (p = 0; p < value.length; p++) {
fields[p] = value[p].berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -102,9 +92,8 @@ public final class Permissions extends ASN1Any {
* Returns a new String object containing a text representing
* of the Permissions.
*/
public String
toString() {
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
int p;
for (p = 0; p < value.length; p++) {
@ -113,5 +102,4 @@ public final class Permissions extends ASN1Any {
str.append("}");
return str.toString();
}
}

View file

@ -8,7 +8,6 @@ import org.xbib.asn1.ASN1Sequence;
import org.xbib.asn1.BERConstructed;
import org.xbib.asn1.BEREncoding;
/**
* Class for representing a <code>Permissions1</code> from <code>Z39-50-APDU-1995</code>.
* <pre>
@ -24,7 +23,6 @@ public final class Permissions1 extends ASN1Any {
public InternationalString s_userId;
public ASN1Integer s_allowableFunctions[];
/**
* Constructor for a Permissions1 from a BER encoding.
*
@ -34,9 +32,7 @@ public final class Permissions1 extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public Permissions1(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public Permissions1(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -49,18 +45,15 @@ public final class Permissions1 extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// Permissions1 should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException
("Permissions1: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
@ -73,14 +66,13 @@ public final class Permissions1 extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("Permissions1: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 1 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("Permissions1: bad tag in s_userId\n");
if (p.getTag() != 1 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in s_userId");
}
s_userId = new InternationalString(p, false);
@ -90,14 +82,13 @@ public final class Permissions1 extends ASN1Any {
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("Permissions1: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 2 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException
("Permissions1: bad tag in s_allowableFunctions\n");
if (p.getTag() != 2 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in s_allowableFunctions");
}
try {
@ -109,14 +100,14 @@ public final class Permissions1 extends ASN1Any {
s_allowableFunctions[n] = new ASN1Integer(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
throw new ASN1EncodingException("bad BER");
}
part++;
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("Permissions1: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -126,10 +117,8 @@ public final class Permissions1 extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -141,6 +130,7 @@ public final class Permissions1 extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
@ -174,9 +164,8 @@ public final class Permissions1 extends ASN1Any {
* Returns a new String object containing a text representing
* of the Permissions1.
*/
public String
toString() {
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
int outputted = 0;
@ -200,5 +189,4 @@ public final class Permissions1 extends ASN1Any {
str.append("}");
return str.toString();
}
}

View file

@ -32,23 +32,24 @@ import org.xbib.asn1.BEREncoding;
public final class PresentRequest extends ASN1Any {
public ReferenceId s_referenceId; // optional
public ResultSetId s_resultSetId;
public ASN1Integer s_resultSetStartPoint;
public ASN1Integer s_numberOfRecordsRequested;
public Range s_additionalRanges[]; // optional
public PresentRequestRecordComposition s_recordComposition; // optional
public ASN1ObjectIdentifier s_preferredRecordSyntax; // optional
public ASN1Integer s_maxSegmentCount; // optional
public ASN1Integer s_maxRecordSize; // optional
public ASN1Integer s_maxSegmentSize; // optional
public OtherInformation s_otherInfo; // optional
public ReferenceId referenceId; // optional
public ResultSetId resultSetId;
public ASN1Integer resultSetStartPoint;
public ASN1Integer numberOfRecordsRequested;
public Range[] additionalRanges; // optional
public PresentRequestRecordComposition recordComposition; // optional
public ASN1ObjectIdentifier preferredRecordSyntax; // optional
public ASN1Integer maxSegmentCount; // optional
public ASN1Integer maxRecordSize; // optional
public ASN1Integer maxSegmentSize; // optional
public OtherInformation otherInfo; // optional
/**
* Default constructor for a PresentRequest.
*/
public PresentRequest() {
}
/**
* Constructor for a PresentRequest from a BER encoding.
*
@ -58,9 +59,7 @@ public final class PresentRequest extends ASN1Any {
* usually be passing true.
* @throws ASN1Exception if the BER encoding is bad.
*/
public PresentRequest(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
public PresentRequest(BEREncoding ber, boolean checkTag) throws ASN1Exception {
super(ber, checkTag);
}
@ -73,201 +72,157 @@ public final class PresentRequest extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
public void
berDecode(BEREncoding ber, boolean checkTag)
throws ASN1Exception {
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
// PresentRequest should be encoded by a constructed BER
BERConstructed berConstructed;
try {
berConstructed = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("PresentRequest: bad BER form\n");
throw new ASN1EncodingException("bad BER form");
}
// Prepare to decode the components
int numParts = berConstructed.numberComponents();
int part = 0;
BEREncoding p;
// Decoding: referenceId ReferenceId OPTIONAL
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("PresentRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
try {
s_referenceId = new ReferenceId(p, true);
referenceId = new ReferenceId(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_referenceId = null; // no, not present
referenceId = null; // no, not present
}
// Decoding: resultSetId ResultSetId
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("PresentRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
s_resultSetId = new ResultSetId(p, true);
resultSetId = new ResultSetId(p, true);
part++;
// Decoding: resultSetStartPoint [30] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("PresentRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 30 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("PresentRequest: bad tag in s_resultSetStartPoint\n");
if (p.getTag() != 30 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("bad tag in resultSetStartPoint\n");
}
s_resultSetStartPoint = new ASN1Integer(p, false);
resultSetStartPoint = new ASN1Integer(p, false);
part++;
// Decoding: numberOfRecordsRequested [29] IMPLICIT INTEGER
if (numParts <= part) {
// End of record, but still more elements to get
throw new ASN1Exception("PresentRequest: incomplete");
throw new ASN1Exception("incomplete");
}
p = berConstructed.elementAt(part);
if (p.tagGet() != 29 ||
p.tagTypeGet() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("PresentRequest: bad tag in s_numberOfRecordsRequested\n");
if (p.getTag() != 29 ||
p.getTagType() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
throw new ASN1EncodingException("PresentRequest: bad tag in numberOfRecordsRequested");
}
s_numberOfRecordsRequested = new ASN1Integer(p, false);
numberOfRecordsRequested = new ASN1Integer(p, false);
part++;
// Remaining elements are optional, set variables
// to null (not present) so can return at endStream of BER
s_additionalRanges = null;
s_recordComposition = null;
s_preferredRecordSyntax = null;
s_maxSegmentCount = null;
s_maxRecordSize = null;
s_maxSegmentSize = null;
s_otherInfo = null;
additionalRanges = null;
recordComposition = null;
preferredRecordSyntax = null;
maxSegmentCount = null;
maxRecordSize = null;
maxSegmentSize = null;
otherInfo = null;
// Decoding: additionalRanges [212] IMPLICIT SEQUENCE OF Range OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 212 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
if (p.getTag() == 212 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
BERConstructed cons = (BERConstructed) p;
int parts = cons.numberComponents();
s_additionalRanges = new Range[parts];
additionalRanges = new Range[parts];
int n;
for (n = 0; n < parts; n++) {
s_additionalRanges[n] = new Range(cons.elementAt(n), true);
additionalRanges[n] = new Range(cons.elementAt(n), true);
}
} catch (ClassCastException e) {
throw new ASN1EncodingException("Bad BER");
throw new ASN1EncodingException("bad BER");
}
part++;
}
// Decoding: recordComposition PresentRequest_recordComposition OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
try {
s_recordComposition = new PresentRequestRecordComposition(p, true);
recordComposition = new PresentRequestRecordComposition(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_recordComposition = null; // no, not present
recordComposition = null; // no, not present
}
// Decoding: preferredRecordSyntax [104] IMPLICIT OBJECT IDENTIFIER OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 104 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_preferredRecordSyntax = new ASN1ObjectIdentifier(p, false);
if (p.getTag() == 104 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
preferredRecordSyntax = new ASN1ObjectIdentifier(p, false);
part++;
}
// Decoding: maxSegmentCount [204] IMPLICIT INTEGER OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 204 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_maxSegmentCount = new ASN1Integer(p, false);
if (p.getTag() == 204 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
maxSegmentCount = new ASN1Integer(p, false);
part++;
}
// Decoding: maxRecordSize [206] IMPLICIT INTEGER OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 206 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_maxRecordSize = new ASN1Integer(p, false);
if (p.getTag() == 206 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
maxRecordSize = new ASN1Integer(p, false);
part++;
}
// Decoding: maxSegmentSize [207] IMPLICIT INTEGER OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
if (p.tagGet() == 207 &&
p.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
s_maxSegmentSize = new ASN1Integer(p, false);
if (p.getTag() == 207 &&
p.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
maxSegmentSize = new ASN1Integer(p, false);
part++;
}
// Decoding: otherInfo OtherInformation OPTIONAL
if (numParts <= part) {
return; // no more data, but ok (rest is optional)
}
p = berConstructed.elementAt(part);
try {
s_otherInfo = new OtherInformation(p, true);
otherInfo = new OtherInformation(p, true);
part++; // yes, consumed
} catch (ASN1Exception e) {
s_otherInfo = null; // no, not present
otherInfo = null; // no, not present
}
// Should not be any more parts
if (part < numParts) {
throw new ASN1Exception("PresentRequest: bad BER: extra data " + part + "/" + numParts + " processed");
throw new ASN1Exception("bad BER: extra data " + part + "/" + numParts + " processed");
}
}
@ -277,10 +232,8 @@ public final class PresentRequest extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
public BEREncoding
berEncode()
throws ASN1Exception {
@Override
public BEREncoding berEncode() throws ASN1Exception {
return berEncode(BEREncoding.UNIVERSAL_TAG, ASN1Sequence.SEQUENCE_TAG);
}
@ -292,111 +245,81 @@ public final class PresentRequest extends ASN1Any {
* @return The BER encoding of the object.
* @throws ASN1Exception When invalid or cannot be encoded.
*/
public BEREncoding
berEncode(int tagType, int tag)
throws ASN1Exception {
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
// Calculate the number of fields in the encoding
int numFields = 3; // number of mandatories
if (s_referenceId != null) {
if (referenceId != null) {
numFields++;
}
if (s_additionalRanges != null) {
if (additionalRanges != null) {
numFields++;
}
if (s_recordComposition != null) {
if (recordComposition != null) {
numFields++;
}
if (s_preferredRecordSyntax != null) {
if (preferredRecordSyntax != null) {
numFields++;
}
if (s_maxSegmentCount != null) {
if (maxSegmentCount != null) {
numFields++;
}
if (s_maxRecordSize != null) {
if (maxRecordSize != null) {
numFields++;
}
if (s_maxSegmentSize != null) {
if (maxSegmentSize != null) {
numFields++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
numFields++;
}
// Encode it
BEREncoding fields[] = new BEREncoding[numFields];
int x = 0;
BEREncoding f2[];
int p;
// Encoding s_referenceId: ReferenceId OPTIONAL
if (s_referenceId != null) {
fields[x++] = s_referenceId.berEncode();
if (referenceId != null) {
fields[x++] = referenceId.berEncode();
}
// Encoding s_resultSetId: ResultSetId
fields[x++] = s_resultSetId.berEncode();
fields[x++] = resultSetId.berEncode();
// Encoding s_resultSetStartPoint: INTEGER
fields[x++] = s_resultSetStartPoint.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 30);
fields[x++] = resultSetStartPoint.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 30);
// Encoding s_numberOfRecordsRequested: INTEGER
fields[x++] = s_numberOfRecordsRequested.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 29);
fields[x++] = numberOfRecordsRequested.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 29);
// Encoding s_additionalRanges: SEQUENCE OF OPTIONAL
if (s_additionalRanges != null) {
f2 = new BEREncoding[s_additionalRanges.length];
for (p = 0; p < s_additionalRanges.length; p++) {
f2[p] = s_additionalRanges[p].berEncode();
if (additionalRanges != null) {
f2 = new BEREncoding[additionalRanges.length];
for (p = 0; p < additionalRanges.length; p++) {
f2[p] = additionalRanges[p].berEncode();
}
fields[x++] = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 212, f2);
}
// Encoding s_recordComposition: PresentRequest_recordComposition OPTIONAL
if (s_recordComposition != null) {
fields[x++] = s_recordComposition.berEncode();
if (recordComposition != null) {
fields[x++] = recordComposition.berEncode();
}
// Encoding s_preferredRecordSyntax: OBJECT IDENTIFIER OPTIONAL
if (s_preferredRecordSyntax != null) {
fields[x++] = s_preferredRecordSyntax.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 104);
if (preferredRecordSyntax != null) {
fields[x++] = preferredRecordSyntax.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 104);
}
// Encoding s_maxSegmentCount: INTEGER OPTIONAL
if (s_maxSegmentCount != null) {
fields[x++] = s_maxSegmentCount.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 204);
if (maxSegmentCount != null) {
fields[x++] = maxSegmentCount.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 204);
}
// Encoding s_maxRecordSize: INTEGER OPTIONAL
if (s_maxRecordSize != null) {
fields[x++] = s_maxRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 206);
if (maxRecordSize != null) {
fields[x++] = maxRecordSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 206);
}
// Encoding s_maxSegmentSize: INTEGER OPTIONAL
if (s_maxSegmentSize != null) {
fields[x++] = s_maxSegmentSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 207);
if (maxSegmentSize != null) {
fields[x++] = maxSegmentSize.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 207);
}
// Encoding s_otherInfo: OtherInformation OPTIONAL
if (s_otherInfo != null) {
fields[x] = s_otherInfo.berEncode();
if (otherInfo != null) {
fields[x] = otherInfo.berEncode();
}
return new BERConstructed(tagType, tag, fields);
}
@ -404,107 +327,95 @@ public final class PresentRequest extends ASN1Any {
* Returns a new String object containing a text representing
* of the PresentRequest.
*/
public String
toString() {
@Override
public String toString() {
int p;
StringBuilder str = new StringBuilder("{");
int outputted = 0;
if (s_referenceId != null) {
if (referenceId != null) {
str.append("referenceId ");
str.append(s_referenceId);
str.append(referenceId);
outputted++;
}
if (0 < outputted) {
str.append(", ");
}
str.append("resultSetId ");
str.append(s_resultSetId);
str.append(resultSetId);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("resultSetStartPoint ");
str.append(s_resultSetStartPoint);
str.append(resultSetStartPoint);
outputted++;
if (0 < outputted) {
str.append(", ");
}
str.append("numberOfRecordsRequested ");
str.append(s_numberOfRecordsRequested);
str.append(numberOfRecordsRequested);
outputted++;
if (s_additionalRanges != null) {
if (additionalRanges != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("additionalRanges ");
str.append("{");
for (p = 0; p < s_additionalRanges.length; p++) {
for (p = 0; p < additionalRanges.length; p++) {
if (p != 0) {
str.append(", ");
}
str.append(s_additionalRanges[p]);
str.append(additionalRanges[p]);
}
str.append("}");
outputted++;
}
if (s_recordComposition != null) {
if (recordComposition != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("recordComposition ");
str.append(s_recordComposition);
str.append(recordComposition);
outputted++;
}
if (s_preferredRecordSyntax != null) {
if (preferredRecordSyntax != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("preferredRecordSyntax ");
str.append(s_preferredRecordSyntax);
str.append(preferredRecordSyntax);
outputted++;
}
if (s_maxSegmentCount != null) {
if (maxSegmentCount != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("maxSegmentCount ");
str.append(s_maxSegmentCount);
str.append(maxSegmentCount);
outputted++;
}
if (s_maxRecordSize != null) {
if (maxRecordSize != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("maxRecordSize ");
str.append(s_maxRecordSize);
str.append(maxRecordSize);
outputted++;
}
if (s_maxSegmentSize != null) {
if (maxSegmentSize != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("maxSegmentSize ");
str.append(s_maxSegmentSize);
str.append(maxSegmentSize);
outputted++;
}
if (s_otherInfo != null) {
if (otherInfo != null) {
if (0 < outputted) {
str.append(", ");
}
str.append("otherInfo ");
str.append(s_otherInfo);
str.append(otherInfo);
}
str.append("}");
return str.toString();

View file

@ -19,14 +19,13 @@ import org.xbib.asn1.BEREncoding;
*/
public final class PresentRequestRecordComposition extends ASN1Any {
public ElementSetNames c_simple;
public ElementSetNames simple;
public CompSpec c_complex;
public CompSpec complex;
/**
* Default constructor for a PresentRequest_recordComposition.
*/
public PresentRequestRecordComposition() {
}
@ -52,29 +51,30 @@ public final class PresentRequestRecordComposition extends ASN1Any {
* @param checkTag if the tag should be checked.
* @throws ASN1Exception if the BER encoding is bad.
*/
@Override
public void berDecode(BEREncoding ber, boolean checkTag) throws ASN1Exception {
BERConstructed tagwrapper;
c_simple = null;
c_complex = null;
if (ber.tagGet() == 19 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
simple = null;
complex = null;
if (ber.getTag() == 19 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
try {
tagwrapper = (BERConstructed) ber;
} catch (ClassCastException e) {
throw new ASN1EncodingException("PresentRequest_recordComposition: bad BER form");
throw new ASN1EncodingException("bad BER form");
}
if (tagwrapper.numberComponents() != 1) {
throw new ASN1EncodingException("PresentRequest_recordComposition: bad BER form");
throw new ASN1EncodingException("bad BER form");
}
c_simple = new ElementSetNames(tagwrapper.elementAt(0), true);
simple = new ElementSetNames(tagwrapper.elementAt(0), true);
return;
}
if (ber.tagGet() == 209 &&
ber.tagTypeGet() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
c_complex = new CompSpec(ber, false);
if (ber.getTag() == 209 &&
ber.getTagType() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
complex = new CompSpec(ber, false);
return;
}
throw new ASN1Exception("PresentRequest_recordComposition: bad BER encoding: choice not matched");
throw new ASN1Exception("bad BER encoding: choice not matched");
}
/**
@ -83,19 +83,20 @@ public final class PresentRequestRecordComposition extends ASN1Any {
* @return The BER encoding.
* @throws ASN1Exception Invalid or cannot be encoded.
*/
@Override
public BEREncoding berEncode() throws ASN1Exception {
BEREncoding chosen = null;
BEREncoding[] enc;
if (c_simple != null) {
if (simple != null) {
enc = new BEREncoding[1];
enc[0] = c_simple.berEncode();
enc[0] = simple.berEncode();
chosen = new BERConstructed(BEREncoding.CONTEXT_SPECIFIC_TAG, 19, enc);
}
if (c_complex != null) {
if (complex != null) {
if (chosen != null) {
throw new ASN1Exception("CHOICE multiply set");
}
chosen = c_complex.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 209);
chosen = complex.berEncode(BEREncoding.CONTEXT_SPECIFIC_TAG, 209);
}
if (chosen == null) {
throw new ASN1Exception("CHOICE not set");
@ -103,28 +104,30 @@ public final class PresentRequestRecordComposition extends ASN1Any {
return chosen;
}
@Override
public BEREncoding berEncode(int tagType, int tag) throws ASN1Exception {
throw new ASN1EncodingException("PresentRequest_recordComposition: cannot implicitly tag");
throw new ASN1EncodingException("cannot implicitly tag");
}
/**
* Returns a new String object containing a text representing
* of the PresentRequest_recordComposition.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder("{");
boolean found = false;
if (c_simple != null) {
if (simple != null) {
found = true;
str.append("simple ");
str.append(c_simple);
str.append(simple);
}
if (c_complex != null) {
if (complex != null) {
if (found) {
str.append("<ERROR: multiple CHOICE: complex> ");
}
str.append("complex ");
str.append(c_complex);
str.append(complex);
}
str.append("}");
return str.toString();

Some files were not shown because too many files have changed in this diff Show more