1 /*
2 * Copyright (c) 2000, 2019, 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
470 * <p>The empty (default) prefix will be included in this
471 * enumeration; note that this behaviour differs from that of
472 * {@link #getPrefix} and {@link #getPrefixes}.</p>
473 *
474 * @return An enumeration of all prefixes declared in this
475 * context.
476 * @see #getPrefixes
477 * @see #getURI
478 */
479 public Enumeration<String> getDeclaredPrefixes ()
480 {
481 return currentContext.getDeclaredPrefixes();
482 }
483
484 /**
485 * Controls whether namespace declaration attributes are placed
486 * into the {@link #NSDECL NSDECL} namespace
487 * by {@link #processName processName()}. This may only be
488 * changed before any contexts have been pushed.
489 *
490 * @since 1.5, SAX 2.1alpha
491 *
492 * @exception IllegalStateException when attempting to set this
493 * after any context has been pushed.
494 */
495 public void setNamespaceDeclUris (boolean value)
496 {
497 if (contextPos != 0)
498 throw new IllegalStateException ();
499 if (value == namespaceDeclUris)
500 return;
501 namespaceDeclUris = value;
502 if (value)
503 currentContext.declarePrefix ("xmlns", NSDECL);
504 else {
505 contexts[contextPos] = currentContext = new Context();
506 currentContext.declarePrefix("xml", XMLNS);
507 }
508 }
509
510 /**
511 * Returns true if namespace declaration attributes are placed into
512 * a namespace. This behavior is not the default.
513 *
514 * @since 1.5, SAX 2.1alpha
515 */
516 public boolean isNamespaceDeclUris ()
517 { return namespaceDeclUris; }
518
519
520
521 ////////////////////////////////////////////////////////////////////
522 // Internal state.
523 ////////////////////////////////////////////////////////////////////
524
525 private Context contexts[];
526 private Context currentContext;
527 private int contextPos;
528 private boolean namespaceDeclUris;
529
530
531 ////////////////////////////////////////////////////////////////////
532 // Internal classes.
533 ////////////////////////////////////////////////////////////////////
|
1 /*
2 * Copyright (c) 2000, 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
470 * <p>The empty (default) prefix will be included in this
471 * enumeration; note that this behaviour differs from that of
472 * {@link #getPrefix} and {@link #getPrefixes}.</p>
473 *
474 * @return An enumeration of all prefixes declared in this
475 * context.
476 * @see #getPrefixes
477 * @see #getURI
478 */
479 public Enumeration<String> getDeclaredPrefixes ()
480 {
481 return currentContext.getDeclaredPrefixes();
482 }
483
484 /**
485 * Controls whether namespace declaration attributes are placed
486 * into the {@link #NSDECL NSDECL} namespace
487 * by {@link #processName processName()}. This may only be
488 * changed before any contexts have been pushed.
489 *
490 * @param value a flag indicating whether namespace declaration attributes
491 * are placed into the {@link #NSDECL NSDECL} namespace
492 * @since 1.5, SAX 2.1alpha
493 *
494 * @exception IllegalStateException when attempting to set this
495 * after any context has been pushed.
496 */
497 public void setNamespaceDeclUris (boolean value)
498 {
499 if (contextPos != 0)
500 throw new IllegalStateException ();
501 if (value == namespaceDeclUris)
502 return;
503 namespaceDeclUris = value;
504 if (value)
505 currentContext.declarePrefix ("xmlns", NSDECL);
506 else {
507 contexts[contextPos] = currentContext = new Context();
508 currentContext.declarePrefix("xml", XMLNS);
509 }
510 }
511
512 /**
513 * Returns true if namespace declaration attributes are placed into
514 * a namespace. This behavior is not the default.
515 *
516 * @return true if namespace declaration attributes are placed into a namespace,
517 * false otherwise
518 * @since 1.5, SAX 2.1alpha
519 */
520 public boolean isNamespaceDeclUris ()
521 { return namespaceDeclUris; }
522
523
524
525 ////////////////////////////////////////////////////////////////////
526 // Internal state.
527 ////////////////////////////////////////////////////////////////////
528
529 private Context contexts[];
530 private Context currentContext;
531 private int contextPos;
532 private boolean namespaceDeclUris;
533
534
535 ////////////////////////////////////////////////////////////////////
536 // Internal classes.
537 ////////////////////////////////////////////////////////////////////
|