KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > om > Validation


1 package net.sf.saxon.om;
2
3
4 /**
5 * This class contains constants and static methods to manipulate the validation
6 * property of a type.
7 */

8
9 public final class Validation {
10
11     public static final int INVALID = -1;
12
13     public static final int STRICT = 1;
14     public static final int LAX = 2;
15     public static final int PRESERVE = 3;
16     public static final int STRIP = 4;
17     public static final int SKIP = 4; // synonym provided for the XQuery API
18

19     public static final int DEFAULT = 0;
20
21     public static final int VALIDATION_MODE_MASK = 0xff;
22
23     public static final int VALIDATE_OUTPUT = 0x10000;
24
25     /**
26      * This class is never instantiated
27      */

28
29     private Validation() {
30     }
31
32     public static int getCode(String JavaDoc value) {
33         if (value.equals("strict")) {
34             return STRICT;
35         } else if (value.equals("lax")) {
36             return LAX;
37         } else if (value.equals("preserve")) {
38             return PRESERVE;
39         } else if (value.equals("strip")) {
40             return STRIP;
41         } else {
42             return INVALID;
43         }
44     }
45
46     public static String JavaDoc toString(int value) {
47         switch(value & VALIDATION_MODE_MASK) {
48             case STRICT: return "strict";
49             case LAX: return "lax";
50             case PRESERVE: return "preserve";
51             case STRIP: return "skip"; // for XQuery
52
default: return "invalid";
53         }
54     }
55 }
56
57 //
58
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
59
// you may not use this file except in compliance with the License. You may obtain a copy of the
60
// License at http://www.mozilla.org/MPL/
61
//
62
// Software distributed under the License is distributed on an "AS IS" basis,
63
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
64
// See the License for the specific language governing rights and limitations under the License.
65
//
66
// The Original Code is: all this file.
67
//
68
// The Initial Developer of the Original Code is Michael H. Kay
69
//
70
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
71
//
72
// Contributor(s): none.
73
//
74
Popular Tags