Project

Profile

Help

Revision 0e9668c2

Added by Michael Kay about 1 year ago

Fix Javadoc omissions and other Java code hygiene warnings

View differences:

latest10/hej/net/sf/saxon/expr/LetExpression.java
412 412
     * and we assume that a sequence has length 5. The resulting estimates may be used, for
413 413
     * example, to reorder the predicates in a filter expression so cheaper predicates are
414 414
     * evaluated first.
415
     * @return
415
     * @return a rough estimate of the evaluation cost
416 416
     */
417 417
    @Override
418 418
    public double getCost() {
latest10/hej/net/sf/saxon/expr/LookupAllExpression.java
150 150
     * and we assume that a sequence has length 5. The resulting estimates may be used, for
151 151
     * example, to reorder the predicates in a filter expression so cheaper predicates are
152 152
     * evaluated first.
153
     * @return
153
     * @return a rough estimate of the cost of evaluation
154 154
     */
155 155
    @Override
156 156
    public double getCost() {
......
221 221

  
222 222
        return new SequenceIterator() {
223 223

  
224
            SequenceIterator level0 = getBaseExpression().iterate(context);
224
            final SequenceIterator level0 = getBaseExpression().iterate(context);
225 225
            Iterator<?> level1 = null;
226 226
                // delivers GroundedValue in the case of an array, or KeyValuePair in the case of a map
227 227
            SequenceIterator level2 = null;
......
254 254
                            } else {
255 255
                                throw new IllegalStateException();
256 256
                            }
257
                            return next();
258 257
                        } else {
259 258
                            level1 = null;
260
                            return next();
261 259
                        }
260
                        return next();
262 261
                    }
