From 6c73c4a81e32f26762f178cbdbd15b3073eae3c5 Mon Sep 17 00:00:00 2001 From: Lukas Jungmann Date: Fri, 20 Oct 2023 12:44:31 +0200 Subject: [PATCH] fix location of spotbugs filter Signed-off-by: Lukas Jungmann --- .../com/sun/xml/fime/DecoderStateTables.java | 124 +++++------ .../BuiltInEncodingAlgorithmFactory.java | 22 +- ...IEEE754FloatingPointEncodingAlgorithm.java | 10 +- .../algorithm/IntegerEncodingAlgorithm.java | 14 +- .../alphabet/BuiltInRestrictedAlphabets.java | 4 +- .../xml/fime/vocab/SerializerVocabulary.java | 4 +- .../org/xml/sax/helpers/NamespaceSupport.java | 4 +- pom.xml | 2 +- .../roundtriptests/AllRoundTripTest.java | 23 +- .../fastinfoset/roundtriptests/FileUtils.java | 26 ++- .../roundtriptests/SingleRountTripTest.java | 23 +- .../roundtriptests/rtt/DOMRoundTripRtt.java | 7 +- .../rtt/DOMSAXRoundTripRtt.java | 7 +- .../roundtriptests/rtt/RoundTripRtt.java | 5 +- .../roundtriptests/rtt/SAXRoundTripRtt.java | 7 +- .../roundtriptests/rtt/SAXStAXDiffRtt.java | 7 +- .../roundtriptests/rtt/StAXRoundTripRtt.java | 7 +- .../src/main/java/samples/common/Util.java | 2 +- .../samples/typed/ConvertLexicalValues.java | 12 +- ...rimitiveTypesWithElementContentSample.java | 196 +++++++++--------- src/main/resources/spotbugs-exclude.xml | 6 + .../analysis/frequency/FrequencyHandler.java | 5 +- .../xml/analysis/frequency/FrequencySet.java | 14 +- .../analysis/frequency/SchemaProcessor.java | 35 +++- .../frequency/tools/PrintFrequency.java | 8 +- .../xml/analysis/types/SchemaProcessor.java | 23 ++ .../FastInfosetReaderSAXBufferCreator.java | 28 ++- .../FastInfosetWriterSAXBufferProcessor.java | 2 +- .../streambuffer/TypedSAXBufferCreator.java | 29 ++- .../streambuffer/tools/RoundTrip.java | 5 +- .../types/LexicalSpaceConvertor.java | 11 +- .../xml/fastinfoset/types/ValueInstance.java | 4 +- .../utilities/tools/XML_SAX_TYPED_FI.java | 5 +- .../vocab/frequency/VocabularyGenerator.java | 8 +- 34 files changed, 433 insertions(+), 256 deletions(-) diff --git a/FIME/src/com/sun/xml/fime/DecoderStateTables.java b/FIME/src/com/sun/xml/fime/DecoderStateTables.java index 64807b2..90d5c7d 100644 --- a/FIME/src/com/sun/xml/fime/DecoderStateTables.java +++ b/FIME/src/com/sun/xml/fime/DecoderStateTables.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -14,34 +14,34 @@ public class DecoderStateTables { private static int RANGE_INDEX_END = 0; private static int RANGE_INDEX_VALUE = 1; - public final static int STATE_ILLEGAL = 255; - public final static int STATE_UNSUPPORTED = 254; + public static final int STATE_ILLEGAL = 255; + public static final int STATE_UNSUPPORTED = 254; // EII child states - public final static int EII_NO_AIIS_INDEX_SMALL = 0; - public final static int EII_AIIS_INDEX_SMALL = 1; - public final static int EII_INDEX_MEDIUM = 2; - public final static int EII_INDEX_LARGE = 3; - public final static int EII_NAMESPACES = 4; - public final static int EII_LITERAL = 5; - public final static int CII_UTF8_SMALL_LENGTH = 6; - public final static int CII_UTF8_MEDIUM_LENGTH = 7; - public final static int CII_UTF8_LARGE_LENGTH = 8; - public final static int CII_UTF16_SMALL_LENGTH = 9; - public final static int CII_UTF16_MEDIUM_LENGTH = 10; - public final static int CII_UTF16_LARGE_LENGTH = 11; - public final static int CII_RA = 12; - public final static int CII_EA = 13; - public final static int CII_INDEX_SMALL = 14; - public final static int CII_INDEX_MEDIUM = 15; - public final static int CII_INDEX_LARGE = 16; - public final static int CII_INDEX_LARGE_LARGE = 17; - public final static int COMMENT_II = 18; - public final static int PROCESSING_INSTRUCTION_II = 19; - public final static int DOCUMENT_TYPE_DECLARATION_II = 20; - public final static int UNEXPANDED_ENTITY_REFERENCE_II = 21; - public final static int TERMINATOR_SINGLE = 22; - public final static int TERMINATOR_DOUBLE = 23; + public static final int EII_NO_AIIS_INDEX_SMALL = 0; + public static final int EII_AIIS_INDEX_SMALL = 1; + public static final int EII_INDEX_MEDIUM = 2; + public static final int EII_INDEX_LARGE = 3; + public static final int EII_NAMESPACES = 4; + public static final int EII_LITERAL = 5; + public static final int CII_UTF8_SMALL_LENGTH = 6; + public static final int CII_UTF8_MEDIUM_LENGTH = 7; + public static final int CII_UTF8_LARGE_LENGTH = 8; + public static final int CII_UTF16_SMALL_LENGTH = 9; + public static final int CII_UTF16_MEDIUM_LENGTH = 10; + public static final int CII_UTF16_LARGE_LENGTH = 11; + public static final int CII_RA = 12; + public static final int CII_EA = 13; + public static final int CII_INDEX_SMALL = 14; + public static final int CII_INDEX_MEDIUM = 15; + public static final int CII_INDEX_LARGE = 16; + public static final int CII_INDEX_LARGE_LARGE = 17; + public static final int COMMENT_II = 18; + public static final int PROCESSING_INSTRUCTION_II = 19; + public static final int DOCUMENT_TYPE_DECLARATION_II = 20; + public static final int UNEXPANDED_ENTITY_REFERENCE_II = 21; + public static final int TERMINATOR_SINGLE = 22; + public static final int TERMINATOR_DOUBLE = 23; public static final int[] DII = new int[256]; @@ -323,12 +323,12 @@ public class DecoderStateTables { // AII states - public final static int AII_INDEX_SMALL = 0; - public final static int AII_INDEX_MEDIUM = 1; - public final static int AII_INDEX_LARGE = 2; - public final static int AII_LITERAL = 3; - public final static int AII_TERMINATOR_SINGLE = 4; - public final static int AII_TERMINATOR_DOUBLE = 5; + public static final int AII_INDEX_SMALL = 0; + public static final int AII_INDEX_MEDIUM = 1; + public static final int AII_INDEX_LARGE = 2; + public static final int AII_LITERAL = 3; + public static final int AII_TERMINATOR_SINGLE = 4; + public static final int AII_TERMINATOR_DOUBLE = 5; public static final int[] AII = new int[256]; @@ -372,18 +372,18 @@ public class DecoderStateTables { // AII value states - public final static int NISTRING_UTF8_SMALL_LENGTH = 0; - public final static int NISTRING_UTF8_MEDIUM_LENGTH = 1; - public final static int NISTRING_UTF8_LARGE_LENGTH = 2; - public final static int NISTRING_UTF16_SMALL_LENGTH = 3; - public final static int NISTRING_UTF16_MEDIUM_LENGTH = 4; - public final static int NISTRING_UTF16_LARGE_LENGTH = 5; - public final static int NISTRING_RA = 6; - public final static int NISTRING_EA = 7; - public final static int NISTRING_INDEX_SMALL = 8; - public final static int NISTRING_INDEX_MEDIUM = 9; - public final static int NISTRING_INDEX_LARGE = 10; - public final static int NISTRING_EMPTY = 11; + public static final int NISTRING_UTF8_SMALL_LENGTH = 0; + public static final int NISTRING_UTF8_MEDIUM_LENGTH = 1; + public static final int NISTRING_UTF8_LARGE_LENGTH = 2; + public static final int NISTRING_UTF16_SMALL_LENGTH = 3; + public static final int NISTRING_UTF16_MEDIUM_LENGTH = 4; + public static final int NISTRING_UTF16_LARGE_LENGTH = 5; + public static final int NISTRING_RA = 6; + public static final int NISTRING_EA = 7; + public static final int NISTRING_INDEX_SMALL = 8; + public static final int NISTRING_INDEX_MEDIUM = 9; + public static final int NISTRING_INDEX_LARGE = 10; + public static final int NISTRING_EMPTY = 11; public static final int[] NISTRING = new int[256]; @@ -495,12 +495,12 @@ public class DecoderStateTables { }; - public final static int ISTRING_SMALL_LENGTH = 0; - public final static int ISTRING_MEDIUM_LENGTH = 1; - public final static int ISTRING_LARGE_LENGTH = 2; - public final static int ISTRING_INDEX_SMALL = 3; - public final static int ISTRING_INDEX_MEDIUM = 4; - public final static int ISTRING_INDEX_LARGE = 5; + public static final int ISTRING_SMALL_LENGTH = 0; + public static final int ISTRING_MEDIUM_LENGTH = 1; + public static final int ISTRING_LARGE_LENGTH = 2; + public static final int ISTRING_INDEX_SMALL = 3; + public static final int ISTRING_INDEX_MEDIUM = 4; + public static final int ISTRING_INDEX_LARGE = 5; public static final int[] ISTRING = new int[256]; @@ -534,11 +534,11 @@ public class DecoderStateTables { }; - public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_3 = 6; - public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_5 = 7; - public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_29 = 8; - public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_36 = 9; - public final static int ISTRING_PREFIX_NAMESPACE_INDEX_ZERO = 10; + public static final int ISTRING_PREFIX_NAMESPACE_LENGTH_3 = 6; + public static final int ISTRING_PREFIX_NAMESPACE_LENGTH_5 = 7; + public static final int ISTRING_PREFIX_NAMESPACE_LENGTH_29 = 8; + public static final int ISTRING_PREFIX_NAMESPACE_LENGTH_36 = 9; + public static final int ISTRING_PREFIX_NAMESPACE_INDEX_ZERO = 10; public static final int[] ISTRING_PREFIX_NAMESPACE = new int[256]; @@ -602,12 +602,12 @@ public class DecoderStateTables { }; // UTF-8 states - public final static int UTF8_NCNAME_NCNAME = 0; - public final static int UTF8_NCNAME_NCNAME_CHAR = 1; - public final static int UTF8_TWO_BYTES = 2; - public final static int UTF8_THREE_BYTES = 3; + public static final int UTF8_NCNAME_NCNAME = 0; + public static final int UTF8_NCNAME_NCNAME_CHAR = 1; + public static final int UTF8_TWO_BYTES = 2; + public static final int UTF8_THREE_BYTES = 3; // Supplementary UTF-8 -// public final static int UTF8_FOUR_BYTES = 4; +// public static final int UTF8_FOUR_BYTES = 4; public static final int[] UTF8_NCNAME = new int[256]; @@ -680,7 +680,7 @@ public class DecoderStateTables { { 0xFF, STATE_ILLEGAL } }; - public final static int UTF8_ONE_BYTE = 1; + public static final int UTF8_ONE_BYTE = 1; public static final int[] UTF8 = new int[256]; diff --git a/FIME/src/com/sun/xml/fime/algorithm/BuiltInEncodingAlgorithmFactory.java b/FIME/src/com/sun/xml/fime/algorithm/BuiltInEncodingAlgorithmFactory.java index 42d39b3..f02ade9 100644 --- a/FIME/src/com/sun/xml/fime/algorithm/BuiltInEncodingAlgorithmFactory.java +++ b/FIME/src/com/sun/xml/fime/algorithm/BuiltInEncodingAlgorithmFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -16,26 +16,26 @@ public final class BuiltInEncodingAlgorithmFactory { - public final static BuiltInEncodingAlgorithm[] table = + public static final BuiltInEncodingAlgorithm[] table = new BuiltInEncodingAlgorithm[EncodingConstants.ENCODING_ALGORITHM_BUILTIN_END + 1]; - public final static HexadecimalEncodingAlgorithm hexadecimalEncodingAlgorithm = new HexadecimalEncodingAlgorithm(); + public static final HexadecimalEncodingAlgorithm hexadecimalEncodingAlgorithm = new HexadecimalEncodingAlgorithm(); - public final static BASE64EncodingAlgorithm base64EncodingAlgorithm = new BASE64EncodingAlgorithm(); + public static final BASE64EncodingAlgorithm base64EncodingAlgorithm = new BASE64EncodingAlgorithm(); - public final static BooleanEncodingAlgorithm booleanEncodingAlgorithm = new BooleanEncodingAlgorithm(); + public static final BooleanEncodingAlgorithm booleanEncodingAlgorithm = new BooleanEncodingAlgorithm(); - public final static ShortEncodingAlgorithm shortEncodingAlgorithm = new ShortEncodingAlgorithm(); + public static final ShortEncodingAlgorithm shortEncodingAlgorithm = new ShortEncodingAlgorithm(); - public final static IntEncodingAlgorithm intEncodingAlgorithm = new IntEncodingAlgorithm(); + public static final IntEncodingAlgorithm intEncodingAlgorithm = new IntEncodingAlgorithm(); - public final static LongEncodingAlgorithm longEncodingAlgorithm = new LongEncodingAlgorithm(); + public static final LongEncodingAlgorithm longEncodingAlgorithm = new LongEncodingAlgorithm(); - public final static FloatEncodingAlgorithm floatEncodingAlgorithm = new FloatEncodingAlgorithm(); + public static final FloatEncodingAlgorithm floatEncodingAlgorithm = new FloatEncodingAlgorithm(); - public final static DoubleEncodingAlgorithm doubleEncodingAlgorithm = new DoubleEncodingAlgorithm(); + public static final DoubleEncodingAlgorithm doubleEncodingAlgorithm = new DoubleEncodingAlgorithm(); - public final static UUIDEncodingAlgorithm uuidEncodingAlgorithm = new UUIDEncodingAlgorithm(); + public static final UUIDEncodingAlgorithm uuidEncodingAlgorithm = new UUIDEncodingAlgorithm(); static { table[EncodingAlgorithmIndexes.HEXADECIMAL] = hexadecimalEncodingAlgorithm; diff --git a/FIME/src/com/sun/xml/fime/algorithm/IEEE754FloatingPointEncodingAlgorithm.java b/FIME/src/com/sun/xml/fime/algorithm/IEEE754FloatingPointEncodingAlgorithm.java index 6702fb8..4a7084c 100644 --- a/FIME/src/com/sun/xml/fime/algorithm/IEEE754FloatingPointEncodingAlgorithm.java +++ b/FIME/src/com/sun/xml/fime/algorithm/IEEE754FloatingPointEncodingAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -11,10 +11,10 @@ package com.sun.xml.fime.algorithm; public abstract class IEEE754FloatingPointEncodingAlgorithm extends BuiltInEncodingAlgorithm { - public final static int FLOAT_SIZE = 4; - public final static int DOUBLE_SIZE = 8; + public static final int FLOAT_SIZE = 4; + public static final int DOUBLE_SIZE = 8; - public final static int FLOAT_MAX_CHARACTER_SIZE = 14; - public final static int DOUBLE_MAX_CHARACTER_SIZE = 24; + public static final int FLOAT_MAX_CHARACTER_SIZE = 14; + public static final int DOUBLE_MAX_CHARACTER_SIZE = 24; } diff --git a/FIME/src/com/sun/xml/fime/algorithm/IntegerEncodingAlgorithm.java b/FIME/src/com/sun/xml/fime/algorithm/IntegerEncodingAlgorithm.java index 8d56823..c58732a 100644 --- a/FIME/src/com/sun/xml/fime/algorithm/IntegerEncodingAlgorithm.java +++ b/FIME/src/com/sun/xml/fime/algorithm/IntegerEncodingAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -11,12 +11,12 @@ package com.sun.xml.fime.algorithm; public abstract class IntegerEncodingAlgorithm extends BuiltInEncodingAlgorithm { - public final static int SHORT_SIZE = 2; - public final static int INT_SIZE = 4; - public final static int LONG_SIZE = 8; + public static final int SHORT_SIZE = 2; + public static final int INT_SIZE = 4; + public static final int LONG_SIZE = 8; - public final static int SHORT_MAX_CHARACTER_SIZE = 6; - public final static int INT_MAX_CHARACTER_SIZE = 11; - public final static int LONG_MAX_CHARACTER_SIZE = 20; + public static final int SHORT_MAX_CHARACTER_SIZE = 6; + public static final int INT_MAX_CHARACTER_SIZE = 11; + public static final int LONG_MAX_CHARACTER_SIZE = 20; } diff --git a/FIME/src/com/sun/xml/fime/alphabet/BuiltInRestrictedAlphabets.java b/FIME/src/com/sun/xml/fime/alphabet/BuiltInRestrictedAlphabets.java index a34797e..be93205 100644 --- a/FIME/src/com/sun/xml/fime/alphabet/BuiltInRestrictedAlphabets.java +++ b/FIME/src/com/sun/xml/fime/alphabet/BuiltInRestrictedAlphabets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -15,7 +15,7 @@ public final class BuiltInRestrictedAlphabets { - public final static char[][] table = + public static final char[][] table = new char[EncodingConstants.RESTRICTED_ALPHABET_BUILTIN_END + 1][]; static { diff --git a/FIME/src/com/sun/xml/fime/vocab/SerializerVocabulary.java b/FIME/src/com/sun/xml/fime/vocab/SerializerVocabulary.java index 8131e05..e7aceea 100644 --- a/FIME/src/com/sun/xml/fime/vocab/SerializerVocabulary.java +++ b/FIME/src/com/sun/xml/fime/vocab/SerializerVocabulary.java @@ -19,8 +19,8 @@ public class SerializerVocabulary extends Vocabulary { - public final static int ATTRIBUTE_VALUE_SIZE_CONSTRAINT = 7; - public final static int CHARACTER_CONTENT_CHUNK_SIZE_CONSTRAINT = 7; + public static final int ATTRIBUTE_VALUE_SIZE_CONSTRAINT = 7; + public static final int CHARACTER_CONTENT_CHUNK_SIZE_CONSTRAINT = 7; public final StringIntMap restrictedAlphabet; public final StringIntMap encodingAlgorithm; diff --git a/FIME/src/org/xml/sax/helpers/NamespaceSupport.java b/FIME/src/org/xml/sax/helpers/NamespaceSupport.java index 8e86b87..5265a8b 100644 --- a/FIME/src/org/xml/sax/helpers/NamespaceSupport.java +++ b/FIME/src/org/xml/sax/helpers/NamespaceSupport.java @@ -86,7 +86,7 @@ public class NamespaceSupport *

This is the Namespace URI that is automatically mapped * to the "xml" prefix.

*/ - public final static String XMLNS = + public static final String XMLNS = "http://www.w3.org/XML/1998/namespace"; @@ -106,7 +106,7 @@ public class NamespaceSupport * @see #setNamespaceDeclUris * @see #isNamespaceDeclUris */ - public final static String NSDECL = + public static final String NSDECL = "http://www.w3.org/xmlns/2000/"; diff --git a/pom.xml b/pom.xml index 083b79d..135559d 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ true ${project.build.commonResourcesDirectory}/config/copyright.txt false - ${project.build.commonResourcesDirectory}/config/spotbugs-exclude.xml + ${project.build.commonResourcesDirectory}/config/spotbugs-exclude.xml false Low 4.7.3.6 diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/AllRoundTripTest.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/AllRoundTripTest.java index ac7e2ea..3f9b81e 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/AllRoundTripTest.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/AllRoundTripTest.java @@ -35,7 +35,10 @@ * @author Alexey Stashok */ public class AllRoundTripTest { - + + public AllRoundTripTest() { + } + private RoundTripRtt[] roundTripTests = new RoundTripRtt[] { new SAXRoundTripRtt(), new StAXRoundTripRtt(), new DOMRoundTripRtt(), new DOMSAXRoundTripRtt(), new SAXStAXDiffRtt()}; @@ -67,17 +70,15 @@ private void cleanupDiffs(File testSrcFile) { testSrcFile = testSrcFile.getParentFile(); } - FileUtils.removeFileRecursivelly(testSrcFile, new FileFilter() { - public boolean accept(File file) { - if (file.isDirectory()) { - return !file.getName().equals(".") && !file.getName().equals(".."); - } else if (file.isFile()) { - String filename = file.getName(); - return filename.endsWith(".finf") || filename.endsWith(".sax-event") || - filename.contains(".diff"); - } - return false; + FileUtils.removeFileRecursivelly(testSrcFile, file -> { + if (file.isDirectory()) { + return !file.getName().equals(".") && !file.getName().equals(".."); + } else if (file.isFile()) { + String filename = file.getName(); + return filename.endsWith(".finf") || filename.endsWith(".sax-event") || + filename.contains(".diff"); } + return false; }); } diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/FileUtils.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/FileUtils.java index 753b37d..5dacfea 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/FileUtils.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/FileUtils.java @@ -26,7 +26,7 @@ */ class FileUtils { - final public static void processFileOrDirectoryRecursivelly(File srcFile, FileFilter filter, FileProcessorHandler handler) { + public static final void processFileOrDirectoryRecursivelly(File srcFile, FileFilter filter, FileProcessorHandler handler) { if (srcFile.isFile()) { String filename = srcFile.getName(); int delim = filename.lastIndexOf('.'); @@ -39,22 +39,26 @@ final public static void processFileOrDirectoryRecursivelly(File srcFile, FileFi } else if (srcFile.isDirectory()) { File[] files = srcFile.listFiles(filter); - for(int i=0; i { + if (file.isDirectory()) { + return !file.getName().equals(".") && !file.getName().equals(".."); + } else if (file.isFile()) { + return file.getName().endsWith(".xml"); + } + return false; + }, file -> processRtt(file)); } public static void main(String[] args) throws Exception { diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMRoundTripRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMRoundTripRtt.java index fb44ee2..b0667e4 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMRoundTripRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMRoundTripRtt.java @@ -26,7 +26,11 @@ * @author Alexey Stashok */ public class DOMRoundTripRtt extends RoundTripRtt { - + + public DOMRoundTripRtt() { + } + + @Override public boolean process(File testFile) throws Exception { String absolutePath = testFile.getAbsolutePath(); @@ -42,6 +46,7 @@ public boolean process(File testFile) throws Exception { return diffText(saxOutputFileName, fiSaxOutputFileName, diffOutputFileName); } + @Override public String getName() { return "domroundtrip"; } diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMSAXRoundTripRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMSAXRoundTripRtt.java index 4fe17e7..83c890b 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMSAXRoundTripRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/DOMSAXRoundTripRtt.java @@ -26,7 +26,11 @@ * @author Alexey Stashok */ public class DOMSAXRoundTripRtt extends RoundTripRtt { - + + public DOMSAXRoundTripRtt() { + } + + @Override public boolean process(File file) throws Exception { String absolutePath = file.getAbsolutePath(); @@ -42,6 +46,7 @@ public boolean process(File file) throws Exception { return diffText(domSaxOutputFileName, fiDomSaxOutputFileName, diffOutputFileName); } + @Override public String getName() { return "domsaxroundtrip"; } diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/RoundTripRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/RoundTripRtt.java index 26f9bd8..8151160 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/RoundTripRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/RoundTripRtt.java @@ -36,7 +36,10 @@ * @author Alexey Stashok */ public abstract class RoundTripRtt { - + + protected RoundTripRtt() { + } + public abstract boolean process(File testFile) throws Exception; public abstract String getName(); diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXRoundTripRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXRoundTripRtt.java index 70a5e9d..7bc4f49 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXRoundTripRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXRoundTripRtt.java @@ -26,7 +26,11 @@ * @author Alexey Stashok */ public class SAXRoundTripRtt extends RoundTripRtt { - + + public SAXRoundTripRtt() { + } + + @Override public boolean process(File file) throws Exception { String absolutePath = file.getAbsolutePath(); @@ -42,6 +46,7 @@ public boolean process(File file) throws Exception { return diffText(SaxOutputFileName, fiSaxOutputFileName, diffOutputFileName); } + @Override public String getName() { return "saxroundtrip"; } diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXStAXDiffRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXStAXDiffRtt.java index bb57eec..3779575 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXStAXDiffRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/SAXStAXDiffRtt.java @@ -26,7 +26,11 @@ * @author Alexey Stashok */ public class SAXStAXDiffRtt extends RoundTripRtt { - + + public SAXStAXDiffRtt() { + } + + @Override public boolean process(File file) throws Exception { String absolutePath = file.getAbsolutePath(); @@ -40,6 +44,7 @@ public boolean process(File file) throws Exception { return diffBinary(fiStaxOutputFileName, fiSaxOutputFileName, diffOutputFileName); } + @Override public String getName() { return "saxstaxdiff"; } diff --git a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/StAXRoundTripRtt.java b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/StAXRoundTripRtt.java index b6e8701..5fc5fd6 100644 --- a/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/StAXRoundTripRtt.java +++ b/roundtrip-tests/src/main/java/com/sun/xml/fastinfoset/roundtriptests/rtt/StAXRoundTripRtt.java @@ -27,7 +27,11 @@ * @author Alexey Stashok */ public class StAXRoundTripRtt extends RoundTripRtt { - + + public StAXRoundTripRtt() { + } + + @Override public boolean process(File file) throws Exception { String absolutePath = file.getAbsolutePath(); @@ -43,6 +47,7 @@ public boolean process(File file) throws Exception { return diffText(saxOutputFileName, fiStaxOutputFileName, diffOutputFileName); } + @Override public String getName() { return "staxroundtrip"; } diff --git a/samples/src/main/java/samples/common/Util.java b/samples/src/main/java/samples/common/Util.java index c8e64c1..9af74b5 100644 --- a/samples/src/main/java/samples/common/Util.java +++ b/samples/src/main/java/samples/common/Util.java @@ -36,7 +36,7 @@ public Util() { * @param eventType event type * @return String */ - public final static String getEventTypeString(int eventType) { + public static final String getEventTypeString(int eventType) { switch (eventType){ case XMLStreamConstants.START_ELEMENT: return "START_ELEMENT"; diff --git a/samples/src/main/java/samples/typed/ConvertLexicalValues.java b/samples/src/main/java/samples/typed/ConvertLexicalValues.java index 621dd32..f33e3b7 100644 --- a/samples/src/main/java/samples/typed/ConvertLexicalValues.java +++ b/samples/src/main/java/samples/typed/ConvertLexicalValues.java @@ -104,8 +104,9 @@ private void replaceAttributeValue(Set attributeTypes, } - public void startElement(String uri, String localName, String qName, - Attributes atts) throws SAXException { + @Override + public void startElement(String uri, String localName, String qName, + Attributes atts) throws SAXException { // Obtain the XS types associated with the local name of this // element _textContent = _elements.get(localName); @@ -132,6 +133,7 @@ public void startElement(String uri, String localName, String qName, super.startElement(uri, localName, qName, atts); } + @Override public void characters (char ch[], int start, int length) throws SAXException { if (_textContent == null) { @@ -238,12 +240,14 @@ public static void main(String[] args) throws Exception { */ SAXDocumentParser p = new SAXDocumentParser(); FastInfosetDefaultHandler h = new FastInfosetDefaultHandler() { - public void bytes(byte[] b, int start, int length) + @Override + public void bytes(byte[] b, int start, int length) throws SAXException { System.out.println("Byte: " + b[start]); } - public void floats(float[] f, int start, int length) + @Override + public void floats(float[] f, int start, int length) throws SAXException { System.out.println("Float: " + f[start]); } diff --git a/samples/src/main/java/samples/typed/PrimitiveTypesWithElementContentSample.java b/samples/src/main/java/samples/typed/PrimitiveTypesWithElementContentSample.java index 9930002..067e9c0 100644 --- a/samples/src/main/java/samples/typed/PrimitiveTypesWithElementContentSample.java +++ b/samples/src/main/java/samples/typed/PrimitiveTypesWithElementContentSample.java @@ -104,86 +104,7 @@ void parseFIDocumentUsingPTC(InputStream in) throws Exception { FastInfosetReader r = new SAXDocumentParser(); // Create a default FI handler that will receive events for primitive types - FastInfosetDefaultHandler h = new FastInfosetDefaultHandler() { - - public void startElement (String uri, String localName, String qName, - Attributes attributes) throws SAXException { - // Check if the attributes implements the EncodingAlgorithmAttributes interface - if (attributes instanceof EncodingAlgorithmAttributes) { - EncodingAlgorithmAttributes a = (EncodingAlgorithmAttributes)attributes; - - // Iterate through the attributes - for (int index = 0; index < a.getLength(); index++) { - // Get the algorithm data - Object data = a.getAlgorithmData(index); - // If there is binary data then the returned valus will not be null - if (data != null) { - // Switch on the algorithm used - switch (a.getAlgorithmIndex(index)) { - case EncodingAlgorithmIndexes.BASE64: - System.out.print("Attribute value as bytes: "); - byte[] bs = (byte[])data; - for (int i = 0; i < bs.length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(bs[i]); - } - System.out.println(); - break; - case EncodingAlgorithmIndexes.INT: - System.out.print("Attribute value as ints: "); - int[] is = (int[])data; - for (int i = 0; i < is.length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(is[i]); - } - System.out.println(); - break; - case EncodingAlgorithmIndexes.FLOAT: - System.out.print("Attribute value as floats: "); - float[] fs = (float[])data; - for (int i = 0; i < fs.length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(fs[i]); - } - System.out.println(); - break; - default: - } - } - } - } - } - - // Recieve events for an array of byte[] - public void bytes(byte[] bs, int start, int length) throws SAXException { - System.out.print("element content as bytes: "); - for (int i = 0; i < length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(bs[start + i]); - } - System.out.println(); - } - - // Recieve events for an array of int[] - public void ints(int[] is, int start, int length) throws SAXException { - System.out.print("element content as ints: "); - for (int i = 0; i < length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(is[start + i]); - } - System.out.println(); - } - - // Recieve events for an array of float[] - public void floats(float[] fs, int start, int length) throws SAXException { - System.out.print("element content as floats: "); - for (int i = 0; i < length; i++) { - if (i > 0) System.out.print(" "); - System.out.print(fs[start + i]); - } - System.out.println(); - } - }; + FastInfosetDefaultHandler h = new FastInfosetHandler(); // Set the handlers r.setContentHandler(h); @@ -207,19 +128,7 @@ void parseFIDocument(InputStream in) throws Exception { FastInfosetReader r = new SAXDocumentParser(); // Create a handler that will receive standard SAX events - ContentHandler h = new DefaultHandler() { - public void startElement (String uri, String localName, String qName, - Attributes attributes) throws SAXException { - for (int index = 0; index < attributes.getLength(); index++) { - System.out.println("attribute value as text: " + attributes.getValue(index)); - } - } - - public void characters (char ch[], int start, int length) throws SAXException { - String s = new String(ch, start, length); - System.out.println("element content as text: " + s); - } - }; + ContentHandler h = new CHandler(); r.setContentHandler(h); @@ -238,4 +147,105 @@ public static void main(String[] args) throws Exception { // Parse the document using a ContentHandler pt.parseFIDocument(new ByteArrayInputStream(b)); } + + private static class CHandler extends DefaultHandler { + @Override + public void startElement (String uri, String localName, String qName, + Attributes attributes) throws SAXException { + for (int index = 0; index < attributes.getLength(); index++) { + System.out.println("attribute value as text: " + attributes.getValue(index)); + } + } + + @Override + public void characters (char ch[], int start, int length) throws SAXException { + String s = new String(ch, start, length); + System.out.println("element content as text: " + s); + } + } + + private static class FastInfosetHandler extends FastInfosetDefaultHandler { + + @Override + public void startElement (String uri, String localName, String qName, + Attributes attributes) throws SAXException { + // Check if the attributes implements the EncodingAlgorithmAttributes interface + if (attributes instanceof EncodingAlgorithmAttributes) { + EncodingAlgorithmAttributes a = (EncodingAlgorithmAttributes)attributes; + + // Iterate through the attributes + for (int index = 0; index < a.getLength(); index++) { + // Get the algorithm data + Object data = a.getAlgorithmData(index); + // If there is binary data then the returned valus will not be null + if (data != null) { + // Switch on the algorithm used + switch (a.getAlgorithmIndex(index)) { + case EncodingAlgorithmIndexes.BASE64: + System.out.print("Attribute value as bytes: "); + byte[] bs = (byte[])data; + for (int i = 0; i < bs.length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(bs[i]); + } + System.out.println(); + break; + case EncodingAlgorithmIndexes.INT: + System.out.print("Attribute value as ints: "); + int[] is = (int[])data; + for (int i = 0; i < is.length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(is[i]); + } + System.out.println(); + break; + case EncodingAlgorithmIndexes.FLOAT: + System.out.print("Attribute value as floats: "); + float[] fs = (float[])data; + for (int i = 0; i < fs.length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(fs[i]); + } + System.out.println(); + break; + default: + } + } + } + } + } + + // Recieve events for an array of byte[] + @Override + public void bytes(byte[] bs, int start, int length) throws SAXException { + System.out.print("element content as bytes: "); + for (int i = 0; i < length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(bs[start + i]); + } + System.out.println(); + } + + // Recieve events for an array of int[] + @Override + public void ints(int[] is, int start, int length) throws SAXException { + System.out.print("element content as ints: "); + for (int i = 0; i < length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(is[start + i]); + } + System.out.println(); + } + + // Recieve events for an array of float[] + @Override + public void floats(float[] fs, int start, int length) throws SAXException { + System.out.print("element content as floats: "); + for (int i = 0; i < length; i++) { + if (i > 0) System.out.print(" "); + System.out.print(fs[start + i]); + } + System.out.println(); + } + } } diff --git a/src/main/resources/spotbugs-exclude.xml b/src/main/resources/spotbugs-exclude.xml index 1c9549b..7e14340 100644 --- a/src/main/resources/spotbugs-exclude.xml +++ b/src/main/resources/spotbugs-exclude.xml @@ -36,6 +36,7 @@ + @@ -92,6 +93,11 @@ + + + + + diff --git a/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencyHandler.java b/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencyHandler.java index a5d46a1..20c1537 100644 --- a/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencyHandler.java +++ b/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencyHandler.java @@ -184,7 +184,8 @@ public void generateQNamesWithPrefix() { public Map getNamespaceURIToPrefixMap() { return namespaceURIToPrefix; } - + + @SuppressWarnings({"unchecked", "rawtypes"}) private void addAll(Set to, Set from) { to.addAll(from); } @@ -205,11 +206,13 @@ private void bucketQNamesToNamespace(Set s, Map> m) { // subs.add(q); // } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { prefixes.add(prefix); namespaces.add(uri); } + @Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { QName q = createQName(uri, localName, qName); addQName(q, namespacesToElements, elements); diff --git a/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencySet.java b/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencySet.java index e422375..6531891 100644 --- a/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencySet.java +++ b/utilities/src/main/java/com/sun/xml/analysis/frequency/FrequencySet.java @@ -35,6 +35,15 @@ */ public class FrequencySet extends HashMap { + private static final long serialVersionUID = 3211015452350934703L; + + public FrequencySet(int initialCapacity) { + super(initialCapacity); + } + + public FrequencySet() { + } + /** * Add a value to the set. * @@ -60,6 +69,7 @@ private void _add(T value, int v) { } private class FrequencyComparator implements Comparator> { + @Override public int compare(Map.Entry e1, Map.Entry e2) { int diff = e2.getValue() - e1.getValue(); if (diff == 0) { @@ -72,8 +82,8 @@ public int compare(Map.Entry e1, Map.Entry e2) { return diff; } } - }; - + } + /** * Create an ordered list of values in the order of decreasing frequency * of occurence. diff --git a/utilities/src/main/java/com/sun/xml/analysis/frequency/SchemaProcessor.java b/utilities/src/main/java/com/sun/xml/analysis/frequency/SchemaProcessor.java index 3c3d336..a44ab79 100644 --- a/utilities/src/main/java/com/sun/xml/analysis/frequency/SchemaProcessor.java +++ b/utilities/src/main/java/com/sun/xml/analysis/frequency/SchemaProcessor.java @@ -76,13 +76,20 @@ public class SchemaProcessor { private static class StringComparator implements Comparator, Serializable { + private static final long serialVersionUID = -864252731405592755L; + + @Override public int compare(String s1, String s2) { return s1.compareTo(s2); } - }; + } + private StringComparator _stringComparator = new StringComparator(); private static class QNameComparator implements Comparator, Serializable { + private static final long serialVersionUID = -2811548628684885213L; + + @Override public int compare(QName q1, QName q2) { if (q1.getNamespaceURI() == null && q2.getNamespaceURI() == null) { @@ -97,7 +104,8 @@ public int compare(QName q1, QName q2) { return q1.getLocalPart().compareTo(q2.getLocalPart()); } } - }; + } + private QNameComparator _qNameComparator = new QNameComparator(); /** @@ -198,9 +206,11 @@ public SchemaProcessor(List schema, boolean collectValues, private class InternalSchemaProcessor implements XSVisitor, XSSimpleTypeVisitor { + @Override public void annotation(XSAnnotation xSAnnotation) { } + @Override public void attGroupDecl(XSAttGroupDecl decl) { Iterator itr = decl.iterateAttGroups(); while (itr.hasNext()) { @@ -213,6 +223,7 @@ public void attGroupDecl(XSAttGroupDecl decl) { } } + @Override public void attributeDecl(XSAttributeDecl xSAttributeDecl) { if (xSAttributeDecl.getDefaultValue() != null) { addAttributeValue(xSAttributeDecl.getDefaultValue().value); @@ -227,12 +238,14 @@ public void attributeDecl(XSAttributeDecl xSAttributeDecl) { } } + @Override public void attributeUse(XSAttributeUse use) { XSAttributeDecl decl = use.getDecl(); attributeDecl(decl); } + @Override public void complexType(XSComplexType type) { if (type.getContentType().asSimpleType() != null) { @@ -274,6 +287,7 @@ public void complexType(XSComplexType type) { } } + @Override public void schema(XSSchema s) { for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) { attGroupDecl(groupDecl); @@ -300,6 +314,7 @@ public void schema(XSSchema s) { } } + @Override public void facet(XSFacet facet) { /* * TODO @@ -313,22 +328,28 @@ public void facet(XSFacet facet) { } } + @Override public void notation(XSNotation xSNotation) { } + @Override public void identityConstraint(XSIdentityConstraint xSIdentityConstraint) { } + @Override public void xpath(XSXPath xSXPath) { } + @Override public void wildcard(XSWildcard xSWildcard) { } + @Override public void modelGroupDecl(XSModelGroupDecl decl) { modelGroup(decl.getModelGroup()); } + @Override public void modelGroup(XSModelGroup group) { final int len = group.getSize(); for (int i = 0; i < len; i++) { @@ -336,6 +357,7 @@ public void modelGroup(XSModelGroup group) { } } + @Override public void elementDecl(XSElementDecl type) { if (type.getDefaultValue() != null) { addTextContentValue(type.getDefaultValue().value); @@ -351,20 +373,25 @@ public void elementDecl(XSElementDecl type) { addElement(type); } + @Override public void particle(XSParticle part) { part.getTerm().visit(this); } + @Override public void empty(XSContentType xSContentType) { } + @Override public void simpleType(XSSimpleType type) { type.visit((XSSimpleTypeVisitor)this); } + @Override public void listSimpleType(XSListSimpleType xSListSimpleType) { } + @Override public void unionSimpleType(XSUnionSimpleType type) { final int len = type.getMemberSize(); for (int i = 0; i < len; i++) { @@ -375,6 +402,7 @@ public void unionSimpleType(XSUnionSimpleType type) { } } + @Override public void restrictionSimpleType(XSRestrictionSimpleType type) { XSSimpleType baseType = type.getSimpleBaseType(); if (baseType == null) { @@ -393,16 +421,19 @@ public void restrictionSimpleType(XSRestrictionSimpleType type) { } private static class ErrorHandlerImpl implements ErrorHandler { + @Override public void warning(SAXParseException e) throws SAXException { System.out.println("WARNING"); e.printStackTrace(); } + @Override public void error(SAXParseException e) throws SAXException { System.out.println("ERROR"); e.printStackTrace(); } + @Override public void fatalError(SAXParseException e) throws SAXException { System.out.println("FATAL ERROR"); e.printStackTrace(); diff --git a/utilities/src/main/java/com/sun/xml/analysis/frequency/tools/PrintFrequency.java b/utilities/src/main/java/com/sun/xml/analysis/frequency/tools/PrintFrequency.java index 7ccea07..87bb5a2 100644 --- a/utilities/src/main/java/com/sun/xml/analysis/frequency/tools/PrintFrequency.java +++ b/utilities/src/main/java/com/sun/xml/analysis/frequency/tools/PrintFrequency.java @@ -32,7 +32,10 @@ * @author Paul.Sandoz@Sun.Com */ public class PrintFrequency { - + + private PrintFrequency() { + } + /** * @param args the command line arguments. arg[0] is the path to a schema, * args[1] to args[n] are the paths to XML documents. @@ -50,7 +53,8 @@ public static void main(String[] args) throws Exception { p.parse(new File(args[i]), fh); } fh.generateQNamesWithPrefix(); - + + @SuppressWarnings({"deprecation"}) FrequencyBasedLists l = fh.getLists(); System.out.println("Prefixes"); for (String s : l.prefixes) { diff --git a/utilities/src/main/java/com/sun/xml/analysis/types/SchemaProcessor.java b/utilities/src/main/java/com/sun/xml/analysis/types/SchemaProcessor.java index cfad5e0..7b33de8 100644 --- a/utilities/src/main/java/com/sun/xml/analysis/types/SchemaProcessor.java +++ b/utilities/src/main/java/com/sun/xml/analysis/types/SchemaProcessor.java @@ -78,9 +78,11 @@ public class SchemaProcessor { private class InternalSchemaProcessor implements XSVisitor, XSSimpleTypeVisitor { + @Override public void annotation(XSAnnotation xSAnnotation) { } + @Override public void attGroupDecl(XSAttGroupDecl decl) { for (XSAttGroupDecl groupDecl : decl.getAttGroups()) { groupDecl.visit(this); @@ -91,6 +93,7 @@ public void attGroupDecl(XSAttGroupDecl decl) { } } + @Override public void attributeDecl(XSAttributeDecl xSAttributeDecl) { _attribute = qname(xSAttributeDecl); _element = null; @@ -99,11 +102,13 @@ public void attributeDecl(XSAttributeDecl xSAttributeDecl) { s.visit((XSSimpleTypeVisitor)this); } + @Override public void attributeUse(XSAttributeUse use) { XSAttributeDecl decl = use.getDecl(); decl.visit(this); } + @Override public void complexType(XSComplexType type) { if (type.getContentType().asSimpleType() != null) { @@ -148,6 +153,7 @@ public void complexType(XSComplexType type) { } } + @Override public void schema(XSSchema s) { for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) { attGroupDecl(groupDecl); @@ -170,25 +176,32 @@ public void schema(XSSchema s) { } } + @Override public void facet(XSFacet facet) { } + @Override public void notation(XSNotation xSNotation) { } + @Override public void identityConstraint(XSIdentityConstraint xSIdentityConstraint) { } + @Override public void xpath(XSXPath xSXPath) { } + @Override public void wildcard(XSWildcard xSWildcard) { } + @Override public void modelGroupDecl(XSModelGroupDecl decl) { modelGroup(decl.getModelGroup()); } + @Override public void modelGroup(XSModelGroup group) { final int len = group.getSize(); for (int i = 0; i < len; i++) { @@ -198,6 +211,7 @@ public void modelGroup(XSModelGroup group) { private Set seen = new HashSet<>(); + @Override public void elementDecl(XSElementDecl type) { if (seen.contains(type)) return; seen.add(type); @@ -206,19 +220,23 @@ public void elementDecl(XSElementDecl type) { type.getType().visit(this); } + @Override public void particle(XSParticle part) { part.getTerm().visit(this); } + @Override public void empty(XSContentType xSContentType) { } + @Override public void simpleType(XSSimpleType type) { type.visit((XSSimpleTypeVisitor)this); } + @Override public void listSimpleType(XSListSimpleType xSListSimpleType) { if (_isListSimpleType) return; @@ -226,9 +244,11 @@ public void listSimpleType(XSListSimpleType xSListSimpleType) { simpleType(xSListSimpleType.getItemType()); } + @Override public void unionSimpleType(XSUnionSimpleType type) { } + @Override public void restrictionSimpleType(XSRestrictionSimpleType type) { if (type.getTargetNamespace().equals("http://www.w3.org/2001/XMLSchema")) { if (_element != null) { @@ -249,16 +269,19 @@ public void restrictionSimpleType(XSRestrictionSimpleType type) { } private static class ErrorHandlerImpl implements ErrorHandler { + @Override public void warning(SAXParseException e) throws SAXException { System.out.println("WARNING"); e.printStackTrace(); } + @Override public void error(SAXParseException e) throws SAXException { System.out.println("ERROR"); e.printStackTrace(); } + @Override public void fatalError(SAXParseException e) throws SAXException { System.out.println("FATAL ERROR"); e.printStackTrace(); diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetReaderSAXBufferCreator.java b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetReaderSAXBufferCreator.java index 4c23d0c..058935b 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetReaderSAXBufferCreator.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetReaderSAXBufferCreator.java @@ -83,18 +83,22 @@ public void reset() { } + @Override public void startDocument() throws SAXException { storeStructure(T_DOCUMENT); } + @Override public void endDocument() throws SAXException { storeStructure(T_END); } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { cacheNamespaceAttribute(prefix, uri); } + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { storeQualifiedName(T_ELEMENT_LN, uri, localName, qName); @@ -110,33 +114,40 @@ public void startElement(String uri, String localName, String qName, Attributes } } + @Override public void endElement(String uri, String localName, String qName) throws SAXException { storeStructure(T_END); } + @Override public void characters(char ch[], int start, int length) throws SAXException { storeContentCharacters(T_TEXT_AS_CHAR_ARRAY, ch, 0, length); } + @Override public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { characters(ch, start, length); } + @Override public void processingInstruction(String target, String data) throws SAXException { storeStructure(T_PROCESSING_INSTRUCTION); storeStructureString(target); storeStructureString(data); } + @Override public void comment(char[] ch, int start, int length) throws SAXException { storeContentCharacters(T_COMMENT_AS_CHAR_ARRAY, ch, start, length); } // + @Override public void octets(String URI, int algorithm, byte[] b, int start, int length) throws SAXException { } + @Override public void object(String URI, int algorithm, Object o) throws SAXException { storeStructure(T_TEXT_AS_OBJECT); storeContentObject(algorithm, o); @@ -221,6 +232,7 @@ private void storeQualifiedName(int item, String uri, String localName, String q // Entity resolver handler + @Override public InputSource resolveEntity (String publicId, String systemId) throws IOException, SAXException { return null; @@ -228,41 +240,55 @@ public InputSource resolveEntity (String publicId, String systemId) // DTD handler + @Override public void notationDecl (String name, String publicId, String systemId) throws SAXException { } + @Override public void unparsedEntityDecl (String name, String publicId, - String systemId, String notationName) + String systemId, String notationName) throws SAXException { } // Content handler + @Override public void setDocumentLocator (Locator locator) { } + @Override public void endPrefixMapping (String prefix) throws SAXException { } + @Override public void skippedEntity (String name) throws SAXException { } // Lexical handler + @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { } + @Override public void endDTD() throws SAXException { } + @Override public void startEntity(String name) throws SAXException { } + @Override public void endEntity(String name) throws SAXException { } + @Override public void startCDATA() throws SAXException { } + @Override public void endCDATA() throws SAXException { } // Error handler + @Override public void warning(SAXParseException e) throws SAXException { } + @Override public void error(SAXParseException e) throws SAXException { } + @Override public void fatalError(SAXParseException e) throws SAXException { throw e; } diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetWriterSAXBufferProcessor.java b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetWriterSAXBufferProcessor.java index 6a701f6..a43ccc8 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetWriterSAXBufferProcessor.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/FastInfosetWriterSAXBufferProcessor.java @@ -66,7 +66,7 @@ public final void process(XMLStreamBuffer buffer, FastInfosetWriter writer) thro } public void setXMLStreamBuffer(XMLStreamBuffer buffer) { - setBuffer(buffer); + setBuffer(buffer, buffer.isFragment()); } public final void process(FastInfosetWriter writer) throws SAXException { diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/TypedSAXBufferCreator.java b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/TypedSAXBufferCreator.java index d5c8d51..c79ae6b 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/TypedSAXBufferCreator.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/TypedSAXBufferCreator.java @@ -107,7 +107,8 @@ public TypedSAXBufferCreator(Map> elements, _elements = elements; _attributes = attributes; } - + + @SuppressWarnings({"this-escape"}) public TypedSAXBufferCreator(Map> elements, Map> attributes, MutableXMLStreamBuffer buffer) { @@ -151,20 +152,24 @@ public void reset() { } + @Override public void startDocument() throws SAXException { storeStructure(T_DOCUMENT); } + @Override public void endDocument() throws SAXException { storeStructure(T_END); } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { storeTextContent(); cacheNamespaceAttribute(prefix, uri); } + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { storeTextContent(); @@ -186,21 +191,25 @@ public void startElement(String uri, String localName, String qName, Attributes } } + @Override public void endElement(String uri, String localName, String qName) throws SAXException { storeTextContent(); storeStructure(T_END); } + @Override public void characters(char ch[], int start, int length) throws SAXException { _storeTextContent = true; _textContent.append(ch, start, length); } + @Override public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { characters(ch, start, length); } + @Override public void processingInstruction(String target, String data) throws SAXException { storeTextContent(); @@ -209,6 +218,7 @@ public void processingInstruction(String target, String data) throws SAXExceptio storeStructureString(data); } + @Override public void comment(char[] ch, int start, int length) throws SAXException { storeTextContent(); @@ -320,6 +330,7 @@ private void storeQualifiedName(int item, String uri, String localName, String q // Entity resolver handler + @Override public InputSource resolveEntity (String publicId, String systemId) throws IOException, SAXException { return null; @@ -327,41 +338,55 @@ public InputSource resolveEntity (String publicId, String systemId) // DTD handler + @Override public void notationDecl (String name, String publicId, String systemId) throws SAXException { } + @Override public void unparsedEntityDecl (String name, String publicId, - String systemId, String notationName) + String systemId, String notationName) throws SAXException { } // Content handler + @Override public void setDocumentLocator (Locator locator) { } + @Override public void endPrefixMapping (String prefix) throws SAXException { } + @Override public void skippedEntity (String name) throws SAXException { } // Lexical handler + @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { } + @Override public void endDTD() throws SAXException { } + @Override public void startEntity(String name) throws SAXException { } + @Override public void endEntity(String name) throws SAXException { } + @Override public void startCDATA() throws SAXException { } + @Override public void endCDATA() throws SAXException { } // Error handler + @Override public void warning(SAXParseException e) throws SAXException { } + @Override public void error(SAXParseException e) throws SAXException { } + @Override public void fatalError(SAXParseException e) throws SAXException { throw e; } diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/tools/RoundTrip.java b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/tools/RoundTrip.java index 2479ac0..9d7a67c 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/tools/RoundTrip.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/streambuffer/tools/RoundTrip.java @@ -39,7 +39,10 @@ * @author Paul.Sandoz@Sun.Com */ public class RoundTrip { - + + private RoundTrip() { + } + public static void main(String[] args) throws Exception { SchemaProcessor sp = new SchemaProcessor(new File(args[0]).toURI().toURL()); sp.process(); diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/types/LexicalSpaceConvertor.java b/utilities/src/main/java/com/sun/xml/fastinfoset/types/LexicalSpaceConvertor.java index e246e9d..8028e84 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/types/LexicalSpaceConvertor.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/types/LexicalSpaceConvertor.java @@ -27,12 +27,15 @@ */ public class LexicalSpaceConvertor { - public static enum LexicalPreference { + public enum LexicalPreference { string, charArray - }; - + } + + private LexicalSpaceConvertor() { + } + public static Object convertToValueSpace(Set types, String s, - LexicalPreference preference) { + LexicalPreference preference) { return convertToValueSpace(types, s.toCharArray(), 0, s.length(), preference); } diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/types/ValueInstance.java b/utilities/src/main/java/com/sun/xml/fastinfoset/types/ValueInstance.java index 9ded72d..bbb1325 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/types/ValueInstance.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/types/ValueInstance.java @@ -23,11 +23,11 @@ * @author Paul.Sandoz@Sun.Com */ public final class ValueInstance { - public static enum Type { + public enum Type { encodingAlgorithm, alphabet, indexedString - }; + } public Type type; public int id; diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/utilities/tools/XML_SAX_TYPED_FI.java b/utilities/src/main/java/com/sun/xml/fastinfoset/utilities/tools/XML_SAX_TYPED_FI.java index 151fa70..bac85e6 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/utilities/tools/XML_SAX_TYPED_FI.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/utilities/tools/XML_SAX_TYPED_FI.java @@ -43,7 +43,10 @@ * Encoding Algorithms and Restricted Alphabets. */ public class XML_SAX_TYPED_FI { - + + public XML_SAX_TYPED_FI() { + } + public void parse(String[] args) throws Exception { String schemaLocation = null; InputStream in = null; diff --git a/utilities/src/main/java/com/sun/xml/fastinfoset/vocab/frequency/VocabularyGenerator.java b/utilities/src/main/java/com/sun/xml/fastinfoset/vocab/frequency/VocabularyGenerator.java index 78eeb89..2bba9be 100644 --- a/utilities/src/main/java/com/sun/xml/fastinfoset/vocab/frequency/VocabularyGenerator.java +++ b/utilities/src/main/java/com/sun/xml/fastinfoset/vocab/frequency/VocabularyGenerator.java @@ -51,10 +51,10 @@ public class VocabularyGenerator { /** * Constants for the various XML-based APIs */ - public static enum XmlApi { - SAX, StAX, DOM; - }; - + public enum XmlApi { + SAX, StAX, DOM + } + private XmlApi _xapi; private SerializerVocabulary _serializerVocabulary;