OSDN Git Service

1701d139876f5981f8c09cde12fca32767090c1b
[mikumikustudio/MikuMikuStudio.git] / src / com / jmex / xml / types / SchemaNormalizedString.java
1 /**
2  * SchemaNormalizedString.java
3  *
4  * This file was generated by XMLSpy 2007sp2 Enterprise Edition.
5  *
6  * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
7  * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
8  *
9  * Refer to the XMLSpy Documentation for further details.
10  * http://www.altova.com/xmlspy
11  */
12
13 package com.jmex.xml.types;
14
15 public class SchemaNormalizedString extends SchemaString {
16     public static final byte WHITESPACE_PRESERVE = 1;
17         public static final byte WHITESPACE_REPLACE = 2;
18         public static final byte WHITESPACE_COLLAPSE = 3;
19      
20         public SchemaNormalizedString() {
21                 super();
22         }
23
24         public SchemaNormalizedString(String newvalue) {
25                 super(newvalue);
26         }
27
28         public SchemaNormalizedString(SchemaNormalizedString newvalue) {
29                 super((SchemaString)newvalue);
30         }
31     
32     public static final String normalize(byte norm, String s)
33           {               
34           if (s == null) 
35               return null;
36         
37                   if (norm == WHITESPACE_COLLAPSE )
38                         return s.replaceAll("\\s{2,}", "").trim();
39                 
40                   if (norm == WHITESPACE_REPLACE)
41                           return s.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ');
42                   
43                   return s;
44           }
45 }