263 262
                } else {
264 263
                    Item next = level2.next();
latest10/hej/net/sf/saxon/expr/LookupExpression.java
194 194
     * and we assume that a sequence has length 5. The resulting estimates may be used, for
195 195
     * example, to reorder the predicates in a filter expression so cheaper predicates are
196 196
     * evaluated first.
197
     * @return
197
     * @return a rough estimate of the cost of evaluation
198 198
     */
199 199
    @Override
200 200
    public double getCost() {
latest10/hej/net/sf/saxon/option/axiom/AxiomObjectModel.java
20 20
import net.sf.saxon.om.Sequence;
21 21
import net.sf.saxon.om.TreeModel;
22 22
import net.sf.saxon.pattern.AnyNodeTest;
23
import net.sf.saxon.trans.XPathException;
24 23
import net.sf.saxon.tree.wrapper.VirtualNode;
25 24
import net.sf.saxon.type.ItemType;
26 25
import org.apache.axiom.om.*;
......
37 36

  
38 37
public class AxiomObjectModel extends TreeModel implements ExternalObjectModel {
39 38

  
40
    private static AxiomObjectModel THE_INSTANCE = new AxiomObjectModel();
39
    private final static AxiomObjectModel THE_INSTANCE = new AxiomObjectModel();
41 40

  
42 41
    public static AxiomObjectModel getInstance() {
43 42
        return THE_INSTANCE;
......
112 111
    public JPConverter getJPConverter(Class sourceClass, Configuration config) {
113 112
        if (isRecognizedNodeClass(sourceClass)) {
114 113
            return new JPConverter() {
115
                public Sequence convert(Object object, XPathContext context) throws XPathException {
114
                public Sequence convert(Object object, XPathContext context) {
116 115
                    return convertObjectToXPathValue(object, context.getConfiguration());
117 116
                }
118 117

  
......
161 160
     * Test whether this object model recognizes a particular kind of JAXP Result object,
162 161
     * and if it does, return a Receiver that builds an instance of this data model from
163 162
     * a sequence of events. If the Result is not recognised, return null.
164
     * @return
163
     * @return always null
165 164
     */
166 165

  
167 166
    public Receiver getDocumentBuilder(Result result) {
latest10/hej/net/sf/saxon/option/dom4j/DOM4JObjectModel.java
34 34

  
35 35
public class DOM4JObjectModel extends TreeModel implements ExternalObjectModel {
36 36

  
37
    private static DOM4JObjectModel THE_INSTANCE = new DOM4JObjectModel();
37
    private final static DOM4JObjectModel THE_INSTANCE = new DOM4JObjectModel();
38 38

  
39 39
    /**
40 40
     * Get a singular instance of this class
......
82 82
    public PJConverter getPJConverter(Class<?> targetClass) {
83 83
        if (isRecognizedNodeClass(targetClass)) {
84 84
            return new PJConverter() {
85
                public Object convert(Sequence value, Class<?> targetClass, XPathContext context) throws XPathException {
85
                public Object convert(Sequence value, Class<?> targetClass, XPathContext context) {
86 86
                    return convertXPathValueToObject(value, targetClass);
87 87
                }
88 88
            };
......
162 162
     * Test whether this object model recognizes a particular kind of JAXP Result object,
163 163
     * and if it does, return a Receiver that builds an instance of this data model from
164 164
     * a sequence of events. If the Result is not recognised, return null.
165
     * @return
165
     * @return always null
166 166
     */
167 167

  
168 168
    public Receiver getDocumentBuilder(Result result) {
......
170 170
    }
171 171

  
172 172
    /**
173
     * Test whether this object model recognizes a particular kind of JAXP Source object,
174
     * and if it does, send the contents of the document to a supplied Receiver, and return true.
175
     * Otherwise, return false.
173
     * Test whether this object model recognizes a particular kind of JAXP Source object.
174
     * @return always false
176 175
     */
177 176

  
178
    public boolean sendSource(Source source, Receiver receiver) throws XPathException {
177
    public boolean sendSource(Source source, Receiver receiver)  {
179 178
        return false;
180 179
    }
181 180

  
......
197 196
     * @param object the node to be converted
198 197
     * @param config the Saxon configuration
199 198
     * @return the resulting XPath value, or null
200
     * @throws net.sf.saxon.trans.XPathException
201
     *          if the object is recognized as a DOM4J node but cannot be
202
     *          wrapped
203 199
     */
204 200

  
205
    private Sequence convertObjectToXPathValue(Node object, Configuration config) throws XPathException {
201
    private Sequence convertObjectToXPathValue(Node object, Configuration config) {
206 202
        if (isRecognizedNode(object)) {
207 203
            if (object instanceof Document) {
208 204
                return wrapDocument(object, "", config).getRootNode();
latest10/hej/net/sf/saxon/option/jdom2/JDOM2ObjectModel.java
34 34

  
35 35
public class JDOM2ObjectModel extends TreeModel implements ExternalObjectModel {
36 36

  
37
    private static JDOM2ObjectModel THE_INSTANCE = new JDOM2ObjectModel();
37
    private final static JDOM2ObjectModel THE_INSTANCE = new JDOM2ObjectModel();
38 38

  
39 39
    public static JDOM2ObjectModel getInstance() {
40 40
        return THE_INSTANCE;
......
159 159
     * Test whether this object model recognizes a particular kind of JAXP Result object,
160 160
     * and if it does, return a Receiver that builds an instance of this data model from
161 161
     * a sequence of events. If the Result is not recognised, return null.
162
     * @return
162
     * @return always null
163 163
     */
164 164

  
165 165
    public Receiver getDocumentBuilder(Result result) {
latest10/hej/net/sf/saxon/option/xom/XOMObjectModel.java
46 46

  
47 47
public class XOMObjectModel extends TreeModel implements ExternalObjectModel {
48 48

  
49
    private static XOMObjectModel THE_INSTANCE = new XOMObjectModel();
49
    private final static XOMObjectModel THE_INSTANCE = new XOMObjectModel();
50 50

  
51 51
    public static XOMObjectModel getInstance() {
52 52
        return THE_INSTANCE;
......
150 150
     * Test whether this object model recognizes a particular kind of JAXP Result object,
151 151
     * and if it does, return a Receiver that builds an instance of this data model from
152 152
     * a sequence of events. If the Result is not recognised, return null.
153
     * @return
153
     * @return always null
154 154
     */
155 155

  
156 156
    public Receiver getDocumentBuilder(Result result) {
latest10/hej/net/sf/saxon/tree/iter/EmptyIterator.java
24 24
        ReversibleIterator, LastPositionFinder, GroundedIterator,
25 25
        LookaheadIterator, UnfailingIterator, AtomizedValueIterator {
26 26

  
27
    private static EmptyIterator theInstance = new EmptyIterator();
27
    private static final EmptyIterator theInstance = new EmptyIterator();
28 28

  
29 29
    /**
30 30
     * Get an EmptyIterator, an iterator over an empty sequence.
......
37 37
        return theInstance;
38 38
    }
39 39

  
40
    @SuppressWarnings("unchecked")
41 40
    public static EmptyIterator emptyIterator() {
42 41
        return theInstance;
43 42
    }
latest10/hej/net/sf/saxon/tree/iter/ListIterator.java
25 25
public class ListIterator<T extends Item>
26 26
        implements UnfailingIterator, LastPositionFinder, LookaheadIterator, GroundedIterator, ReversibleIterator {
27 27

  
28
    private int index = 0;
28
    private int index;
29 29
    protected List<T> list;
30 30

  
31 31
    /**
......
94 94
        return new ReverseListIterator<>(list);
95 95
    }
96 96

  
97
    public static class Atomic extends ListIterator<AtomicValue> implements AtomicIterator {
97
    public static class Atomic extends ListIterator<AtomicValue> implements AtomicIterator<AtomicValue> {
98 98
        public Atomic (List<AtomicValue> list) {
99 99
            super(list);
100 100
        }
latest10/hej/net/sf/saxon/tree/iter/NodeWrappingAxisIterator.java
22 22

  
23 23

  
24 24
    Iterator<? extends B> base;
25
    private NodeWrappingFunction<? super B, NodeInfo> wrappingFunction;
25
    private final NodeWrappingFunction<? super B, NodeInfo> wrappingFunction;
26 26

  
27 27

  
28 28
    /**
latest10/hej/net/sf/saxon/tree/iter/ReverseListIterator.java
25 25
public class ReverseListIterator<T extends Item> implements UnfailingIterator,
26 26
        ReversibleIterator, LookaheadIterator, LastPositionFinder {
27 27

  
28
    List<T> items;
29
    int index = 0;
30
    int start;
31
    int end;         // item after the last to be output
28
    private final List<T> items;
29
    private int index;
32 30

  
33 31
    /**
34 32
     * Create an iterator a slice of an array
latest10/hej/net/sf/saxon/tree/iter/SingleNodeIterator.java
21 21
public class SingleNodeIterator implements AxisIterator,
22 22
        ReversibleIterator, LastPositionFinder, GroundedIterator, LookaheadIterator {
23 23

  
24
    private NodeInfo item;
24
    private final NodeInfo item;
25 25
    private int position = 0;
26 26

  
27 27
    /**
......
100 100

  
101 101
    /*@NotNull*/
102 102
    public GroundedValue materialize() {
103
        return new ZeroOrOne(item);
103
        return new ZeroOrOne<>(item);
104 104
    }
105 105

  
106 106
    @Override
107 107
    public GroundedValue getResidue() {
108
        return item==null ? EmptySequence.getInstance() : new One(item);
108
        return item==null ? EmptySequence.getInstance() : new One<>(item);
109 109
    }
110 110

  
111 111
    /**
latest10/hej/net/sf/saxon/tree/iter/SingletonIterator.java
11 11
import net.sf.saxon.om.GroundedValue;
12 12
import net.sf.saxon.om.Item;
13 13
import net.sf.saxon.om.SequenceIterator;
14
import net.sf.saxon.om.ZeroOrOne;
15 14
import net.sf.saxon.value.EmptySequence;
16 15

  
17 16
import java.util.EnumSet;
......
24 23
public class SingletonIterator<T extends Item> implements SequenceIterator, UnfailingIterator,
25 24
        ReversibleIterator, LastPositionFinder, GroundedIterator, LookaheadIterator {
26 25

  
27
    private T item;
26
    private final T item;
28 27
    boolean gone = false;
29 28

  
30 29
    /**
......
113 112

  
114 113
    /*@NotNull*/
115 114
    public GroundedValue materialize() {
116
        if (item instanceof GroundedValue) {
117
            // noinspection unchecked
118
            return (GroundedValue)item;
115
        if (item != null) {
116
            return item;
119 117
        } else {
120
            return new ZeroOrOne(null);
118
            return EmptySequence.getInstance();
121 119
        }
122 120
    }
123 121

  
latest10/hej/net/sf/saxon/tree/iter/UntypedAtomizingIterator.java
27 27
public class UntypedAtomizingIterator implements SequenceIterator,
28 28
        LastPositionFinder, LookaheadIterator {
29 29

  
30
    private SequenceIterator base;
30
    private final SequenceIterator base;
31 31

  
32 32
    /**
33 33
     * Construct an AtomizingIterator that will atomize the values returned by the base iterator.
latest10/hej/net/sf/saxon/tree/linked/AttributeAxisIterator.java
21 21

  
22 22
final class AttributeAxisIterator implements AxisIterator, LookaheadIterator {
23 23

  
24
    private ElementImpl element;
25
    private Predicate<? super NodeInfo> nodeTest;
24
    private final ElementImpl element;
25
    private final Predicate<? super NodeInfo> nodeTest;
26 26
    /*@Nullable*/ private NodeInfo next;
27 27
    private int index;
28
    private int length;
28
    private final int length;
29 29

  
30 30
    /**
31 31
     * Constructor
latest10/hej/net/sf/saxon/tree/tiny/AttributeIterator.java
23 23

  
24 24
final class AttributeIterator implements AxisIterator, AtomizedValueIterator {
25 25

  
26
    private TinyTree tree;
27
    private int element;
28
    private NodeTest nodeTest;
26
    private final TinyTree tree;
27
    private final int element;
28
    private final NodeTest nodeTest;
29 29
    private int index;
30 30
    private int currentNodeNr;
31 31

  
latest10/hej/net/sf/saxon/type/Converter.java
178 178
     */
179 179

  
180 180
    public static class UpCastingConverter extends UnfailingConverter {
181
        private AtomicType newTypeAnnotation;
181
        private final AtomicType newTypeAnnotation;
182 182

  
183 183
        public UpCastingConverter(AtomicType annotation) {
184 184
            this.newTypeAnnotation = annotation;
......
196 196
     */
197 197

  
198 198
    public static class DownCastingConverter extends Converter {
199
        private AtomicType newType;
199
        private final AtomicType newType;
200 200

  
201 201
        public DownCastingConverter(AtomicType annotation, ConversionRules rules) {
202 202
            this.newType = annotation;
......
233 233
     */
234 234

  
235 235
    public static class TwoPhaseConverter extends Converter {
236
        private Converter phaseOne;
237
        private Converter phaseTwo;
236
        private final Converter phaseOne;
237
        private final Converter phaseTwo;
238 238

  
239 239
        public TwoPhaseConverter(Converter phaseOne, Converter phaseTwo) {
240 240
            this.phaseOne = phaseOne;
......
682 682
                if (stringToDouble == null) {
683 683
                    stringToDouble = BuiltInAtomicType.DOUBLE.getStringConverter(getConversionRules());
684 684
                }
685
                return stringToDouble.convert((UntypedAtomicValue)input);
685
                return stringToDouble.convert(input);
686 686
            } else {
687 687
                ValidationFailure err = new ValidationFailure(
688 688
                        "Cannot promote non-numeric value to xs:double");
......
716 716
                if (stringToFloat == null) {
717 717
                    stringToFloat = BuiltInAtomicType.FLOAT.getStringConverter(getConversionRules());
718 718
                }
719
                return stringToFloat.convert((UntypedAtomicValue)input);
719
                return stringToFloat.convert(input);
720 720
            } else {
721 721
                ValidationFailure err = new ValidationFailure(
722 722
                        "Cannot promote non-numeric value to xs:double");
latest10/hej/net/sf/saxon/value/DayTimeDurationValue.java
16 16
import java.math.BigDecimal;
17 17
import java.math.BigInteger;
18 18
import java.math.RoundingMode;
19
import java.util.Objects;
19 20

  
20 21
/**
21 22
 * A value of type xs:dayTimeDuration.
......
204 205
            if (nanoseconds == 0) {
205 206
                sb.append(seconds + "S");
206 207
            } else {
207
                long ms = (seconds * 1_000_000_000L) + nanoseconds;
208
                String mss = ms + "";
209
                if (seconds == 0) {
210
                    mss = "0000000000" + mss;
211
                    mss = mss.substring(mss.length() - 10);
212
                }
213
                sb.append(mss.substring(0, mss.length() - 9));
214
                sb.cat('.');
215
                int lastSigDigit = mss.length() - 1;
216
                while (mss.charAt(lastSigDigit) == '0') {
217
                    lastSigDigit--;
218
                }
219
                sb.append(mss.substring(mss.length() - 9, lastSigDigit + 1));
220
                sb.cat('S');
208
                formatFractionalSeconds(sb, seconds, (seconds * 1_000_000_000L) + nanoseconds);
221 209
            }
222 210
        }
223 211
        return sb;
......
342 330
     */
343 331

  
344 332
    public static DayTimeDurationValue fromNanoseconds(long nanoseconds) throws IllegalArgumentException {
345
        int sign = Long.signum(nanoseconds);
346 333
        return new DayTimeDurationValue(
347 334
                    0, 0, 0, nanoseconds / 1_000_000_000L, (int) (nanoseconds % 1_000_000_000L));
348 335
    }
......
575 562
     * @param other The other dateTime value
576 563
     * @return negative value if this one is the smaller, 0 if they are equal,
577 564
     *         positive value if this one is the greater.
578
     * @throws ClassCastException if the other value is not a DayTimeDurationValue
565
     * @throws NullPointerException if the other value is null
579 566
     */
580 567

  
581 568
    public int compareTo(DayTimeDurationValue other) {
582
        if (other instanceof DayTimeDurationValue) {
583
            if (this.negative != other.negative) {
584
                return this.negative ? -1 : +1;
585
            } else if (this.seconds != other.seconds) {
586
                return Long.compare(this.seconds, other.seconds) * (this.negative ? -1 : +1);
587
            } else {
588
                return Integer.compare(this.nanoseconds, other.nanoseconds) * (this.negative ? -1 : +1);
589
            }
569
        Objects.requireNonNull(other);
570
        if (this.negative != other.negative) {
571
            return this.negative ? -1 : +1;
572
        } else if (this.seconds != other.seconds) {
573
            return Long.compare(this.seconds, other.seconds) * (this.negative ? -1 : +1);
590 574
        } else {
591
            throw new ClassCastException("Cannot compare a dayTimeDuration to an object of class "
592
                    + other.getClass());
575
            return Integer.compare(this.nanoseconds, other.nanoseconds) * (this.negative ? -1 : +1);
593 576
        }
594 577
    }
595 578

  
latest10/hej/net/sf/saxon/value/DurationValue.java
169 169
        typeLabel = type;
170 170
    }
171 171

  
172
    protected static void formatFractionalSeconds(FastStringBuffer sb, int seconds, long nanosecs) {
173
        String mss = nanosecs + "";
174
        if (seconds == 0) {
175
            mss = "0000000000" + mss;
176
            mss = mss.substring(mss.length() - 10);
177
        }
178
        sb.append(mss.substring(0, mss.length() - 9));
179
        sb.cat('.');
180
        int lastSigDigit = mss.length() - 1;
181
        while (mss.charAt(lastSigDigit) == '0') {
182
            lastSigDigit--;
183
        }
184
        sb.append(mss.substring(mss.length() - 9, lastSigDigit + 1));
185
        sb.cat('S');
186
    }
187

  
172 188

  
173 189
    /**
174 190
     * Ensure that a zero duration is considered positive
......
594 610
            if (seconds != 0 && nanoseconds == 0) {
595 611
                sb.append(seconds + "S");
596 612
            } else {
597
                long ms = (seconds * 1_000_000_000L) + nanoseconds;
598
                String mss = ms + "";
599
                if (seconds == 0) {
600
                    mss = "0000000000" + mss;
601
                    mss = mss.substring(mss.length() - 10);
602
                }
603
                sb.append(mss.substring(0, mss.length() - 9));
604
                sb.cat('.');
605
                int lastSigDigit = mss.length() - 1;
606
                while (mss.charAt(lastSigDigit) == '0') {
607
                    lastSigDigit--;
608
                }
609
                sb.append(mss.substring(mss.length() - 9, lastSigDigit + 1));
610
                sb.cat('S');
613
                formatFractionalSeconds(sb, seconds, (seconds * 1_000_000_000L) + nanoseconds);
611 614
            }
612 615
        }
613 616

  

Also available in: Unified diff