1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
477 * should override this method if it supports schema.
478 */
479 public DirContext getAttributeSyntaxDefinition() throws NamingException {
480 throw new OperationNotSupportedException("attribute syntax");
481 }
482
483 /**
484 * Retrieves this attribute's schema definition.
485 *<p>
486 * This method by default throws OperationNotSupportedException. A subclass
487 * should override this method if it supports schema.
488 */
489 public DirContext getAttributeDefinition() throws NamingException {
490 throw new OperationNotSupportedException("attribute definition");
491 }
492
493
494 // ---- serialization methods
495
496 /**
497 * Overridden to avoid exposing implementation details
498 * @serialData Default field (the attribute ID -- a String),
499 * followed by the number of values (an int), and the
500 * individual values.
501 */
502 private void writeObject(java.io.ObjectOutputStream s)
503 throws java.io.IOException {
504 s.defaultWriteObject(); // write out the attrID
505 s.writeInt(values.size());
506 for (int i = 0; i < values.size(); i++) {
507 s.writeObject(values.elementAt(i));
508 }
509 }
510
511 /**
512 * Overridden to avoid exposing implementation details.
513 */
514 private void readObject(java.io.ObjectInputStream s)
515 throws java.io.IOException, ClassNotFoundException {
516 s.defaultReadObject(); // read in the attrID
517 int n = s.readInt(); // number of values
518 values = new Vector<>(Math.min(1024, n));
519 while (--n >= 0) {
520 values.addElement(s.readObject());
521 }
522 }
523
524
525 class ValuesEnumImpl implements NamingEnumeration<Object> {
526 Enumeration<Object> list;
527
528 ValuesEnumImpl() {
529 list = values.elements();
530 }
531
532 public boolean hasMoreElements() {
533 return list.hasMoreElements();
534 }
535
|
1 /*
2 * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
477 * should override this method if it supports schema.
478 */
479 public DirContext getAttributeSyntaxDefinition() throws NamingException {
480 throw new OperationNotSupportedException("attribute syntax");
481 }
482
483 /**
484 * Retrieves this attribute's schema definition.
485 *<p>
486 * This method by default throws OperationNotSupportedException. A subclass
487 * should override this method if it supports schema.
488 */
489 public DirContext getAttributeDefinition() throws NamingException {
490 throw new OperationNotSupportedException("attribute definition");
491 }
492
493
494 // ---- serialization methods
495
496 /**
497 * @serialData Default field (the attribute ID - a {@code String}),
498 * followed by the number of values (an {@code int}), and the
499 * individual values.
500 *
501 * @param s the {@code ObjectOutputStream} to write to
502 * @throws java.io.IOException if an I/O error occurs.
503 */
504 @java.io.Serial
505 private void writeObject(java.io.ObjectOutputStream s)
506 throws java.io.IOException {
507 // Overridden to avoid exposing implementation details
508 s.defaultWriteObject(); // write out the attrID
509 s.writeInt(values.size());
510 for (int i = 0; i < values.size(); i++) {
511 s.writeObject(values.elementAt(i));
512 }
513 }
514
515 /**
516 * Initializes the {@code BasicAttribute} from deserialized data.
517 *
518 * See {@code writeObject} for a description of the serial form.
519 *
520 * @param s the {@code ObjectInputStream} to read from
521 * @throws java.io.IOException if an I/O error occurs.
522 * @throws ClassNotFoundException if the class of a serialized object
523 * could not be found.
524 */
525 @java.io.Serial
526 private void readObject(java.io.ObjectInputStream s)
527 throws java.io.IOException, ClassNotFoundException {
528 // Overridden to avoid exposing implementation details.
529 s.defaultReadObject(); // read in the attrID
530 int n = s.readInt(); // number of values
531 values = new Vector<>(Math.min(1024, n));
532 while (--n >= 0) {
533 values.addElement(s.readObject());
534 }
535 }
536
537
538 class ValuesEnumImpl implements NamingEnumeration<Object> {
539 Enumeration<Object> list;
540
541 ValuesEnumImpl() {
542 list = values.elements();
543 }
544
545 public boolean hasMoreElements() {
546 return list.hasMoreElements();
547 }
548
|