Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 209435 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/ecore/resource/impl/URIConverterImpl.java (-664 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: URIConverterImpl.java,v 1.8 2006/05/05 16:58:57 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
18
19
20
import java.io.ByteArrayInputStream;
21
import java.io.ByteArrayOutputStream;
22
import java.io.File;
23
import java.io.FileInputStream;
24
import java.io.FileOutputStream;
25
import java.io.IOException;
26
import java.io.InputStream;
27
import java.io.OutputStream;
28
import java.net.URL;
29
import java.net.URLConnection;
30
import java.util.Map;
31
32
import org.eclipse.core.resources.IContainer;
33
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.resources.IFolder;
35
import org.eclipse.core.resources.IResource;
36
import org.eclipse.core.resources.IWorkspaceRoot;
37
import org.eclipse.core.runtime.CoreException;
38
import org.eclipse.core.runtime.IProgressMonitor;
39
import org.eclipse.core.runtime.Path;
40
import org.eclipse.emf.common.archive.ArchiveURLConnection;
41
import org.eclipse.emf.common.util.URI;
42
import org.eclipse.emf.ecore.plugin.EcorePlugin;
43
import org.eclipse.emf.ecore.resource.Resource;
44
import org.eclipse.emf.ecore.resource.URIConverter;
45
46
47
/**
48
 * A highly functional and extensible URI converter implementation.
49
 * <p>
50
 * This implementation provides seamless transparent Eclipse integration
51
 * by supporting the <code>platform:/resource</code> mechanism both inside of Eclipse and outside of Eclipse.
52
 * Furthermore, although the implementation imports 
53
 * both {@link org.eclipse.core.runtime} and {@link org.eclipse.core.resources},
54
 * and hence requires the Eclipse libraries at development time,
55
 * the implementation does <b>not</b> require them at runtime. 
56
 * Clients of this implementation must be cautious if they wish to maintain this platform neutral behaviour.
57
 * </p>
58
 */
59
public class URIConverterImpl implements URIConverter
60
{
61
  // ECLIPSE-DEPEND-BEGIN 
62
  /** 
63
   * An output stream that transfers its contents to an {@link IFile} upon closing.
64
   */
65
  public static class PlatformResourceOutputStream extends ByteArrayOutputStream
66
  {
67
    protected IFile file;
68
    protected boolean force;
69
    protected boolean keepHistory;
70
    protected IProgressMonitor progressMonitor;
71
    protected boolean previouslyFlushed;
72
73
    public PlatformResourceOutputStream(IFile file,  boolean force, boolean keepHistory, IProgressMonitor progressMonitor)
74
    {
75
      this.file = file;
76
      this.force = force;
77
      this.keepHistory = keepHistory;
78
      this.progressMonitor = progressMonitor;
79
    }
80
81
    protected void createContainer(IContainer container) throws IOException
82
    {
83
      if (!container.exists())
84
      {
85
        if (container.getType() == IResource.FOLDER)
86
        {
87
          createContainer(container.getParent());
88
          try
89
          {
90
            ((IFolder)container).create(force, keepHistory, progressMonitor);
91
          }
92
          catch (CoreException exception)
93
          {
94
            throw new ResourceImpl.IOWrappedException(exception);
95
          }
96
        }
97
      }
98
    }
99
100
    public void close() throws IOException 
101
    {
102
      flush();
103
      super.close();
104
    }
105
106
    public void flush() throws IOException 
107
    {
108
      super.flush();
109
110
      if (previouslyFlushed)
111
      {
112
        if (count == 0)
113
        {
114
          return;
115
        }
116
      }
117
      else
118
      {
119
        createContainer(file.getParent());
120
      }
121
122
      byte[] contents = toByteArray();
123
      InputStream inputStream = new ByteArrayInputStream(contents, 0, contents.length);
124
  
125
      try 
126
      {
127
        if (previouslyFlushed)
128
        {
129
          file.appendContents(inputStream, force, false, progressMonitor); 
130
        }
131
        else if (!file.exists())
132
        {
133
          file.create(inputStream, false, null);
134
          previouslyFlushed = true;
135
        }
136
        else 
137
        {
138
          if (!file.isSynchronized(IResource.DEPTH_ONE))
139
          {
140
            file.refreshLocal(IResource.DEPTH_ONE, progressMonitor);
141
          }
142
          file.setContents(inputStream, force, keepHistory, progressMonitor); 
143
          previouslyFlushed = true;
144
        }
145
        reset();
146
      }
147
      catch (CoreException exception) 
148
      {
149
        throw new Resource.IOWrappedException(exception);
150
      }
151
    }
152
  }
153
154
  /**
155
   * Isolated Eclipse workbench utilities.
156
   */
157
  public static class WorkbenchHelper
158
  {
159
    /**
160
     * Creates an output stream for the given {@link IFile} path.
161
     * <p>
162
     * This implementation uses a {@link URIConverterImpl.PlatformResourceOutputStream}.
163
     * </p>
164
     * @return an open output stream.
165
     * @exception IOException if there is a problem obtaining an open output stream.
166
     * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
167
     * @see URIConverterImpl.PlatformResourceOutputStream
168
     * @see IFile#setContents(InputStream, boolean, boolean, IProgressMonitor)
169
     */
170
    public static OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException
171
    {
172
      IFile file = workspaceRoot.getFile(new Path(platformResourcePath));
173
      return new PlatformResourceOutputStream(file, false, true, null);
174
    }
175
176
    /**
177
     * Creates an input stream for the given {@link IFile} path.
178
     * <p>
179
     * This implementation uses {@link IFile#getContents IFile.getContents}.
180
     * </p>
181
     * @return an open input stream.
182
     * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
183
     * @see IFile#getContents
184
     * @exception IOException if there is a problem obtaining an open input stream.
185
     */
186
    public static InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException
187
    {
188
      IFile file = workspaceRoot.getFile(new Path(platformResourcePath));
189
      try
190
      {
191
        if (!file.isSynchronized(IResource.DEPTH_ONE))
192
        {
193
          file.refreshLocal(IResource.DEPTH_ONE, null);
194
        }
195
        return file.getContents();
196
      }
197
      catch (CoreException exception)
198
      {
199
        throw new Resource.IOWrappedException(exception);
200
      }
201
    }
202
  }
203
204
  /**
205
   * The cached Eclipse workspace.
206
   */
207
  protected static IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot();
208
209
  // ECLIPSE-DEPEND-END
210
211
  /**
212
   * A map that remaps URIs.
213
   */
214
  public interface URIMap extends Map
215
  {
216
    /**
217
     * Returns the remapped URI, or the URI itself.
218
     * @param uri the URI to remap.
219
     * @return the remapped URI, or the URI itself.
220
     */
221
    URI getURI(URI uri);
222
  }
223
224
  /** 
225
   * The URI map.
226
   */
227
  protected URIMap uriMap;
228
229
  /**
230
   * Creates an instance.
231
   */
232
  public URIConverterImpl()
233
  {
234
    // This is a hacky way to test stand-alone platform:/resource support in what's really an headless environment.
235
    //
236
    // org.eclipse.core.resources.IProject [] projects = workspaceRoot.getProjects();
237
    // for (int i = 0; i < projects.length; ++i)
238
    // {
239
    //   String rootContainerName = projects[i].getName();
240
    //   URI rootContainerLocation = URI.createFileURI(projects[i].getLocation().toString() + "/");
241
    //   platformResourceMap.put(rootContainerName, rootContainerLocation);
242
    // }
243
    //
244
    // workspaceRoot = null;
245
  }
246
  
247
  /**
248
   * Returns whether the scheme is one that this implementation should treat as an archive.
249
   * This implementation returns <code>true</code> which the schem is <code>"archive"</code>.
250
   * @param scheme the scheme to consider.
251
   * @return whether the scheme is one that this implementation treats as an archive.
252
   */
253
  protected boolean isArchiveScheme(String scheme)
254
  {
255
    return "archive".equals(scheme);
256
  }
257
258
  /**
259
   * Creates an output stream for the URI and returns it.
260
   * <p>
261
   * This implementation {@link #normalize normalizes} the URI and uses that as the basis for further processing.
262
   * It factors out the URI schemes <code>file</code> and <code>platform</code> (with leading <code>resource</code> segment)
263
   * for special processing by 
264
   * {@link #createFileOutputStream createFileOutputStream} and
265
   * {@link #createPlatformResourceOutputStream createPlatformResourceOutputStream}, respectively.
266
   * The file-based URI is {@link URI#toFileString converted} to a file path, e.g.,
267
   *<pre>
268
   *  file:///C:/directory/file
269
   *    ->
270
   *   C:/directory/file
271
   *</pre>
272
   * and the platform-based URI is converted to a platform path by trimming the leading <code>platform:/resource</code>, e.g.,
273
   *<pre>
274
   *  platform:/resource/project/directory/file 
275
   *    ->
276
   *  /project/directory/file 
277
   *</pre>
278
   * All other cases are handled as standard URLs by {@link #createURLOutputStream createURLOutputStream}.
279
   * </p>
280
   * @return an open output stream.
281
   * @exception IOException if there is a problem obtaining an open output stream.
282
   */
283
  public OutputStream createOutputStream(URI uri) throws IOException
284
  {
285
    URI converted = normalize(uri);
286
    if (converted.isFile())
287
    {
288
      String filePath = converted.toFileString();
289
      return createFileOutputStream(filePath);
290
    }
291
    else 
292
    {
293
      String scheme = converted.scheme();
294
      if (isArchiveScheme(scheme))
295
      {
296
        return createArchiveOutputStream(converted);  
297
      }
298
      else if ("platform".equals(scheme) && converted.segmentCount() > 1 && "resource".equals(converted.segment(0)))
299
      {
300
        StringBuffer platformResourcePath = new StringBuffer();
301
        for (int i = 1, size = converted.segmentCount(); i < size; ++i)
302
        {
303
          platformResourcePath.append('/');
304
          platformResourcePath.append(URI.decode(converted.segment(i)));
305
        }
306
        return createPlatformResourceOutputStream(platformResourcePath.toString());
307
      }
308
      else
309
      {
310
        return createURLOutputStream(converted);
311
      }
312
    }
313
  }
314
315
  /**
316
   * Creates an output stream for the file path and returns it.
317
   * <p>
318
   * This implementation allocates a {@link FileOutputStream} and creates subdirectories as necessary.
319
   * </p>
320
   * @return an open output stream.
321
   * @exception IOException if there is a problem obtaining an open output stream.
322
   */
323
  protected OutputStream createFileOutputStream(String filePath) throws IOException
324
  {
325
    File file = new File(filePath);
326
    String parent = file.getParent();
327
    if (parent != null)
328
    {
329
      new File(parent).mkdirs();
330
    }
331
    OutputStream outputStream = new FileOutputStream(file);
332
    return outputStream;
333
  }
334
  
335
  /**
336
   * Creates an output stream for the archive access.
337
   * </p>
338
   * @return an open output stream.
339
   * @exception IOException if there is a problem obtaining an open output stream.
340
   */
341
  protected OutputStream createArchiveOutputStream(URI archiveURI) throws IOException
342
  {
343
    return createArchive(archiveURI).getOutputStream();
344
  }
345
346
  /**
347
   * Creates an output stream for the platform resource path and returns it.
348
   * <p>
349
   * This implementation does one of two things, depending on the runtime environment.
350
   * If there is an Eclipse workspace, it delegates to 
351
   * {@link WorkbenchHelper#createPlatformResourceOutputStream WorkbenchHelper.createPlatformResourceOutputStream},
352
   * which gives the expected Eclipse behaviour.
353
   * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI 
354
   * is delegated to {@link #createOutputStream createOutputStream}
355
   * for recursive processing.
356
   * @return an open output stream.
357
   * @exception IOException if there is a problem obtaining an open output stream or a valid interpretation of the path.
358
   * @see EcorePlugin#resolvePlatformResourcePath(String)
359
   */
360
  protected OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException
361
  {
362
    // ECLIPSE-DEPEND-BEGIN
363
    if (workspaceRoot != null)
364
    {
365
      return WorkbenchHelper.createPlatformResourceOutputStream(platformResourcePath);
366
    }
367
    else
368
    // ECLIPSE-DEPEND-END
369
    {
370
      URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
371
      if (resolvedLocation != null)
372
      {
373
        return createOutputStream(resolvedLocation);
374
      }
375
376
      throw new IOException("The path '" + platformResourcePath + "' is unmapped");
377
    }
378
  }
379
380
  /**
381
   * Creates an output stream for the URI, assuming it's a URL, and returns it.
382
   * @return an open output stream.
383
   * @exception IOException if there is a problem obtaining an open output stream.
384
   */
385
  protected OutputStream createURLOutputStream(URI uri) throws IOException
386
  {
387
    try
388
    {
389
      URL url = new URL(uri.toString());
390
      URLConnection urlConnection = url.openConnection();
391
      urlConnection.setDoOutput(true);
392
      return urlConnection.getOutputStream();
393
    }
394
    catch (RuntimeException exception)
395
    {
396
      throw new Resource.IOWrappedException(exception);
397
    }
398
  }
399
400
  /**
401
   * Creates an input stream for the URI and returns it.
402
   * <p>
403
   * This implementation {@link #normalize normalizes} the URI and uses that as the basis for further processing.
404
   * It factors out the URI schemes <code>file</code> and <code>platform</code> (with leading <code>resource</code> segment)
405
   * for special processing by 
406
   * {@link #createFileInputStream createFileInputStream} and
407
   * {@link #createPlatformResourceInputStream createPlatformResourceInputStream}, respectively.
408
   * The file-based URI is {@link URI#toFileString converted} to a file path, e.g.,
409
   *<pre>
410
   *  file:///C:/directory/file
411
   *    ->
412
   *   C:/directory/file
413
   *</pre>
414
   * and the platform-based URI is converted to a platform path by trimming the leading <code>platform:/resource</code>, e.g.,
415
   *<pre>
416
   *  platform:/resource/project/directory/file 
417
   *    ->
418
   *  /project/directory/file 
419
   *</pre>
420
   * All other cases are handled as standard URLs by {@link #createURLInputStream createURLInputStream}.
421
   * </p>
422
   * @return an open Input stream.
423
   * @exception IOException if there is a problem obtaining an open input stream.
424
   */
425
  public InputStream createInputStream(URI uri) throws IOException
426
  {
427
    URI converted = normalize(uri);
428
    if (converted.isFile())
429
    {
430
      String filePath = converted.toFileString();
431
      return createFileInputStream(filePath);
432
    }
433
    else
434
    {
435
      String scheme = converted.scheme();
436
      if (isArchiveScheme(scheme))
437
      {
438
        return createArchiveInputStream(converted);
439
      }
440
      else if ("platform".equals(scheme) && converted.segmentCount() > 1 && "resource".equals(converted.segment(0)))
441
      {
442
        
443
        StringBuffer platformResourcePath = new StringBuffer();
444
        for (int i = 1, size = converted.segmentCount(); i < size; ++i)
445
        {
446
          platformResourcePath.append('/');
447
          platformResourcePath.append(URI.decode(converted.segment(i)));
448
        }
449
        return createPlatformResourceInputStream(platformResourcePath.toString());
450
      }
451
      else
452
      {
453
        return createURLInputStream(converted);
454
      }
455
    }
456
  }
457
458
  /**
459
   * Creates an input stream for the file path and returns it.
460
   * <p>
461
   * This implementation allocates a {@link FileInputStream}.
462
   * </p>
463
   * @return an open input stream.
464
   * @exception IOException if there is a problem obtaining an open input stream.
465
   */
466
  protected InputStream createFileInputStream(String filePath) throws IOException
467
  {
468
    File file = new File(filePath);
469
    InputStream inputStream = new FileInputStream(file);
470
    return inputStream;
471
  }
472
  
473
  /**
474
   * A specialized class for reading from an archive.
475
   */
476
  protected class Archive extends ArchiveURLConnection
477
  {
478
    public Archive(URI uri)
479
    {
480
      super(uri.toString());
481
    }
482
    
483
    protected boolean emulateArchiveScheme()
484
    {
485
      return false;
486
    }
487
    
488
    protected boolean useZipFile()
489
    {
490
      return true;
491
    }
492
    
493
    protected InputStream createInputStream(String nestedURL) throws IOException
494
    {
495
      return URIConverterImpl.this.createInputStream(URI.createURI(nestedURL));
496
    }
497
    
498
    protected OutputStream createOutputStream(String nestedURL) throws IOException
499
    {
500
      return URIConverterImpl.this.createOutputStream(URI.createURI(nestedURL));
501
    }
502
  }
503
  
504
  protected Archive createArchive(URI uri)
505
  {
506
    return new Archive(uri);
507
  }
508
  
509
  /**
510
   * Creates an input stream for the archive paths and returns it.
511
   * It uses {@link ArchiveReader} to implement read access.
512
   * </p>
513
   * @return an open input stream.
514
   * @exception IOException if there is a problem obtaining an open input stream.
515
   */
516
  protected InputStream createArchiveInputStream(URI archiveURI) throws IOException
517
  {
518
    return createArchive(archiveURI).getInputStream();
519
  }
520
521
  /**
522
   * Creates an input stream for the platform resource path and returns it.
523
   * <p>
524
   * This implementation does one of two things, depending on the runtime environment.
525
   * If there is an Eclipse workspace, it delegates to 
526
   * {@link WorkbenchHelper#createPlatformResourceInputStream WorkbenchHelper.createPlatformResourceInputStream},
527
   * which gives the expected Eclipse behaviour.
528
   * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI 
529
   * is delegated to {@link #createInputStream createInputStream}
530
   * for recursive processing.
531
   * @return an open input stream.
532
   * @exception IOException if there is a problem obtaining an open input stream or a valid interpretation of the path.
533
   * @see EcorePlugin#resolvePlatformResourcePath(String)
534
   */
535
  protected InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException
536
  {
537
    // ECLIPSE-DEPEND-BEGIN
538
    if (workspaceRoot != null)
539
    {
540
      return WorkbenchHelper.createPlatformResourceInputStream(platformResourcePath);
541
    }
542
    else
543
    // ECLIPSE-DEPEND-END
544
    {
545
      URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
546
      if (resolvedLocation != null)
547
      {
548
        return createInputStream(resolvedLocation);
549
      }
550
551
      throw new IOException("The path '" + platformResourcePath + "' is unmapped");
552
    }
553
  }
554
555
  /**
556
   * Creates an input stream for the URI, assuming it's a URL, and returns it.
557
   * @return an open input stream.
558
   * @exception IOException if there is a problem obtaining an open input stream.
559
   */
560
  protected InputStream createURLInputStream(URI uri) throws IOException
561
  {
562
    try
563
    {
564
      URL url = new URL(uri.toString());
565
      URLConnection urlConnection = url.openConnection();
566
      return urlConnection.getInputStream();
567
    }
568
    catch (RuntimeException exception)
569
    {
570
      throw new Resource.IOWrappedException(exception);
571
    }
572
  }
573
574
  /**
575
   * Returns the normalized form of the URI.
576
   * <p>
577
   * This implementation does precisely and only the {@link URIConverter#normalize typical} thing.
578
   * It calls itself recursively so that mapped chains are followed.
579
   * </p>
580
   * @param uri the URI to normalize.
581
   * @return the normalized form.
582
   * @see org.eclipse.emf.ecore.plugin.EcorePlugin#getPlatformResourceMap
583
   */
584
  public URI normalize(URI uri)
585
  {
586
    String fragment = uri.fragment();
587
    URI result = 
588
      fragment == null ? 
589
        getInternalURIMap().getURI(uri) :
590
        getInternalURIMap().getURI(uri.trimFragment()).appendFragment(fragment);
591
    String scheme = result.scheme();
592
    if (scheme == null)
593
    {
594
      // ECLIPSE-DEPEND-BEGIN
595
      if (workspaceRoot != null)
596
      {
597
        if (result.hasAbsolutePath())
598
        {
599
          result = URI.createPlatformResourceURI(result.trimFragment().toString());
600
          if (fragment != null)
601
          {
602
            result = result.appendFragment(fragment);
603
          }
604
        }
605
      }
606
      else 
607
      // ECLIPSE-DEPEND-END
608
      {
609
        if (result.hasAbsolutePath())
610
        {
611
          result = URI.createURI("file:" + result);
612
        }
613
        else
614
        {
615
          result = URI.createFileURI(new File(result.trimFragment().toString()).getAbsolutePath());
616
          if (fragment != null)
617
          {
618
            result = result.appendFragment(fragment);
619
          }
620
        }
621
      }
622
    }
623
624
    if (result.equals(uri))
625
    {
626
      return uri;
627
    }
628
    else
629
    {
630
      return normalize(result);
631
    }
632
  }
633
634
  /*
635
   * Javadoc copied from interface.
636
   */
637
  public Map getURIMap()
638
  {
639
    return getInternalURIMap();
640
  }
641
642
  /**
643
   * Returns the internal version of the URI map.
644
   * @return the internal version of the URI map.
645
   */
646
  protected URIMap getInternalURIMap()
647
  {
648
    if (uriMap == null)
649
    {
650
      URIMappingRegistryImpl mappingRegistryImpl = 
651
        new URIMappingRegistryImpl()
652
        {
653
          protected URI delegatedGetURI(URI uri)
654
          {
655
            return URIMappingRegistryImpl.INSTANCE.getURI(uri);
656
          }
657
        };
658
659
      uriMap = (URIMap)mappingRegistryImpl.map();
660
    }
661
662
    return uriMap;
663
  }
664
}
(-)src/org/eclipse/emf/ecore/resource/impl/ResourceFactoryRegistryImpl.java (-106 / +14 lines)
Lines 1-115 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ResourceFactoryRegistryImpl.java,v 1.3 2005/06/12 13:29:22 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
1
package org.eclipse.emf.ecore.resource.impl;
18
2
19
20
import java.util.HashMap;
21
import java.util.Map;
3
import java.util.Map;
22
4
23
import org.eclipse.emf.common.util.URI;
5
import org.eclipse.emf.common.util.URI;
24
import org.eclipse.emf.ecore.resource.Resource;
6
import org.eclipse.emf.ecore.resource.Resource;
7
import org.eclipse.emf.ecore.resource.Resource.Factory;
8
9
public class ResourceFactoryRegistryImpl implements Resource.Factory.Registry {
10
11
	public Map getExtensionToFactoryMap() {
12
		throw new UnsupportedOperationException();
13
	}
14
15
	public Factory getFactory(URI uri) {
16
		throw new UnsupportedOperationException();
17
	}
25
18
19
	public Map getProtocolToFactoryMap() {
20
		throw new UnsupportedOperationException();
21
	}
26
22
27
/**
28
 * An extensible implementation of a resource factory registry.
29
 */
30
public class ResourceFactoryRegistryImpl implements Resource.Factory.Registry
31
{
32
  /**
33
   * The protocol map.
34
   */
35
  protected Map protocolToFactoryMap = new HashMap();
36
37
  /**
38
   * The extension map.
39
   */
40
  protected Map extensionToFactoryMap = new HashMap();
41
42
  /**
43
   * Creates an instance.
44
   */
45
  public ResourceFactoryRegistryImpl()
46
  {
47
  }
48
49
  /**
50
   * Returns the resource factory appropriate for the given URI.
51
   * <p>
52
   * This implementation does the {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getFactory typical} thing.
53
   * It will delegate to {@link #delegatedGetFactory(URI)} 
54
   * in the case that the typical behaviour doesn't produce a result;
55
   * clients are encouraged to override that method only.
56
   * </p>
57
   * @param uri the URI.
58
   * @return the resource factory appropriate for the given URI.
59
   * @see org.eclipse.emf.ecore.resource.ResourceSet#createResource(URI)
60
   */
61
  public Resource.Factory getFactory(URI uri)
62
  {
63
    String protocol = uri.scheme();
64
    Object resourceFactory =  protocolToFactoryMap.get(protocol);
65
    if (resourceFactory == null)
66
    {
67
      String extension = uri.fileExtension();
68
      resourceFactory = extensionToFactoryMap.get(extension);
69
      if (resourceFactory == null)
70
      {
71
        resourceFactory = extensionToFactoryMap.get("*");
72
        if (resourceFactory == null)
73
        {
74
          resourceFactory = delegatedGetFactory(uri);
75
        }
76
      }
77
    }
78
79
    return 
80
      resourceFactory instanceof Resource.Factory.Descriptor ?
81
        ((Resource.Factory.Descriptor)resourceFactory).createFactory() :
82
        (Resource.Factory)resourceFactory;
83
  }
84
85
  /**
86
   * Returns the resource factory appropriate for the given URI, when standard alternatives fail.
87
   * <p>
88
   * This implementation returns <code>null</code>;
89
   * clients are encouraged to override it.
90
   * </p>
91
   * @param uri the URI.
92
   * @return the resource factory appropriate for the given URI.
93
   * @see #getFactory(URI)
94
   */
95
  protected Resource.Factory delegatedGetFactory(URI uri)
96
  {
97
    return null;
98
  }
99
100
  /*
101
   * Javadoc copied from interface.
102
   */
103
  public Map getExtensionToFactoryMap()
104
  {
105
    return extensionToFactoryMap;
106
  }
107
108
  /*
109
   * Javadoc copied from interface.
110
   */
111
  public Map getProtocolToFactoryMap()
112
  {
113
    return protocolToFactoryMap;
114
  }
115
}
23
}
(-)src/org/eclipse/emf/ecore/resource/impl/ResourceFactoryImpl.java (-38 / +6 lines)
Lines 1-45 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ResourceFactoryImpl.java,v 1.3 2005/06/08 06:20:10 nickb Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
1
package org.eclipse.emf.ecore.resource.impl;
18
2
19
20
import org.eclipse.emf.common.util.URI;
3
import org.eclipse.emf.common.util.URI;
21
import org.eclipse.emf.ecore.resource.Resource;
4
import org.eclipse.emf.ecore.resource.Resource;
22
5
6
public class ResourceFactoryImpl implements Resource.Factory {
7
8
	public Resource createResource(URI uri) {
9
		// TODO Auto-generated method stub
10
		return null;
11
	}
23
12
24
/**
25
 * A trivial implementation of a resource factory.
26
 */
27
public class ResourceFactoryImpl implements Resource.Factory
28
{
29
  /**
30
   * Creates an instance.
31
   */
32
  public ResourceFactoryImpl()
33
  {
34
  }
35
  
36
  /**
37
   * Returns a newly allocated default resource {@link org.eclipse.emf.ecore.resource.impl.ResourceImpl#ResourceImpl(URI) implementation}.
38
   * @param uri the URI.
39
   * @return a new resource for the URI.
40
   */
41
  public Resource createResource(URI uri)
42
  {
43
    return new ResourceImpl(uri);
44
  }
45
}
13
}
(-)src/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java (-1383 / +4 lines)
Lines 1-1390 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ResourceImpl.java,v 1.18 2006/09/18 15:47:04 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
1
package org.eclipse.emf.ecore.resource.impl;
18
2
19
20
import java.io.IOException;
21
import java.io.InputStream;
22
import java.io.OutputStream;
23
import java.util.ArrayList;
24
import java.util.HashMap;
25
import java.util.Iterator;
26
import java.util.List;
27
import java.util.ListIterator;
28
import java.util.Map;
29
import java.util.zip.ZipEntry;
30
import java.util.zip.ZipInputStream;
31
import java.util.zip.ZipOutputStream;
32
33
import org.eclipse.emf.common.notify.Adapter;
34
import org.eclipse.emf.common.notify.Notification;
35
import org.eclipse.emf.common.notify.NotificationChain;
36
import org.eclipse.emf.common.notify.impl.AdapterImpl;
37
import org.eclipse.emf.common.notify.impl.NotificationChainImpl;
38
import org.eclipse.emf.common.notify.impl.NotificationImpl;
39
import org.eclipse.emf.common.notify.impl.NotifierImpl;
40
import org.eclipse.emf.common.notify.impl.NotifyingListImpl;
41
import org.eclipse.emf.common.util.AbstractTreeIterator;
42
import org.eclipse.emf.common.util.EList;
43
import org.eclipse.emf.common.util.TreeIterator;
44
import org.eclipse.emf.common.util.URI;
3
import org.eclipse.emf.common.util.URI;
45
import org.eclipse.emf.common.util.WrappedException;
46
import org.eclipse.emf.ecore.EObject;
47
import org.eclipse.emf.ecore.InternalEObject;
48
import org.eclipse.emf.ecore.resource.Resource;
49
import org.eclipse.emf.ecore.resource.ResourceSet;
50
import org.eclipse.emf.ecore.resource.URIConverter;
51
import org.eclipse.emf.ecore.util.EcoreUtil;
52
import org.eclipse.emf.ecore.util.InternalEList;
53
import org.eclipse.emf.ecore.util.EcoreUtil.ContentTreeIterator;
54
import org.eclipse.emf.ecore.util.EcoreUtil.ProperContentIterator;
55
56
57
/**
58
 * A highly extensible resource implementation.
59
 * <p>
60
 * The following configuration and control mechanisms are provided:
61
 * <ul>
62
 *   <li><b>Serialization</b></li>
63
 *   <ul>
64
 *     <li>{@link #doSave(OutputStream, Map)}</li>
65
 *     <li>{@link #doLoad(InputStream, Map)}</li>
66
 *     <li>{@link #doUnload}</li>
67
 *   </ul>
68
 *   <li><b>Root URI Fragment</b></li>
69
 *   <ul>
70
 *     <li>{@link #getURIFragmentRootSegment(EObject)}</li>
71
 *     <li>{@link #getEObjectForURIFragmentRootSegment(String)}</li>
72
 *   </ul>
73
 *   <li><b>Containment Changes</b></li>
74
 *   <ul>
75
 *     <li>{@link #attached(EObject)}</li>
76
 *     <li>{@link #detached(EObject)}</li>
77
 *     <li>{@link #unloaded(InternalEObject)}</li>
78
 *   </ul>
79
 *   <li><b>ZIP</b></li>
80
 *   <ul>
81
 *     <li>{@link #useZip}</li>
82
 *     <li>{@link #newContentZipEntry}</li>
83
 *     <li>{@link #isContentZipEntry(ZipEntry)}</li>
84
 *   </ul>
85
 *   <li><b>URI Conversion</b></li>
86
 *   <ul>
87
 *     <li>{@link #getURIConverter}</li>
88
 *   </ul>
89
 *   <li><b>Modification</b></li>
90
 *   <ul>
91
 *     <li>{@link #createModificationTrackingAdapter()}</li>
92
 *   </ul>
93
 * </ul>
94
 * </p>
95
 */
96
public class ResourceImpl extends NotifierImpl implements Resource, Resource.Internal
97
{
98
  /**
99
   * The default URI converter when there is no resource set.
100
   */
101
  private static URIConverter defaultURIConverter;
102
103
  /**
104
   * Returns the default URI converter that's used when there is no resource set.
105
   * @return the default URI converter.
106
   * @see #getURIConverter
107
   */
108
  protected static URIConverter getDefaultURIConverter()
109
  {
110
    if (defaultURIConverter == null)
111
    {
112
      defaultURIConverter = new URIConverterImpl();
113
    }
114
    return defaultURIConverter;
115
  }
116
  
117
  /**
118
   * Merges 2 maps, without changing any of them.  If map2 and map1
119
   * have the same key for an entry, map1's value will be the one in 
120
   * the merged map.
121
   */
122
  protected static Map mergeMaps(Map map1, Map map2)
123
  {
124
    if (map1 == null || map1.isEmpty())
125
    {
126
      return map2;
127
    }
128
    else if (map2 == null || map2.isEmpty())
129
    {
130
      return map1;
131
    }
132
    else
133
    {
134
      Map mergedMap = new HashMap(map2);
135
      mergedMap.putAll(map1);
136
      return mergedMap;
137
    }
138
  }
139
140
  /**
141
   * The storage for the default save options.
142
   */
143
  protected Map defaultSaveOptions;
144
145
  /**
146
   * The storage for the default load options.
147
   */
148
  protected Map defaultLoadOptions;
149
150
  /**
151
   * The containing resource set.
152
   * @see #getResourceSet
153
   */
154
  protected ResourceSet resourceSet;
155
156
  /**
157
   * The URI.
158
   * @see #getURI
159
   */
160
  protected URI uri;
161
162
  /**
163
   * The contents.
164
   * @see #getContents
165
   */
166
  protected ContentsEList contents;
167
168
  /**
169
   * The errors.
170
   * @see #getErrors
171
   */
172
  protected EList errors;
173
174
  /**
175
   * The warnings.
176
   * @see #getErrors
177
   */
178
  protected EList warnings;
179
180
  /**
181
   * The modified flag.
182
   * @see #isModified
183
   */
184
  protected boolean isModified;
185
186
  /**
187
   * The loaded flag.
188
   * @see #isLoaded
189
   */
190
  protected boolean isLoaded;
191
192
  /**
193
   * The loading flag.
194
   * @see #isLoading
195
   */
196
  protected boolean isLoading;
197
  
198
  /**
199
   * The modification tracking adapter.
200
   * @see #isTrackingModification
201
   * @see #attached(EObject)
202
   * @see #detached(EObject)
203
   */
204
  protected Adapter modificationTrackingAdapter;
205
206
  /**
207
   * A map to retrieve the EObject based on the value of its ID feature.
208
   * @see #setIntrinsicIDToEObjectMap(Map)
209
   */
210
  protected Map intrinsicIDToEObjectMap;
211
212
  /**
213
   * Creates a empty instance.
214
   */
215
  public ResourceImpl()
216
  {
217
  }
218
219
  /**
220
   * Creates an instance with the given URI.
221
   * @param uri the URI.
222
   */
223
  public ResourceImpl(URI uri)
224
  {
225
    this();
226
    this.uri = uri;
227
  }
228
229
  /*
230
   * Javadoc copied from interface.
231
   */
232
  public ResourceSet getResourceSet()
233
  {
234
    return resourceSet;
235
  }
236
237
  /**
238
   * Sets the new containing resource set, and removes the resource from a previous containing resource set, if necessary.
239
   * @param resourceSet the new containing resource set.
240
   * @param notifications the accumulating notifications.
241
   * @return notification of the change.
242
   */
243
  public NotificationChain basicSetResourceSet(ResourceSet resourceSet, NotificationChain notifications)
244
  {
245
    ResourceSet oldResourceSet = this.resourceSet;
246
    if (oldResourceSet != null)
247
    {
248
      notifications = ((InternalEList)oldResourceSet.getResources()).basicRemove(this, notifications);
249
    }
250
251
    this.resourceSet = resourceSet;
252
253
    if (eNotificationRequired())
254
    {
255
      if (notifications == null)
256
      {
257
        notifications = new NotificationChainImpl(2);
258
      }
259
      notifications.add
260
        (new NotificationImpl(Notification.SET, oldResourceSet, resourceSet)
261
         {
262
           public Object getNotifier()
263
           {
264
             return ResourceImpl.this;
265
           }
266
           public int getFeatureID(Class expectedClass)
267
           {
268
             return RESOURCE__RESOURCE_SET;
269
           }
270
         });
271
    }
272
273
    return notifications;
274
  }
275
276
  /*
277
   * Javadoc copied from interface.
278
   */
279
  public URI getURI()
280
  {
281
    return uri;
282
  }
283
284
  /*
285
   * Javadoc copied from interface.
286
   */
287
  public void setURI(URI uri)
288
  {
289
    URI oldURI = this.uri;
290
    this.uri = uri;
291
    if (eNotificationRequired())
292
    {
293
      Notification notification =
294
        new NotificationImpl(Notification.SET, oldURI, uri)
295
        {
296
          public Object getNotifier()
297
          {
298
            return ResourceImpl.this;
299
          }
300
          public int getFeatureID(Class expectedClass)
301
          {
302
            return RESOURCE__URI;
303
          }
304
        };
305
      eNotify(notification);
306
    }
307
  }
308
309
  /**
310
   * A notifying list implementation for supporting {@link Resource#getContents}.
311
   */
312
  protected class ContentsEList extends NotifyingListImpl implements InternalEList
313
  {
314
    public Object getNotifier()
315
    {
316
      return ResourceImpl.this;
317
    }
318
319
    public int getFeatureID()
320
    {
321
      return RESOURCE__CONTENTS;
322
    }
323
324
    protected boolean isNotificationRequired()
325
    {
326
      return ResourceImpl.this.eNotificationRequired();
327
    }
328
329
    protected boolean useEquals()
330
    {
331
      return false;
332
    }
333
334
    protected boolean hasInverse()
335
    {
336
      return true;
337
    }
338
339
    protected boolean isUnique()
340
    {
341
      return true;
342
    }
343
344
    public NotificationChain inverseAdd(Object object, NotificationChain notifications)
345
    {
346
      InternalEObject eObject = (InternalEObject)object;
347
      notifications = eObject.eSetResource(ResourceImpl.this, notifications);
348
      ResourceImpl.this.attached(eObject);
349
      return notifications;
350
    }
351
352
    public NotificationChain inverseRemove(Object object, NotificationChain notifications)
353
    {
354
      InternalEObject eObject = (InternalEObject)object;
355
      if (ResourceImpl.this.isLoaded)
356
      {
357
        ResourceImpl.this.detached(eObject);
358
      }
359
      return eObject.eSetResource(null, notifications);
360
    }
361
362
    public Iterator basicIterator()
363
    {
364
      return super.basicIterator();
365
    }
366
367
    public ListIterator basicListIterator()
368
    {
369
      return super.basicListIterator();
370
    }
371
  
372
    public ListIterator basicListIterator(int index)
373
    {
374
      return super.basicListIterator(index);
375
    }
376
377
    public List basicList()
378
    {
379
      return super.basicList();
380
    }
381
382
    protected Object [] newData(int capacity)
383
    {
384
      return new EObject [capacity];
385
    }
386
387
    protected void didAdd(int index, Object object)
388
    {
389
      super.didAdd(index, object);
390
      if (index == size - 1)
391
      {
392
        loaded();
393
      }
394
      modified();
395
    }
396
397
    protected void didRemove(int index, Object object)
398
    {
399
      super.didRemove(index, object);
400
      modified();
401
    }
402
403
    protected void didSet(int index, Object newObject, Object oldObject)
404
    {
405
      super.didSet(index, newObject, oldObject);
406
      modified();
407
    }
408
409
    protected void didClear(int oldSize, Object [] oldData)
410
    {
411
      if (oldSize == 0)
412
      {
413
        loaded();
414
      }
415
      else
416
      {
417
        super.didClear(oldSize, oldData);
418
      }
419
    }
420
421
    protected void loaded()
422
    {
423
      if (!ResourceImpl.this.isLoaded())
424
      {
425
        Notification notification = ResourceImpl.this.setLoaded(true);
426
        if (notification != null)
427
        {
428
          ResourceImpl.this.eNotify(notification);
429
        }
430
      }
431
    }
432
433
    protected void modified()
434
    {
435
      if (isTrackingModification())
436
      {
437
        setModified(true);
438
      }
439
    }
440
  }
441
442
  /*
443
   * Javadoc copied from interface.
444
   */
445
  public EList getContents()
446
  {
447
    if (contents == null)
448
    {
449
      contents = new ContentsEList();
450
    }
451
    return contents;
452
  }
453
454
  /*
455
   * Javadoc copied from interface.
456
   */
457
  public TreeIterator getAllContents()
458
  {
459
    return
460
      new AbstractTreeIterator(this, false)
461
      {
462
        public Iterator getChildren(Object object)
463
        {
464
          return object == ResourceImpl.this ? ResourceImpl.this.getContents().iterator() : ((EObject)object).eContents().iterator();
465
        }
466
      };
467
  }
468
  
469
  protected TreeIterator getAllProperContents(EObject eObject)
470
  {
471
    return EcoreUtil.getAllProperContents(eObject, false);
472
  }
473
474
  protected TreeIterator getAllProperContents(List contents)
475
  {
476
    return  
477
      new ContentTreeIterator(contents, false)
478
      {
479
        public Iterator getChildren(Object object)
480
        {
481
          return object == this.object ? ((List)object).iterator() : new ProperContentIterator(((EObject)object));
482
        }
483
      };
484
  }
485
486
  /*
487
   * Javadoc copied from interface.
488
   */
489
  public EList getErrors()
490
  {
491
    if (errors == null)
492
    {
493
      errors =
494
        new NotifyingListImpl()
495
        {
496
          protected boolean isNotificationRequired()
497
          {
498
             return ResourceImpl.this.eNotificationRequired();
499
          }
500
501
          public Object getNotifier()
502
          {
503
            return ResourceImpl.this;
504
          }
505
506
          public int getFeatureID()
507
          {
508
            return RESOURCE__ERRORS;
509
          }
510
        };
511
    }
512
    return errors;
513
  }
514
515
  /*
516
   * Javadoc copied from interface.
517
   */
518
  public EList getWarnings()
519
  {
520
    if (warnings == null)
521
    {
522
      warnings =
523
        new NotifyingListImpl()
524
        {
525
          protected boolean isNotificationRequired()
526
          {
527
             return ResourceImpl.this.eNotificationRequired();
528
          }
529
530
          public Object getNotifier()
531
          {
532
            return ResourceImpl.this;
533
          }
534
535
          public int getFeatureID()
536
          {
537
            return RESOURCE__WARNINGS;
538
          }
539
        };
540
    }
541
    return warnings;
542
  }
543
544
  /**
545
   * Returns whether contents will be compressed.
546
   * This implementation returns <code>false</code>.
547
   * When this returns <code>true</code>,
548
   * {@link #save(OutputStream, Map)} and {@link #load(InputStream, Map)}
549
   * will zip compress and decompress contents.
550
   * @return whether contents will be compressed.
551
   * @see #newContentZipEntry
552
   * @see #isContentZipEntry(ZipEntry)
553
   */
554
  protected boolean useZip()
555
  {
556
    return false;
557
  }
558
559
560
  /**
561
   * Returns the URI fragment root segment for reaching the given direct content object.
562
   * This default implementation returns the position of the object, if there is more than one object,
563
   * otherwise, the empty string.
564
   * As a result, the URI fragment for a single root object will be <code>"/"</code>.
565
   * @return the URI fragment root segment for reaching the given direct content object.
566
   */
567
  protected String getURIFragmentRootSegment(EObject eObject)
568
  {
569
    List contents = getContents();
570
    return contents.size() > 1 ?
571
      Integer.toString(contents.indexOf(eObject)) :
572
      "";
573
  }
574
575
  /*
576
   * Javadoc copied from interface.
577
   */
578
  public String getURIFragment(EObject eObject)
579
  {
580
    String id = EcoreUtil.getID(eObject);
581
    if (id != null)
582
    {
583
      return id;
584
    }
585
    else
586
    {
587
      InternalEObject internalEObject = (InternalEObject)eObject;
588
      if (internalEObject.eDirectResource() == this)
589
      {
590
        return "/" + getURIFragmentRootSegment(eObject);
591
      }
592
      else
593
      {
594
        List uriFragmentPath = new ArrayList();
595
        for (InternalEObject container = internalEObject.eInternalContainer(); container != null; container = internalEObject.eInternalContainer())
596
        {
597
          uriFragmentPath.add(container.eURIFragmentSegment(internalEObject.eContainingFeature(), internalEObject));
598
          internalEObject = container;
599
          if (container.eDirectResource() == this)
600
          {
601
            break;
602
          }
603
        }
604
  
605
        StringBuffer result = new StringBuffer("/");
606
        result.append(getURIFragmentRootSegment(internalEObject));
607
  
608
        for (int i = uriFragmentPath.size() - 1; i >= 0; --i)
609
        {
610
          result.append('/');
611
          result.append(uriFragmentPath.get(i));
612
        }
613
        return result.toString();
614
      }
615
    }
616
  }
617
618
  /**
619
   * Returns the object associated with the URI fragment root segment.
620
   * This default implementation uses the position of the object;
621
   * an empty string is the same as <code>"0"</code>.
622
   * @return the object associated with the URI fragment root segment.
623
   */
624
  protected EObject getEObjectForURIFragmentRootSegment(String uriFragmentRootSegment)
625
  {
626
    int position =  0;
627
    if (uriFragmentRootSegment.length() > 0)
628
    {
629
      try
630
      {
631
        position = Integer.parseInt(uriFragmentRootSegment);
632
      }
633
      catch (NumberFormatException exception)
634
      {
635
        throw new WrappedException(exception);
636
      }
637
    }
638
639
    List contents = getContents();
640
    if (position < contents.size())
641
    {
642
      return (EObject)contents.get(position);
643
    }
644
    else
645
    {
646
      return null;
647
    }
648
  }
649
650
  /*
651
   * Javadoc copied from interface.
652
   */
653
  public EObject getEObject(String uriFragment)
654
  {
655
    int length = uriFragment.length();
656
    if (length > 0)
657
    {
658
      if (uriFragment.charAt(0) == '/')
659
      {
660
        ArrayList uriFragmentPath = new ArrayList(4);
661
        int start = 1;
662
        for (int i = 1; i < length; ++i)
663
        {
664
          if (uriFragment.charAt(i) == '/')
665
          {
666
            uriFragmentPath.add(start == i ? "" : uriFragment.substring(start, i));
667
            start = i + 1;
668
          }
669
        }
670
        uriFragmentPath.add(uriFragment.substring(start));
671
        return getEObject(uriFragmentPath);
672
      }
673
      else if (uriFragment.charAt(length - 1) == '?')
674
      {
675
        int index = uriFragment.lastIndexOf('?', length - 2);
676
        if (index > 0)
677
        {
678
          uriFragment = uriFragment.substring(0, index);
679
        }
680
      }
681
    }
682
    
683
    return getEObjectByID(uriFragment);
684
  }
685
686
  /**
687
   * Returns the object based on the fragment path as a list of Strings.
688
   */
689
  protected EObject getEObject(List uriFragmentPath)
690
  {
691
    int size = uriFragmentPath.size();
692
    EObject eObject = getEObjectForURIFragmentRootSegment(size == 0 ? "" : (String)uriFragmentPath.get(0));
693
    for (int i = 1; i < size && eObject != null; ++i)
694
    {
695
      eObject = ((InternalEObject)eObject).eObjectForURIFragmentSegment((String)uriFragmentPath.get(i));
696
    }
697
698
    return eObject;
699
  }
700
701
  /**
702
   * Returns the map used to cache the EObject that is identified by the {@link #getEObjectByID(String) value} 
703
   * of its ID feature.
704
   * @return the map used to cache the EObject that is identified by the value of its ID feature.
705
   * @see #setIntrinsicIDToEObjectMap
706
   */
707
  public Map getIntrinsicIDToEObjectMap()
708
  {
709
    return intrinsicIDToEObjectMap;
710
  }
711
712
  /**
713
   * Sets the map used to cache the EObject identified by the value of its ID feature.
714
   * This cache is only activated if the map is not <code>null</code>.  
715
   * The map will be lazily loaded by the {@link #getEObjectByID(String) getEObjectByID} method.
716
   * It is up to the client to clear the cache when it becomes invalid, 
717
   * e.g., when the ID of a previously mapped EObject is changed.
718
   * @param intrinsicIDToEObjectMap the new map or <code>null</code>.
719
   * @see #getIntrinsicIDToEObjectMap
720
   */
721
  public void setIntrinsicIDToEObjectMap(Map intrinsicIDToEObjectMap)
722
  {
723
    this.intrinsicIDToEObjectMap = intrinsicIDToEObjectMap;
724
  }
725
  
726
727
  /**
728
   * Returns the object based on the fragment as an ID.
729
   */
730
  protected EObject getEObjectByID(String id)
731
  {
732
    Map map = getIntrinsicIDToEObjectMap();
733
    if (map != null)
734
    {
735
      EObject eObject = (EObject)map.get(id);
736
      if (eObject != null)
737
      {
738
        return eObject;
739
      }
740
    }
741
    
742
    EObject result = null;
743
    for (TreeIterator i = getAllProperContents(getContents()); i.hasNext(); )
744
    {
745
      EObject eObject = (EObject)i.next();
746
      String eObjectId = EcoreUtil.getID(eObject);
747
      if (eObjectId != null)
748
      {
749
        if (map != null)
750
        {
751
          map.put(eObjectId, eObject);
752
        }
753
          
754
        if (eObjectId.equals(id))
755
        {
756
          result = eObject;
757
          if (map == null)
758
          {
759
            break;
760
          }
761
        }
762
      }
763
    }
764
765
    return result;
766
  }
767
768
  public void attached(EObject eObject)
769
  {   
770
    if (isAttachedDetachedHelperRequired())
771
    {
772
      attachedHelper(eObject);
773
      for (TreeIterator tree = getAllProperContents(eObject); tree.hasNext(); )
774
      {
775
        attachedHelper((EObject)tree.next());
776
      }
777
    }
778
  }
779
  
780
  protected boolean isAttachedDetachedHelperRequired()
781
  {
782
    return isTrackingModification() || getIntrinsicIDToEObjectMap() != null;
783
  }
784
785
  protected void attachedHelper(EObject eObject)
786
  {
787
    if (isTrackingModification())
788
    {
789
      eObject.eAdapters().add(modificationTrackingAdapter);
790
    }
791
    
792
    Map map = getIntrinsicIDToEObjectMap();
793
    if (map != null)
794
    {
795
      String id = EcoreUtil.getID(eObject);
796
      if (id != null)
797
      {
798
        map.put(id, eObject);
799
      }
800
    }    
801
  }
802
  
803
804
  /**
805
   * Adds modification tracking adapters to the object and it's content tree.
806
   * @param eObject the object.
807
   * @see #attached(EObject)
808
   * @deprecated since 2.1.0.  This method is not invoked anymore.  See 
809
   * {@link #attachedHelper(EObject)}.
810
   */
811
  final protected void addModificationTrackingAdapters(EObject eObject)
812
  {
813
  }
814
815
  public void detached(EObject eObject)
816
  {
817
    if (isAttachedDetachedHelperRequired())
818
    {
819
      detachedHelper(eObject);
820
      for (TreeIterator tree = getAllProperContents(eObject); tree.hasNext(); )
821
      {
822
        detachedHelper((EObject)tree.next());
823
      }
824
    }
825
  }
826
  
827
  protected void detachedHelper(EObject eObject)
828
  {
829
    Map map = getIntrinsicIDToEObjectMap();
830
    if (map != null)
831
    {
832
      String id = EcoreUtil.getID(eObject);
833
      if (id != null)
834
      {
835
        map.remove(id);
836
      }
837
    }
838
839
    if (isTrackingModification())
840
    {
841
      eObject.eAdapters().remove(modificationTrackingAdapter);
842
    }
843
  }  
844
845
  /**
846
   * Removes modification tracking adapters to the object and it's content tree.
847
   * @param eObject the object.
848
   * @see #detached(EObject)
849
   * @deprecated since 2.1.0.  This method is not invoked anymore.  See 
850
   * {@link #attachedHelper(EObject)}.
851
   */
852
  final protected void removeModificationTrackingAdapters(EObject eObject)
853
  {
854
  }
855
856
857
  /**
858
   * Returns the URI converter.
859
   * This typically gets the {@link ResourceSet#getURIConverter converter}
860
   * from the {@link #getResourceSet containing} resource set,
861
   * but it calls {@link #getDefaultURIConverter} when there is no containing resource set.
862
   * @return the URI converter.
863
   */
864
  protected URIConverter getURIConverter()
865
  {
866
    return
867
      getResourceSet() == null ?
868
        getDefaultURIConverter() :
869
        getResourceSet().getURIConverter();
870
  }
871
872
  /*
873
   * Javadoc copied from interface.
874
   */
875
  public void save(Map options) throws IOException
876
  {
877
    URIConverter uriConverter = getURIConverter();
878
    OutputStream outputStream = uriConverter.createOutputStream(getURI());
879
    try
880
    {
881
      save(outputStream, options);
882
    }
883
    finally
884
    {
885
      outputStream.close();
886
    }
887
  }
888
889
  /*
890
   * Javadoc copied from interface.
891
   */
892
  public void load(Map options) throws IOException
893
  {
894
    if (!isLoaded)
895
    {
896
      URIConverter uriConverter = getURIConverter();
897
      InputStream inputStream = uriConverter.createInputStream(getURI());
898
      try
899
      {
900
        load(inputStream, options);
901
      }
902
      finally
903
      {
904
        inputStream.close();
905
      }
906
    }
907
  }
908
909
  /**
910
   * Returns a new zip entry for {@link #save(OutputStream, Map) saving} the resource contents.
911
   * It is called by {@link #save(OutputStream, Map)} when writing {@link #useZip zipped} contents.
912
   * This implementation creates an entry called <code>ResourceContents</code>.
913
   * @return a new zip entry.
914
   * @see #isContentZipEntry(ZipEntry)
915
   */
916
  protected ZipEntry newContentZipEntry()
917
  {
918
    return new ZipEntry("ResourceContents");
919
  }
920
921
  /**
922
   * Saves the resource to the output stream using the specified options.
923
   * <p>
924
   * This implementation is <code>final</code>;
925
   * clients should override {@link #doSave doSave}.
926
   * </p>
927
   * @param options the save options.
928
   * @see #save(Map)
929
   * @see #doSave(OutputStream, Map)
930
   * @see #load(InputStream, Map)
931
   */
932
  public final void save(OutputStream outputStream, Map options) throws IOException
933
  {
934
    if (errors != null)
935
    {
936
      errors.clear();
937
    }
938
939
    if (warnings != null)
940
    {
941
      warnings.clear();
942
    }
943
944
    options = mergeMaps(options, defaultSaveOptions);
945
    URIConverter.Cipher cipher = options != null ? 
946
      (URIConverter.Cipher)options.get(Resource.OPTION_CIPHER) : 
947
      null;
948
      
949
    if (cipher != null)
950
    {
951
      try
952
      {
953
        outputStream = cipher.encrypt(outputStream);
954
      }
955
      catch (Exception e)
956
      {
957
        throw new IOWrappedException(e);
958
      }
959
    }
960
961
    ZipOutputStream zipOutputStream = null;
962
    if (useZip() || (options != null && Boolean.TRUE.equals(options.get(Resource.OPTION_ZIP))))
963
    {
964
      zipOutputStream = 
965
        new ZipOutputStream(outputStream)
966
        {
967
          public void finish() throws IOException
968
          {
969
            super.finish();
970
            def.end();
971
          }
972
973
          public void flush()
974
          {
975
          }
976
977
          public void close() throws IOException
978
          {
979
            try
980
            {
981
              super.flush();
982
            }
983
            catch (IOException exception)
984
            {
985
            }
986
            super.close();
987
          }
988
        };
989
      zipOutputStream.putNextEntry(newContentZipEntry());
990
      outputStream = zipOutputStream;
991
    }
992
        
993
    doSave(outputStream, options);
994
995
    if (cipher != null)
996
    {
997
      try
998
      {
999
        cipher.finish(outputStream);
1000
      }
1001
      catch (Exception e)
1002
      {
1003
        throw new IOWrappedException(e);
1004
      }
1005
    }
1006
    
1007
    setModified(false);
1008
1009
    if (zipOutputStream != null)
1010
    {
1011
      zipOutputStream.finish();
1012
    }
1013
  }
1014
1015
  /**
1016
   * Called to save the resource.
1017
   * This implementation throws an exception;
1018
   * clients must override it.
1019
   * @param outputStream the stream
1020
   * @param options the save options.
1021
   * @exception UnsupportedOperationException.
1022
   */
1023
  protected void doSave(OutputStream outputStream, Map options) throws IOException
1024
  {
1025
    throw new UnsupportedOperationException();
1026
  }
1027
1028
  /**
1029
   * Returns whether the given entry is the content entry for this resource.
1030
   * It is called by {@link #load(InputStream, Map)} when reading {@link #useZip zipped} contents.
1031
   * This implementation return <code>true</code>;
1032
   * i.e., the first entry will be read.
1033
   * @return whether the given entry is the content entry for this resource.
1034
   * @see #newContentZipEntry
1035
   */
1036
  protected boolean isContentZipEntry(ZipEntry zipEntry)
1037
  {
1038
    return true;
1039
  }
1040
1041
  /*
1042
   * Javadoc copied from interface.
1043
   */
1044
  public final void load(InputStream inputStream, Map options) throws IOException
1045
  {
1046
    if (!isLoaded)
1047
    {
1048
      Notification notification = setLoaded(true);
1049
      isLoading = true;
1050
1051
      if (errors != null)
1052
      {
1053
        errors.clear();
1054
      }
1055
1056
      if (warnings != null)
1057
      {
1058
        warnings.clear();
1059
      }
1060
1061
      try
1062
      {
1063
        if (useZip() || (options != null && Boolean.TRUE.equals(options.get(Resource.OPTION_ZIP))))
1064
        {
1065
          ZipInputStream zipInputStream = new ZipInputStream(inputStream);
1066
          while (zipInputStream.available() != 0)
1067
          {
1068
            ZipEntry zipEntry = zipInputStream.getNextEntry();
1069
            if (isContentZipEntry(zipEntry))
1070
            {
1071
              inputStream = zipInputStream;
1072
              break;
1073
            }
1074
          }
1075
        }
1076
1077
        options = mergeMaps(options, defaultLoadOptions);
1078
        URIConverter.Cipher cipher = options != null ?
1079
          (URIConverter.Cipher)options.get(Resource.OPTION_CIPHER) :
1080
          null;
1081
          
1082
        if (cipher != null)
1083
        {
1084
          try
1085
          {
1086
            inputStream = cipher.decrypt(inputStream);
1087
          }
1088
          catch (Exception e)
1089
          {
1090
            throw new IOWrappedException(e);
1091
          }
1092
        }
1093
        
1094
        doLoad(inputStream, options);
1095
        
1096
        if (cipher != null)
1097
        {
1098
          try
1099
          {
1100
            cipher.finish(inputStream);
1101
          }
1102
          catch (Exception e)
1103
          {
1104
            throw new IOWrappedException(e);
1105
          }
1106
        }        
1107
      }
1108
      finally
1109
      {
1110
        isLoading = false;
1111
1112
        if (notification != null)
1113
        {
1114
          eNotify(notification);
1115
        }
1116
  
1117
        setModified(false);
1118
      } 
1119
    }
1120
  }
1121
1122
  /**
1123
   * Called to load the resource.
1124
   * This implementation throws an exception;
1125
   * clients must override it.
1126
   * @param inputStream the stream
1127
   * @param options the load options.
1128
   * @exception UnsupportedOperationException.
1129
   */
1130
  protected void doLoad(InputStream inputStream, Map options) throws IOException
1131
  {
1132
    throw new UnsupportedOperationException();
1133
  }
1134
1135
  /*
1136
   * Javadoc copied from interface.
1137
   */
1138
  public boolean isLoaded()
1139
  {
1140
    return isLoaded;
1141
  }
1142
1143
  /*
1144
   * Javadoc copied from interface.
1145
   */
1146
  public boolean isLoading()
1147
  {
1148
    return isLoading;
1149
  }
1150
1151
  /**
1152
   * Called when the object is unloaded.
1153
   * This implementation 
1154
   * {@link InternalEObject#eSetProxyURI sets} the object to be a proxy 
1155
   * and clears the {@link #eAdapters adapters}.
1156
   */
1157
  protected void unloaded(InternalEObject internalEObject)
1158
  {
1159
    internalEObject.eSetProxyURI(uri.appendFragment(getURIFragment(internalEObject)));
1160
    internalEObject.eAdapters().clear();
1161
  }
1162
1163
  /**
1164
   * Sets the load state as indicated, and returns a notification, if {@link org.eclipse.emf.common.notify.impl.BasicNotifierImpl#eNotificationRequired required}.
1165
   * Clients are <b>not</b> expected to call this directly; it is managed by the implementation.
1166
   * @param isLoaded whether the resource is loaded.
1167
   * @return a notification.
1168
   */
1169
  protected Notification setLoaded(boolean isLoaded)
1170
  {
1171
    boolean oldIsLoaded = this.isLoaded;
1172
    this.isLoaded = isLoaded;
1173
1174
    if (eNotificationRequired())
1175
    {
1176
      Notification notification =
1177
        new NotificationImpl(Notification.SET, oldIsLoaded, isLoaded)
1178
        {
1179
          public Object getNotifier()
1180
          {
1181
            return ResourceImpl.this;
1182
          }
1183
          public int getFeatureID(Class expectedClass)
1184
          {
1185
            return RESOURCE__IS_LOADED;
1186
          }
1187
        };
1188
      return notification;
1189
    }
1190
    else
1191
    {
1192
      return null;
1193
    }
1194
  }
1195
1196
  /**
1197
   * Does all the work of unloading the resource.
1198
   * It calls {@link #unloaded unloaded} for each object it the content {@link #getAllContents tree},
1199
   * and clears the {@link #getContents contents}, {@link #getErrors errors}, and {@link #getWarnings warnings}.
1200
   */
1201
  protected void doUnload()
1202
  {
1203
    Iterator allContents = getAllProperContents(new ArrayList(getContents()));
1204
1205
    // This guard is needed to ensure that clear doesn't make the resource become loaded.
1206
    //
1207
    if (!getContents().isEmpty())
1208
    {
1209
      getContents().clear();
1210
    }
1211
    getErrors().clear();
1212
    getWarnings().clear();
1213
1214
    while (allContents.hasNext())
1215
    {
1216
      unloaded((InternalEObject)allContents.next());
1217
    }
1218
  }
1219
1220
  /*
1221
   * Javadoc copied from interface.
1222
   */
1223
  public final void unload()
1224
  {
1225
    if (isLoaded)
1226
    {
1227
      Notification notification = setLoaded(false);
1228
      doUnload();
1229
      if (notification != null)
1230
      {
1231
        eNotify(notification);
1232
      }
1233
    }
1234
  }
1235
1236
  /**
1237
   * An adapter implementation for tracking resource modification.
1238
   */
1239
  protected class ModificationTrackingAdapter extends AdapterImpl
1240
  {
1241
    public void notifyChanged(Notification notification)
1242
    {
1243
      switch (notification.getEventType())
1244
      {
1245
        case Notification.SET:
1246
        case Notification.UNSET:
1247
        case Notification.MOVE:
1248
        {
1249
          if (!notification.isTouch())
1250
          {
1251
            setModified(true);
1252
          }
1253
          break;
1254
        }
1255
        case Notification.ADD:
1256
        case Notification.REMOVE:
1257
        case Notification.ADD_MANY:
1258
        case Notification.REMOVE_MANY:
1259
        {
1260
          setModified(true);
1261
          break;
1262
        }
1263
      }
1264
    }
1265
  }
1266
1267
  /*
1268
   * Javadoc copied from interface.
1269
   */
1270
  public boolean isTrackingModification()
1271
  {
1272
    return modificationTrackingAdapter != null;
1273
  }
1274
1275
  /*
1276
   * Javadoc copied from interface.
1277
   */
1278
  public void setTrackingModification(boolean isTrackingModification)
1279
  {
1280
    boolean oldIsTrackingModification = modificationTrackingAdapter != null;
1281
1282
    if (oldIsTrackingModification != isTrackingModification)
1283
    {
1284
      if (isTrackingModification)
1285
      {
1286
        modificationTrackingAdapter = createModificationTrackingAdapter();
1287
        
1288
        for (TreeIterator i = getAllProperContents(getContents()); i.hasNext(); )
1289
        {
1290
          EObject eObject = (EObject)i.next();
1291
          eObject.eAdapters().add(modificationTrackingAdapter);
1292
        }
1293
      }
1294
      else
1295
      {
1296
        Adapter oldModificationTrackingAdapter = modificationTrackingAdapter;
1297
        modificationTrackingAdapter = null;
1298
        
1299
        for (TreeIterator i = getAllProperContents(getContents()); i.hasNext(); )
1300
        {
1301
          EObject eObject = (EObject)i.next();
1302
          eObject.eAdapters().remove(oldModificationTrackingAdapter);
1303
        }
1304
      }
1305
    }
1306
1307
    if (eNotificationRequired())
1308
    {
1309
      Notification notification =
1310
        new NotificationImpl(Notification.SET, oldIsTrackingModification, isTrackingModification)
1311
        {
1312
          public Object getNotifier()
1313
          {
1314
            return ResourceImpl.this;
1315
          }
1316
          public int getFeatureID(Class expectedClass)
1317
          {
1318
            return RESOURCE__IS_TRACKING_MODIFICATION;
1319
          }
1320
        };
1321
      eNotify(notification);
1322
    }
1323
  }
1324
1325
1326
  /**
1327
   * Creates a modification tracking adapter.
1328
   * This implementation creates a {@link ResourceImpl.ModificationTrackingAdapter}.
1329
   * Clients may override this to any adapter.
1330
   * @see #modificationTrackingAdapter
1331
   * @see #isTrackingModification
1332
   */
1333
  protected Adapter createModificationTrackingAdapter()
1334
  {
1335
    return new ModificationTrackingAdapter();
1336
  }
1337
1338
  /*
1339
   * Javadoc copied from interface.
1340
   */
1341
  public boolean isModified()
1342
  {
1343
    return isModified;
1344
  }
1345
4
1346
  /*
5
public class ResourceImpl {
1347
   * Javadoc copied from interface.
1348
   */
1349
  public void setModified(boolean isModified)
1350
  {
1351
    boolean oldIsModified = this.isModified;
1352
    this.isModified = isModified;
1353
    if (eNotificationRequired())
1354
    {
1355
      Notification notification =
1356
        new NotificationImpl(Notification.SET, oldIsModified, isModified)
1357
        {
1358
          public Object getNotifier()
1359
          {
1360
            return ResourceImpl.this;
1361
          }
1362
          public int getFeatureID(Class expectedClass)
1363
          {
1364
            return RESOURCE__IS_MODIFIED;
1365
          }
1366
        };
1367
      eNotify(notification);
1368
    }
1369
  }
1370
6
1371
  /**
7
	public ResourceImpl(URI uri) {
1372
   * If an implementation uses IDs and stores the IDs as part of the resource
8
		throw new UnsupportedOperationException();
1373
   * rather than as objects, this method should return a string representation of
9
	}
1374
   * the ID to object mapping, which might be implemented as a Java Map.
1375
   * @return a string representation of the ID to object mapping
1376
   */
1377
  public String toKeyString()
1378
  {
1379
    StringBuffer result = new StringBuffer("Key type: ");
1380
    result.append(getClass().toString());
1381
    return result.toString();
1382
  }
1383
10
1384
  public String toString()
1385
  {
1386
    return
1387
      getClass().getName() + '@' + Integer.toHexString(hashCode()) +
1388
        " uri='" + uri + "'";
1389
  }
1390
}
11
}
(-)src/org/eclipse/emf/ecore/resource/impl/URIMappingRegistryImpl.java (-251 / +2 lines)
Lines 1-256 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: URIMappingRegistryImpl.java,v 1.2 2005/06/08 06:20:10 nickb Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
1
package org.eclipse.emf.ecore.resource.impl;
18
2
19
20
import java.util.List;
21
import java.util.Map;
22
23
import org.eclipse.emf.common.util.BasicEList;
24
import org.eclipse.emf.common.util.BasicEMap;
3
import org.eclipse.emf.common.util.BasicEMap;
25
import org.eclipse.emf.common.util.URI;
26
27
28
/**
29
 * An extensible implementation of a URI mapping registry.
30
 */
31
public class URIMappingRegistryImpl extends BasicEMap 
32
{
33
  /**
34
   * The implementation of the global mapping registry.
35
   * @see org.eclipse.emf.ecore.resource.URIConverter#URI_MAP
36
   */
37
  public static final URIMappingRegistryImpl INSTANCE = new URIMappingRegistryImpl();
38
39
  /**
40
   * A list of lists of prefix URIs; 
41
   * it is indexed by segment count to yield a list of prefixes of that length.
42
   */
43
  protected BasicEList prefixMaps = new BasicEList();
44
45
  /**
46
   * Creates an instance.
47
   */
48
  public URIMappingRegistryImpl()
49
  {
50
  }
51
52
  /**
53
   * Creates an {@link MappingEntryImpl}.
54
   */
55
  protected Entry newEntry(int hash, Object key, Object value)
56
  {
57
    validateKey(key);
58
    validateValue(value);
59
    return new MappingEntryImpl(hash, key, value);
60
  }
61
62
  /**
63
   * An extended implementation that maintains a bit 
64
   * indicating if the entry represents a folder to folder mapping.
65
   */
66
  protected class MappingEntryImpl extends EntryImpl
67
  {
68
    /**
69
     * The indicator whether this entry represents a folder to folder mapping.
70
     */
71
    public boolean isPrefixMapEntry;
72
73
    /**
74
     * Creates an instance.
75
     */
76
    public MappingEntryImpl(int hash, Object key, Object value)
77
    {
78
      super(hash, key, value);
79
      determineEntryType();
80
    }
81
82
    /**
83
     * Computes whether this entry represents a folder to folder mapping.
84
     */
85
    public void determineEntryType()
86
    {
87
      isPrefixMapEntry = ((URI)key).isPrefix() && ((URI)value).isPrefix();
88
    }
89
  }
90
91
  /**
92
   * Returns the remapped URI, or the URI itself.
93
   * This implementation uses the map to find an exact match.
94
   * Failing that, it matches the {@link #prefixMaps} prefixes in order.
95
   * And failing that, it delegates to {@link #delegatedGetURI(URI) delegatedGetURI}.
96
   * @param uri the URI to remap.
97
   * @return the remapped URI, or the URI itself.
98
   */
99
  public URI getURI(URI uri)
100
  {
101
    URI result = (URI)get(uri);
102
    if (result == null)
103
    {
104
      if (prefixMaps != null)
105
      {
106
        for (int i = Math.min(prefixMaps.size() - 1, uri.segmentCount()); i >= 0; --i)
107
        {
108
          List prefixes = (List)prefixMaps.get(i);
109
          for (int j = prefixes.size() - 1; j >= 0; --j)
110
          {
111
            Entry entry = (Entry)prefixes.get(j);
112
            result = uri.replacePrefix((URI)entry.getKey(), (URI)entry.getValue());
113
114
            if (result != null)
115
            {
116
              return result;
117
            }
118
          }
119
        }
120
      }
121
122
      result = delegatedGetURI(uri);
123
    }
124
125
    return result;
126
  }
127
128
  /**
129
   * Returns the mapped URI for the given URI, when standard alternatives fail.
130
   * <p>
131
   * This implementation returns <code>uri</code>.
132
   * </p>
133
   * @param uri the URI.
134
   * @return the mapped URI.
135
   * @see #getURI(URI)
136
   */
137
  protected URI delegatedGetURI(URI uri)
138
  {
139
    return uri;
140
  }
141
142
  /**
143
   * A map that is a {@link URIConverterImpl.URIMap}.
144
   */
145
  protected class URIMapImpl extends DelegatingMap implements URIConverterImpl.URIMap
146
  {
147
    /**
148
     * Creates an isntance.
149
     */
150
    public URIMapImpl()
151
    {
152
    }
153
154
    /**
155
     * Returns the remapped URI, or the URI itself.
156
     * This implementation delegates to the containing {@link URIMappingRegistryImpl}.
157
     * @param uri the URI to remap.
158
     * @return the remapped URI, or the URI itself.
159
     */
160
    public URI getURI(URI uri)
161
    {
162
      return URIMappingRegistryImpl.this.getURI(uri);
163
    }
164
  }
165
166
  /** 
167
   * Returns a map view that implements {@link URIConverterImpl.URIMap}.
168
   */
169
  public Map map()
170
  {
171
    if (view == null)
172
    {
173
      view = new View();
174
    }
175
    if (view.map == null)
176
    {
177
      view.map = new URIMapImpl();
178
    }
179
180
    return view.map;
181
  }
182
183
  /**
184
   * Validates that the key is a URI.
185
   */
186
  protected void validateKey(Object key)
187
  {
188
    if (!(key instanceof URI))
189
    {
190
      throw new IllegalArgumentException();
191
    }
192
  }
193
194
  /**
195
   * Validates that the value is a URI.
196
   */
197
  protected void validateValue(Object value)
198
  {
199
    if (!(value instanceof URI))
200
    {
201
      throw new IllegalArgumentException();
202
    }
203
  }
204
205
  /**
206
   * Checks for folder mappings to populate the {@link #prefixMaps prefix maps}.
207
   */
208
  protected void didAdd(Entry entry)
209
  {
210
    if (((MappingEntryImpl)entry).isPrefixMapEntry)
211
    {
212
      int length = ((URI)entry.getKey()).segmentCount();
213
      if (prefixMaps == null)
214
      {
215
        prefixMaps = new BasicEList();
216
      }
217
218
      for (int i = prefixMaps.size() - 1; i <= length; ++i)
219
      {
220
        prefixMaps.add(new BasicEList());
221
      }
222
223
      ((List)prefixMaps.get(length)).add(entry);
224
    }
225
  }
226
227
  /**
228
   * Checks for folder mappings to update the {@link #prefixMaps prefix maps}.
229
   */
230
  protected void didModify(Entry entry, Object oldValue)
231
  {
232
    didRemove(entry);
233
    ((MappingEntryImpl)entry).determineEntryType();
234
    didAdd(entry);
235
  }
236
237
  /**
238
   * Checks for folder mappings to cleanup the {@link #prefixMaps prefix maps}.
239
   */
240
  protected void didRemove(Entry entry)
241
  {
242
    if (((MappingEntryImpl)entry).isPrefixMapEntry)
243
    {
244
      int length = ((URI)entry.getKey()).segmentCount();
245
      ((List)prefixMaps.get(length)).remove(entry);
246
    }
247
  }
248
4
249
  /**
5
public class URIMappingRegistryImpl extends BasicEMap {
250
   * Discards all the {@link #prefixMaps prefix maps}.
6
	public static final URIMappingRegistryImpl INSTANCE = new URIMappingRegistryImpl();
251
   */
252
  protected void didClear(BasicEList [] oldEntryData)
253
  {
254
    prefixMaps = null;
255
  }
256
}
7
}
(-)src/org/eclipse/emf/ecore/resource/impl/CryptoCipherImpl.java (-91 lines)
Removed Link Here
1
package org.eclipse.emf.ecore.resource.impl;
2
3
import java.io.InputStream;
4
import java.io.OutputStream;
5
6
import javax.crypto.Cipher;
7
import javax.crypto.CipherInputStream;
8
import javax.crypto.CipherOutputStream;
9
import javax.crypto.SecretKey;
10
import javax.crypto.SecretKeyFactory;
11
import javax.crypto.spec.DESKeySpec;
12
13
import org.eclipse.emf.ecore.resource.URIConverter;
14
15
/**
16
 * <p>EMF default implementation for the {@link URIConverter.Cipher} interface.  
17
 * This is an example of how this class can be used:<p>
18
 * <pre>Map options = new HashMap();
19
    options.put(Resource.OPTION_CIPHER, 
20
                new CryptoCipherImpl("a very long key indeed"));
21
    resource.save(options);
22
    resource.load(options);</pre>
23
 * 
24
 */
25
public class CryptoCipherImpl implements URIConverter.Cipher
26
{
27
  public static class LocalCipherOutputStream extends CipherOutputStream
28
  {
29
    protected Cipher cipher;
30
    
31
    public LocalCipherOutputStream(OutputStream os, Cipher cipher)
32
    {
33
      super(os, cipher);
34
      this.cipher = cipher;
35
    }
36
    
37
    public void finish() throws Exception
38
    {
39
      write(cipher.doFinal());
40
      flush();
41
    }
42
  }
43
  
44
  protected static final String ENCRYPTION_SCHEME = "DES";
45
  protected static final String UNICODE_FORMAT = "UTF-8";
46
47
  protected String key;
48
  
49
  public CryptoCipherImpl()
50
  {
51
    this(null);
52
  }
53
  
54
  public CryptoCipherImpl(String key)
55
  {
56
    this.key = key;
57
  }
58
59
  public OutputStream encrypt(OutputStream outputStream) throws Exception
60
  {
61
    Cipher cipher = Cipher.getInstance(ENCRYPTION_SCHEME);
62
    cipher.init(Cipher.ENCRYPT_MODE, getKey());
63
    return new CipherOutputStream(outputStream, cipher);
64
  }
65
  
66
  public void finish(OutputStream outputStream) throws Exception
67
  {
68
    if (outputStream instanceof LocalCipherOutputStream)
69
    {
70
      ((LocalCipherOutputStream)outputStream).finish();
71
    }
72
  }
73
74
  public InputStream decrypt(InputStream inputStream) throws Exception
75
  {
76
    Cipher cipher = Cipher.getInstance(ENCRYPTION_SCHEME);
77
    cipher.init(Cipher.DECRYPT_MODE, getKey());
78
    return new CipherInputStream(inputStream, cipher);
79
  }
80
  
81
  public void finish(InputStream inputStream) throws Exception
82
  {
83
  }
84
85
  protected SecretKey getKey() throws Exception
86
  {
87
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ENCRYPTION_SCHEME);
88
    DESKeySpec keySpec = new DESKeySpec(key.getBytes(UNICODE_FORMAT));
89
    return keyFactory.generateSecret(keySpec);
90
  }
91
}
(-)src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java (-582 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ResourceSetImpl.java,v 1.8 2006/05/01 16:22:30 marcelop Exp $
16
 */
17
package org.eclipse.emf.ecore.resource.impl;
18
19
20
import java.io.IOException;
21
import java.util.Collections;
22
import java.util.HashMap;
23
import java.util.Iterator;
24
import java.util.List;
25
import java.util.ListIterator;
26
import java.util.Map;
27
28
import org.eclipse.emf.common.notify.AdapterFactory;
29
import org.eclipse.emf.common.notify.NotificationChain;
30
import org.eclipse.emf.common.notify.impl.NotifierImpl;
31
import org.eclipse.emf.common.notify.impl.NotifyingListImpl;
32
import org.eclipse.emf.common.util.BasicEList;
33
import org.eclipse.emf.common.util.EList;
34
import org.eclipse.emf.common.util.TreeIterator;
35
import org.eclipse.emf.common.util.URI;
36
import org.eclipse.emf.common.util.WrappedException;
37
import org.eclipse.emf.ecore.EObject;
38
import org.eclipse.emf.ecore.EPackage;
39
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
40
import org.eclipse.emf.ecore.resource.Resource;
41
import org.eclipse.emf.ecore.resource.ResourceSet;
42
import org.eclipse.emf.ecore.resource.URIConverter;
43
import org.eclipse.emf.ecore.util.EcoreUtil;
44
import org.eclipse.emf.ecore.util.InternalEList;
45
46
47
/**
48
 * An extensible resource set implementation.
49
 * <p>
50
 * The following configuration and control mechanisms are provided:
51
 * <ul>
52
 *   <li><b>Resolve</b></li>
53
 *   <ul>
54
 *     <li>{@link #delegatedGetResource(URI, boolean)}</li>
55
 *     <li>{@link #getEObject(URI, boolean)}</li>
56
 *   </ul>
57
 *   <li><b>Demand</b></li>
58
 *   <ul>
59
 *     <li>{@link #demandCreateResource(URI)}</li>
60
 *     <li>{@link #demandLoad(Resource)}</li>
61
 *     <li>{@link #demandLoadHelper(Resource)}</li>
62
 *   </ul>
63
 * </ul> 
64
 * </p>
65
 */
66
public class ResourceSetImpl extends NotifierImpl implements ResourceSet
67
{
68
  /**
69
   * The contained resources.
70
   * @see #getResources
71
   */
72
  protected EList resources;
73
74
  /**
75
   * The registered adapter factories.
76
   * @see #getAdapterFactories
77
   */
78
  protected EList adapterFactories;
79
80
  /**
81
   * The load options.
82
   * @see #getLoadOptions
83
   */
84
  protected Map loadOptions;
85
86
  /**
87
   * The local resource factory registry.
88
   * @see #getResourceFactoryRegistry
89
   */
90
  protected Resource.Factory.Registry resourceFactoryRegistry;
91
92
  /**
93
   * The URI converter.
94
   * @see #getURIConverter
95
   */
96
  protected URIConverter uriConverter;
97
98
  /**
99
   * The local package registry.
100
   * @see #getPackageRegistry
101
   */
102
  protected EPackage.Registry packageRegistry;
103
  
104
  /**
105
   * A map to cache the resource associated with a specific URI.
106
   * @see #setURIResourceMap(Map)
107
   */
108
  protected Map uriResourceMap;
109
110
  /**
111
   * Creates an empty instance.
112
   */
113
  public ResourceSetImpl()
114
  {
115
  }
116
  
117
  /**
118
   * Returns the map used to cache the resource {@link #getResource(URI, boolean) associated} with a specific URI.
119
   * @return the map used to cache the resource associated with a specific URI.
120
   * @see #setURIResourceMap
121
   */
122
  public Map getURIResourceMap()
123
  {
124
    return uriResourceMap;
125
  }
126
127
  /**
128
   * Sets the map used to cache the resource associated with a specific URI.
129
   * This cache is only activated if the map is not <code>null</code>.  
130
   * The map will be lazily loaded by the {@link #getResource(URI, boolean) getResource} method.
131
   * It is up to the client to clear the cache when it becomes invalid, 
132
   * e.g., when the URI of a previously mapped resource is changed.
133
   * @param uriResourceMap the new map or <code>null</code>.
134
   * @see #getURIResourceMap
135
   */
136
  public void setURIResourceMap(Map uriResourceMap)
137
  {
138
    this.uriResourceMap = uriResourceMap;
139
  }
140
  
141
  /*
142
   * Javadoc copied from interface.
143
   */
144
  public EList getResources()
145
  {
146
    if (resources == null)
147
    {
148
      resources = new ResourcesEList();
149
    }
150
    return resources;
151
  }
152
153
  /*
154
   * Javadoc copied from interface.
155
   */
156
  public TreeIterator getAllContents()
157
  {
158
    TreeIterator result = EcoreUtil.getAllContents(Collections.singleton(this));
159
    result.next();
160
    return result;
161
  }
162
163
  /*
164
   * Javadoc copied from interface.
165
   */
166
  public EList getAdapterFactories()
167
  {
168
    if (adapterFactories == null)
169
    {
170
      adapterFactories = 
171
        new BasicEList()
172
        {
173
          protected boolean useEquals()
174
          {
175
            return false;
176
          }
177
178
          protected boolean isUnique()
179
          {
180
            return true;
181
          }
182
183
          protected Object [] newData(int capacity)
184
          {
185
            return new AdapterFactory [capacity];
186
          }
187
        };
188
    }
189
    return adapterFactories;
190
  }
191
192
  /*
193
   * Javadoc copied from interface.
194
   */
195
  public Map getLoadOptions()
196
  {
197
    if (loadOptions == null)
198
    {
199
      loadOptions = new HashMap();
200
    }
201
202
    return loadOptions;
203
  }
204
205
  /*
206
   * Javadoc copied from interface.
207
   */
208
  public EObject getEObject(URI uri, boolean loadOnDemand)
209
  {
210
    Resource resource = getResource(uri.trimFragment(), loadOnDemand);
211
    if (resource != null)
212
    {
213
      return resource.getEObject(uri.fragment());
214
    }
215
    else
216
    {
217
      return null;
218
    }
219
  }
220
221
  /**
222
   * Creates a new resource appropriate for the URI.
223
   * It is called by {@link #getResource(URI, boolean) getResource(URI, boolean)} 
224
   * when a URI that doesn't exist as a resource is demand loaded.
225
   * This implementation simply calls {@link #createResource(URI) createResource(URI)}.
226
   * Clients may extend this as appropriate.
227
   * @param uri the URI of the resource to create.
228
   * @return a new resource.
229
   * @see #getResource(URI, boolean)
230
   */
231
  protected Resource demandCreateResource(URI uri)
232
  {
233
    return createResource(uri);
234
  }
235
236
  /**
237
   * Loads the given resource.
238
   * It is called by {@link #demandLoadHelper(Resource) demandLoadHelper(Resource)} 
239
   * to perform a demand load.
240
   * This implementation simply calls <code>resource.</code>{@link Resource#load(Map) load}({@link #getLoadOptions() getLoadOptions}()).
241
   * Clients may extend this as appropriate.
242
   * @param resource  a resource that isn't loaded.
243
   * @exception IOException if there are serious problems loading the resource.
244
   * @see #getResource(URI, boolean)
245
   * @see #demandLoadHelper(Resource)
246
   */
247
  protected void demandLoad(Resource resource) throws IOException
248
  {
249
    resource.load(getLoadOptions());
250
  }
251
  
252
  /**
253
   * Demand loads the given resource using {@link #demandLoad(Resource)} 
254
   * and {@link WrappedException wraps} any {@link IOException} as a runtime exception. 
255
   * It is called by {@link #getResource(URI, boolean) getResource(URI, boolean)} 
256
   * to perform a demand load.
257
   * @param resource a resource that isn't loaded.
258
   * @see #demandLoad(Resource)
259
   */
260
  protected void demandLoadHelper(Resource resource)
261
  {
262
    try
263
    {
264
      demandLoad(resource);
265
    }
266
    catch (IOException exception)
267
    {
268
      handleDemandLoadException(resource, exception);
269
    }    
270
  }
271
  
272
  /**
273
   * Handles the exception thrown during demand load 
274
   * by recording it as an error diagnostic 
275
   * and throwing a wrapping runtime exception.
276
   * @param resource the resource that threw an exception while loading.
277
   * @param resource the exception thrown from the resource while loading.
278
   * @see #demandLoadHelper(Resource)
279
   */
280
  protected void handleDemandLoadException(Resource resource, IOException exception) throws RuntimeException
281
  {
282
    final String location = resource.getURI() == null ? null : resource.getURI().toString();
283
    class DiagnosticWrappedException extends WrappedException implements Resource.Diagnostic
284
    {
285
      public DiagnosticWrappedException(Exception exception)
286
      {
287
        super(exception);
288
      }
289
290
      public String getLocation()
291
      {
292
        return location;
293
      }
294
295
      public int getColumn()
296
      {
297
        return 0;
298
      }
299
300
      public int getLine()
301
      {
302
        return 0;
303
      }
304
    };
305
    
306
    Exception cause = exception instanceof Resource.IOWrappedException ? (Exception)exception.getCause() : exception;
307
    WrappedException wrappedException = new DiagnosticWrappedException(cause);
308
    
309
    if (resource.getErrors().isEmpty())
310
    {
311
      resource.getErrors().add(exception instanceof Resource.Diagnostic ? (Exception)exception : (Exception)wrappedException);
312
    }
313
    
314
    throw wrappedException;
315
  }
316
317
  /**
318
   * Returns a resolved resource available outside of the resource set.
319
   * It is called by {@link #getResource(URI, boolean) getResource(URI, boolean)} 
320
   * after it has determined that the URI cannot be resolved 
321
   * based on the existing contents of the resource set.
322
   * This implementation looks up the URI in the {#getPackageRegistry() local} package registry.
323
   * Clients may extend this as appropriate.
324
   * @param uri the URI
325
   * @param loadOnDemand whether demand loading is required.
326
   */
327
  protected Resource delegatedGetResource(URI uri, boolean loadOnDemand)
328
  {
329
    EPackage ePackage = getPackageRegistry().getEPackage(uri.toString());
330
    return ePackage == null ? null : ePackage.eResource();
331
  }
332
333
  /*
334
   * Javadoc copied from interface.
335
   */
336
  public Resource getResource(URI uri, boolean loadOnDemand)
337
  {
338
    Map map = getURIResourceMap();
339
    if (map != null)
340
    {
341
      Resource resource = (Resource)map.get(uri);
342
      if (resource != null)
343
      {
344
        if (loadOnDemand && !resource.isLoaded())
345
        {
346
          demandLoadHelper(resource);
347
        }        
348
        return resource;
349
      }
350
    }
351
    
352
    URIConverter theURIConverter = getURIConverter();
353
    URI normalizedURI = theURIConverter.normalize(uri);
354
    for (Iterator i = getResources().iterator(); i.hasNext(); )
355
    {
356
      Resource resource = (Resource)i.next();
357
      if (theURIConverter.normalize(resource.getURI()).equals(normalizedURI))
358
      {
359
        if (loadOnDemand && !resource.isLoaded())
360
        {
361
          demandLoadHelper(resource);
362
        }
363
        
364
        if (map != null)
365
        {
366
          map.put(uri, resource);
367
        } 
368
        return resource;
369
      }
370
    }
371
    
372
    Resource delegatedResource = delegatedGetResource(uri, loadOnDemand);
373
    if (delegatedResource != null)
374
    {
375
      if (map != null)
376
      {
377
        map.put(uri, delegatedResource);
378
      }
379
      return delegatedResource;
380
    }
381
382
    if (loadOnDemand)
383
    {
384
      Resource resource = demandCreateResource(uri);
385
      if (resource == null)
386
      {
387
        throw new RuntimeException("Cannot create a resource for '" + uri + "'; a registered resource factory is needed");
388
      }
389
390
      demandLoadHelper(resource);
391
392
      if (map != null)
393
      {
394
        map.put(uri, resource);
395
      }      
396
      return resource;
397
    }
398
399
    return null;
400
  }
401
402
  /*
403
   * Javadoc copied from interface.
404
   */
405
  public Resource createResource(URI uri)
406
  {
407
    Resource.Factory resourceFactory = getResourceFactoryRegistry().getFactory(uri);
408
    if (resourceFactory != null)
409
    {
410
      Resource result = resourceFactory.createResource(uri);
411
      getResources().add(result);
412
      return result;
413
    }
414
    else
415
    {
416
      return null;
417
    }
418
  }
419
420
  /*
421
   * Javadoc copied from interface.
422
   */
423
  public Resource.Factory.Registry getResourceFactoryRegistry()
424
  {
425
    if (resourceFactoryRegistry == null)
426
    {
427
      resourceFactoryRegistry =
428
        new ResourceFactoryRegistryImpl()
429
        {
430
          public Resource.Factory delegatedGetFactory(URI uri)
431
          {
432
            return Resource.Factory.Registry.INSTANCE.getFactory(uri);
433
          }
434
        };
435
    }
436
    return resourceFactoryRegistry;
437
  }
438
439
  /*
440
   * Javadoc copied from interface.
441
   */
442
  public void setResourceFactoryRegistry(Resource.Factory.Registry resourceFactoryRegistry)
443
  {
444
    this.resourceFactoryRegistry = resourceFactoryRegistry;
445
  }
446
447
  /*
448
   * Javadoc copied from interface.
449
   */
450
  public URIConverter getURIConverter()
451
  {
452
    if (uriConverter == null)
453
    {
454
      uriConverter = new URIConverterImpl();
455
    }
456
    return uriConverter;
457
  }
458
459
  /*
460
   * Javadoc copied from interface.
461
   */
462
  public void setURIConverter(URIConverter uriConverter)
463
  {
464
    this.uriConverter = uriConverter;
465
  }
466
467
  /*
468
   * Javadoc copied from interface.
469
   */
470
  public EPackage.Registry getPackageRegistry()
471
  {
472
    if (packageRegistry == null)
473
    {
474
      packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
475
    }
476
    return packageRegistry;
477
  }
478
479
  /*
480
   * Javadoc copied from interface.
481
   */
482
  public void setPackageRegistry(EPackage.Registry packageRegistry)
483
  {
484
    this.packageRegistry = packageRegistry;
485
  }
486
487
488
  /**
489
   * A notifying list implementation for supporting {@link ResourceSet#getResources}.
490
   */
491
  protected class ResourcesEList extends NotifyingListImpl implements InternalEList
492
  {
493
    protected boolean isNotificationRequired()
494
    {
495
      return ResourceSetImpl.this.eNotificationRequired();
496
    }
497
498
    protected Object [] newData(int capacity)
499
    {
500
      return new Resource [capacity];
501
    }
502
503
    public Object getNotifier()
504
    {
505
      return ResourceSetImpl.this;
506
    }
507
508
    public int getFeatureID()
509
    {
510
      return RESOURCE_SET__RESOURCES;
511
    }
512
513
    protected boolean useEquals()
514
    {
515
      return false;
516
    }
517
518
    protected boolean hasInverse()
519
    {
520
      return true;
521
    }
522
523
    protected boolean isUnique()
524
    {
525
      return true;
526
    }
527
528
    protected NotificationChain inverseAdd(Object object, NotificationChain notifications)
529
    {
530
      Resource.Internal resource = (Resource.Internal)object;
531
      return resource.basicSetResourceSet(ResourceSetImpl.this, notifications);
532
    }
533
534
    protected NotificationChain inverseRemove(Object object, NotificationChain notifications)
535
    {
536
      Resource.Internal resource = (Resource.Internal)object;
537
      Map map = getURIResourceMap();
538
      if (map != null)
539
      {
540
        for (Iterator i = map.values().iterator(); i.hasNext();)
541
        {
542
          if (resource == i.next())
543
          {
544
            i.remove();
545
          }
546
        }
547
      }
548
      return resource.basicSetResourceSet(null, notifications);
549
    }
550
551
    public Iterator basicIterator()
552
    {
553
      return super.basicIterator();
554
    }
555
556
    public ListIterator basicListIterator()
557
    {
558
      return super.basicListIterator();
559
    }
560
  
561
    public ListIterator basicListIterator(int index)
562
    {
563
      return super.basicListIterator(index);
564
    }
565
566
    public List basicList()
567
    {
568
      return super.basicList();
569
    }
570
  }
571
572
  /**
573
   * Returns a standard label with the list of resources.
574
   * @return the string form.
575
   */
576
  public String toString()
577
  {
578
    return 
579
      getClass().getName() +  '@' + Integer.toHexString(hashCode()) + 
580
        " resources=" + (resources == null ? "[]" : resources.toString());
581
  }
582
}
(-)src/org/eclipse/emf/ecore/xml/type/XMLTypeFactory.java (-136 / +136 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.xml.type;
17
package org.eclipse.emf.ecore.xml.type;
18
18
19
import java.math.BigDecimal;
19
//import java.math.BigDecimal;
20
import java.math.BigInteger;
20
//import java.math.BigInteger;
21
21
22
import java.util.List;
22
import java.util.List;
23
23
Lines 248-272 Link Here
248
   */
248
   */
249
  String convertDateTime(Object instanceValue);
249
  String convertDateTime(Object instanceValue);
250
250
251
  /**
251
//  /**
252
   * Returns an instance of data type '<em>Decimal</em>' corresponding the given literal.
252
//   * Returns an instance of data type '<em>Decimal</em>' corresponding the given literal.
253
   * <!-- begin-user-doc -->
253
//   * <!-- begin-user-doc -->
254
   * <!-- end-user-doc -->
254
//   * <!-- end-user-doc -->
255
   * @param literal a literal of the data type.
255
//   * @param literal a literal of the data type.
256
   * @return a new instance value of the data type.
256
//   * @return a new instance value of the data type.
257
   * @generated
257
//   * @generated
258
   */
258
//   */
259
  BigDecimal createDecimal(String literal);
259
//  BigDecimal createDecimal(String literal);
260
260
//
261
  /**
261
//  /**
262
   * Returns a literal representation of an instance of data type '<em>Decimal</em>'.
262
//   * Returns a literal representation of an instance of data type '<em>Decimal</em>'.
263
   * <!-- begin-user-doc -->
263
//   * <!-- begin-user-doc -->
264
   * <!-- end-user-doc -->
264
//   * <!-- end-user-doc -->
265
   * @param instanceValue an instance value of the data type.
265
//   * @param instanceValue an instance value of the data type.
266
   * @return a literal representation of the instance value.
266
//   * @return a literal representation of the instance value.
267
   * @generated
267
//   * @generated
268
   */
268
//   */
269
  String convertDecimal(BigDecimal instanceValue);
269
//  String convertDecimal(BigDecimal instanceValue);
270
270
271
  /**
271
  /**
272
   * Returns an instance of data type '<em>Double</em>' corresponding the given literal.
272
   * Returns an instance of data type '<em>Double</em>' corresponding the given literal.
Lines 648-672 Link Here
648
   */
648
   */
649
  String convertInt(int instanceValue);
649
  String convertInt(int instanceValue);
650
650
651
  /**
651
//  /**
652
   * Returns an instance of data type '<em>Integer</em>' corresponding the given literal.
652
//   * Returns an instance of data type '<em>Integer</em>' corresponding the given literal.
653
   * <!-- begin-user-doc -->
653
//   * <!-- begin-user-doc -->
654
   * <!-- end-user-doc -->
654
//   * <!-- end-user-doc -->
655
   * @param literal a literal of the data type.
655
//   * @param literal a literal of the data type.
656
   * @return a new instance value of the data type.
656
//   * @return a new instance value of the data type.
657
   * @generated
657
//   * @generated
658
   */
658
//   */
659
  BigInteger createInteger(String literal);
659
//  BigInteger createInteger(String literal);
660
660
//
661
  /**
661
//  /**
662
   * Returns a literal representation of an instance of data type '<em>Integer</em>'.
662
//   * Returns a literal representation of an instance of data type '<em>Integer</em>'.
663
   * <!-- begin-user-doc -->
663
//   * <!-- begin-user-doc -->
664
   * <!-- end-user-doc -->
664
//   * <!-- end-user-doc -->
665
   * @param instanceValue an instance value of the data type.
665
//   * @param instanceValue an instance value of the data type.
666
   * @return a literal representation of the instance value.
666
//   * @return a literal representation of the instance value.
667
   * @generated
667
//   * @generated
668
   */
668
//   */
669
  String convertInteger(BigInteger instanceValue);
669
//  String convertInteger(BigInteger instanceValue);
670
670
671
  /**
671
  /**
672
   * Returns an instance of data type '<em>Int Object</em>' corresponding the given literal.
672
   * Returns an instance of data type '<em>Int Object</em>' corresponding the given literal.
Lines 788-812 Link Here
788
   */
788
   */
789
  String convertNCName(String instanceValue);
789
  String convertNCName(String instanceValue);
790
790
791
  /**
791
//  /**
792
   * Returns an instance of data type '<em>Negative Integer</em>' corresponding the given literal.
792
//   * Returns an instance of data type '<em>Negative Integer</em>' corresponding the given literal.
793
   * <!-- begin-user-doc -->
793
//   * <!-- begin-user-doc -->
794
   * <!-- end-user-doc -->
794
//   * <!-- end-user-doc -->
795
   * @param literal a literal of the data type.
795
//   * @param literal a literal of the data type.
796
   * @return a new instance value of the data type.
796
//   * @return a new instance value of the data type.
797
   * @generated
797
//   * @generated
798
   */
798
//   */
799
  BigInteger createNegativeInteger(String literal);
799
//  BigInteger createNegativeInteger(String literal);
800
800
//
801
  /**
801
//  /**
802
   * Returns a literal representation of an instance of data type '<em>Negative Integer</em>'.
802
//   * Returns a literal representation of an instance of data type '<em>Negative Integer</em>'.
803
   * <!-- begin-user-doc -->
803
//   * <!-- begin-user-doc -->
804
   * <!-- end-user-doc -->
804
//   * <!-- end-user-doc -->
805
   * @param instanceValue an instance value of the data type.
805
//   * @param instanceValue an instance value of the data type.
806
   * @return a literal representation of the instance value.
806
//   * @return a literal representation of the instance value.
807
   * @generated
807
//   * @generated
808
   */
808
//   */
809
  String convertNegativeInteger(BigInteger instanceValue);
809
//  String convertNegativeInteger(BigInteger instanceValue);
810
810
811
  /**
811
  /**
812
   * Returns an instance of data type '<em>NMTOKEN</em>' corresponding the given literal.
812
   * Returns an instance of data type '<em>NMTOKEN</em>' corresponding the given literal.
Lines 868-912 Link Here
868
   */
868
   */
869
  String convertNMTOKENSBase(List instanceValue);
869
  String convertNMTOKENSBase(List instanceValue);
870
870
871
  /**
871
//  /**
872
   * Returns an instance of data type '<em>Non Negative Integer</em>' corresponding the given literal.
872
//   * Returns an instance of data type '<em>Non Negative Integer</em>' corresponding the given literal.
873
   * <!-- begin-user-doc -->
873
//   * <!-- begin-user-doc -->
874
   * <!-- end-user-doc -->
874
//   * <!-- end-user-doc -->
875
   * @param literal a literal of the data type.
875
//   * @param literal a literal of the data type.
876
   * @return a new instance value of the data type.
876
//   * @return a new instance value of the data type.
877
   * @generated
877
//   * @generated
878
   */
878
//   */
879
  BigInteger createNonNegativeInteger(String literal);
879
//  BigInteger createNonNegativeInteger(String literal);
880
880
//
881
  /**
881
//  /**
882
   * Returns a literal representation of an instance of data type '<em>Non Negative Integer</em>'.
882
//   * Returns a literal representation of an instance of data type '<em>Non Negative Integer</em>'.
883
   * <!-- begin-user-doc -->
883
//   * <!-- begin-user-doc -->
884
   * <!-- end-user-doc -->
884
//   * <!-- end-user-doc -->
885
   * @param instanceValue an instance value of the data type.
885
//   * @param instanceValue an instance value of the data type.
886
   * @return a literal representation of the instance value.
886
//   * @return a literal representation of the instance value.
887
   * @generated
887
//   * @generated
888
   */
888
//   */
889
  String convertNonNegativeInteger(BigInteger instanceValue);
889
//  String convertNonNegativeInteger(BigInteger instanceValue);
890
890
//
891
  /**
891
//  /**
892
   * Returns an instance of data type '<em>Non Positive Integer</em>' corresponding the given literal.
892
//   * Returns an instance of data type '<em>Non Positive Integer</em>' corresponding the given literal.
893
   * <!-- begin-user-doc -->
893
//   * <!-- begin-user-doc -->
894
   * <!-- end-user-doc -->
894
//   * <!-- end-user-doc -->
895
   * @param literal a literal of the data type.
895
//   * @param literal a literal of the data type.
896
   * @return a new instance value of the data type.
896
//   * @return a new instance value of the data type.
897
   * @generated
897
//   * @generated
898
   */
898
//   */
899
  BigInteger createNonPositiveInteger(String literal);
899
//  BigInteger createNonPositiveInteger(String literal);
900
900
//
901
  /**
901
//  /**
902
   * Returns a literal representation of an instance of data type '<em>Non Positive Integer</em>'.
902
//   * Returns a literal representation of an instance of data type '<em>Non Positive Integer</em>'.
903
   * <!-- begin-user-doc -->
903
//   * <!-- begin-user-doc -->
904
   * <!-- end-user-doc -->
904
//   * <!-- end-user-doc -->
905
   * @param instanceValue an instance value of the data type.
905
//   * @param instanceValue an instance value of the data type.
906
   * @return a literal representation of the instance value.
906
//   * @return a literal representation of the instance value.
907
   * @generated
907
//   * @generated
908
   */
908
//   */
909
  String convertNonPositiveInteger(BigInteger instanceValue);
909
//  String convertNonPositiveInteger(BigInteger instanceValue);
910
910
911
  /**
911
  /**
912
   * Returns an instance of data type '<em>Normalized String</em>' corresponding the given literal.
912
   * Returns an instance of data type '<em>Normalized String</em>' corresponding the given literal.
Lines 948-972 Link Here
948
   */
948
   */
949
  String convertNOTATION(Object instanceValue);
949
  String convertNOTATION(Object instanceValue);
950
950
951
  /**
951
//  /**
952
   * Returns an instance of data type '<em>Positive Integer</em>' corresponding the given literal.
952
//   * Returns an instance of data type '<em>Positive Integer</em>' corresponding the given literal.
953
   * <!-- begin-user-doc -->
953
//   * <!-- begin-user-doc -->
954
   * <!-- end-user-doc -->
954
//   * <!-- end-user-doc -->
955
   * @param literal a literal of the data type.
955
//   * @param literal a literal of the data type.
956
   * @return a new instance value of the data type.
956
//   * @return a new instance value of the data type.
957
   * @generated
957
//   * @generated
958
   */
958
//   */
959
  BigInteger createPositiveInteger(String literal);
959
//  BigInteger createPositiveInteger(String literal);
960
960
//
961
  /**
961
//  /**
962
   * Returns a literal representation of an instance of data type '<em>Positive Integer</em>'.
962
//   * Returns a literal representation of an instance of data type '<em>Positive Integer</em>'.
963
   * <!-- begin-user-doc -->
963
//   * <!-- begin-user-doc -->
964
   * <!-- end-user-doc -->
964
//   * <!-- end-user-doc -->
965
   * @param instanceValue an instance value of the data type.
965
//   * @param instanceValue an instance value of the data type.
966
   * @return a literal representation of the instance value.
966
//   * @return a literal representation of the instance value.
967
   * @generated
967
//   * @generated
968
   */
968
//   */
969
  String convertPositiveInteger(BigInteger instanceValue);
969
//  String convertPositiveInteger(BigInteger instanceValue);
970
970
971
  /**
971
  /**
972
   * Returns an instance of data type '<em>QName</em>' corresponding the given literal.
972
   * Returns an instance of data type '<em>QName</em>' corresponding the given literal.
Lines 1168-1192 Link Here
1168
   */
1168
   */
1169
  String convertUnsignedIntObject(Long instanceValue);
1169
  String convertUnsignedIntObject(Long instanceValue);
1170
1170
1171
  /**
1171
//  /**
1172
   * Returns an instance of data type '<em>Unsigned Long</em>' corresponding the given literal.
1172
//   * Returns an instance of data type '<em>Unsigned Long</em>' corresponding the given literal.
1173
   * <!-- begin-user-doc -->
1173
//   * <!-- begin-user-doc -->
1174
   * <!-- end-user-doc -->
1174
//   * <!-- end-user-doc -->
1175
   * @param literal a literal of the data type.
1175
//   * @param literal a literal of the data type.
1176
   * @return a new instance value of the data type.
1176
//   * @return a new instance value of the data type.
1177
   * @generated
1177
//   * @generated
1178
   */
1178
//   */
1179
  BigInteger createUnsignedLong(String literal);
1179
//  BigInteger createUnsignedLong(String literal);
1180
1180
//
1181
  /**
1181
//  /**
1182
   * Returns a literal representation of an instance of data type '<em>Unsigned Long</em>'.
1182
//   * Returns a literal representation of an instance of data type '<em>Unsigned Long</em>'.
1183
   * <!-- begin-user-doc -->
1183
//   * <!-- begin-user-doc -->
1184
   * <!-- end-user-doc -->
1184
//   * <!-- end-user-doc -->
1185
   * @param instanceValue an instance value of the data type.
1185
//   * @param instanceValue an instance value of the data type.
1186
   * @return a literal representation of the instance value.
1186
//   * @return a literal representation of the instance value.
1187
   * @generated
1187
//   * @generated
1188
   */
1188
//   */
1189
  String convertUnsignedLong(BigInteger instanceValue);
1189
//  String convertUnsignedLong(BigInteger instanceValue);
1190
1190
1191
  /**
1191
  /**
1192
   * Returns an instance of data type '<em>Unsigned Short</em>' corresponding the given literal.
1192
   * Returns an instance of data type '<em>Unsigned Short</em>' corresponding the given literal.
(-)src/org/eclipse/emf/ecore/xml/type/InvalidDatatypeValueException.java (-28 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: InvalidDatatypeValueException.java,v 1.2 2005/06/08 06:20:10 nickb Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type;
18
19
/**
20
 * Datatype exception for invalid values.
21
 */
22
public class InvalidDatatypeValueException extends RuntimeException
23
{
24
  public InvalidDatatypeValueException(String reason)
25
  {
26
    super(reason);
27
  }
28
}
(-)src/org/eclipse/emf/ecore/xml/type/internal/XMLCalendar.java (-1426 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2004-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLCalendar.java,v 1.7.2.1 2007/02/23 22:26:38 emerks Exp $
16
 *
17
 * ---------------------------------------------------------------------
18
 *
19
 * The Apache Software License, Version 1.1
20
 *
21
 *
22
 * Copyright (c) 1999-2004 The Apache Software Foundation.  All rights
23
 * reserved.
24
 *
25
 * Redistribution and use in source and binary forms, with or without
26
 * modification, are permitted provided that the following conditions
27
 * are met:
28
 *
29
 * 1. Redistributions of source code must retain the above copyright
30
 *    notice, this list of conditions and the following disclaimer.
31
 *
32
 * 2. Redistributions in binary form must reproduce the above copyright
33
 *    notice, this list of conditions and the following disclaimer in
34
 *    the documentation and/or other materials provided with the
35
 *    distribution.
36
 *
37
 * 3. The end-user documentation included with the redistribution,
38
 *    if any, must include the following acknowledgment:
39
 *       "This product includes software developed by the
40
 *        Apache Software Foundation (http://www.apache.org/)."
41
 *    Alternately, this acknowledgment may appear in the software itself,
42
 *    if and wherever such third-party acknowledgments normally appear.
43
 *
44
 * 4. The names "Xerces" and "Apache Software Foundation" must
45
 *    not be used to endorse or promote products derived from this
46
 *    software without prior written permission. For written
47
 *    permission, please contact apache@apache.org.
48
 *
49
 * 5. Products derived from this software may not be called "Apache",
50
 *    nor may "Apache" appear in their name, without prior written
51
 *    permission of the Apache Software Foundation.
52
 *
53
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
54
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
57
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
60
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
61
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
62
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
63
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64
 * SUCH DAMAGE.
65
 * ====================================================================
66
 *
67
 * This software consists of voluntary contributions made by many
68
 * individuals on behalf of the Apache Software Foundation and was
69
 * originally based on software copyright (c) 1999-2003, International
70
 * Business Machines, Inc., http://www.apache.org.  For more
71
 * information on the Apache Software Foundation, please see
72
 * <http://www.apache.org/>.
73
 */
74
75
package org.eclipse.emf.ecore.xml.type.internal;
76
77
78
import java.text.DateFormat;
79
import java.text.ParseException;
80
import java.text.SimpleDateFormat;
81
import java.util.Date;
82
import java.util.TimeZone;
83
84
import org.eclipse.emf.common.util.WrappedException;
85
import org.eclipse.emf.ecore.xml.type.InvalidDatatypeValueException;
86
import org.eclipse.emf.ecore.xml.type.internal.DataValue.TypeValidator;
87
88
/**
89
 * Representation for the <a href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">W3C XML Schema 1.0</a> 
90
 * dateTime, time, date, gYearMonth,  gYear, gMonthDay, gDay, gMonth datatypes.
91
 * 
92
 * NOTE: this class is for internal use only. 
93
 * Later this class will be replaced by JAXP 1.3 javax.xml.datatype.XMLGregorianCalendar class.
94
 * This class is based on Apache Xerces2 2.6.2 parser implementation of date/time validation.
95
 */
96
public final class XMLCalendar
97
{
98
  public final static short DATETIME = 0;
99
100
  public final static short TIME = 1;
101
102
  public final static short DATE = 2;
103
104
  public final static short GYEARMONTH = 3;
105
106
  public final static short GYEAR = 4;
107
108
  public final static short GMONTHDAY = 5;
109
110
  public final static short GDAY = 6;
111
112
  public final static short GMONTH = 7;
113
  
114
  public final static int EQUALS = 0;
115
  public final static int LESS_THAN = -1;
116
  public final static int GREATER_THAN = 1;
117
  public final static int INDETERMINATE = 2;
118
  
119
120
  //define shared variables for date/time
121
122
  //define constants
123
  protected final static int CY = 0, M = 1, D = 2, h = 3, m = 4, s = 5, ms = 6, msp = 7, utc = 8, hh = 0, mm = 1;
124
125
  //size for all objects must have the same fields:
126
  //CCYY, MM, DD, h, m, s, ms + timeZone
127
  protected final static int TOTAL_SIZE = 9;
128
129
  //size without time zone: ---09
130
  private final static int DAY_SIZE = 5;
131
132
  //size without time zone: --MM-DD
133
  private final static int MONTHDAY_SIZE = 7;
134
135
  //define constants to be used in assigning default values for
136
  //all date/time excluding duration
137
  protected final static int YEAR = 2000;
138
139
  protected final static int MONTH = 01;
140
141
  protected final static int DAY = 15;
142
143
  private int[] dateValue;
144
145
  final short dataType;
146
147
  private Date date;
148
  
149
  protected static final DateFormat [] EDATE_FORMATS =
150
  {
151
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"),
152
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"),
153
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'S"), 
154
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'S'Z'"),
155
    new SafeSimpleDateFormat("yyyy-MM-dd'Z'"),
156
    new SafeSimpleDateFormat("yyyy-MM-dd")
157
  };
158
159
  {
160
    EDATE_FORMATS[0].setTimeZone(TimeZone.getTimeZone("GMT"));
161
    EDATE_FORMATS[3].setTimeZone(TimeZone.getTimeZone("GMT"));    
162
  }
163
164
  public XMLCalendar(String value, short datatype)
165
  {
166
    if (value == null || value.length() == 0)
167
    {
168
      throw new InvalidDatatypeValueException("Incomplete value");
169
    }
170
171
    this.dataType = datatype;
172
    switch (dataType)
173
    {
174
      case DATETIME:
175
        {
176
          this.dateValue = parseDateTime(value);
177
          break;
178
        }
179
      case TIME:
180
        {
181
          this.dateValue = parseTime(value);
182
          break;
183
        }
184
      case DATE:
185
        {
186
          this.dateValue = parseDate(value);
187
          break;
188
        }
189
      case GYEAR:
190
        {
191
          this.dateValue = parseYear(value);
192
          break;
193
        }
194
      case GYEARMONTH:
195
        {
196
          this.dateValue = parseYearMonth(value);
197
          break;
198
        }
199
      case GMONTHDAY:
200
        {
201
          this.dateValue = parseMonthDay(value);
202
          break;
203
        }
204
      case GMONTH:
205
        {
206
          this.dateValue = parseMonth(value);
207
          break;
208
        }
209
      case GDAY:
210
        {
211
          this.dateValue = parseDay(value);
212
          break;
213
        }
214
      default:
215
        throw new IllegalArgumentException("Illegal datatype value");
216
    }
217
  }
218
219
  public XMLCalendar(Date date, short dataType)
220
  {
221
    this.date = date;
222
    this.dataType = dataType;
223
  }
224
225
  public boolean equals(Object obj)
226
  {
227
    if (!(obj instanceof XMLCalendar))
228
    {
229
      return false;
230
    }
231
232
    XMLCalendar xmlCalendarObj = (XMLCalendar)obj;
233
    if (dataType != xmlCalendarObj.dataType)
234
    {
235
      return false;
236
    }
237
238
    return compare(this, (XMLCalendar)obj) == EQUALS;
239
  }
240
241
  public int hashCode()
242
  {
243
    int hashCode = dataType;
244
    int [] dateValue = getDateValue();
245
    for (int i=0;i<TOTAL_SIZE;i++)
246
    {
247
      hashCode^=dateValue[i];
248
    }
249
    return hashCode;
250
  }
251
  
252
  public String toString()
253
  {
254
    switch (dataType)
255
    {
256
      case DATETIME: return dateTimeToString();
257
      case TIME: return timeToString();
258
      case DATE: return dateToString(); 
259
      case GYEAR: return yearToString();
260
      case GYEARMONTH: return yearMonthToString();
261
      case GMONTHDAY: return monthDayToString();
262
      case GMONTH: return monthToString();
263
      case GDAY: return dayToString();
264
    }
265
    return null;
266
  }
267
268
  // the parameters are in compiled form (from getActualValue)
269
  public static int compare(XMLCalendar value1, XMLCalendar value2)
270
  {
271
    return (value1.dataType != value2.dataType) ? INDETERMINATE : compareDates(value1.getDateValue(), value2.getDateValue(), true); 
272
  }//compare()
273
274
  protected int[] getDateValue()
275
  {
276
    if (dateValue == null)
277
    {
278
      dateValue = parseDateTime(XMLCalendar.EDATE_FORMATS[0].format(date));
279
    }
280
    return dateValue;
281
  }
282
283
  public Date getDate()
284
  {
285
    if (date == null)
286
    {
287
      try
288
      {
289
        if (dataType == XMLCalendar.DATETIME)
290
        {
291
          try
292
          {
293
            date = XMLCalendar.EDATE_FORMATS[0].parse(dateTimeToString());
294
          }
295
          catch (Exception e)
296
          {
297
            try
298
            {
299
              date = XMLCalendar.EDATE_FORMATS[1].parse(dateTimeToString());
300
            }
301
            catch (Exception e2)
302
            {
303
              try
304
              {
305
                date = XMLCalendar.EDATE_FORMATS[2].parse(dateTimeToString());
306
              }
307
              catch (Exception e3)
308
              {
309
                date = XMLCalendar.EDATE_FORMATS[3].parse(dateTimeToString());
310
              }
311
            }
312
          }
313
        }
314
        else if (dataType == XMLCalendar.DATE)
315
        {
316
          try
317
          {
318
            date = XMLCalendar.EDATE_FORMATS[4].parse(dateToString());
319
          }
320
          catch (Exception e)
321
          {
322
            date = XMLCalendar.EDATE_FORMATS[5].parse(dateToString());
323
          }
324
        }
325
      }
326
      catch (Exception e)
327
      {
328
        throw new WrappedException(e);
329
      }
330
    }
331
    return date;
332
  }
333
334
  /**
335
   * Compare algorithm described in dateDime (3.2.7).
336
   * Duration datatype overwrites this method
337
   *
338
   * @param date1  normalized date representation of the first value
339
   * @param date2  normalized date representation of the second value
340
   * @param strict
341
   * @return less, greater, less_equal, greater_equal, equal
342
   */
343
  private static int compareDates(int[] date1, int[] date2, boolean strict)
344
  {
345
    if (date1[utc] == date2[utc])
346
    {
347
      return compareOrder(date1, date2);
348
    }
349
    short c1, c2;
350
351
    int[] tempDate = new int [TOTAL_SIZE];
352
    int[] timeZone = new int [2];
353
354
    if (date1[utc] == 'Z')
355
    {
356
357
      //compare date1<=date1<=(date2 with time zone -14)
358
      //
359
      cloneDate(date2, tempDate); //clones date1 value to global temporary storage: fTempDate
360
      timeZone[hh] = 14;
361
      timeZone[mm] = 0;
362
      tempDate[utc] = '+';
363
      normalize(tempDate, timeZone);
364
      c1 = compareOrder(date1, tempDate);
365
      if (c1 == TypeValidator.LESS_THAN)
366
        return c1;
367
368
      //compare date1>=(date2 with time zone +14)
369
      //
370
      cloneDate(date2, tempDate); //clones date1 value to global temporary storage: tempDate
371
      timeZone[hh] = 14;
372
      timeZone[mm] = 0;
373
      tempDate[utc] = '-';
374
      normalize(tempDate, timeZone);
375
      c2 = compareOrder(date1, tempDate);
376
      if (c2 == TypeValidator.GREATER_THAN)
377
        return c2;
378
379
      return TypeValidator.INDETERMINATE;
380
    }
381
    else if (date2[utc] == 'Z')
382
    {
383
384
      //compare (date1 with time zone -14)<=date2
385
      //
386
      cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
387
      timeZone[hh] = 14;
388
      timeZone[mm] = 0;
389
      tempDate[utc] = '-';
390
      
391
      normalize(tempDate, timeZone);
392
      c1 = compareOrder(tempDate, date2);
393
394
      if (c1 == TypeValidator.LESS_THAN)
395
        return c1;
396
397
      //compare (date1 with time zone +14)<=date2
398
      //
399
      cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
400
      timeZone[hh] = 14;
401
      timeZone[mm] = 0;
402
      tempDate[utc] = '+';
403
      normalize(tempDate, timeZone);
404
      c2 = compareOrder(tempDate, date2);
405
406
      if (c2 == TypeValidator.GREATER_THAN)
407
        return c2;
408
409
      return TypeValidator.INDETERMINATE;
410
    }
411
    return TypeValidator.INDETERMINATE;
412
413
  }
414
415
  /**
416
   * Given normalized values, determines order-relation
417
   * between give date/time objects.
418
   *
419
   * @param date1  date/time object
420
   * @param date2  date/time object
421
   * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
422
   */
423
  protected static short compareOrder(int[] date1, int[] date2)
424
  {
425
426
    for (int i = 0; i < ms; i++)
427
    {
428
      if (date1[i] < date2[i])
429
      {
430
        return -1;
431
      }
432
      else if (date1[i] > date2[i])
433
      {
434
        return 1;
435
      }
436
    }
437
438
    double milliSeconds1 = date1[ms];
439
    for (int i = 0; i < date1[msp]; ++i)
440
    {
441
      milliSeconds1 /= 10.0;
442
    }
443
    double milliSeconds2 = date2[ms];
444
    for (int i = 0; i < date2[msp]; ++i)
445
    {
446
      milliSeconds2 /= 10.0;
447
    }
448
    return milliSeconds1 < milliSeconds2 ? (short)-1 : milliSeconds1 > milliSeconds2 ? (short)1 : 0;
449
  }
450
451
  /**
452
   * Parses time hh:mm:ss.sss and time zone if any
453
   */
454
  protected static void getTime(String buffer, int start, int end, int[] data, int[] timeZone)
455
  {
456
457
    int stop = start + 2;
458
459
    //get hours (hh)
460
    data[h] = parseInt(buffer, start, stop);
461
462
    //get minutes (mm)
463
464
    if (buffer.charAt(stop++) != ':')
465
    {
466
      throw new InvalidDatatypeValueException("Error in parsing time zone");
467
    }
468
    start = stop;
469
    stop = stop + 2;
470
    data[m] = parseInt(buffer, start, stop);
471
472
    //get seconds (ss)
473
    if (buffer.charAt(stop++) != ':')
474
    {
475
      throw new InvalidDatatypeValueException("Error in parsing time zone");
476
    }
477
    start = stop;
478
    stop = stop + 2;
479
    data[s] = parseInt(buffer, start, stop);
480
481
    if (stop == end)
482
      return;
483
484
    //get miliseconds (ms)
485
    start = stop;
486
    int milisec = buffer.charAt(start) == '.' ? start : -1;
487
488
    //find UTC sign if any
489
    int sign = findUTCSign(buffer, start, end);
490
491
    //parse miliseconds
492
    if (milisec != -1)
493
    {
494
      // The end of millisecond part is between . and
495
      // either the end of the UTC sign
496
      start = sign < 0 ? end : sign;
497
      data[ms] = parseInt(buffer, milisec + 1, start);
498
      data[msp] = start - milisec - 1;
499
    }
500
501
    //parse UTC time zone (hh:mm)
502
    if (sign > 0)
503
    {
504
      if (start != sign)
505
        throw new InvalidDatatypeValueException("Error in parsing time zone");
506
      getTimeZone(buffer, data, sign, end, timeZone);
507
    }
508
    else if (start != end)
509
    {
510
      throw new InvalidDatatypeValueException("Error in parsing time zone");
511
    }
512
  }
513
514
  /**
515
   * Parses date CCYY-MM-DD
516
   *
517
   * @param start
518
   * @param end
519
   * @param date
520
   */
521
  protected static int getDate(String buffer, int start, int end, int[] date)
522
  {
523
524
    start = getYearMonth(buffer, start, end, date);
525
526
    if (buffer.charAt(start++) != '-')
527
    {
528
      throw new InvalidDatatypeValueException("CCYY-MM must be followed by '-' sign");
529
    }
530
    int stop = start + 2;
531
    date[D] = parseInt(buffer, start, stop);
532
    return stop;
533
  }
534
535
  /**
536
   * Parses date CCYY-MM
537
   *
538
   * @param start
539
   * @param end
540
   * @param date
541
   */
542
  protected static int getYearMonth(String buffer, int start, int end, int[] date)
543
  {
544
545
    if (buffer.charAt(0) == '-')
546
    {
547
      // REVISIT: date starts with preceding '-' sign
548
      //          do we have to do anything with it?
549
      //
550
      start++;
551
    }
552
    int i = indexOf(buffer, start, end, '-');
553
    if (i == -1)
554
      throw new InvalidDatatypeValueException("Year separator is missing or misplaced");
555
    int length = i - start;
556
    if (length < 4)
557
    {
558
      throw new InvalidDatatypeValueException("Year must have 'CCYY' format");
559
    }
560
    else if (length > 4 && buffer.charAt(start) == '0')
561
    {
562
      throw new InvalidDatatypeValueException(
563
          "Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
564
    }
565
    date[CY] = parseIntYear(buffer, i);
566
    if (buffer.charAt(i) != '-')
567
    {
568
      throw new InvalidDatatypeValueException("CCYY must be followed by '-' sign");
569
    }
570
    start = ++i;
571
    i = start + 2;
572
    date[M] = parseInt(buffer, start, i);
573
    return i; //fStart points right after the MONTH
574
  }
575
576
  /**
577
   * Shared code from Date and YearMonth datatypes.
578
   * Finds if time zone sign is present
579
   *
580
   * @param end
581
   * @param date
582
   */
583
  protected static void parseTimeZone(String buffer, int start, int end, int[] date, int[] timeZone)
584
  {
585
586
    //fStart points right after the date
587
588
    if (start < end)
589
    {
590
      int sign = findUTCSign(buffer, start, end);
591
      if (sign < 0)
592
      {
593
        throw new InvalidDatatypeValueException("Error in month parsing");
594
      }
595
      else
596
      {
597
        getTimeZone(buffer, date, sign, end, timeZone);
598
      }
599
    }
600
  }
601
602
  /**
603
   * Parses time zone: 'Z' or {+,-} followed by  hh:mm
604
   *
605
   * @param data
606
   * @param sign
607
   */
608
  protected static void getTimeZone(String buffer, int[] data, int sign, int end, int[] timeZone)
609
  {
610
    data[utc] = buffer.charAt(sign);
611
612
    if (buffer.charAt(sign) == 'Z')
613
    {
614
      if (end > (++sign))
615
      {
616
        throw new InvalidDatatypeValueException("Error in parsing time zone");
617
      }
618
      return;
619
    }
620
    if (sign <= (end - 6))
621
    {
622
623
      //parse [hh]
624
      int stop = ++sign + 2;
625
      timeZone[hh] = parseInt(buffer, sign, stop);
626
      if (buffer.charAt(stop++) != ':')
627
      {
628
        throw new InvalidDatatypeValueException("Error in parsing time zone");
629
      }
630
631
      //parse [ss]
632
      timeZone[mm] = parseInt(buffer, stop, stop + 2);
633
634
      if (stop + 2 != end)
635
      {
636
        throw new InvalidDatatypeValueException("Error in parsing time zone");
637
      }
638
639
    }
640
    else
641
    {
642
      throw new InvalidDatatypeValueException("Error in parsing time zone");
643
    }
644
  }
645
646
  /**
647
   * Computes index of given char within StringBuffer
648
   *
649
   * @param start
650
   * @param end
651
   * @param ch     character to look for in StringBuffer
652
   * @return index of ch within StringBuffer
653
   */
654
  protected static int indexOf(String buffer, int start, int end, char ch)
655
  {
656
    for (int i = start; i < end; i++)
657
    {
658
      if (buffer.charAt(i) == ch)
659
      {
660
        return i;
661
      }
662
    }
663
    return -1;
664
  }
665
666
  /**
667
   * Validates given date/time object accoring to W3C PR Schema
668
   * [D.1 ISO 8601 Conventions]
669
   *
670
   * @param data
671
   */
672
  protected static void validateDateTime(int[] data, int[] timeZone)
673
  {
674
675
    //REVISIT: should we throw an exception for not valid dates
676
    //          or reporting an error message should be sufficient?
677
    if (data[CY] == 0)
678
    {
679
      throw new InvalidDatatypeValueException("The year \"0000\" is an illegal year value");
680
681
    }
682
683
    if (data[M] < 1 || data[M] > 12)
684
    {
685
      throw new InvalidDatatypeValueException("The month must have values 1 to 12");
686
687
    }
688
689
    //validate days
690
    if (data[D] > maxDayInMonthFor(data[CY], data[M]) || data[D] < 1)
691
    {
692
      throw new InvalidDatatypeValueException("The day must have values 1 to 31");
693
    }
694
695
    //validate hours
696
    if (data[h] > 23 || data[h] < 0)
697
    {
698
      if (data[h] == 24 && data[m] == 0 && data[s] == 0 && data[ms] == 0)
699
      {
700
        data[h] = 0;
701
        if (++data[D] > maxDayInMonthFor(data[CY], data[M]))
702
        {
703
          data[D] = 1;
704
          if (++data[M] > 12)
705
          {
706
            data[M] = 1;
707
            if (++data[CY] == 0)
708
              data[CY] = 1;
709
          }
710
        }
711
      }
712
      else
713
      {
714
        throw new InvalidDatatypeValueException("Hour must have values 0-23, unless 24:00:00");
715
      }
716
    }
717
718
    //validate
719
    if (data[m] > 59 || data[m] < 0)
720
    {
721
      throw new InvalidDatatypeValueException("Minute must have values 0-59");
722
    }
723
724
    //validate
725
    if (data[s] > 60 || data[s] < 0)
726
    {
727
      throw new InvalidDatatypeValueException("Second must have values 0-60");
728
729
    }
730
731
    //validate
732
    if (timeZone[hh] > 14 || timeZone[hh] < -14)
733
    {
734
      throw new InvalidDatatypeValueException("Time zone should have range -14..+14");
735
    }
736
737
    //validate
738
    if (timeZone[mm] > 59 || timeZone[mm] < -59)
739
    {
740
      throw new InvalidDatatypeValueException("Minute must have values 0-59");
741
    }
742
  }
743
744
  /**
745
   * Return index of UTC char: 'Z', '+', '-'
746
   *
747
   * @param start
748
   * @param end
749
   * @return index of the UTC character that was found
750
   */
751
  private static int findUTCSign(String buffer, int start, int end)
752
  {
753
    int c;
754
    for (int i = start; i < end; i++)
755
    {
756
      c = buffer.charAt(i);
757
      if (c == 'Z' || c == '+' || c == '-')
758
      {
759
        return i;
760
      }
761
762
    }
763
    return -1;
764
  }
765
766
  /**
767
   * Given start and end position, parses string value
768
   *
769
   * @param buffer  string to parse
770
   * @param start  Start position
771
   * @param end    end position
772
   * @return  return integer representation of characters
773
   */
774
  protected static int parseInt(String buffer, int start, int end) throws NumberFormatException
775
  {
776
    //REVISIT: more testing on this parsing needs to be done.
777
    int radix = 10;
778
    int result = 0;
779
    int digit = 0;
780
    int limit = -Integer.MAX_VALUE;
781
    int multmin = limit / radix;
782
    int i = start;
783
    do
784
    {
785
      digit = TypeValidator.getDigit(buffer.charAt(i));
786
      if (digit < 0)
787
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
788
      if (result < multmin)
789
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
790
      result *= radix;
791
      if (result < limit + digit)
792
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
793
      result -= digit;
794
795
    }
796
    while (++i < end);
797
    return -result;
798
  }
799
800
  // parse Year differently to support negative value.
801
  protected static int parseIntYear(String buffer, int end)
802
  {
803
    int radix = 10;
804
    int result = 0;
805
    boolean negative = false;
806
    int i = 0;
807
    int limit;
808
    int multmin;
809
    int digit = 0;
810
811
    if (buffer.charAt(0) == '-')
812
    {
813
      negative = true;
814
      limit = Integer.MIN_VALUE;
815
      i++;
816
817
    }
818
    else
819
    {
820
      limit = -Integer.MAX_VALUE;
821
    }
822
    multmin = limit / radix;
823
    while (i < end)
824
    {
825
      digit = TypeValidator.getDigit(buffer.charAt(i++));
826
      if (digit < 0)
827
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
828
      if (result < multmin)
829
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
830
      result *= radix;
831
      if (result < limit + digit)
832
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
833
      result -= digit;
834
    }
835
836
    if (negative)
837
    {
838
      if (i > 1)
839
        return result;
840
      else
841
        throw new NumberFormatException("'" + buffer.toString() + "' has wrong format");
842
    }
843
    return -result;
844
845
  }
846
847
  /**
848
   * If timezone present - normalize dateTime  [E Adding durations to dateTimes]
849
   *
850
   * @param date   CCYY-MM-DDThh:mm:ss+03
851
   * @return CCYY-MM-DDThh:mm:ssZ
852
   */
853
  protected static void normalize(int[] date, int[] timeZone)
854
  {
855
856
    // REVISIT: we have common code in addDuration() for durations
857
    //          should consider reorganizing it.
858
    //
859
860
    //add minutes (from time zone)
861
    int negate = 1;
862
    if (date[utc] == '+')
863
    {
864
      negate = -1;
865
    }
866
    int temp = date[m] + negate * timeZone[mm];
867
    int carry = fQuotient(temp, 60);
868
    date[m] = mod(temp, 60, carry);
869
870
    //add hours
871
    temp = date[h] + negate * timeZone[hh] + carry;
872
    carry = fQuotient(temp, 24);
873
    date[h] = mod(temp, 24, carry);
874
875
    date[D] = date[D] + carry;
876
877
    while (true)
878
    {
879
      temp = maxDayInMonthFor(date[CY], date[M]);
880
      if (date[D] < 1)
881
      {
882
        date[D] = date[D] + maxDayInMonthFor(date[CY], date[M] - 1);
883
        carry = -1;
884
      }
885
      else if (date[D] > temp)
886
      {
887
        date[D] = date[D] - temp;
888
        carry = 1;
889
      }
890
      else
891
      {
892
        break;
893
      }
894
      temp = date[M] + carry;
895
      date[M] = modulo(temp, 1, 13);
896
      date[CY] = date[CY] + fQuotient(temp, 1, 13);
897
    }
898
899
    // Drop trailing zeros.
900
    while (date[msp] != 0)
901
    {
902
      int milliSeconds = date[ms];
903
      if (milliSeconds % 10 != 0)
904
      {
905
        break;
906
      }
907
      date[ms] = date[ms] / 10;
908
      --date[msp];
909
    }
910
    date[utc] = 'Z';
911
  }
912
913
  /**
914
   * Resets object representation of date/time
915
   *
916
   * @param data   date/time object
917
   */
918
  protected static void resetDateObj(int[] data)
919
  {
920
    for (int i = 0; i < TOTAL_SIZE; i++)
921
    {
922
      data[i] = 0;
923
    }
924
  }
925
926
  /**
927
   * Given {year,month} computes maximum
928
   * number of days for given month
929
   *
930
   * @param year
931
   * @param month
932
   * @return integer containg the number of days in a given month
933
   */
934
  protected static int maxDayInMonthFor(int year, int month)
935
  {
936
    //validate days
937
    if (month == 4 || month == 6 || month == 9 || month == 11)
938
    {
939
      return 30;
940
    }
941
    else if (month == 2)
942
    {
943
      if (isLeapYear(year))
944
      {
945
        return 29;
946
      }
947
      else
948
      {
949
        return 28;
950
      }
951
    }
952
    else
953
    {
954
      return 31;
955
    }
956
  }
957
958
  private static boolean isLeapYear(int year)
959
  {
960
961
    //REVISIT: should we take care about Julian calendar?
962
    return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
963
  }
964
965
  //
966
  // help function described in W3C PR Schema [E Adding durations to dateTimes]
967
  //
968
  protected static int mod(int a, int b, int quotient)
969
  {
970
    //modulo(a, b) = a - fQuotient(a,b)*b
971
    return (a - quotient * b);
972
  }
973
974
  //
975
  // help function described in W3C PR Schema [E Adding durations to dateTimes]
976
  //
977
  protected static int fQuotient(int a, int b)
978
  {
979
980
    //fQuotient(a, b) = the greatest integer less than or equal to a/b
981
    return (int)Math.floor((float)a / b);
982
  }
983
984
  //
985
  // help function described in W3C PR Schema [E Adding durations to dateTimes]
986
  //
987
  protected static int modulo(int temp, int low, int high)
988
  {
989
    //modulo(a - low, high - low) + low
990
    int a = temp - low;
991
    int b = high - low;
992
    return (mod(a, b, fQuotient(a, b)) + low);
993
  }
994
995
  //
996
  // help function described in W3C PR Schema [E Adding durations to dateTimes]
997
  //
998
  protected static int fQuotient(int temp, int low, int high)
999
  {
1000
    //fQuotient(a - low, high - low)
1001
    return fQuotient(temp - low, high - low);
1002
  }
1003
1004
  private String dateTimeToString()
1005
  {
1006
    int[] dateValue = getDateValue();
1007
    StringBuffer message = new StringBuffer(25);
1008
    append(message, dateValue[CY], 4);
1009
    message.append('-');
1010
    append(message, dateValue[M], 2);
1011
    message.append('-');
1012
    append(message, dateValue[D], 2);
1013
    message.append('T');
1014
    append(message, dateValue[h], 2);
1015
    message.append(':');
1016
    append(message, dateValue[m], 2);
1017
    message.append(':');
1018
    append(message, dateValue[s], 2);
1019
    if (dateValue[ms] > 0)
1020
    {
1021
      message.append('.');
1022
      String value = Integer.toString(dateValue[ms]);
1023
      for (int i = value.length(), limit = dateValue[msp]; i < limit; ++i)
1024
      {
1025
        message.append('0');
1026
      }
1027
      message.append(value);
1028
    }
1029
    append(message, (char)dateValue[utc], 0);
1030
    return message.toString();
1031
  }
1032
1033
  private String dateToString()
1034
  {
1035
    StringBuffer message = new StringBuffer(25);
1036
    int[] dateValue = getDateValue();
1037
    append(message, dateValue[CY], 4);
1038
    message.append('-');
1039
    append(message, dateValue[M], 2);
1040
    message.append('-');
1041
    append(message, dateValue[D], 2);
1042
    append(message, (char)dateValue[utc], 0);
1043
    return message.toString();
1044
  }
1045
1046
  private String dayToString()
1047
  {
1048
    StringBuffer message = new StringBuffer(6);
1049
    message.append('-');
1050
    message.append('-');
1051
    message.append('-');
1052
    append(message, dateValue[D], 2);
1053
    append(message, (char)dateValue[utc], 0);
1054
    return message.toString();
1055
  }
1056
1057
  private String monthDayToString()
1058
  {
1059
    StringBuffer message = new StringBuffer(8);
1060
    message.append('-');
1061
    message.append('-');
1062
    append(message, dateValue[M], 2);
1063
    message.append('-');
1064
    append(message, dateValue[D], 2);
1065
    append(message, (char)dateValue[utc], 0);
1066
    return message.toString();
1067
  }
1068
1069
  private String monthToString()
1070
  {
1071
    StringBuffer message = new StringBuffer(5);
1072
    message.append('-');
1073
    message.append('-');
1074
    append(message, dateValue[M], 2);
1075
    append(message, (char)dateValue[utc], 0);
1076
    return message.toString();
1077
  }
1078
1079
  private String timeToString()
1080
  {
1081
    StringBuffer message = new StringBuffer(16);
1082
    append(message, dateValue[h], 2);
1083
    message.append(':');
1084
    append(message, dateValue[m], 2);
1085
    message.append(':');
1086
    append(message, dateValue[s], 2);
1087
    if (dateValue[ms] > 0)
1088
    {
1089
      message.append('.');
1090
      String value = Integer.toString(dateValue[ms]);
1091
      for (int i = value.length(), limit = dateValue[msp]; i < limit; ++i)
1092
      {
1093
        message.append('0');
1094
      }
1095
      message.append(value);
1096
    }
1097
    append(message, (char)dateValue[utc], 0);
1098
    return message.toString();
1099
  }
1100
1101
  private String yearToString()
1102
  {
1103
    StringBuffer message = new StringBuffer(5);
1104
    append(message, dateValue[CY], 4);
1105
    append(message, (char)dateValue[utc], 0);
1106
    return message.toString();
1107
  }
1108
1109
  private String yearMonthToString()
1110
  {
1111
    StringBuffer message = new StringBuffer(25);
1112
    append(message, dateValue[CY], 4);
1113
    message.append('-');
1114
    append(message, dateValue[M], 2);
1115
    append(message, (char)dateValue[utc], 0);
1116
    return message.toString();
1117
  }
1118
1119
  private static void append(StringBuffer message, int value, int nch)
1120
  {
1121
    if (value < 0)
1122
    {
1123
      message.append('-');
1124
      value = -value;
1125
    }
1126
    if (nch == 4)
1127
    {
1128
      if (value < 10)
1129
        message.append("000");
1130
      else if (value < 100)
1131
        message.append("00");
1132
      else if (value < 1000)
1133
        message.append("0");
1134
      message.append(value);
1135
    }
1136
    else if (nch == 2)
1137
    {
1138
      if (value < 10)
1139
        message.append('0');
1140
      message.append(value);
1141
    }
1142
    else
1143
    {
1144
      if (value != 0)
1145
        message.append((char)value);
1146
    }
1147
  }
1148
1149
  //
1150
  //Private help functions
1151
  //
1152
1153
  private static void cloneDate(int[] finalValue, int[] tempDate)
1154
  {
1155
    System.arraycopy(finalValue, 0, tempDate, 0, TOTAL_SIZE);
1156
  }
1157
1158
  private int[] parseDateTime(String str) throws InvalidDatatypeValueException
1159
  {
1160
    int len = str.length();
1161
    int[] date = new int [TOTAL_SIZE];
1162
    int[] timeZone = new int [2];
1163
1164
    int end = indexOf(str, 0, len, 'T');
1165
1166
    // both time and date
1167
    getDate(str, 0, end, date);
1168
    getTime(str, end + 1, len, date, timeZone);
1169
1170
    //validate and normalize
1171
    validateDateTime(date, timeZone);
1172
1173
    if (date[utc] != 0 && date[utc] != 'Z')
1174
    {
1175
      normalize(date, timeZone);
1176
    }
1177
    return date;
1178
  }
1179
1180
  private int[] parseDate(String str) throws InvalidDatatypeValueException
1181
  {
1182
    int len = str.length();
1183
    int[] date = new int [TOTAL_SIZE];
1184
    int[] timeZone = new int [2];
1185
1186
    int end = getDate(str, 0, len, date);
1187
    parseTimeZone(str, end, len, date, timeZone);
1188
1189
    //validate and normalize
1190
    validateDateTime(date, timeZone);
1191
1192
    if (date[utc] != 0 && date[utc] != 'Z')
1193
    {
1194
      normalize(date, timeZone);
1195
    }
1196
    return date;
1197
  }
1198
1199
  private int[] parseDay(String str) throws InvalidDatatypeValueException
1200
  {
1201
    int len = str.length();
1202
    int[] date = new int [TOTAL_SIZE];
1203
    int[] timeZone = new int [2];
1204
1205
    if (str.charAt(0) != '-' || str.charAt(1) != '-' || str.charAt(2) != '-')
1206
    {
1207
      throw new InvalidDatatypeValueException("Error in day parsing");
1208
    }
1209
1210
    //initialize values
1211
    date[CY] = YEAR;
1212
    date[M] = MONTH;
1213
1214
    date[D] = parseInt(str, 3, 5);
1215
1216
    if (DAY_SIZE < len)
1217
    {
1218
      int sign = findUTCSign(str, DAY_SIZE, len);
1219
      if (sign < 0)
1220
      {
1221
        throw new InvalidDatatypeValueException("Error in day parsing");
1222
      }
1223
      else
1224
      {
1225
        getTimeZone(str, date, sign, len, timeZone);
1226
      }
1227
    }
1228
1229
    //validate and normalize
1230
    validateDateTime(date, timeZone);
1231
1232
    if (date[utc] != 0 && date[utc] != 'Z')
1233
    {
1234
      normalize(date, timeZone);
1235
    }
1236
    return date;
1237
  }
1238
1239
  private int[] parseMonthDay(String str) throws InvalidDatatypeValueException
1240
  {
1241
    int len = str.length();
1242
    int[] date = new int [TOTAL_SIZE];
1243
    int[] timeZone = new int [2];
1244
1245
    //initialize
1246
    date[CY] = YEAR;
1247
1248
    if (str.charAt(0) != '-' || str.charAt(1) != '-')
1249
    {
1250
      throw new InvalidDatatypeValueException("Invalid format for gMonthDay: " + str);
1251
    }
1252
    date[M] = parseInt(str, 2, 4);
1253
    int start = 4;
1254
1255
    if (str.charAt(start++) != '-')
1256
    {
1257
      throw new InvalidDatatypeValueException("Invalid format for gMonthDay: " + str);
1258
    }
1259
1260
    date[D] = parseInt(str, start, start + 2);
1261
1262
    if (MONTHDAY_SIZE < len)
1263
    {
1264
      int sign = findUTCSign(str, MONTHDAY_SIZE, len);
1265
      if (sign < 0)
1266
      {
1267
        throw new InvalidDatatypeValueException("Error in month parsing:" + str);
1268
      }
1269
      else
1270
      {
1271
        getTimeZone(str, date, sign, len, timeZone);
1272
      }
1273
    }
1274
    //validate and normalize
1275
1276
    validateDateTime(date, timeZone);
1277
1278
    if (date[utc] != 0 && date[utc] != 'Z')
1279
    {
1280
      normalize(date, timeZone);
1281
    }
1282
    return date;
1283
  }
1284
1285
  private int[] parseMonth(String str) throws InvalidDatatypeValueException
1286
  {
1287
    int len = str.length();
1288
    int[] date = new int [TOTAL_SIZE];
1289
    int[] timeZone = new int [2];
1290
1291
    //set constants
1292
    date[CY] = YEAR;
1293
    date[D] = DAY;
1294
    if (str.charAt(0) != '-' || str.charAt(1) != '-')
1295
    {
1296
      throw new InvalidDatatypeValueException("Invalid format for gMonth: " + str);
1297
    }
1298
    int stop = 4;
1299
    date[M] = parseInt(str, 2, stop);
1300
1301
    // REVISIT: allow both --MM and --MM-- now.
1302
    // need to remove the following 4 lines to disallow --MM--
1303
    // when the errata is offically in the rec.
1304
    if (str.length() >= stop + 2 && str.charAt(stop) == '-' && str.charAt(stop + 1) == '-')
1305
    {
1306
      stop += 2;
1307
    }
1308
    if (stop < len)
1309
    {
1310
      int sign = findUTCSign(str, stop, len);
1311
      if (sign < 0)
1312
      {
1313
        throw new InvalidDatatypeValueException("Error in month parsing: " + str);
1314
      }
1315
      else
1316
      {
1317
        getTimeZone(str, date, sign, len, timeZone);
1318
      }
1319
    }
1320
    //validate and normalize
1321
    validateDateTime(date, timeZone);
1322
1323
    if (date[utc] != 0 && date[utc] != 'Z')
1324
    {
1325
      normalize(date, timeZone);
1326
    }
1327
    return date;
1328
  }
1329
1330
  private int[] parseYear(String str) throws InvalidDatatypeValueException
1331
  {
1332
    int len = str.length();
1333
    int[] date = new int [TOTAL_SIZE];
1334
    int[] timeZone = new int [2];
1335
1336
    // check for preceding '-' sign
1337
    int start = 0;
1338
    if (str.charAt(0) == '-')
1339
    {
1340
      start = 1;
1341
    }
1342
    int sign = findUTCSign(str, start, len);
1343
    if (sign == -1)
1344
    {
1345
      date[CY] = parseIntYear(str, len);
1346
    }
1347
    else
1348
    {
1349
      date[CY] = parseIntYear(str, sign);
1350
      getTimeZone(str, date, sign, len, timeZone);
1351
    }
1352
1353
    //initialize values
1354
    date[M] = MONTH;
1355
    date[D] = 1;
1356
1357
    //validate and normalize
1358
    validateDateTime(date, timeZone);
1359
1360
    if (date[utc] != 0 && date[utc] != 'Z')
1361
    {
1362
      normalize(date, timeZone);
1363
    }
1364
    return date;
1365
  }
1366
1367
  private int[] parseYearMonth(String str) throws InvalidDatatypeValueException
1368
  {
1369
    int len = str.length();
1370
    int[] date = new int [TOTAL_SIZE];
1371
    int[] timeZone = new int [2];
1372
1373
    // get date
1374
    int end = getYearMonth(str, 0, len, date);
1375
    date[D] = DAY;
1376
    parseTimeZone(str, end, len, date, timeZone);
1377
1378
    //validate and normalize
1379
    validateDateTime(date, timeZone);
1380
1381
    if (date[utc] != 0 && date[utc] != 'Z')
1382
    {
1383
      normalize(date, timeZone);
1384
    }
1385
    return date;
1386
  }
1387
1388
  private int[] parseTime(String str) throws InvalidDatatypeValueException
1389
  {
1390
    int len = str.length();
1391
    int[] date = new int [TOTAL_SIZE];
1392
    int[] timeZone = new int [2];
1393
1394
    // time
1395
    // initialize to default values
1396
    date[CY] = YEAR;
1397
    date[M] = MONTH;
1398
    date[D] = DAY;
1399
    getTime(str, 0, len, date, timeZone);
1400
1401
    //validate and normalize
1402
1403
    validateDateTime(date, timeZone);
1404
1405
    if (date[utc] != 0)
1406
    {
1407
      normalize(date, timeZone);
1408
    }
1409
    return date;
1410
  }
1411
  
1412
1413
  private static class SafeSimpleDateFormat extends SimpleDateFormat
1414
  {
1415
    public SafeSimpleDateFormat(String pattern)
1416
    {
1417
      super(pattern);
1418
    }
1419
1420
    public synchronized Date parse(String source) throws ParseException
1421
    {
1422
      return super.parse(source);
1423
    }
1424
  }
1425
1426
}
(-)src/org/eclipse/emf/ecore/xml/type/internal/QName.java (-172 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: QName.java,v 1.3 2005/06/08 06:20:10 nickb Exp $
16
 */
17
18
package org.eclipse.emf.ecore.xml.type.internal;
19
20
import org.eclipse.emf.ecore.xml.type.InvalidDatatypeValueException;
21
import org.eclipse.emf.ecore.xml.type.internal.DataValue.XMLChar;
22
23
/**
24
 * A structure that holds the components of an XML Namespaces qualified
25
 * name.
26
 * Two QNames are equal iff they both have same namespaceURI and same localPart.
27
 * Note: prefix is not used in QName.equals(Object).
28
 * If not specified, the prefix is set to empty string ("").
29
 * If not specified, the namespace uri is set to empty string ("");
30
 * <p>
31
 * NOTE: this class is for internal use only.
32
 */
33
public final class QName
34
{
35
36
  private String prefix;
37
38
  private String localPart;
39
40
  private String namespaceURI;
41
  
42
  /**
43
   * Constructs a QName.
44
   * @param qname a <a href="http://www.w3.org/TR/REC-xml-names/#dt-qname">qualified name</a>
45
   * Throws Exception if value is not legal qualified name 
46
   */
47
  public QName (String qname)
48
  {
49
    String rawname = qname;
50
    int index = rawname.indexOf(":");
51
52
    String prefix = "";
53
    String localName = rawname;
54
    if (index != -1)
55
    {
56
      prefix    = rawname.substring(0, index);
57
      localName = rawname.substring(index + 1);
58
    }
59
    // both prefix (if any) a localpart must be valid NCName
60
    if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix))
61
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname);
62
63
    if(!XMLChar.isValidNCName(localName))
64
      throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname);
65
     
66
    setPrefix(prefix);
67
    setLocalPart(localName);
68
    setNamespaceURI(null);
69
  }
70
71
  /** Constructs a QName with the specified values. */
72
  public QName(String namespaceURI, String localPart, String prefix)
73
  {
74
    setNamespaceURI(namespaceURI);
75
    setPrefix(prefix);
76
    setLocalPart(localPart);
77
    if (this.prefix.length() > 0 && !XMLChar.isValidNCName(this.prefix))
78
      throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+prefix);
79
80
    if(!XMLChar.isValidNCName(this.localPart))
81
       throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+localPart);
82
  }
83
84
  /** Returns true if the two objects are equal. */
85
  public boolean equals(Object object)
86
  {
87
    if (object instanceof QName)
88
    {
89
      QName qname = (QName)object;
90
      return namespaceURI.equals(qname.getNamespaceURI()) && localPart.equals(qname.getLocalPart());
91
    }
92
    return false;
93
  }
94
  
95
  public int hashCode() 
96
  {
97
    return namespaceURI.hashCode() + localPart.hashCode();
98
  }
99
100
  /** Returns a string representation of this object. */
101
  public String toString()
102
  {
103
    return (prefix.length() >0) ? prefix + ":" + localPart : localPart;
104
  }
105
106
  /**
107
   * @return Returns the localpart.
108
   */
109
  public String getLocalPart()
110
  {
111
    return localPart;
112
  }
113
114
  /**
115
   * @param localpart The localpart to set.
116
   */
117
  public void setLocalPart(String localpart)
118
  {   
119
    if (localpart == null || localpart.length() == 0)
120
    {
121
      throw new IllegalArgumentException("QName localPart must have value.");
122
    }
123
    this.localPart = localpart;
124
  }
125
126
  /**
127
   * @return Returns the namespaceURI.
128
   */
129
  public String getNamespaceURI()
130
  {   
131
    return namespaceURI;
132
  }
133
134
  /**
135
   * @param namespaceUri The namespaceURI to set.
136
   */
137
  public void setNamespaceURI(String namespaceUri)
138
  {
139
    if (namespaceUri == null)
140
    {
141
      this.namespaceURI = "";
142
    }
143
    else 
144
    {
145
      this.namespaceURI = namespaceUri;
146
    }
147
    
148
  }
149
150
  /**
151
   * @return Returns the prefix.
152
   */
153
  public String getPrefix()
154
  {
155
    return prefix;
156
  }
157
158
  /**
159
   * @param prefix The prefix to set.
160
   */
161
  public void setPrefix(String prefix)
162
  {
163
    if (prefix == null)
164
    {
165
      this.prefix = "";
166
    }
167
    else
168
    {
169
      this.prefix = prefix;
170
    }
171
  }
172
} 
(-)src/org/eclipse/emf/ecore/xml/type/internal/RegEx.java (-7957 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2004-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: RegEx.java,v 1.8.4.1 2007/08/14 18:18:44 emerks Exp $
16
 *
17
 * ---------------------------------------------------------------------
18
 *
19
 * The Apache Software License, Version 1.1
20
 *
21
 *
22
 * Copyright (c) 1999-2004 The Apache Software Foundation.  All rights
23
 * reserved.
24
 *
25
 * Redistribution and use in source and binary forms, with or without
26
 * modification, are permitted provided that the following conditions
27
 * are met:
28
 *
29
 * 1. Redistributions of source code must retain the above copyright
30
 *    notice, this list of conditions and the following disclaimer.
31
 *
32
 * 2. Redistributions in binary form must reproduce the above copyright
33
 *    notice, this list of conditions and the following disclaimer in
34
 *    the documentation and/or other materials provided with the
35
 *    distribution.
36
 *
37
 * 3. The end-user documentation included with the redistribution,
38
 *    if any, must include the following acknowledgment:
39
 *       "This product includes software developed by the
40
 *        Apache Software Foundation (http://www.apache.org/)."
41
 *    Alternately, this acknowledgment may appear in the software itself,
42
 *    if and wherever such third-party acknowledgments normally appear.
43
 *
44
 * 4. The names "Xerces" and "Apache Software Foundation" must
45
 *    not be used to endorse or promote products derived from this
46
 *    software without prior written permission. For written
47
 *    permission, please contact apache@apache.org.
48
 *
49
 * 5. Products derived from this software may not be called "Apache",
50
 *    nor may "Apache" appear in their name, without prior written
51
 *    permission of the Apache Software Foundation.
52
 *
53
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
54
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
57
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
60
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
61
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
62
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
63
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64
 * SUCH DAMAGE.
65
 * ====================================================================
66
 *
67
 * This software consists of voluntary contributions made by many
68
 * individuals on behalf of the Apache Software Foundation and was
69
 * originally based on software copyright (c) 1999-2003, International
70
 * Business Machines, Inc., http://www.apache.org.  For more
71
 * information on the Apache Software Foundation, please see
72
 * <http://www.apache.org/>.
73
 */
74
75
package org.eclipse.emf.ecore.xml.type.internal;
76
77
78
import java.text.CharacterIterator;
79
import java.util.Hashtable;
80
import java.util.Locale;
81
import java.util.ResourceBundle;
82
import java.util.Vector;
83
84
import org.eclipse.emf.ecore.plugin.EcorePlugin;
85
86
/**
87
 * NOTE: this class is for internal use only.
88
 */
89
public final class RegEx
90
{
91
  static class BMPattern
92
  {
93
    char[] pattern;
94
95
    int[] shiftTable;
96
97
    boolean ignoreCase;
98
99
    public BMPattern(String pat, boolean ignoreCase)
100
    {
101
      this(pat, 256, ignoreCase);
102
    }
103
104
    public BMPattern(String pat, int tableSize, boolean ignoreCase)
105
    {
106
      this.pattern = pat.toCharArray();
107
      this.shiftTable = new int [tableSize];
108
      this.ignoreCase = ignoreCase;
109
      int length = pattern.length;
110
      for (int i = 0; i < this.shiftTable.length; i++)
111
        this.shiftTable[i] = length;
112
      for (int i = 0; i < length; i++)
113
      {
114
        char ch = this.pattern[i];
115
        int diff = length - i - 1;
116
        int index = ch % this.shiftTable.length;
117
        if (diff < this.shiftTable[index])
118
          this.shiftTable[index] = diff;
119
        if (this.ignoreCase)
120
        {
121
          ch = Character.toUpperCase(ch);
122
          index = ch % this.shiftTable.length;
123
          if (diff < this.shiftTable[index])
124
            this.shiftTable[index] = diff;
125
          ch = Character.toLowerCase(ch);
126
          index = ch % this.shiftTable.length;
127
          if (diff < this.shiftTable[index])
128
            this.shiftTable[index] = diff;
129
        }
130
      }
131
    }
132
133
    /**
134
     *
135
     * @return -1 if <var>iterator</var> does not contain this pattern.
136
     */
137
    public int matches(CharacterIterator iterator, int start, int limit)
138
    {
139
      if (this.ignoreCase)
140
        return this.matchesIgnoreCase(iterator, start, limit);
141
      int plength = this.pattern.length;
142
      if (plength == 0)
143
        return start;
144
      int index = start + plength;
145
      while (index <= limit)
146
      {
147
        int pindex = plength;
148
        int nindex = index + 1;
149
        char ch;
150
        do
151
        {
152
          if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
153
            break;
154
          if (pindex == 0)
155
            return index;
156
        }
157
        while (pindex > 0);
158
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
159
        if (index < nindex)
160
          index = nindex;
161
      }
162
      return -1;
163
    }
164
165
    /**
166
     *
167
     * @return -1 if <var>str</var> does not contain this pattern.
168
     */
169
    public int matches(String str, int start, int limit)
170
    {
171
      if (this.ignoreCase)
172
        return this.matchesIgnoreCase(str, start, limit);
173
      int plength = this.pattern.length;
174
      if (plength == 0)
175
        return start;
176
      int index = start + plength;
177
      while (index <= limit)
178
      {
179
        //System.err.println("Starts at "+index);
180
        int pindex = plength;
181
        int nindex = index + 1;
182
        char ch;
183
        do
184
        {
185
          if ((ch = str.charAt(--index)) != this.pattern[--pindex])
186
            break;
187
          if (pindex == 0)
188
            return index;
189
        }
190
        while (pindex > 0);
191
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
192
        if (index < nindex)
193
          index = nindex;
194
      }
195
      return -1;
196
    }
197
198
    /**
199
     *
200
     * @return -1 if <var>chars</char> does not contain this pattern.
201
     */
202
    public int matches(char[] chars, int start, int limit)
203
    {
204
      if (this.ignoreCase)
205
        return this.matchesIgnoreCase(chars, start, limit);
206
      int plength = this.pattern.length;
207
      if (plength == 0)
208
        return start;
209
      int index = start + plength;
210
      while (index <= limit)
211
      {
212
        //System.err.println("Starts at "+index);
213
        int pindex = plength;
214
        int nindex = index + 1;
215
        char ch;
216
        do
217
        {
218
          if ((ch = chars[--index]) != this.pattern[--pindex])
219
            break;
220
          if (pindex == 0)
221
            return index;
222
        }
223
        while (pindex > 0);
224
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
225
        if (index < nindex)
226
          index = nindex;
227
      }
228
      return -1;
229
    }
230
231
    int matchesIgnoreCase(CharacterIterator iterator, int start, int limit)
232
    {
233
      int plength = this.pattern.length;
234
      if (plength == 0)
235
        return start;
236
      int index = start + plength;
237
      while (index <= limit)
238
      {
239
        int pindex = plength;
240
        int nindex = index + 1;
241
        char ch;
242
        do
243
        {
244
          char ch1 = ch = iterator.setIndex(--index);
245
          char ch2 = this.pattern[--pindex];
246
          if (ch1 != ch2)
247
          {
248
            ch1 = Character.toUpperCase(ch1);
249
            ch2 = Character.toUpperCase(ch2);
250
            if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
251
              break;
252
          }
253
          if (pindex == 0)
254
            return index;
255
        }
256
        while (pindex > 0);
257
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
258
        if (index < nindex)
259
          index = nindex;
260
      }
261
      return -1;
262
    }
263
264
    int matchesIgnoreCase(String text, int start, int limit)
265
    {
266
      int plength = this.pattern.length;
267
      if (plength == 0)
268
        return start;
269
      int index = start + plength;
270
      while (index <= limit)
271
      {
272
        int pindex = plength;
273
        int nindex = index + 1;
274
        char ch;
275
        do
276
        {
277
          char ch1 = ch = text.charAt(--index);
278
          char ch2 = this.pattern[--pindex];
279
          if (ch1 != ch2)
280
          {
281
            ch1 = Character.toUpperCase(ch1);
282
            ch2 = Character.toUpperCase(ch2);
283
            if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
284
              break;
285
          }
286
          if (pindex == 0)
287
            return index;
288
        }
289
        while (pindex > 0);
290
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
291
        if (index < nindex)
292
          index = nindex;
293
      }
294
      return -1;
295
    }
296
297
    int matchesIgnoreCase(char[] chars, int start, int limit)
298
    {
299
      int plength = this.pattern.length;
300
      if (plength == 0)
301
        return start;
302
      int index = start + plength;
303
      while (index <= limit)
304
      {
305
        int pindex = plength;
306
        int nindex = index + 1;
307
        char ch;
308
        do
309
        {
310
          char ch1 = ch = chars[--index];
311
          char ch2 = this.pattern[--pindex];
312
          if (ch1 != ch2)
313
          {
314
            ch1 = Character.toUpperCase(ch1);
315
            ch2 = Character.toUpperCase(ch2);
316
            if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
317
              break;
318
          }
319
          if (pindex == 0)
320
            return index;
321
        }
322
        while (pindex > 0);
323
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
324
        if (index < nindex)
325
          index = nindex;
326
      }
327
      return -1;
328
    }
329
    /*
330
     public static void main(String[] argv) {
331
     try {
332
     int[] shiftTable = new int[256];
333
     initializeBoyerMoore(argv[0], shiftTable, true);
334
     int o = -1;
335
     CharacterIterator ite = new java.text.StringCharacterIterator(argv[1]);
336
     long start = System.currentTimeMillis();
337
     //for (int i = 0;  i < 10000;  i ++)
338
     o = searchIgnoreCasesWithBoyerMoore(ite, 0, argv[0], shiftTable);
339
     start = System.currentTimeMillis()-start;
340
     System.out.println("Result: "+o+", Elapsed: "+start);
341
     } catch (Exception ex) {
342
     ex.printStackTrace();
343
     }
344
     }*/
345
  }
346
  
347
  public static class Match implements Cloneable {
348
    int[] beginpos = null;
349
    int[] endpos = null;
350
    int nofgroups = 0;
351
352
    CharacterIterator ciSource = null;
353
    String strSource = null;
354
    char[] charSource = null;
355
356
    /**
357
     * Creates an instance.
358
     */
359
    public Match() {
360
    }
361
362
    /**
363
     *
364
     */
365
    public synchronized Object clone() {
366
        Match ma = new Match();
367
        if (this.nofgroups > 0) {
368
            ma.setNumberOfGroups(this.nofgroups);
369
            if (this.ciSource != null)  ma.setSource(this.ciSource);
370
            if (this.strSource != null)  ma.setSource(this.strSource);
371
            for (int i = 0;  i < this.nofgroups;  i ++) {
372
                ma.setBeginning(i, this.getBeginning(i));
373
                ma.setEnd(i, this.getEnd(i));
374
            }
375
        }
376
        return ma;
377
    }
378
379
    /**
380
     *
381
     */
382
    protected void setNumberOfGroups(int n) {
383
        int oldn = this.nofgroups;
384
        this.nofgroups = n;
385
        if (oldn <= 0
386
            || oldn < n || n*2 < oldn) {
387
            this.beginpos = new int[n];
388
            this.endpos = new int[n];
389
        }
390
        for (int i = 0;  i < n;  i ++) {
391
            this.beginpos[i] = -1;
392
            this.endpos[i] = -1;
393
        }
394
    }
395
396
    /**
397
     *
398
     */
399
    protected void setSource(CharacterIterator ci) {
400
        this.ciSource = ci;
401
        this.strSource = null;
402
        this.charSource = null;
403
    }
404
    /**
405
     *
406
     */
407
    protected void setSource(String str) {
408
        this.ciSource = null;
409
        this.strSource = str;
410
        this.charSource = null;
411
    }
412
    /**
413
     *
414
     */
415
    protected void setSource(char[] chars) {
416
        this.ciSource = null;
417
        this.strSource = null;
418
        this.charSource = chars;
419
    }
420
421
    /**
422
     *
423
     */
424
    protected void setBeginning(int index, int v) {
425
        this.beginpos[index] = v;
426
    }
427
428
    /**
429
     *
430
     */
431
    protected void setEnd(int index, int v) {
432
        this.endpos[index] = v;
433
    }
434
435
    /**
436
     * Return the number of regular expression groups.
437
     * This method returns 1 when the regular expression has no capturing-parenthesis.
438
     */
439
    public int getNumberOfGroups() {
440
        if (this.nofgroups <= 0)
441
            throw new IllegalStateException("A result is not set.");
442
        return this.nofgroups;
443
    }
444
445
    /**
446
     * Return a start position in the target text matched to specified regular expression group.
447
     *
448
     * @param index Less than <code>getNumberOfGroups()</code>.
449
     */
450
    public int getBeginning(int index) {
451
        if (this.beginpos == null)
452
            throw new IllegalStateException("A result is not set.");
453
        if (index < 0 || this.nofgroups <= index)
454
            throw new IllegalArgumentException("The parameter must be less than "
455
                                               +this.nofgroups+": "+index);
456
        return this.beginpos[index];
457
    }
458
459
    /**
460
     * Return an end position in the target text matched to specified regular expression group.
461
     *
462
     * @param index Less than <code>getNumberOfGroups()</code>.
463
     */
464
    public int getEnd(int index) {
465
        if (this.endpos == null)
466
            throw new IllegalStateException("A result is not set.");
467
        if (index < 0 || this.nofgroups <= index)
468
            throw new IllegalArgumentException("The parameter must be less than "
469
                                               +this.nofgroups+": "+index);
470
        return this.endpos[index];
471
    }
472
473
    /**
474
     * Return an substring of the target text matched to specified regular expression group.
475
     *
476
     * @param index Less than <code>getNumberOfGroups()</code>.
477
     */
478
    public String getCapturedText(int index) {
479
        if (this.beginpos == null)
480
            throw new IllegalStateException("match() has never been called.");
481
        if (index < 0 || this.nofgroups <= index)
482
            throw new IllegalArgumentException("The parameter must be less than "
483
                                               +this.nofgroups+": "+index);
484
        String ret;
485
        int begin = this.beginpos[index], end = this.endpos[index];
486
        if (begin < 0 || end < 0)  return null;
487
        if (this.ciSource != null) {
488
            ret = REUtil.substring(this.ciSource, begin, end);
489
        } else if (this.strSource != null) {
490
            ret = this.strSource.substring(begin, end);
491
        } else {
492
            ret = new String(this.charSource, begin, end-begin);
493
        }
494
        return ret;
495
    }
496
  }
497
  
498
  public final static class REUtil {
499
    private REUtil() {
500
    }
501
502
    static final int composeFromSurrogates(int high, int low) {
503
        return 0x10000 + ((high-0xd800)<<10) + low-0xdc00;
504
    }
505
506
    static final boolean isLowSurrogate(int ch) {
507
        return (ch & 0xfc00) == 0xdc00;
508
    }
509
510
    static final boolean isHighSurrogate(int ch) {
511
        return (ch & 0xfc00) == 0xd800;
512
    }
513
514
    static final String decomposeToSurrogates(int ch) {
515
        char[] chs = new char[2];
516
        ch -= 0x10000;
517
        chs[0] = (char)((ch>>10)+0xd800);
518
        chs[1] = (char)((ch&0x3ff)+0xdc00);
519
        return new String(chs);
520
    }
521
522
    static final String substring(CharacterIterator iterator, int begin, int end) {
523
        char[] src = new char[end-begin];
524
        for (int i = 0;  i < src.length;  i ++)
525
            src[i] = iterator.setIndex(i+begin);
526
        return new String(src);
527
    }
528
529
    // ================================================================
530
531
    static final int getOptionValue(int ch) {
532
        int ret = 0;
533
        switch (ch) {
534
          case 'i':
535
            ret = RegularExpression.IGNORE_CASE;
536
            break;
537
          case 'm':
538
            ret = RegularExpression.MULTIPLE_LINES;
539
            break;
540
          case 's':
541
            ret = RegularExpression.SINGLE_LINE;
542
            break;
543
          case 'x':
544
            ret = RegularExpression.EXTENDED_COMMENT;
545
            break;
546
          case 'u':
547
            ret = RegularExpression.USE_UNICODE_CATEGORY;
548
            break;
549
          case 'w':
550
            ret = RegularExpression.UNICODE_WORD_BOUNDARY;
551
            break;
552
          case 'F':
553
            ret = RegularExpression.PROHIBIT_FIXED_STRING_OPTIMIZATION;
554
            break;
555
          case 'H':
556
            ret = RegularExpression.PROHIBIT_HEAD_CHARACTER_OPTIMIZATION;
557
            break;
558
          case 'X':
559
            ret = RegularExpression.XMLSCHEMA_MODE;
560
            break;
561
          case ',':
562
            ret = RegularExpression.SPECIAL_COMMA;
563
            break;
564
          default:
565
        }
566
        return ret;
567
    }
568
569
    static final int parseOptions(String opts) throws ParseException {
570
        if (opts == null)  return 0;
571
        int options = 0;
572
        for (int i = 0;  i < opts.length();  i ++) {
573
            int v = getOptionValue(opts.charAt(i));
574
            if (v == 0)
575
                throw new ParseException("Unknown Option: "+opts.substring(i), -1);
576
            options |= v;
577
        }
578
        return options;
579
    }
580
581
    static final String createOptionString(int options) {
582
        StringBuffer sb = new StringBuffer(9);
583
        if ((options & RegularExpression.PROHIBIT_FIXED_STRING_OPTIMIZATION) != 0)
584
            sb.append('F');
585
        if ((options & RegularExpression.PROHIBIT_HEAD_CHARACTER_OPTIMIZATION) != 0)
586
            sb.append('H');
587
        if ((options & RegularExpression.XMLSCHEMA_MODE) != 0)
588
            sb.append('X');
589
        if ((options & RegularExpression.IGNORE_CASE) != 0)
590
            sb.append('i');
591
        if ((options & RegularExpression.MULTIPLE_LINES) != 0)
592
            sb.append('m');
593
        if ((options & RegularExpression.SINGLE_LINE) != 0)
594
            sb.append('s');
595
        if ((options & RegularExpression.USE_UNICODE_CATEGORY) != 0)
596
            sb.append('u');
597
        if ((options & RegularExpression.UNICODE_WORD_BOUNDARY) != 0)
598
            sb.append('w');
599
        if ((options & RegularExpression.EXTENDED_COMMENT) != 0)
600
            sb.append('x');
601
        if ((options & RegularExpression.SPECIAL_COMMA) != 0)
602
            sb.append(',');
603
        return sb.toString().intern();
604
    }
605
606
    // ================================================================
607
608
    static String stripExtendedComment(String regex) {
609
        int len = regex.length();
610
        StringBuffer buffer = new StringBuffer(len);
611
        int offset = 0;
612
        while (offset < len) {
613
            int ch = regex.charAt(offset++);
614
                                                // Skips a white space.
615
            if (ch == '\t' || ch == '\n' || ch == '\f' || ch == '\r' || ch == ' ')
616
                continue;
617
618
            if (ch == '#') {                    // Skips chracters between '#' and a line end.
619
                while (offset < len) {
620
                    ch = regex.charAt(offset++);
621
                    if (ch == '\r' || ch == '\n')
622
                        break;
623
                }
624
                continue;
625
            }
626
627
            int next;                           // Strips an escaped white space.
628
            if (ch == '\\' && offset < len) {
629
                if ((next = regex.charAt(offset)) == '#'
630
                    || next == '\t' || next == '\n' || next == '\f'
631
                    || next == '\r' || next == ' ') {
632
                    buffer.append((char)next);
633
                    offset ++;
634
                } else {                        // Other escaped character.
635
                    buffer.append('\\');
636
                    buffer.append((char)next);
637
                    offset ++;
638
                }
639
            } else                              // As is.
640
                buffer.append((char)ch);
641
        }
642
        return buffer.toString();
643
    }
644
645
    // ================================================================
646
647
    /**
648
     * Sample entry.
649
     * <div>Usage: <KBD>org.apache.xerces.utils.regex.REUtil &lt;regex&gt; &lt;string&gt;</KBD></div>
650
     */
651
    public static void main(String[] argv) {
652
        String pattern = null;
653
        try {
654
            String options = "";
655
            String target = null;
656
            if( argv.length == 0 ) {
657
                System.out.println( "Error:Usage: java REUtil -i|-m|-s|-u|-w|-X regularExpression String" );
658
                System.exit( 0 );
659
            }
660
            for (int i = 0;  i < argv.length;  i ++) {
661
                if (argv[i].length() == 0 || argv[i].charAt(0) != '-') {
662
                    if (pattern == null)
663
                        pattern = argv[i];
664
                    else if (target == null)
665
                        target = argv[i];
666
                    else
667
                        System.err.println("Unnecessary: "+argv[i]);
668
                } else if (argv[i].equals("-i")) {
669
                    options += "i";
670
                } else if (argv[i].equals("-m")) {
671
                    options += "m";
672
                } else if (argv[i].equals("-s")) {
673
                    options += "s";
674
                } else if (argv[i].equals("-u")) {
675
                    options += "u";
676
                } else if (argv[i].equals("-w")) {
677
                    options += "w";
678
                } else if (argv[i].equals("-X")) {
679
                    options += "X";
680
                } else {
681
                    System.err.println("Unknown option: "+argv[i]);
682
                }
683
            }
684
            RegularExpression reg = new RegularExpression(pattern, options);
685
            System.out.println("RegularExpression: "+reg);
686
            Match match = new Match();
687
            reg.matches(target, match);
688
            for (int i = 0;  i < match.getNumberOfGroups();  i ++) {
689
                if (i == 0 )  System.out.print("Matched range for the whole pattern: ");
690
                else System.out.print("["+i+"]: ");
691
                if (match.getBeginning(i) < 0)
692
                    System.out.println("-1");
693
                else {
694
                    System.out.print(match.getBeginning(i)+", "+match.getEnd(i)+", ");
695
                    System.out.println("\""+match.getCapturedText(i)+"\"");
696
                }
697
            }
698
        } catch (ParseException pe) {
699
            if (pattern == null) {
700
                pe.printStackTrace();
701
            } else {
702
                System.err.println("org.apache.xerces.utils.regex.ParseException: "+pe.getMessage());
703
                String indent = "        ";
704
                System.err.println(indent+pattern);
705
                int loc = pe.getLocation();
706
                if (loc >= 0) {
707
                    System.err.print(indent);
708
                    for (int i = 0;  i < loc;  i ++)  System.err.print("-");
709
                    System.err.println("^");
710
                }
711
            }
712
        } catch (Exception e) {
713
            e.printStackTrace();
714
        }
715
    }
716
717
    static final int CACHESIZE = 20;
718
    static final RegularExpression[] regexCache = new RegularExpression[CACHESIZE];
719
    /**
720
     * Creates a RegularExpression instance.
721
     * This method caches created instances.
722
     *
723
     * @see RegularExpression#RegularExpression(String, String)
724
     */
725
    public static RegularExpression createRegex(String pattern, String options)
726
        throws ParseException {
727
        RegularExpression re = null;
728
        int intOptions = REUtil.parseOptions(options);
729
        synchronized (REUtil.regexCache) {
730
            int i;
731
            for (i = 0;  i < REUtil.CACHESIZE;  i ++) {
732
                RegularExpression cached = REUtil.regexCache[i];
733
                if (cached == null) {
734
                    i = -1;
735
                    break;
736
                }
737
                if (cached.equals(pattern, intOptions)) {
738
                    re = cached;
739
                    break;
740
                }
741
            }
742
            if (re != null) {
743
                if (i != 0) {
744
                    System.arraycopy(REUtil.regexCache, 0, REUtil.regexCache, 1, i);
745
                    REUtil.regexCache[0] = re;
746
                }
747
            } else {
748
                re = new RegularExpression(pattern, options);
749
                System.arraycopy(REUtil.regexCache, 0, REUtil.regexCache, 1, REUtil.CACHESIZE-1);
750
                REUtil.regexCache[0] = re;
751
            }
752
        }
753
        return re;
754
    }
755
756
    /**
757
     *
758
     * @see RegularExpression#matches(String)
759
     */
760
    public static boolean matches(String regex, String target) throws ParseException {
761
        return REUtil.createRegex(regex, null).matches(target);
762
    }
763
764
    /**
765
     *
766
     * @see RegularExpression#matches(String)
767
     */
768
    public static boolean matches(String regex, String options, String target) throws ParseException {
769
        return REUtil.createRegex(regex, options).matches(target);
770
    }
771
772
    // ================================================================
773
774
    /**
775
     *
776
     */
777
    public static String quoteMeta(String literal) {
778
        int len = literal.length();
779
        StringBuffer buffer = null;
780
        for (int i = 0;  i < len;  i ++) {
781
            int ch = literal.charAt(i);
782
            if (".*+?{[()|\\^$".indexOf(ch) >= 0) {
783
                if (buffer == null) {
784
                    buffer = new StringBuffer(i+(len-i)*2);
785
                    if (i > 0)  buffer.append(literal.substring(0, i));
786
                }
787
                buffer.append('\\');
788
                buffer.append((char)ch);
789
            } else if (buffer != null)
790
                buffer.append((char)ch);
791
        }
792
        return buffer != null ? buffer.toString() : literal;
793
    }
794
795
    // ================================================================
796
797
    static void dumpString(String v) {
798
        for (int i = 0;  i < v.length();  i ++) {
799
            System.out.print(Integer.toHexString(v.charAt(i)));
800
            System.out.print(" ");
801
        }
802
        System.out.println();
803
    }
804
}
805
  
806
807
  /**
808
   * A regular expression matching engine using Non-deterministic Finite Automaton (NFA).
809
   * This engine does not conform to the POSIX regular expression.
810
   *
811
   * <hr width="50%">
812
   * <h3>How to use</h3>
813
   *
814
   * <dl>
815
   *   <dt>A. Standard way
816
   *   <dd>
817
   * <pre>
818
   * RegularExpression re = new RegularExpression(<var>regex</var>);
819
   * if (re.matches(text)) { ... }
820
   * </pre>
821
   *
822
   *   <dt>B. Capturing groups
823
   *   <dd>
824
   * <pre>
825
   * RegularExpression re = new RegularExpression(<var>regex</var>);
826
   * Match match = new Match();
827
   * if (re.matches(text, match)) {
828
   *     ... // You can refer captured texts with methods of the <code>Match</code> class.
829
   * }
830
   * </pre>
831
   *
832
   * </dl>
833
   *
834
   * <h4>Case-insensitive matching</h4>
835
   * <pre>
836
   * RegularExpression re = new RegularExpression(<var>regex</var>, "i");
837
   * if (re.matches(text) >= 0) { ...}
838
   * </pre>
839
   *
840
   * <h4>Options</h4>
841
   * <p>You can specify options to <a href="#RegularExpression(java.lang.String, java.lang.String)"><code>RegularExpression(</code><var>regex</var><code>, </code><var>options</var><code>)</code></a>
842
   *    or <a href="#setPattern(java.lang.String, java.lang.String)"><code>setPattern(</code><var>regex</var><code>, </code><var>options</var><code>)</code></a>.
843
   *    This <var>options</var> parameter consists of the following characters.
844
   * </p>
845
   * <dl>
846
   *   <dt><a name="I_OPTION"><code>"i"</code></a>
847
   *   <dd>This option indicates case-insensitive matching.
848
   *   <dt><a name="M_OPTION"><code>"m"</code></a>
849
   *   <dd class="REGEX"><kbd>^</kbd> and <kbd>$</kbd> consider the EOL characters within the text.
850
   *   <dt><a name="S_OPTION"><code>"s"</code></a>
851
   *   <dd class="REGEX"><kbd>.</kbd> matches any one character.
852
   *   <dt><a name="U_OPTION"><code>"u"</code></a>
853
   *   <dd class="REGEX">Redefines <Kbd>\d \D \w \W \s \S \b \B \&lt; \></kbd> as becoming to Unicode.
854
   *   <dt><a name="W_OPTION"><code>"w"</code></a>
855
   *   <dd class="REGEX">By this option, <kbd>\b \B \&lt; \></kbd> are processed with the method of
856
   *      'Unicode Regular Expression Guidelines' Revision 4.
857
   *      When "w" and "u" are specified at the same time,
858
   *      <kbd>\b \B \&lt; \></kbd> are processed for the "w" option.
859
   *   <dt><a name="COMMA_OPTION"><code>","</code></a>
860
   *   <dd>The parser treats a comma in a character class as a range separator.
861
   *      <kbd class="REGEX">[a,b]</kbd> matches <kbd>a</kbd> or <kbd>,</kbd> or <kbd>b</kbd> without this option.
862
   *      <kbd class="REGEX">[a,b]</kbd> matches <kbd>a</kbd> or <kbd>b</kbd> with this option.
863
   *
864
   *   <dt><a name="X_OPTION"><code>"X"</code></a>
865
   *   <dd class="REGEX">
866
   *       By this option, the engine confoms to <a href="http://www.w3.org/TR/2000/WD-xmlschema-2-20000407/#regexs">XML Schema: Regular Expression</a>.
867
   *       The <code>match()</code> method does not do subsring matching
868
   *       but entire string matching.
869
   *
870
   * </dl>
871
   * 
872
   * <hr width="50%">
873
   * <h3>Syntax</h3>
874
   * <table border="1" bgcolor="#ddeeff">
875
   *   <tr>
876
   *    <td>
877
   *     <h4>Differences from the Perl 5 regular expression</h4>
878
   *     <ul>
879
   *      <li>There is 6-digit hexadecimal character representation  (<kbd>\u005cv</kbd><var>HHHHHH</var>.)
880
   *      <li>Supports subtraction, union, and intersection operations for character classes.
881
   *      <li>Not supported: <kbd>\</kbd><var>ooo</var> (Octal character representations),
882
   *          <Kbd>\G</kbd>, <kbd>\C</kbd>, <kbd>\l</kbd><var>c</var>,
883
   *          <kbd>\u005c u</kbd><var>c</var>, <kbd>\L</kbd>, <kbd>\U</kbd>,
884
   *          <kbd>\E</kbd>, <kbd>\Q</kbd>, <kbd>\N{</kbd><var>name</var><kbd>}</kbd>,
885
   *          <Kbd>(?{<kbd><var>code</var><kbd>})</kbd>, <Kbd>(??{<kbd><var>code</var><kbd>})</kbd>
886
   *     </ul>
887
   *    </td>
888
   *   </tr>
889
   * </table>
890
   *
891
   * <P>Meta characters are `<KBD>. * + ? { [ ( ) | \ ^ $</KBD>'.</P>
892
   * <ul>
893
   *   <li>Character
894
   *     <dl>
895
   *       <dt class="REGEX"><kbd>.</kbd> (A period)
896
   *       <dd>Matches any one character except the following characters.
897
   *       <dd>LINE FEED (U+000A), CARRIAGE RETURN (U+000D),
898
   *           PARAGRAPH SEPARATOR (U+2029), LINE SEPARATOR (U+2028)
899
   *       <dd>This expression matches one code point in Unicode. It can match a pair of surrogates.
900
   *       <dd>When <a href="#S_OPTION">the "s" option</a> is specified,
901
   *           it matches any character including the above four characters.
902
   *
903
   *       <dt class="REGEX"><Kbd>\e \f \n \r \t</kbd>
904
   *       <dd>Matches ESCAPE (U+001B), FORM FEED (U+000C), LINE FEED (U+000A),
905
   *           CARRIAGE RETURN (U+000D), HORIZONTAL TABULATION (U+0009)
906
   *
907
   *       <dt class="REGEX"><kbd>\c</kbd><var>C</var>
908
   *       <dd>Matches a control character.
909
   *           The <var>C</var> must be one of '<kbd>@</kbd>', '<kbd>A</kbd>'-'<kbd>Z</kbd>',
910
   *           '<kbd>[</kbd>', '<kbd>\u005c</kbd>', '<kbd>]</kbd>', '<kbd>^</kbd>', '<kbd>_</kbd>'.
911
   *           It matches a control character of which the character code is less than
912
   *           the character code of the <var>C</var> by 0x0040.
913
   *       <dd class="REGEX">For example, a <kbd>\cJ</kbd> matches a LINE FEED (U+000A),
914
   *           and a <kbd>\c[</kbd> matches an ESCAPE (U+001B).
915
   *
916
   *       <dt class="REGEX">a non-meta character
917
   *       <dd>Matches the character.
918
   *
919
   *       <dt class="REGEX"><KBD>\</KBD> + a meta character
920
   *       <dd>Matches the meta character.
921
   *
922
   *       <dt class="REGEX"><kbd>\u005cx</kbd><var>HH</var> <kbd>\u005cx{</kbd><var>HHHH</var><kbd>}</kbd>
923
   *       <dd>Matches a character of which code point is <var>HH</var> (Hexadecimal) in Unicode.
924
   *           You can write just 2 digits for <kbd>\u005cx</kbd><var>HH</var>, and
925
   *           variable length digits for <kbd>\u005cx{</kbd><var>HHHH</var><kbd>}</kbd>.
926
   *
927
   *       <!--
928
   *       <dt class="REGEX"><kbd>\u005c u</kbd><var>HHHH</var>
929
   *       <dd>Matches a character of which code point is <var>HHHH</var> (Hexadecimal) in Unicode.
930
   *       -->
931
   *
932
   *       <dt class="REGEX"><kbd>\u005cv</kbd><var>HHHHHH</var>
933
   *       <dd>Matches a character of which code point is <var>HHHHHH</var> (Hexadecimal) in Unicode.
934
   *
935
   *       <dt class="REGEX"><kbd>\g</kbd>
936
   *       <dd>Matches a grapheme.
937
   *       <dd class="REGEX">It is equivalent to <kbd>(?[\p{ASSIGNED}]-[\p{M}\p{C}])?(?:\p{M}|[\x{094D}\x{09CD}\x{0A4D}\x{0ACD}\x{0B3D}\x{0BCD}\x{0C4D}\x{0CCD}\x{0D4D}\x{0E3A}\x{0F84}]\p{L}|[\x{1160}-\x{11A7}]|[\x{11A8}-\x{11FF}]|[\x{FF9E}\x{FF9F}])*</kbd>
938
   *
939
   *       <dt class="REGEX"><kbd>\X</kbd>
940
   *       <dd class="REGEX">Matches a combining character sequence.
941
   *       It is equivalent to <kbd>(?:\PM\pM*)</kbd>
942
   *     </dl>
943
   *   </li>
944
   *
945
   *   <li>Character class
946
   *     <dl>
947
  + *       <dt class="REGEX"><kbd>[</kbd><var>R<sub>1</sub></var><var>R<sub>2</sub></var><var>...</var><var>R<sub>n</sub></var><kbd>]</kbd> (without <a href="#COMMA_OPTION">"," option</a>)
948
  + *       <dt class="REGEX"><kbd>[</kbd><var>R<sub>1</sub></var><kbd>,</kbd><var>R<sub>2</sub></var><kbd>,</kbd><var>...</var><kbd>,</kbd><var>R<sub>n</sub></var><kbd>]</kbd> (with <a href="#COMMA_OPTION">"," option</a>)
949
   *       <dd>Positive character class.  It matches a character in ranges.
950
   *       <dd><var>R<sub>n</sub></var>:
951
   *       <ul>
952
   *         <li class="REGEX">A character (including <Kbd>\e \f \n \r \t</kbd> <kbd>\u005cx</kbd><var>HH</var> <kbd>\u005cx{</kbd><var>HHHH</var><kbd>}</kbd> <!--kbd>\u005c u</kbd><var>HHHH</var--> <kbd>\u005cv</kbd><var>HHHHHH</var>)
953
   *             <p>This range matches the character.
954
   *         <li class="REGEX"><var>C<sub>1</sub></var><kbd>-</kbd><var>C<sub>2</sub></var>
955
   *             <p>This range matches a character which has a code point that is >= <var>C<sub>1</sub></var>'s code point and &lt;= <var>C<sub>2</sub></var>'s code point.
956
  + *         <li class="REGEX">A POSIX character class: <Kbd>[:alpha:] [:alnum:] [:ascii:] [:cntrl:] [:digit:] [:graph:] [:lower:] [:print:] [:punct:] [:space:] [:upper:] [:xdigit:]</kbd>,
957
  + *             and negative POSIX character classes in Perl like <kbd>[:^alpha:]</kbd>
958
   *             <p>...
959
   *         <li class="REGEX"><kbd>\d \D \s \S \w \W \p{</kbd><var>name</var><kbd>} \P{</kbd><var>name</var><kbd>}</kbd>
960
   *             <p>These expressions specifies the same ranges as the following expressions.
961
   *       </ul>
962
   *       <p class="REGEX">Enumerated ranges are merged (union operation).
963
   *          <kbd>[a-ec-z]</kbd> is equivalent to <kbd>[a-z]</kbd>
964
   *
965
   *       <dt class="REGEX"><kbd>[^</kbd><var>R<sub>1</sub></var><var>R<sub>2</sub></var><var>...</var><var>R<sub>n</sub></var><kbd>]</kbd> (without a <a href="#COMMA_OPTION">"," option</a>)
966
   *       <dt class="REGEX"><kbd>[^</kbd><var>R<sub>1</sub></var><kbd>,</kbd><var>R<sub>2</sub></var><kbd>,</kbd><var>...</var><kbd>,</kbd><var>R<sub>n</sub></var><kbd>]</kbd> (with a <a href="#COMMA_OPTION">"," option</a>)
967
   *       <dd>Negative character class.  It matches a character not in ranges.
968
   *
969
   *       <dt class="REGEX"><kbd>(?[</kbd><var>ranges</var><kbd>]</kbd><var>op</var><kbd>[</kbd><var>ranges</var><kbd>]</kbd><var>op</var><kbd>[</kbd><var>ranges</var><kbd>]</kbd> ... <Kbd>)</kbd>
970
   *       (<var>op</var> is <kbd>-</kbd> or <kbd>+</kbd> or <kbd>&</kbd>.)
971
   *       <dd>Subtraction or union or intersection for character classes.
972
   *       <dd class="REGEX">For exmaple, <kbd>(?[A-Z]-[CF])</kbd> is equivalent to <kbd>[A-BD-EG-Z]</kbd>, and <kbd>(?[0x00-0x7f]-[K]&[\p{Lu}])</kbd> is equivalent to <kbd>[A-JL-Z]</kbd>.
973
   *       <dd>The result of this operations is a <u>positive character class</u>
974
   *           even if an expression includes any negative character classes.
975
   *           You have to take care on this in case-insensitive matching.
976
   *           For instance, <kbd>(?[^b])</kbd> is equivalent to <kbd>[\x00-ac-\x{10ffff}]</kbd>,
977
   *           which is equivalent to <kbd>[^b]</kbd> in case-sensitive matching.
978
   *           But, in case-insensitive matching, <kbd>(?[^b])</kbd> matches any character because
979
   *           it includes '<kbd>B</kbd>' and '<kbd>B</kbd>' matches '<kbd>b</kbd>'
980
   *           though <kbd>[^b]</kbd> is processed as <kbd>[^Bb]</kbd>.
981
   *
982
   *       <dt class="REGEX"><kbd>[</kbd><var>R<sub>1</sub>R<sub>2</sub>...</var><kbd>-[</kbd><var>R<sub>n</sub>R<sub>n+1</sub>...</var><kbd>]]</kbd> (with an <a href="#X_OPTION">"X" option</a>)</dt>
983
   *       <dd>Character class subtraction for the XML Schema.
984
   *           You can use this syntax when you specify an <a href="#X_OPTION">"X" option</a>.
985
   *           
986
   *       <dt class="REGEX"><kbd>\d</kbd>
987
   *       <dd class="REGEX">Equivalent to <kbd>[0-9]</kbd>.
988
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
989
   *           <span class="REGEX"><kbd>\p{Nd}</kbd></span>.
990
   *
991
   *       <dt class="REGEX"><kbd>\D</kbd>
992
   *       <dd class="REGEX">Equivalent to <kbd>[^0-9]</kbd>
993
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
994
   *           <span class="REGEX"><kbd>\P{Nd}</kbd></span>.
995
   *
996
   *       <dt class="REGEX"><kbd>\s</kbd>
997
   *       <dd class="REGEX">Equivalent to <kbd>[ \f\n\r\t]</kbd>
998
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
999
   *           <span class="REGEX"><kbd>[ \f\n\r\t\p{Z}]</kbd></span>.
1000
   *
1001
   *       <dt class="REGEX"><kbd>\S</kbd>
1002
   *       <dd class="REGEX">Equivalent to <kbd>[^ \f\n\r\t]</kbd>
1003
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
1004
   *           <span class="REGEX"><kbd>[^ \f\n\r\t\p{Z}]</kbd></span>.
1005
   *
1006
   *       <dt class="REGEX"><kbd>\w</kbd>
1007
   *       <dd class="REGEX">Equivalent to <kbd>[a-zA-Z0-9_]</kbd>
1008
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
1009
   *           <span class="REGEX"><kbd>[\p{Lu}\p{Ll}\p{Lo}\p{Nd}_]</kbd></span>.
1010
   *
1011
   *       <dt class="REGEX"><kbd>\W</kbd>
1012
   *       <dd class="REGEX">Equivalent to <kbd>[^a-zA-Z0-9_]</kbd>
1013
   *       <dd>When <a href="#U_OPTION">a "u" option</a> is set, it is equivalent to
1014
   *           <span class="REGEX"><kbd>[^\p{Lu}\p{Ll}\p{Lo}\p{Nd}_]</kbd></span>.
1015
   *
1016
   *       <dt class="REGEX"><kbd>\p{</kbd><var>name</var><kbd>}</kbd>
1017
   *       <dd>Matches one character in the specified General Category (the second field in <a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt"><kbd>UnicodeData.txt</kbd></a>) or the specified <a href="ftp://ftp.unicode.org/Public/UNIDATA/Blocks.txt">Block</a>.
1018
   *       The following names are available:
1019
   *       <dl>
1020
   *         <dt>Unicode General Categories:
1021
   *         <dd><kbd>
1022
   *       L, M, N, Z, C, P, S, Lu, Ll, Lt, Lm, Lo, Mn, Me, Mc, Nd, Nl, No, Zs, Zl, Zp,
1023
   *       Cc, Cf, Cn, Co, Cs, Pd, Ps, Pe, Pc, Po, Sm, Sc, Sk, So,
1024
   *         </kbd>
1025
   *         <dd>(Currently the Cn category includes U+10000-U+10FFFF characters)
1026
   *         <dt>Unicode Blocks:
1027
   *         <dd><kbd>
1028
   *       Basic Latin, Latin-1 Supplement, Latin Extended-A, Latin Extended-B,
1029
   *       IPA Extensions, Spacing Modifier Letters, Combining Diacritical Marks, Greek,
1030
   *       Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Bengali, Gurmukhi, Gujarati,
1031
   *       Oriya, Tamil, Telugu, Kannada, Malayalam, Thai, Lao, Tibetan, Georgian,
1032
   *       Hangul Jamo, Latin Extended Additional, Greek Extended, General Punctuation,
1033
   *       Superscripts and Subscripts, Currency Symbols, Combining Marks for Symbols,
1034
   *       Letterlike Symbols, Number Forms, Arrows, Mathematical Operators,
1035
   *       Miscellaneous Technical, Control Pictures, Optical Character Recognition,
1036
   *       Enclosed Alphanumerics, Box Drawing, Block Elements, Geometric Shapes,
1037
   *       Miscellaneous Symbols, Dingbats, CJK Symbols and Punctuation, Hiragana,
1038
   *       Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun,
1039
   *       Enclosed CJK Letters and Months, CJK Compatibility, CJK Unified Ideographs,
1040
   *       Hangul Syllables, High Surrogates, High Private Use Surrogates, Low Surrogates,
1041
   *       Private Use, CJK Compatibility Ideographs, Alphabetic Presentation Forms,
1042
   *       Arabic Presentation Forms-A, Combining Half Marks, CJK Compatibility Forms,
1043
   *       Small Form Variants, Arabic Presentation Forms-B, Specials,
1044
   *       Halfwidth and Fullwidth Forms
1045
   *         </kbd>
1046
   *         <dt>Others:
1047
   *         <dd><kbd>ALL</kbd> (Equivalent to <kbd>[\u005cu0000-\u005cv10FFFF]</kbd>)
1048
   *         <dd><kbd>ASSGINED</kbd> (<kbd>\p{ASSIGNED}</kbd> is equivalent to <kbd>\P{Cn}</kbd>)
1049
   *         <dd><kbd>UNASSGINED</kbd>
1050
   *             (<kbd>\p{UNASSIGNED}</kbd> is equivalent to <kbd>\p{Cn}</kbd>)
1051
   *       </dl>
1052
   *
1053
   *       <dt class="REGEX"><kbd>\P{</kbd><var>name</var><kbd>}</kbd>
1054
   *       <dd>Matches one character not in the specified General Category or the specified Block.
1055
   *     </dl>
1056
   *   </li>
1057
   *
1058
   *   <li>Selection and Quantifier
1059
   *     <dl>
1060
   *       <dt class="REGEX"><VAR>X</VAR><kbd>|</kbd><VAR>Y</VAR>
1061
   *       <dd>...
1062
   *
1063
   *       <dt class="REGEX"><VAR>X</VAR><kbd>*</KBD>
1064
   *       <dd>Matches 0 or more <var>X</var>.
1065
   *
1066
   *       <dt class="REGEX"><VAR>X</VAR><kbd>+</KBD>
1067
   *       <dd>Matches 1 or more <var>X</var>.
1068
   *
1069
   *       <dt class="REGEX"><VAR>X</VAR><kbd>?</KBD>
1070
   *       <dd>Matches 0 or 1 <var>X</var>.
1071
   *
1072
   *       <dt class="REGEX"><var>X</var><kbd>{</kbd><var>number</var><kbd>}</kbd>
1073
   *       <dd>Matches <var>number</var> times.
1074
   *
1075
   *       <dt class="REGEX"><var>X</var><kbd>{</kbd><var>min</var><kbd>,}</kbd>
1076
   *       <dd>...
1077
   *
1078
   *       <dt class="REGEX"><var>X</var><kbd>{</kbd><var>min</var><kbd>,</kbd><var>max</var><kbd>}</kbd>
1079
   *       <dd>...
1080
   *
1081
   *       <dt class="REGEX"><VAR>X</VAR><kbd>*?</kbd>
1082
   *       <dt class="REGEX"><VAR>X</VAR><kbd>+?</kbd>
1083
   *       <dt class="REGEX"><VAR>X</VAR><kbd>??</kbd>
1084
   *       <dt class="REGEX"><var>X</var><kbd>{</kbd><var>min</var><kbd>,}?</kbd>
1085
   *       <dt class="REGEX"><var>X</var><kbd>{</kbd><var>min</var><kbd>,</kbd><var>max</var><kbd>}?</kbd>
1086
   *       <dd>Non-greedy matching.
1087
   *     </dl>
1088
   *   </li>
1089
   *
1090
   *   <li>Grouping, Capturing, and Back-reference
1091
   *     <dl>
1092
   *       <dt class="REGEX"><KBD>(?:</kbd><VAR>X</VAR><kbd>)</KBD>
1093
   *       <dd>Grouping. "<KBD>foo+</KBD>" matches "<KBD>foo</KBD>" or "<KBD>foooo</KBD>".
1094
   *       If you want it matches "<KBD>foofoo</KBD>" or "<KBD>foofoofoo</KBD>",
1095
   *       you have to write "<KBD>(?:foo)+</KBD>".
1096
   *
1097
   *       <dt class="REGEX"><KBD>(</kbd><VAR>X</VAR><kbd>)</KBD>
1098
   *       <dd>Grouping with capturing.
1099
   * It make a group and applications can know
1100
   * where in target text a group matched with methods of a <code>Match</code> instance
1101
   * after <code><a href="#matches(java.lang.String, org.apache.xerces.utils.regex.Match)">matches(String,Match)</a></code>.
1102
   * The 0th group means whole of this regular expression.
1103
   * The <VAR>N</VAR>th gorup is the inside of the <VAR>N</VAR>th left parenthesis.
1104
   * 
1105
   *   <p>For instance, a regular expression is
1106
   *   "<FONT color=blue><KBD> *([^&lt;:]*) +&lt;([^&gt;]*)&gt; *</KBD></FONT>"
1107
   *   and target text is
1108
   *   "<FONT color=red><KBD>From: TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;</KBD></FONT>":
1109
   *   <ul>
1110
   *     <li><code>Match.getCapturedText(0)</code>:
1111
   *     "<FONT color=red><KBD> TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;</KBD></FONT>"
1112
   *     <li><code>Match.getCapturedText(1)</code>: "<FONT color=red><KBD>TAMURA Kent</KBD></FONT>"
1113
   *     <li><code>Match.getCapturedText(2)</code>: "<FONT color=red><KBD>kent@trl.ibm.co.jp</KBD></FONT>"
1114
   *   </ul>
1115
   *
1116
   *       <dt class="REGEX"><kbd>\1 \2 \3 \4 \5 \6 \7 \8 \9</kbd>
1117
   *       <dd>
1118
   *
1119
   *       <dt class="REGEX"><kbd>(?></kbd><var>X</var><kbd>)</kbd>
1120
   *       <dd>Independent expression group. ................
1121
   *
1122
   *       <dt class="REGEX"><kbd>(?</kbd><var>options</var><kbd>:</kbd><var>X</var><kbd>)</kbd>
1123
   *       <dt class="REGEX"><kbd>(?</kbd><var>options</var><kbd>-</kbd><var>options2</var><kbd>:</kbd><var>X</var><kbd>)</kbd>
1124
   *       <dd>............................
1125
   *       <dd>The <var>options</var> or the <var>options2</var> consists of 'i' 'm' 's' 'w'.
1126
   *           Note that it can not contain 'u'.
1127
   *
1128
   *       <dt class="REGEX"><kbd>(?</kbd><var>options</var><kbd>)</kbd>
1129
   *       <dt class="REGEX"><kbd>(?</kbd><var>options</var><kbd>-</kbd><var>options2</var><kbd>)</kbd>
1130
   *       <dd>......
1131
   *       <dd>These expressions must be at the beginning of a group.
1132
   *     </dl>
1133
   *   </li>
1134
   *
1135
   *   <li>Anchor
1136
   *     <dl>
1137
   *       <dt class="REGEX"><kbd>\A</kbd>
1138
   *       <dd>Matches the beginnig of the text.
1139
   *
1140
   *       <dt class="REGEX"><kbd>\Z</kbd>
1141
   *       <dd>Matches the end of the text, or before an EOL character at the end of the text,
1142
   *           or CARRIAGE RETURN + LINE FEED at the end of the text.
1143
   *
1144
   *       <dt class="REGEX"><kbd>\z</kbd>
1145
   *       <dd>Matches the end of the text.
1146
   *
1147
   *       <dt class="REGEX"><kbd>^</kbd>
1148
   *       <dd>Matches the beginning of the text.  It is equivalent to <span class="REGEX"><Kbd>\A</kbd></span>.
1149
   *       <dd>When <a href="#M_OPTION">a "m" option</a> is set,
1150
   *           it matches the beginning of the text, or after one of EOL characters (
1151
   *           LINE FEED (U+000A), CARRIAGE RETURN (U+000D), LINE SEPARATOR (U+2028),
1152
   *           PARAGRAPH SEPARATOR (U+2029).)
1153
   *
1154
   *       <dt class="REGEX"><kbd>$</kbd>
1155
   *       <dd>Matches the end of the text, or before an EOL character at the end of the text,
1156
   *           or CARRIAGE RETURN + LINE FEED at the end of the text.
1157
   *       <dd>When <a href="#M_OPTION">a "m" option</a> is set,
1158
   *           it matches the end of the text, or before an EOL character.
1159
   *
1160
   *       <dt class="REGEX"><kbd>\b</kbd>
1161
   *       <dd>Matches word boundary.
1162
   *           (See <a href="#W_OPTION">a "w" option</a>)
1163
   *
1164
   *       <dt class="REGEX"><kbd>\B</kbd>
1165
   *       <dd>Matches non word boundary.
1166
   *           (See <a href="#W_OPTION">a "w" option</a>)
1167
   *
1168
   *       <dt class="REGEX"><kbd>\&lt;</kbd>
1169
   *       <dd>Matches the beginning of a word.
1170
   *           (See <a href="#W_OPTION">a "w" option</a>)
1171
   *
1172
   *       <dt class="REGEX"><kbd>\&gt;</kbd>
1173
   *       <dd>Matches the end of a word.
1174
   *           (See <a href="#W_OPTION">a "w" option</a>)
1175
   *     </dl>
1176
   *   </li>
1177
   *   <li>Lookahead and lookbehind
1178
   *     <dl>
1179
   *       <dt class="REGEX"><kbd>(?=</kbd><var>X</var><kbd>)</kbd>
1180
   *       <dd>Lookahead.
1181
   *
1182
   *       <dt class="REGEX"><kbd>(?!</kbd><var>X</var><kbd>)</kbd>
1183
   *       <dd>Negative lookahead.
1184
   *
1185
   *       <dt class="REGEX"><kbd>(?&lt;=</kbd><var>X</var><kbd>)</kbd>
1186
   *       <dd>Lookbehind.
1187
   *       <dd>(Note for text capturing......)
1188
   *
1189
   *       <dt class="REGEX"><kbd>(?&lt;!</kbd><var>X</var><kbd>)</kbd>
1190
   *       <dd>Negative lookbehind.
1191
   *     </dl>
1192
   *   </li>
1193
   *
1194
   *   <li>Misc.
1195
   *     <dl>
1196
   *       <dt class="REGEX"><kbd>(?(</Kbd><var>condition</var><Kbd>)</kbd><var>yes-pattern</var><kbd>|</kbd><var>no-pattern</var><kbd>)</kbd>,
1197
   *       <dt class="REGEX"><kbd>(?(</kbd><var>condition</var><kbd>)</kbd><var>yes-pattern</var><kbd>)</kbd>
1198
   *       <dd>......
1199
   *       <dt class="REGEX"><kbd>(?#</kbd><var>comment</var><kbd>)</kbd>
1200
   *       <dd>Comment.  A comment string consists of characters except '<kbd>)</kbd>'.
1201
   *           You can not write comments in character classes and before quantifiers.
1202
   *     </dl>
1203
   *   </li>
1204
   * </ul>
1205
   *
1206
   *
1207
   * <hr width="50%">
1208
   * <h3>BNF for the regular expression</h3>
1209
   * <pre>
1210
   * regex ::= ('(?' options ')')? term ('|' term)*
1211
   * term ::= factor+
1212
   * factor ::= anchors | atom (('*' | '+' | '?' | minmax ) '?'? )?
1213
   *            | '(?#' [^)]* ')'
1214
   * minmax ::= '{' ([0-9]+ | [0-9]+ ',' | ',' [0-9]+ | [0-9]+ ',' [0-9]+) '}'
1215
   * atom ::= char | '.' | char-class | '(' regex ')' | '(?:' regex ')' | '\' [0-9]
1216
   *          | '\w' | '\W' | '\d' | '\D' | '\s' | '\S' | category-block | '\X'
1217
   *          | '(?>' regex ')' | '(?' options ':' regex ')'
1218
   *          | '(?' ('(' [0-9] ')' | '(' anchors ')' | looks) term ('|' term)? ')'
1219
   * options ::= [imsw]* ('-' [imsw]+)?
1220
   * anchors ::= '^' | '$' | '\A' | '\Z' | '\z' | '\b' | '\B' | '\&lt;' | '\>'
1221
   * looks ::= '(?=' regex ')'  | '(?!' regex ')'
1222
   *           | '(?&lt;=' regex ')' | '(?&lt;!' regex ')'
1223
   * char ::= '\\' | '\' [efnrtv] | '\c' [@-_] | code-point | character-1
1224
   * category-block ::= '\' [pP] category-symbol-1
1225
   *                    | ('\p{' | '\P{') (category-symbol | block-name
1226
   *                                       | other-properties) '}'
1227
   * category-symbol-1 ::= 'L' | 'M' | 'N' | 'Z' | 'C' | 'P' | 'S'
1228
   * category-symbol ::= category-symbol-1 | 'Lu' | 'Ll' | 'Lt' | 'Lm' | Lo'
1229
   *                     | 'Mn' | 'Me' | 'Mc' | 'Nd' | 'Nl' | 'No'
1230
   *                     | 'Zs' | 'Zl' | 'Zp' | 'Cc' | 'Cf' | 'Cn' | 'Co' | 'Cs'
1231
   *                     | 'Pd' | 'Ps' | 'Pe' | 'Pc' | 'Po'
1232
   *                     | 'Sm' | 'Sc' | 'Sk' | 'So'
1233
   * block-name ::= (See above)
1234
   * other-properties ::= 'ALL' | 'ASSIGNED' | 'UNASSIGNED'
1235
   * character-1 ::= (any character except meta-characters)
1236
   *
1237
   * char-class ::= '[' ranges ']'
1238
   *                | '(?[' ranges ']' ([-+&] '[' ranges ']')? ')'
1239
   * ranges ::= '^'? (range <a href="#COMMA_OPTION">','?</a>)+
1240
   * range ::= '\d' | '\w' | '\s' | '\D' | '\W' | '\S' | category-block
1241
   *           | range-char | range-char '-' range-char
1242
   * range-char ::= '\[' | '\]' | '\\' | '\' [,-efnrtv] | code-point | character-2
1243
   * code-point ::= '\x' hex-char hex-char
1244
   *                | '\x{' hex-char+ '}'
1245
   * <!--               | '\u005c u' hex-char hex-char hex-char hex-char
1246
   * -->               | '\v' hex-char hex-char hex-char hex-char hex-char hex-char
1247
   * hex-char ::= [0-9a-fA-F]
1248
   * character-2 ::= (any character except \[]-,)
1249
   * </pre>
1250
   *
1251
   * <hr width="50%">
1252
   * <h3>to do</h3>
1253
   * <ul>
1254
   *   <li><a href="http://www.unicode.org/unicode/reports/tr18/">Unicode Regular Expression Guidelines</a>
1255
   *     <ul>
1256
   *       <li>2.4 Canonical Equivalents
1257
   *       <li>Level 3
1258
   *     </ul>
1259
   *   <li>Parsing performance
1260
   * </ul>
1261
   *
1262
   * <hr width="50%">
1263
   *
1264
   * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
1265
   * @version $Id: RegEx.java,v 1.8.4.1 2007/08/14 18:18:44 emerks Exp $
1266
   */
1267
  public static class RegularExpression implements java.io.Serializable {
1268
      static final boolean DEBUG = false;
1269
1270
      /**
1271
       * Compiles a token tree into an operation flow.
1272
       */
1273
      private synchronized void compile(Token tok) {
1274
          if (this.operations != null)
1275
              return;
1276
          this.numberOfClosures = 0;
1277
          this.operations = this.compile(tok, null, false);
1278
      }
1279
1280
      /**
1281
       * Converts a token to an operation.
1282
       */
1283
      private Op compile(Token tok, Op next, boolean reverse) {
1284
          Op ret;
1285
          switch (tok.type) {
1286
          case Token.DOT:
1287
              ret = Op.createDot();
1288
              ret.next = next;
1289
              break;
1290
1291
          case Token.CHAR:
1292
              ret = Op.createChar(tok.getChar());
1293
              ret.next = next;
1294
              break;
1295
1296
          case Token.ANCHOR:
1297
              ret = Op.createAnchor(tok.getChar());
1298
              ret.next = next;
1299
              break;
1300
1301
          case Token.RANGE:
1302
          case Token.NRANGE:
1303
              ret = Op.createRange(tok);
1304
              ret.next = next;
1305
              break;
1306
1307
          case Token.CONCAT:
1308
              ret = next;
1309
              if (!reverse) {
1310
                  for (int i = tok.size()-1;  i >= 0;  i --) {
1311
                      ret = compile(tok.getChild(i), ret, false);
1312
                  }
1313
              } else {
1314
                  for (int i = 0;  i < tok.size();  i ++) {
1315
                      ret = compile(tok.getChild(i), ret, true);
1316
                  }
1317
              }
1318
              break;
1319
1320
          case Token.UNION:
1321
              Op.UnionOp uni = Op.createUnion(tok.size());
1322
              for (int i = 0;  i < tok.size();  i ++) {
1323
                  uni.addElement(compile(tok.getChild(i), next, reverse));
1324
              }
1325
              ret = uni;                          // ret.next is null.
1326
              break;
1327
1328
          case Token.CLOSURE:
1329
          case Token.NONGREEDYCLOSURE:
1330
              Token child = tok.getChild(0);
1331
              int min = tok.getMin();
1332
              int max = tok.getMax();
1333
              if (min >= 0 && min == max) { // {n}
1334
                  ret = next;
1335
                  for (int i = 0; i < min;  i ++) {
1336
                      ret = compile(child, ret, reverse);
1337
                  }
1338
                  break;
1339
              }
1340
              if (min > 0 && max > 0)
1341
                  max -= min;
1342
              if (max > 0) {
1343
                  // X{2,6} -> XX(X(X(XX?)?)?)?
1344
                  ret = next;
1345
                  for (int i = 0;  i < max;  i ++) {
1346
                      Op.ChildOp q = Op.createQuestion(tok.type == Token.NONGREEDYCLOSURE);
1347
                      q.next = next;
1348
                      q.setChild(compile(child, ret, reverse));
1349
                      ret = q;
1350
                  }
1351
              } else {
1352
                  Op.ChildOp op;
1353
                  if (tok.type == Token.NONGREEDYCLOSURE) {
1354
                      op = Op.createNonGreedyClosure();
1355
                  } else {                        // Token.CLOSURE
1356
                      if (child.getMinLength() == 0)
1357
                          op = Op.createClosure(this.numberOfClosures++);
1358
                      else
1359
                          op = Op.createClosure(-1);
1360
                  }
1361
                  op.next = next;
1362
                  op.setChild(compile(child, op, reverse));
1363
                  ret = op;
1364
              }
1365
              if (min > 0) {
1366
                  for (int i = 0;  i < min;  i ++) {
1367
                      ret = compile(child, ret, reverse);
1368
                  }
1369
              }
1370
              break;
1371
1372
          case Token.EMPTY:
1373
              ret = next;
1374
              break;
1375
1376
          case Token.STRING:
1377
              ret = Op.createString(tok.getString());
1378
              ret.next = next;
1379
              break;
1380
1381
          case Token.BACKREFERENCE:
1382
              ret = Op.createBackReference(tok.getReferenceNumber());
1383
              ret.next = next;
1384
              break;
1385
1386
          case Token.PAREN:
1387
              if (tok.getParenNumber() == 0) {
1388
                  ret = compile(tok.getChild(0), next, reverse);
1389
              } else if (reverse) {
1390
                  next = Op.createCapture(tok.getParenNumber(), next);
1391
                  next = compile(tok.getChild(0), next, reverse);
1392
                  ret = Op.createCapture(-tok.getParenNumber(), next);
1393
              } else {
1394
                  next = Op.createCapture(-tok.getParenNumber(), next);
1395
                  next = compile(tok.getChild(0), next, reverse);
1396
                  ret = Op.createCapture(tok.getParenNumber(), next);
1397
              }
1398
              break;
1399
1400
          case Token.LOOKAHEAD:
1401
              ret = Op.createLook(Op.LOOKAHEAD, next, compile(tok.getChild(0), null, false));
1402
              break;
1403
          case Token.NEGATIVELOOKAHEAD:
1404
              ret = Op.createLook(Op.NEGATIVELOOKAHEAD, next, compile(tok.getChild(0), null, false));
1405
              break;
1406
          case Token.LOOKBEHIND:
1407
              ret = Op.createLook(Op.LOOKBEHIND, next, compile(tok.getChild(0), null, true));
1408
              break;
1409
          case Token.NEGATIVELOOKBEHIND:
1410
              ret = Op.createLook(Op.NEGATIVELOOKBEHIND, next, compile(tok.getChild(0), null, true));
1411
              break;
1412
1413
          case Token.INDEPENDENT:
1414
              ret = Op.createIndependent(next, compile(tok.getChild(0), null, reverse));
1415
              break;
1416
1417
          case Token.MODIFIERGROUP:
1418
              ret = Op.createModifier(next, compile(tok.getChild(0), null, reverse),
1419
                                      ((Token.ModifierToken)tok).getOptions(),
1420
                                      ((Token.ModifierToken)tok).getOptionsMask());
1421
              break;
1422
1423
          case Token.CONDITION:
1424
              Token.ConditionToken ctok = (Token.ConditionToken)tok;
1425
              int ref = ctok.refNumber;
1426
              Op condition = ctok.condition == null ? null : compile(ctok.condition, null, reverse);
1427
              Op yes = compile(ctok.yes, next, reverse);
1428
              Op no = ctok.no == null ? null : compile(ctok.no, next, reverse);
1429
              ret = Op.createCondition(next, ref, condition, yes, no);
1430
              break;
1431
1432
          default:
1433
              throw new RuntimeException("Unknown token type: "+tok.type);
1434
          } // switch (tok.type)
1435
          return ret;
1436
      }
1437
1438
1439
//  Public
1440
1441
      /**
1442
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
1443
       *
1444
       * @return true if the target is matched to this regular expression.
1445
       */
1446
      public boolean matches(char[]  target) {
1447
          return this.matches(target, 0,  target .length , (Match)null);
1448
      }
1449
1450
      /**
1451
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern
1452
       * in specified range or not.
1453
       *
1454
       * @param start Start offset of the range.
1455
       * @param end  End offset +1 of the range.
1456
       * @return true if the target is matched to this regular expression.
1457
       */
1458
      public boolean matches(char[]  target, int start, int end) {
1459
          return this.matches(target, start, end, (Match)null);
1460
      }
1461
1462
      /**
1463
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
1464
       *
1465
       * @param match A Match instance for storing matching result.
1466
       * @return Offset of the start position in <VAR>target</VAR>; or -1 if not match.
1467
       */
1468
      public boolean matches(char[]  target, Match match) {
1469
          return this.matches(target, 0,  target .length , match);
1470
      }
1471
1472
1473
      /**
1474
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern
1475
       * in specified range or not.
1476
       *
1477
       * @param start Start offset of the range.
1478
       * @param end  End offset +1 of the range.
1479
       * @param match A Match instance for storing matching result.
1480
       * @return Offset of the start position in <VAR>target</VAR>; or -1 if not match.
1481
       */
1482
      public boolean matches(char[]  target, int start, int end, Match match) {
1483
1484
          synchronized (this) {
1485
              if (this.operations == null)
1486
                  this.prepare();
1487
              if (this.context == null)
1488
                  this.context = new Context();
1489
          }
1490
          Context con = null;
1491
          synchronized (this.context) {
1492
              con = this.context.inuse ? new Context() : this.context;
1493
              con.reset(target, start, end, this.numberOfClosures);
1494
          }
1495
          if (match != null) {
1496
              match.setNumberOfGroups(this.nofparen);
1497
              match.setSource(target);
1498
          } else if (this.hasBackReferences) {
1499
              match = new Match();
1500
              match.setNumberOfGroups(this.nofparen);
1501
              // Need not to call setSource() because
1502
              // a caller can not access this match instance.
1503
          }
1504
          con.match = match;
1505
1506
          if (RegularExpression.isSet(this.options, XMLSCHEMA_MODE)) {
1507
              int matchEnd = this. matchCharArray (con, this.operations, con.start, 1, this.options);
1508
              //System.err.println("DEBUG: matchEnd="+matchEnd);
1509
              if (matchEnd == con.limit) {
1510
                  if (con.match != null) {
1511
                      con.match.setBeginning(0, con.start);
1512
                      con.match.setEnd(0, matchEnd);
1513
                  }
1514
                  con.inuse = false;
1515
                  return true;
1516
              }
1517
              return false;
1518
          }
1519
1520
          /*
1521
           * The pattern has only fixed string.
1522
           * The engine uses Boyer-Moore.
1523
           */
1524
          if (this.fixedStringOnly) {
1525
              //System.err.println("DEBUG: fixed-only: "+this.fixedString);
1526
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
1527
              if (o >= 0) {
1528
                  if (con.match != null) {
1529
                      con.match.setBeginning(0, o);
1530
                      con.match.setEnd(0, o+this.fixedString.length());
1531
                  }
1532
                  con.inuse = false;
1533
                  return true;
1534
              }
1535
              con.inuse = false;
1536
              return false;
1537
          }
1538
1539
          /*
1540
           * The pattern contains a fixed string.
1541
           * The engine checks with Boyer-Moore whether the text contains the fixed string or not.
1542
           * If not, it return with false.
1543
           */
1544
          if (this.fixedString != null) {
1545
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
1546
              if (o < 0) {
1547
                  //System.err.println("Non-match in fixed-string search.");
1548
                  con.inuse = false;
1549
                  return false;
1550
              }
1551
          }
1552
1553
          int limit = con.limit-this.minlength;
1554
          int matchStart;
1555
          int matchEnd = -1;
1556
1557
          /*
1558
           * Checks whether the expression starts with ".*".
1559
           */
1560
          if (this.operations != null
1561
              && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) {
1562
              if (isSet(this.options, SINGLE_LINE)) {
1563
                  matchStart = con.start;
1564
                  matchEnd = this. matchCharArray (con, this.operations, con.start, 1, this.options);
1565
              } else {
1566
                  boolean previousIsEOL = true;
1567
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
1568
                      int ch =  target [  matchStart ] ;
1569
                      if (isEOLChar(ch)) {
1570
                          previousIsEOL = true;
1571
                      } else {
1572
                          if (previousIsEOL) {
1573
                              if (0 <= (matchEnd = this. matchCharArray (con, this.operations,
1574
                                                                         matchStart, 1, this.options)))
1575
                                  break;
1576
                          }
1577
                          previousIsEOL = false;
1578
                      }
1579
                  }
1580
              }
1581
          }
1582
1583
          /*
1584
           * Optimization against the first character.
1585
           */
1586
          else if (this.firstChar != null) {
1587
              //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
1588
              RangeToken range = this.firstChar;
1589
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
1590
                  range = this.firstChar.getCaseInsensitiveToken();
1591
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
1592
                      int ch =  target [  matchStart ] ;
1593
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
1594
                          ch = REUtil.composeFromSurrogates(ch,  target [  matchStart+1 ] );
1595
                          if (!range.match(ch))  continue;
1596
                      } else {
1597
                          if (!range.match(ch)) {
1598
                              char ch1 = Character.toUpperCase((char)ch);
1599
                              if (!range.match(ch1))
1600
                                  if (!range.match(Character.toLowerCase(ch1)))
1601
                                      continue;
1602
                          }
1603
                      }
1604
                      if (0 <= (matchEnd = this. matchCharArray (con, this.operations,
1605
                                                                 matchStart, 1, this.options)))
1606
                          break;
1607
                  }
1608
              } else {
1609
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
1610
                      int ch =  target [  matchStart ] ;
1611
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
1612
                          ch = REUtil.composeFromSurrogates(ch,  target [  matchStart+1 ] );
1613
                      if (!range.match(ch))  continue;
1614
                      if (0 <= (matchEnd = this. matchCharArray (con, this.operations,
1615
                                                                 matchStart, 1, this.options)))
1616
                          break;
1617
                  }
1618
              }
1619
          }
1620
1621
          /*
1622
           * Straightforward matching.
1623
           */
1624
          else {
1625
              for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
1626
                  if (0 <= (matchEnd = this. matchCharArray (con, this.operations, matchStart, 1, this.options)))
1627
                      break;
1628
              }
1629
          }
1630
1631
          if (matchEnd >= 0) {
1632
              if (con.match != null) {
1633
                  con.match.setBeginning(0, matchStart);
1634
                  con.match.setEnd(0, matchEnd);
1635
              }
1636
              con.inuse = false;
1637
              return true;
1638
          } else {
1639
              con.inuse = false;
1640
              return false;
1641
          }
1642
      }
1643
1644
  /**
1645
   * @return -1 when not match; offset of the end of matched string when match.
1646
   */
1647
      private int matchCharArray (Context con, Op op, int offset, int dx, int opts) {
1648
1649
          char[] target = con.charTarget;
1650
1651
1652
          while (true) {
1653
              if (op == null)
1654
                  return isSet(opts, XMLSCHEMA_MODE) && offset != con.limit ? -1 : offset;
1655
              if (offset > con.limit || offset < con.start)
1656
                  return -1;
1657
              switch (op.type) {
1658
              case Op.CHAR:
1659
                  if (isSet(opts, IGNORE_CASE)) {
1660
                      int ch = op.getData();
1661
                      if (dx > 0) {
1662
                          if (offset >= con.limit || !matchIgnoreCase(ch,  target [  offset ] ))
1663
                              return -1;
1664
                          offset ++;
1665
                      } else {
1666
                          int o1 = offset-1;
1667
                          if (o1 >= con.limit || o1 < 0 || !matchIgnoreCase(ch,  target [  o1 ] ))
1668
                              return -1;
1669
                          offset = o1;
1670
                      }
1671
                  } else {
1672
                      int ch = op.getData();
1673
                      if (dx > 0) {
1674
                          if (offset >= con.limit || ch !=  target [  offset ] )
1675
                              return -1;
1676
                          offset ++;
1677
                      } else {
1678
                          int o1 = offset-1;
1679
                          if (o1 >= con.limit || o1 < 0 || ch !=  target [  o1 ] )
1680
                              return -1;
1681
                          offset = o1;
1682
                      }
1683
                  }
1684
                  op = op.next;
1685
                  break;
1686
1687
              case Op.DOT:
1688
                  if (dx > 0) {
1689
                      if (offset >= con.limit)
1690
                          return -1;
1691
                      int ch =  target [  offset ] ;
1692
                      if (isSet(opts, SINGLE_LINE)) {
1693
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
1694
                              offset ++;
1695
                      } else {
1696
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
1697
                              ch = REUtil.composeFromSurrogates(ch,  target [  ++offset ] );
1698
                          if (isEOLChar(ch))
1699
                              return -1;
1700
                      }
1701
                      offset ++;
1702
                  } else {
1703
                      int o1 = offset-1;
1704
                      if (o1 >= con.limit || o1 < 0)
1705
                          return -1;
1706
                      int ch =  target [  o1 ] ;
1707
                      if (isSet(opts, SINGLE_LINE)) {
1708
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
1709
                              o1 --;
1710
                      } else {
1711
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
1712
                              ch = REUtil.composeFromSurrogates( target [  --o1 ] , ch);
1713
                          if (!isEOLChar(ch))
1714
                              return -1;
1715
                      }
1716
                      offset = o1;
1717
                  }
1718
                  op = op.next;
1719
                  break;
1720
1721
              case Op.RANGE:
1722
              case Op.NRANGE:
1723
                  if (dx > 0) {
1724
                      if (offset >= con.limit)
1725
                          return -1;
1726
                      int ch =  target [  offset ] ;
1727
                      if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
1728
                          ch = REUtil.composeFromSurrogates(ch,  target [  ++offset ] );
1729
                      RangeToken tok = op.getToken();
1730
                      if (isSet(opts, IGNORE_CASE)) {
1731
                          tok = tok.getCaseInsensitiveToken();
1732
                          if (!tok.match(ch)) {
1733
                              if (ch >= 0x10000)  return -1;
1734
                              char uch;
1735
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
1736
                                  && !tok.match(Character.toLowerCase(uch)))
1737
                                  return -1;
1738
                          }
1739
                      } else {
1740
                          if (!tok.match(ch))  return -1;
1741
                      }
1742
                      offset ++;
1743
                  } else {
1744
                      int o1 = offset-1;
1745
                      if (o1 >= con.limit || o1 < 0)
1746
                          return -1;
1747
                      int ch =  target [  o1 ] ;
1748
                      if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
1749
                          ch = REUtil.composeFromSurrogates( target [  --o1 ] , ch);
1750
                      RangeToken tok = op.getToken();
1751
                      if (isSet(opts, IGNORE_CASE)) {
1752
                          tok = tok.getCaseInsensitiveToken();
1753
                          if (!tok.match(ch)) {
1754
                              if (ch >= 0x10000)  return -1;
1755
                              char uch;
1756
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
1757
                                  && !tok.match(Character.toLowerCase(uch)))
1758
                                  return -1;
1759
                          }
1760
                      } else {
1761
                          if (!tok.match(ch))  return -1;
1762
                      }
1763
                      offset = o1;
1764
                  }
1765
                  op = op.next;
1766
                  break;
1767
1768
              case Op.ANCHOR:
1769
                  boolean go = false;
1770
                  switch (op.getData()) {
1771
                  case '^':
1772
                      if (isSet(opts, MULTIPLE_LINES)) {
1773
                          if (!(offset == con.start
1774
                                || offset > con.start && isEOLChar( target [  offset-1 ] )))
1775
                              return -1;
1776
                      } else {
1777
                          if (offset != con.start)
1778
                              return -1;
1779
                      }
1780
                      break;
1781
1782
                  case '@':                         // Internal use only.
1783
                      // The @ always matches line beginnings.
1784
                      if (!(offset == con.start
1785
                            || offset > con.start && isEOLChar( target [  offset-1 ] )))
1786
                          return -1;
1787
                      break;
1788
1789
                  case '$':
1790
                      if (isSet(opts, MULTIPLE_LINES)) {
1791
                          if (!(offset == con.limit
1792
                                || offset < con.limit && isEOLChar( target [  offset ] )))
1793
                              return -1;
1794
                      } else {
1795
                          if (!(offset == con.limit
1796
                                || offset+1 == con.limit && isEOLChar( target [  offset ] )
1797
                                || offset+2 == con.limit &&  target [  offset ]  == CARRIAGE_RETURN
1798
                                &&  target [  offset+1 ]  == LINE_FEED))
1799
                              return -1;
1800
                      }
1801
                      break;
1802
1803
                  case 'A':
1804
                      if (offset != con.start)  return -1;
1805
                      break;
1806
1807
                  case 'Z':
1808
                      if (!(offset == con.limit
1809
                            || offset+1 == con.limit && isEOLChar( target [  offset ] )
1810
                            || offset+2 == con.limit &&  target [  offset ]  == CARRIAGE_RETURN
1811
                            &&  target [  offset+1 ]  == LINE_FEED))
1812
                          return -1;
1813
                      break;
1814
1815
                  case 'z':
1816
                      if (offset != con.limit)  return -1;
1817
                      break;
1818
1819
                  case 'b':
1820
                      if (con.length == 0)  return -1;
1821
                      {
1822
                          int after = getWordType(target, con.start, con.limit, offset, opts);
1823
                          if (after == WT_IGNORE)  return -1;
1824
                          int before = getPreviousWordType(target, con.start, con.limit, offset, opts);
1825
                          if (after == before)  return -1;
1826
                      }
1827
                      break;
1828
1829
                  case 'B':
1830
                      if (con.length == 0)
1831
                          go = true;
1832
                      else {
1833
                          int after = getWordType(target, con.start, con.limit, offset, opts);
1834
                          go = after == WT_IGNORE
1835
                               || after == getPreviousWordType(target, con.start, con.limit, offset, opts);
1836
                      }
1837
                      if (!go)  return -1;
1838
                      break;
1839
1840
                  case '<':
1841
                      if (con.length == 0 || offset == con.limit)  return -1;
1842
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER
1843
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)
1844
                          return -1;
1845
                      break;
1846
1847
                  case '>':
1848
                      if (con.length == 0 || offset == con.start)  return -1;
1849
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER
1850
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)
1851
                          return -1;
1852
                      break;
1853
                  } // switch anchor type
1854
                  op = op.next;
1855
                  break;
1856
1857
              case Op.BACKREFERENCE:
1858
                  {
1859
                      int refno = op.getData();
1860
                      if (refno <= 0 || refno >= this.nofparen)
1861
                          throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);
1862
                      if (con.match.getBeginning(refno) < 0
1863
                          || con.match.getEnd(refno) < 0)
1864
                          return -1;                // ********
1865
                      int o2 = con.match.getBeginning(refno);
1866
                      int literallen = con.match.getEnd(refno)-o2;
1867
                      if (!isSet(opts, IGNORE_CASE)) {
1868
                          if (dx > 0) {
1869
                              if (!regionMatches(target, offset, con.limit, o2, literallen))
1870
                                  return -1;
1871
                              offset += literallen;
1872
                          } else {
1873
                              if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))
1874
                                  return -1;
1875
                              offset -= literallen;
1876
                          }
1877
                      } else {
1878
                          if (dx > 0) {
1879
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
1880
                                  return -1;
1881
                              offset += literallen;
1882
                          } else {
1883
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
1884
                                                           o2, literallen))
1885
                                  return -1;
1886
                              offset -= literallen;
1887
                          }
1888
                      }
1889
                  }
1890
                  op = op.next;
1891
                  break;
1892
              case Op.STRING:
1893
                  {
1894
                      String literal = op.getString();
1895
                      int literallen = literal.length();
1896
                      if (!isSet(opts, IGNORE_CASE)) {
1897
                          if (dx > 0) {
1898
                              if (!regionMatches(target, offset, con.limit, literal, literallen))
1899
                                  return -1;
1900
                              offset += literallen;
1901
                          } else {
1902
                              if (!regionMatches(target, offset-literallen, con.limit, literal, literallen))
1903
                                  return -1;
1904
                              offset -= literallen;
1905
                          }
1906
                      } else {
1907
                          if (dx > 0) {
1908
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen))
1909
                                  return -1;
1910
                              offset += literallen;
1911
                          } else {
1912
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
1913
                                                           literal, literallen))
1914
                                  return -1;
1915
                              offset -= literallen;
1916
                          }
1917
                      }
1918
                  }
1919
                  op = op.next;
1920
                  break;
1921
1922
              case Op.CLOSURE:
1923
                  {
1924
                      /*
1925
                       * Saves current position to avoid
1926
                       * zero-width repeats.
1927
                       */
1928
                      int id = op.getData();
1929
                      if (id >= 0) {
1930
                          int previousOffset = con.offsets[id];
1931
                          if (previousOffset < 0 || previousOffset != offset) {
1932
                              con.offsets[id] = offset;
1933
                          } else {
1934
                              con.offsets[id] = -1;
1935
                              op = op.next;
1936
                              break;
1937
                          }
1938
                      }
1939
1940
                      int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);
1941
                      if (id >= 0)  con.offsets[id] = -1;
1942
                      if (ret >= 0)  return ret;
1943
                      op = op.next;
1944
                  }
1945
                  break;
1946
1947
              case Op.QUESTION:
1948
                  {
1949
                      int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);
1950
                      if (ret >= 0)  return ret;
1951
                      op = op.next;
1952
                  }
1953
                  break;
1954
1955
              case Op.NONGREEDYCLOSURE:
1956
              case Op.NONGREEDYQUESTION:
1957
                  {
1958
                      int ret = this. matchCharArray (con, op.next, offset, dx, opts);
1959
                      if (ret >= 0)  return ret;
1960
                      op = op.getChild();
1961
                  }
1962
                  break;
1963
1964
              case Op.UNION:
1965
                  for (int i = 0;  i < op.size();  i ++) {
1966
                      int ret = this. matchCharArray (con, op.elementAt(i), offset, dx, opts);
1967
                      if (DEBUG) {
1968
                          System.err.println("UNION: "+i+", ret="+ret);
1969
                      }
1970
                      if (ret >= 0)  return ret;
1971
                  }
1972
                  return -1;
1973
1974
              case Op.CAPTURE:
1975
                  int refno = op.getData();
1976
                  if (con.match != null && refno > 0) {
1977
                      int save = con.match.getBeginning(refno);
1978
                      con.match.setBeginning(refno, offset);
1979
                      int ret = this. matchCharArray (con, op.next, offset, dx, opts);
1980
                      if (ret < 0)  con.match.setBeginning(refno, save);
1981
                      return ret;
1982
                  } else if (con.match != null && refno < 0) {
1983
                      int index = -refno;
1984
                      int save = con.match.getEnd(index);
1985
                      con.match.setEnd(index, offset);
1986
                      int ret = this. matchCharArray (con, op.next, offset, dx, opts);
1987
                      if (ret < 0)  con.match.setEnd(index, save);
1988
                      return ret;
1989
                  }
1990
                  op = op.next;
1991
                  break;
1992
1993
              case Op.LOOKAHEAD:
1994
                  if (0 > this. matchCharArray (con, op.getChild(), offset, 1, opts))  return -1;
1995
                  op = op.next;
1996
                  break;
1997
              case Op.NEGATIVELOOKAHEAD:
1998
                  if (0 <= this. matchCharArray (con, op.getChild(), offset, 1, opts))  return -1;
1999
                  op = op.next;
2000
                  break;
2001
              case Op.LOOKBEHIND:
2002
                  if (0 > this. matchCharArray (con, op.getChild(), offset, -1, opts))  return -1;
2003
                  op = op.next;
2004
                  break;
2005
              case Op.NEGATIVELOOKBEHIND:
2006
                  if (0 <= this. matchCharArray (con, op.getChild(), offset, -1, opts))  return -1;
2007
                  op = op.next;
2008
                  break;
2009
2010
              case Op.INDEPENDENT:
2011
                  {
2012
                      int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);
2013
                      if (ret < 0)  return ret;
2014
                      offset = ret;
2015
                      op = op.next;
2016
                  }
2017
                  break;
2018
2019
              case Op.MODIFIER:
2020
                  {
2021
                      int localopts = opts;
2022
                      localopts |= op.getData();
2023
                      localopts &= ~op.getData2();
2024
                      //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16));
2025
                      int ret = this. matchCharArray (con, op.getChild(), offset, dx, localopts);
2026
                      if (ret < 0)  return ret;
2027
                      offset = ret;
2028
                      op = op.next;
2029
                  }
2030
                  break;
2031
2032
              case Op.CONDITION:
2033
                  {
2034
                      Op.ConditionOp cop = (Op.ConditionOp)op;
2035
                      boolean matchp = false;
2036
                      if (cop.refNumber > 0) {
2037
                          if (cop.refNumber >= this.nofparen)
2038
                              throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber);
2039
                          matchp = con.match.getBeginning(cop.refNumber) >= 0
2040
                                   && con.match.getEnd(cop.refNumber) >= 0;
2041
                      } else {
2042
                          matchp = 0 <= this. matchCharArray (con, cop.condition, offset, dx, opts);
2043
                      }
2044
2045
                      if (matchp) {
2046
                          op = cop.yes;
2047
                      } else if (cop.no != null) {
2048
                          op = cop.no;
2049
                      } else {
2050
                          op = cop.next;
2051
                      }
2052
                  }
2053
                  break;
2054
2055
              default:
2056
                  throw new RuntimeException("Unknown operation type: "+op.type);
2057
              } // switch (op.type)
2058
          } // while
2059
      }
2060
2061
      private static final int getPreviousWordType(char[]  target, int begin, int end,
2062
                                                   int offset, int opts) {
2063
          int ret = getWordType(target, begin, end, --offset, opts);
2064
          while (ret == WT_IGNORE)
2065
              ret = getWordType(target, begin, end, --offset, opts);
2066
          return ret;
2067
      }
2068
2069
      private static final int getWordType(char[]  target, int begin, int end,
2070
                                           int offset, int opts) {
2071
          if (offset < begin || offset >= end)  return WT_OTHER;
2072
          return getWordType0( target [  offset ] , opts);
2073
      }
2074
2075
2076
2077
      private static final boolean regionMatches(char[]  target, int offset, int limit,
2078
                                                 String part, int partlen) {
2079
          if (offset < 0)  return false;
2080
          if (limit-offset < partlen)
2081
              return false;
2082
          int i = 0;
2083
          while (partlen-- > 0) {
2084
              if ( target [  offset++ ]  != part.charAt(i++))
2085
                  return false;
2086
          }
2087
          return true;
2088
      }
2089
2090
      private static final boolean regionMatches(char[]  target, int offset, int limit,
2091
                                                 int offset2, int partlen) {
2092
          if (offset < 0)  return false;
2093
          if (limit-offset < partlen)
2094
              return false;
2095
          int i = offset2;
2096
          while (partlen-- > 0) {
2097
              if ( target [  offset++ ]  !=  target [  i++ ] )
2098
                  return false;
2099
          }
2100
          return true;
2101
      }
2102
2103
  /**
2104
   * @see java.lang.String#regionMatches
2105
   */
2106
      private static final boolean regionMatchesIgnoreCase(char[]  target, int offset, int limit,
2107
                                                           String part, int partlen) {
2108
          if (offset < 0)  return false;
2109
          if (limit-offset < partlen)
2110
              return false;
2111
          int i = 0;
2112
          while (partlen-- > 0) {
2113
              char ch1 =  target [  offset++ ] ;
2114
              char ch2 = part.charAt(i++);
2115
              if (ch1 == ch2)
2116
                  continue;
2117
              char uch1 = Character.toUpperCase(ch1);
2118
              char uch2 = Character.toUpperCase(ch2);
2119
              if (uch1 == uch2)
2120
                  continue;
2121
              if (Character.toLowerCase(uch1) != Character.toLowerCase(uch2))
2122
                  return false;
2123
          }
2124
          return true;
2125
      }
2126
2127
      private static final boolean regionMatchesIgnoreCase(char[]  target, int offset, int limit,
2128
                                                           int offset2, int partlen) {
2129
          if (offset < 0)  return false;
2130
          if (limit-offset < partlen)
2131
              return false;
2132
          int i = offset2;
2133
          while (partlen-- > 0) {
2134
              char ch1 =  target [  offset++ ] ;
2135
              char ch2 =  target [  i++ ] ;
2136
              if (ch1 == ch2)
2137
                  continue;
2138
              char uch1 = Character.toUpperCase(ch1);
2139
              char uch2 = Character.toUpperCase(ch2);
2140
              if (uch1 == uch2)
2141
                  continue;
2142
              if (Character.toLowerCase(uch1) != Character.toLowerCase(uch2))
2143
                  return false;
2144
          }
2145
          return true;
2146
      }
2147
2148
2149
2150
2151
      /**
2152
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
2153
       *
2154
       * @return true if the target is matched to this regular expression.
2155
       */
2156
      public boolean matches(String  target) {
2157
          return this.matches(target, 0,  target .length() , (Match)null);
2158
      }
2159
2160
      /**
2161
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern
2162
       * in specified range or not.
2163
       *
2164
       * @param start Start offset of the range.
2165
       * @param end  End offset +1 of the range.
2166
       * @return true if the target is matched to this regular expression.
2167
       */
2168
      public boolean matches(String  target, int start, int end) {
2169
          return this.matches(target, start, end, (Match)null);
2170
      }
2171
2172
      /**
2173
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
2174
       *
2175
       * @param match A Match instance for storing matching result.
2176
       * @return Offset of the start position in <VAR>target</VAR>; or -1 if not match.
2177
       */
2178
      public boolean matches(String  target, Match match) {
2179
          return this.matches(target, 0,  target .length() , match);
2180
      }
2181
2182
      /**
2183
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern
2184
       * in specified range or not.
2185
       *
2186
       * @param start Start offset of the range.
2187
       * @param end  End offset +1 of the range.
2188
       * @param match A Match instance for storing matching result.
2189
       * @return Offset of the start position in <VAR>target</VAR>; or -1 if not match.
2190
       */
2191
      public boolean matches(String  target, int start, int end, Match match) {
2192
2193
          synchronized (this) {
2194
              if (this.operations == null)
2195
                  this.prepare();
2196
              if (this.context == null)
2197
                  this.context = new Context();
2198
          }
2199
          Context con = null;
2200
          synchronized (this.context) {
2201
              con = this.context.inuse ? new Context() : this.context;
2202
              con.reset(target, start, end, this.numberOfClosures);
2203
          }
2204
          if (match != null) {
2205
              match.setNumberOfGroups(this.nofparen);
2206
              match.setSource(target);
2207
          } else if (this.hasBackReferences) {
2208
              match = new Match();
2209
              match.setNumberOfGroups(this.nofparen);
2210
              // Need not to call setSource() because
2211
              // a caller can not access this match instance.
2212
          }
2213
          con.match = match;
2214
2215
          if (RegularExpression.isSet(this.options, XMLSCHEMA_MODE)) {
2216
              if (DEBUG) {
2217
                  System.err.println("target string="+target);
2218
              }
2219
              int matchEnd = this. matchString (con, this.operations, con.start, 1, this.options);
2220
              if (DEBUG) {
2221
                  System.err.println("matchEnd="+matchEnd);
2222
                  System.err.println("con.limit="+con.limit);
2223
              }
2224
              if (matchEnd == con.limit) {
2225
                  if (con.match != null) {
2226
                      con.match.setBeginning(0, con.start);
2227
                      con.match.setEnd(0, matchEnd);
2228
                  }
2229
                  con.inuse = false;
2230
                  return true;
2231
              }
2232
              return false;
2233
          }
2234
2235
          /*
2236
           * The pattern has only fixed string.
2237
           * The engine uses Boyer-Moore.
2238
           */
2239
          if (this.fixedStringOnly) {
2240
              //System.err.println("DEBUG: fixed-only: "+this.fixedString);
2241
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
2242
              if (o >= 0) {
2243
                  if (con.match != null) {
2244
                      con.match.setBeginning(0, o);
2245
                      con.match.setEnd(0, o+this.fixedString.length());
2246
                  }
2247
                  con.inuse = false;
2248
                  return true;
2249
              }
2250
              con.inuse = false;
2251
              return false;
2252
          }
2253
2254
          /*
2255
           * The pattern contains a fixed string.
2256
           * The engine checks with Boyer-Moore whether the text contains the fixed string or not.
2257
           * If not, it return with false.
2258
           */
2259
          if (this.fixedString != null) {
2260
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
2261
              if (o < 0) {
2262
                  //System.err.println("Non-match in fixed-string search.");
2263
                  con.inuse = false;
2264
                  return false;
2265
              }
2266
          }
2267
2268
          int limit = con.limit-this.minlength;
2269
          int matchStart;
2270
          int matchEnd = -1;
2271
2272
          /*
2273
           * Checks whether the expression starts with ".*".
2274
           */
2275
          if (this.operations != null
2276
              && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) {
2277
              if (isSet(this.options, SINGLE_LINE)) {
2278
                  matchStart = con.start;
2279
                  matchEnd = this. matchString (con, this.operations, con.start, 1, this.options);
2280
              } else {
2281
                  boolean previousIsEOL = true;
2282
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2283
                      int ch =  target .charAt(  matchStart ) ;
2284
                      if (isEOLChar(ch)) {
2285
                          previousIsEOL = true;
2286
                      } else {
2287
                          if (previousIsEOL) {
2288
                              if (0 <= (matchEnd = this. matchString (con, this.operations,
2289
                                                                      matchStart, 1, this.options)))
2290
                                  break;
2291
                          }
2292
                          previousIsEOL = false;
2293
                      }
2294
                  }
2295
              }
2296
          }
2297
2298
          /*
2299
           * Optimization against the first character.
2300
           */
2301
          else if (this.firstChar != null) {
2302
              //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
2303
              RangeToken range = this.firstChar;
2304
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
2305
                  range = this.firstChar.getCaseInsensitiveToken();
2306
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2307
                      int ch =  target .charAt(  matchStart ) ;
2308
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
2309
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
2310
                          if (!range.match(ch))  continue;
2311
                      } else {
2312
                          if (!range.match(ch)) {
2313
                              char ch1 = Character.toUpperCase((char)ch);
2314
                              if (!range.match(ch1))
2315
                                  if (!range.match(Character.toLowerCase(ch1)))
2316
                                      continue;
2317
                          }
2318
                      }
2319
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
2320
                                                              matchStart, 1, this.options)))
2321
                          break;
2322
                  }
2323
              } else {
2324
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2325
                      int ch =  target .charAt(  matchStart ) ;
2326
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
2327
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
2328
                      if (!range.match(ch))  continue;
2329
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
2330
                                                              matchStart, 1, this.options)))
2331
                          break;
2332
                  }
2333
              }
2334
          }
2335
2336
          /*
2337
           * Straightforward matching.
2338
           */
2339
          else {
2340
              for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2341
                  if (0 <= (matchEnd = this. matchString (con, this.operations, matchStart, 1, this.options)))
2342
                      break;
2343
              }
2344
          }
2345
2346
          if (matchEnd >= 0) {
2347
              if (con.match != null) {
2348
                  con.match.setBeginning(0, matchStart);
2349
                  con.match.setEnd(0, matchEnd);
2350
              }
2351
              con.inuse = false;
2352
              return true;
2353
          } else {
2354
              con.inuse = false;
2355
              return false;
2356
          }
2357
      }
2358
2359
      /**
2360
       * @return -1 when not match; offset of the end of matched string when match.
2361
       */
2362
      private int matchString (Context con, Op op, int offset, int dx, int opts) {
2363
2364
2365
2366
2367
          String target = con.strTarget;
2368
2369
2370
2371
2372
          while (true) {
2373
              if (op == null)
2374
                  return isSet(opts, XMLSCHEMA_MODE) && offset != con.limit ? -1 : offset;
2375
              if (offset > con.limit || offset < con.start)
2376
                  return -1;
2377
              switch (op.type) {
2378
              case Op.CHAR:
2379
                  if (isSet(opts, IGNORE_CASE)) {
2380
                      int ch = op.getData();
2381
                      if (dx > 0) {
2382
                          if (offset >= con.limit || !matchIgnoreCase(ch,  target .charAt(  offset ) ))
2383
                              return -1;
2384
                          offset ++;
2385
                      } else {
2386
                          int o1 = offset-1;
2387
                          if (o1 >= con.limit || o1 < 0 || !matchIgnoreCase(ch,  target .charAt(  o1 ) ))
2388
                              return -1;
2389
                          offset = o1;
2390
                      }
2391
                  } else {
2392
                      int ch = op.getData();
2393
                      if (dx > 0) {
2394
                          if (offset >= con.limit || ch !=  target .charAt(  offset ) )
2395
                              return -1;
2396
                          offset ++;
2397
                      } else {
2398
                          int o1 = offset-1;
2399
                          if (o1 >= con.limit || o1 < 0 || ch !=  target .charAt(  o1 ) )
2400
                              return -1;
2401
                          offset = o1;
2402
                      }
2403
                  }
2404
                  op = op.next;
2405
                  break;
2406
2407
              case Op.DOT:
2408
                  if (dx > 0) {
2409
                      if (offset >= con.limit)
2410
                          return -1;
2411
                      int ch =  target .charAt(  offset ) ;
2412
                      if (isSet(opts, SINGLE_LINE)) {
2413
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
2414
                              offset ++;
2415
                      } else {
2416
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
2417
                              ch = REUtil.composeFromSurrogates(ch,  target .charAt(  ++offset ) );
2418
                          if (isEOLChar(ch))
2419
                              return -1;
2420
                      }
2421
                      offset ++;
2422
                  } else {
2423
                      int o1 = offset-1;
2424
                      if (o1 >= con.limit || o1 < 0)
2425
                          return -1;
2426
                      int ch =  target .charAt(  o1 ) ;
2427
                      if (isSet(opts, SINGLE_LINE)) {
2428
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
2429
                              o1 --;
2430
                      } else {
2431
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
2432
                              ch = REUtil.composeFromSurrogates( target .charAt(  --o1 ) , ch);
2433
                          if (!isEOLChar(ch))
2434
                              return -1;
2435
                      }
2436
                      offset = o1;
2437
                  }
2438
                  op = op.next;
2439
                  break;
2440
2441
              case Op.RANGE:
2442
              case Op.NRANGE:
2443
                  if (dx > 0) {
2444
                      if (offset >= con.limit)
2445
                          return -1;
2446
                      int ch =  target .charAt(  offset ) ;
2447
                      if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
2448
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  ++offset ) );
2449
                      RangeToken tok = op.getToken();
2450
                      if (isSet(opts, IGNORE_CASE)) {
2451
                          tok = tok.getCaseInsensitiveToken();
2452
                          if (!tok.match(ch)) {
2453
                              if (ch >= 0x10000)  return -1;
2454
                              char uch;
2455
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
2456
                                  && !tok.match(Character.toLowerCase(uch)))
2457
                                  return -1;
2458
                          }
2459
                      } else {
2460
                          if (!tok.match(ch))  return -1;
2461
                      }
2462
                      offset ++;
2463
                  } else {
2464
                      int o1 = offset-1;
2465
                      if (o1 >= con.limit || o1 < 0)
2466
                          return -1;
2467
                      int ch =  target .charAt(  o1 ) ;
2468
                      if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
2469
                          ch = REUtil.composeFromSurrogates( target .charAt(  --o1 ) , ch);
2470
                      RangeToken tok = op.getToken();
2471
                      if (isSet(opts, IGNORE_CASE)) {
2472
                          tok = tok.getCaseInsensitiveToken();
2473
                          if (!tok.match(ch)) {
2474
                              if (ch >= 0x10000)  return -1;
2475
                              char uch;
2476
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
2477
                                  && !tok.match(Character.toLowerCase(uch)))
2478
                                  return -1;
2479
                          }
2480
                      } else {
2481
                          if (!tok.match(ch))  return -1;
2482
                      }
2483
                      offset = o1;
2484
                  }
2485
                  op = op.next;
2486
                  break;
2487
2488
              case Op.ANCHOR:
2489
                  boolean go = false;
2490
                  switch (op.getData()) {
2491
                  case '^':
2492
                      if (isSet(opts, MULTIPLE_LINES)) {
2493
                          if (!(offset == con.start
2494
                                || offset > con.start && isEOLChar( target .charAt(  offset-1 ) )))
2495
                              return -1;
2496
                      } else {
2497
                          if (offset != con.start)
2498
                              return -1;
2499
                      }
2500
                      break;
2501
2502
                  case '@':                         // Internal use only.
2503
                      // The @ always matches line beginnings.
2504
                      if (!(offset == con.start
2505
                            || offset > con.start && isEOLChar( target .charAt(  offset-1 ) )))
2506
                          return -1;
2507
                      break;
2508
2509
                  case '$':
2510
                      if (isSet(opts, MULTIPLE_LINES)) {
2511
                          if (!(offset == con.limit
2512
                                || offset < con.limit && isEOLChar( target .charAt(  offset ) )))
2513
                              return -1;
2514
                      } else {
2515
                          if (!(offset == con.limit
2516
                                || offset+1 == con.limit && isEOLChar( target .charAt(  offset ) )
2517
                                || offset+2 == con.limit &&  target .charAt(  offset )  == CARRIAGE_RETURN
2518
                                &&  target .charAt(  offset+1 )  == LINE_FEED))
2519
                              return -1;
2520
                      }
2521
                      break;
2522
2523
                  case 'A':
2524
                      if (offset != con.start)  return -1;
2525
                      break;
2526
2527
                  case 'Z':
2528
                      if (!(offset == con.limit
2529
                            || offset+1 == con.limit && isEOLChar( target .charAt(  offset ) )
2530
                            || offset+2 == con.limit &&  target .charAt(  offset )  == CARRIAGE_RETURN
2531
                            &&  target .charAt(  offset+1 )  == LINE_FEED))
2532
                          return -1;
2533
                      break;
2534
2535
                  case 'z':
2536
                      if (offset != con.limit)  return -1;
2537
                      break;
2538
2539
                  case 'b':
2540
                      if (con.length == 0)  return -1;
2541
                      {
2542
                          int after = getWordType(target, con.start, con.limit, offset, opts);
2543
                          if (after == WT_IGNORE)  return -1;
2544
                          int before = getPreviousWordType(target, con.start, con.limit, offset, opts);
2545
                          if (after == before)  return -1;
2546
                      }
2547
                      break;
2548
2549
                  case 'B':
2550
                      if (con.length == 0)
2551
                          go = true;
2552
                      else {
2553
                          int after = getWordType(target, con.start, con.limit, offset, opts);
2554
                          go = after == WT_IGNORE
2555
                               || after == getPreviousWordType(target, con.start, con.limit, offset, opts);
2556
                      }
2557
                      if (!go)  return -1;
2558
                      break;
2559
2560
                  case '<':
2561
                      if (con.length == 0 || offset == con.limit)  return -1;
2562
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER
2563
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)
2564
                          return -1;
2565
                      break;
2566
2567
                  case '>':
2568
                      if (con.length == 0 || offset == con.start)  return -1;
2569
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER
2570
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)
2571
                          return -1;
2572
                      break;
2573
                  } // switch anchor type
2574
                  op = op.next;
2575
                  break;
2576
2577
              case Op.BACKREFERENCE:
2578
                  {
2579
                      int refno = op.getData();
2580
                      if (refno <= 0 || refno >= this.nofparen)
2581
                          throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);
2582
                      if (con.match.getBeginning(refno) < 0
2583
                          || con.match.getEnd(refno) < 0)
2584
                          return -1;                // ********
2585
                      int o2 = con.match.getBeginning(refno);
2586
                      int literallen = con.match.getEnd(refno)-o2;
2587
                      if (!isSet(opts, IGNORE_CASE)) {
2588
                          if (dx > 0) {
2589
                              if (!regionMatches(target, offset, con.limit, o2, literallen))
2590
                                  return -1;
2591
                              offset += literallen;
2592
                          } else {
2593
                              if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))
2594
                                  return -1;
2595
                              offset -= literallen;
2596
                          }
2597
                      } else {
2598
                          if (dx > 0) {
2599
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
2600
                                  return -1;
2601
                              offset += literallen;
2602
                          } else {
2603
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
2604
                                                           o2, literallen))
2605
                                  return -1;
2606
                              offset -= literallen;
2607
                          }
2608
                      }
2609
                  }
2610
                  op = op.next;
2611
                  break;
2612
              case Op.STRING:
2613
                  {
2614
                      String literal = op.getString();
2615
                      int literallen = literal.length();
2616
                      if (!isSet(opts, IGNORE_CASE)) {
2617
                          if (dx > 0) {
2618
                              if (!regionMatches(target, offset, con.limit, literal, literallen))
2619
                                  return -1;
2620
                              offset += literallen;
2621
                          } else {
2622
                              if (!regionMatches(target, offset-literallen, con.limit, literal, literallen))
2623
                                  return -1;
2624
                              offset -= literallen;
2625
                          }
2626
                      } else {
2627
                          if (dx > 0) {
2628
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen))
2629
                                  return -1;
2630
                              offset += literallen;
2631
                          } else {
2632
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
2633
                                                           literal, literallen))
2634
                                  return -1;
2635
                              offset -= literallen;
2636
                          }
2637
                      }
2638
                  }
2639
                  op = op.next;
2640
                  break;
2641
2642
              case Op.CLOSURE:
2643
                  {
2644
                      /*
2645
                       * Saves current position to avoid
2646
                       * zero-width repeats.
2647
                       */
2648
                      int id = op.getData();
2649
                      if (id >= 0) {
2650
                          int previousOffset = con.offsets[id];
2651
                          if (previousOffset < 0 || previousOffset != offset) {
2652
                              con.offsets[id] = offset;
2653
                          } else {
2654
                              con.offsets[id] = -1;
2655
                              op = op.next;
2656
                              break;
2657
                          }
2658
                      }
2659
                      int ret = this. matchString (con, op.getChild(), offset, dx, opts);
2660
                      if (id >= 0)  con.offsets[id] = -1;
2661
                      if (ret >= 0)  return ret;
2662
                      op = op.next;
2663
                  }
2664
                  break;
2665
2666
              case Op.QUESTION:
2667
                  {
2668
                      int ret = this. matchString (con, op.getChild(), offset, dx, opts);
2669
                      if (ret >= 0)  return ret;
2670
                      op = op.next;
2671
                  }
2672
                  break;
2673
2674
              case Op.NONGREEDYCLOSURE:
2675
              case Op.NONGREEDYQUESTION:
2676
                  {
2677
                      int ret = this. matchString (con, op.next, offset, dx, opts);
2678
                      if (ret >= 0)  return ret;
2679
                      op = op.getChild();
2680
                  }
2681
                  break;
2682
2683
              case Op.UNION:
2684
                  for (int i = 0;  i < op.size();  i ++) {
2685
                      int ret = this. matchString (con, op.elementAt(i), offset, dx, opts);
2686
                      if (DEBUG) {
2687
                          System.err.println("UNION: "+i+", ret="+ret);
2688
                      }
2689
                      if (ret >= 0)  return ret;
2690
                  }
2691
                  return -1;
2692
2693
              case Op.CAPTURE:
2694
                  int refno = op.getData();
2695
                  if (con.match != null && refno > 0) {
2696
                      int save = con.match.getBeginning(refno);
2697
                      con.match.setBeginning(refno, offset);
2698
                      int ret = this. matchString (con, op.next, offset, dx, opts);
2699
                      if (ret < 0)  con.match.setBeginning(refno, save);
2700
                      return ret;
2701
                  } else if (con.match != null && refno < 0) {
2702
                      int index = -refno;
2703
                      int save = con.match.getEnd(index);
2704
                      con.match.setEnd(index, offset);
2705
                      int ret = this. matchString (con, op.next, offset, dx, opts);
2706
                      if (ret < 0)  con.match.setEnd(index, save);
2707
                      return ret;
2708
                  }
2709
                  op = op.next;
2710
                  break;
2711
2712
              case Op.LOOKAHEAD:
2713
                  if (0 > this. matchString (con, op.getChild(), offset, 1, opts))  return -1;
2714
                  op = op.next;
2715
                  break;
2716
              case Op.NEGATIVELOOKAHEAD:
2717
                  if (0 <= this. matchString (con, op.getChild(), offset, 1, opts))  return -1;
2718
                  op = op.next;
2719
                  break;
2720
              case Op.LOOKBEHIND:
2721
                  if (0 > this. matchString (con, op.getChild(), offset, -1, opts))  return -1;
2722
                  op = op.next;
2723
                  break;
2724
              case Op.NEGATIVELOOKBEHIND:
2725
                  if (0 <= this. matchString (con, op.getChild(), offset, -1, opts))  return -1;
2726
                  op = op.next;
2727
                  break;
2728
2729
              case Op.INDEPENDENT:
2730
                  {
2731
                      int ret = this. matchString (con, op.getChild(), offset, dx, opts);
2732
                      if (ret < 0)  return ret;
2733
                      offset = ret;
2734
                      op = op.next;
2735
                  }
2736
                  break;
2737
2738
              case Op.MODIFIER:
2739
                  {
2740
                      int localopts = opts;
2741
                      localopts |= op.getData();
2742
                      localopts &= ~op.getData2();
2743
                      //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16));
2744
                      int ret = this. matchString (con, op.getChild(), offset, dx, localopts);
2745
                      if (ret < 0)  return ret;
2746
                      offset = ret;
2747
                      op = op.next;
2748
                  }
2749
                  break;
2750
2751
              case Op.CONDITION:
2752
                  {
2753
                      Op.ConditionOp cop = (Op.ConditionOp)op;
2754
                      boolean matchp = false;
2755
                      if (cop.refNumber > 0) {
2756
                          if (cop.refNumber >= this.nofparen)
2757
                              throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber);
2758
                          matchp = con.match.getBeginning(cop.refNumber) >= 0
2759
                                   && con.match.getEnd(cop.refNumber) >= 0;
2760
                      } else {
2761
                          matchp = 0 <= this. matchString (con, cop.condition, offset, dx, opts);
2762
                      }
2763
2764
                      if (matchp) {
2765
                          op = cop.yes;
2766
                      } else if (cop.no != null) {
2767
                          op = cop.no;
2768
                      } else {
2769
                          op = cop.next;
2770
                      }
2771
                  }
2772
                  break;
2773
2774
              default:
2775
                  throw new RuntimeException("Unknown operation type: "+op.type);
2776
              } // switch (op.type)
2777
          } // while
2778
      }
2779
2780
      private static final int getPreviousWordType(String  target, int begin, int end,
2781
                                                   int offset, int opts) {
2782
          int ret = getWordType(target, begin, end, --offset, opts);
2783
          while (ret == WT_IGNORE)
2784
              ret = getWordType(target, begin, end, --offset, opts);
2785
          return ret;
2786
      }
2787
2788
      private static final int getWordType(String  target, int begin, int end,
2789
                                           int offset, int opts) {
2790
          if (offset < begin || offset >= end)  return WT_OTHER;
2791
          return getWordType0( target .charAt(  offset ) , opts);
2792
      }
2793
2794
2795
      private static final boolean regionMatches(String text, int offset, int limit,
2796
                                                 String part, int partlen) {
2797
          if (limit-offset < partlen)  return false;
2798
          return text.regionMatches(offset, part, 0, partlen);
2799
      }
2800
2801
      private static final boolean regionMatches(String text, int offset, int limit,
2802
                                                 int offset2, int partlen) {
2803
          if (limit-offset < partlen)  return false;
2804
          return text.regionMatches(offset, text, offset2, partlen);
2805
      }
2806
2807
      private static final boolean regionMatchesIgnoreCase(String text, int offset, int limit,
2808
                                                           String part, int partlen) {
2809
          return text.regionMatches(true, offset, part, 0, partlen);
2810
      }
2811
2812
      private static final boolean regionMatchesIgnoreCase(String text, int offset, int limit,
2813
                                                           int offset2, int partlen) {
2814
          if (limit-offset < partlen)  return false;
2815
          return text.regionMatches(true, offset, text, offset2, partlen);
2816
      }
2817
2818
2819
2820
2821
2822
2823
2824
      /**
2825
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
2826
       *
2827
       * @return true if the target is matched to this regular expression.
2828
       */
2829
      public boolean matches(CharacterIterator target) {
2830
          return this.matches(target, (Match)null);
2831
      }
2832
2833
2834
      /**
2835
       * Checks whether the <var>target</var> text <strong>contains</strong> this pattern or not.
2836
       *
2837
       * @param match A Match instance for storing matching result.
2838
       * @return Offset of the start position in <VAR>target</VAR>; or -1 if not match.
2839
       */
2840
      public boolean matches(CharacterIterator  target, Match match) {
2841
          int start = target.getBeginIndex();
2842
          int end = target.getEndIndex();
2843
2844
2845
2846
          synchronized (this) {
2847
              if (this.operations == null)
2848
                  this.prepare();
2849
              if (this.context == null)
2850
                  this.context = new Context();
2851
          }
2852
          Context con = null;
2853
          synchronized (this.context) {
2854
              con = this.context.inuse ? new Context() : this.context;
2855
              con.reset(target, start, end, this.numberOfClosures);
2856
          }
2857
          if (match != null) {
2858
              match.setNumberOfGroups(this.nofparen);
2859
              match.setSource(target);
2860
          } else if (this.hasBackReferences) {
2861
              match = new Match();
2862
              match.setNumberOfGroups(this.nofparen);
2863
              // Need not to call setSource() because
2864
              // a caller can not access this match instance.
2865
          }
2866
          con.match = match;
2867
2868
          if (RegularExpression.isSet(this.options, XMLSCHEMA_MODE)) {
2869
              int matchEnd = this. matchCharacterIterator (con, this.operations, con.start, 1, this.options);
2870
              //System.err.println("DEBUG: matchEnd="+matchEnd);
2871
              if (matchEnd == con.limit) {
2872
                  if (con.match != null) {
2873
                      con.match.setBeginning(0, con.start);
2874
                      con.match.setEnd(0, matchEnd);
2875
                  }
2876
                  con.inuse = false;
2877
                  return true;
2878
              }
2879
              return false;
2880
          }
2881
2882
          /*
2883
           * The pattern has only fixed string.
2884
           * The engine uses Boyer-Moore.
2885
           */
2886
          if (this.fixedStringOnly) {
2887
              //System.err.println("DEBUG: fixed-only: "+this.fixedString);
2888
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
2889
              if (o >= 0) {
2890
                  if (con.match != null) {
2891
                      con.match.setBeginning(0, o);
2892
                      con.match.setEnd(0, o+this.fixedString.length());
2893
                  }
2894
                  con.inuse = false;
2895
                  return true;
2896
              }
2897
              con.inuse = false;
2898
              return false;
2899
          }
2900
2901
          /*
2902
           * The pattern contains a fixed string.
2903
           * The engine checks with Boyer-Moore whether the text contains the fixed string or not.
2904
           * If not, it return with false.
2905
           */
2906
          if (this.fixedString != null) {
2907
              int o = this.fixedStringTable.matches(target, con.start, con.limit);
2908
              if (o < 0) {
2909
                  //System.err.println("Non-match in fixed-string search.");
2910
                  con.inuse = false;
2911
                  return false;
2912
              }
2913
          }
2914
2915
          int limit = con.limit-this.minlength;
2916
          int matchStart;
2917
          int matchEnd = -1;
2918
2919
          /*
2920
           * Checks whether the expression starts with ".*".
2921
           */
2922
          if (this.operations != null
2923
              && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) {
2924
              if (isSet(this.options, SINGLE_LINE)) {
2925
                  matchStart = con.start;
2926
                  matchEnd = this. matchCharacterIterator (con, this.operations, con.start, 1, this.options);
2927
              } else {
2928
                  boolean previousIsEOL = true;
2929
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2930
                      int ch =  target .setIndex(  matchStart ) ;
2931
                      if (isEOLChar(ch)) {
2932
                          previousIsEOL = true;
2933
                      } else {
2934
                          if (previousIsEOL) {
2935
                              if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
2936
                                                                                 matchStart, 1, this.options)))
2937
                                  break;
2938
                          }
2939
                          previousIsEOL = false;
2940
                      }
2941
                  }
2942
              }
2943
          }
2944
2945
          /*
2946
           * Optimization against the first character.
2947
           */
2948
          else if (this.firstChar != null) {
2949
              //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
2950
              RangeToken range = this.firstChar;
2951
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
2952
                  range = this.firstChar.getCaseInsensitiveToken();
2953
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2954
                      int ch =  target .setIndex(  matchStart ) ;
2955
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
2956
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
2957
                          if (!range.match(ch))  continue;
2958
                      } else {
2959
                          if (!range.match(ch)) {
2960
                              char ch1 = Character.toUpperCase((char)ch);
2961
                              if (!range.match(ch1))
2962
                                  if (!range.match(Character.toLowerCase(ch1)))
2963
                                      continue;
2964
                          }
2965
                      }
2966
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
2967
                                                                         matchStart, 1, this.options)))
2968
                          break;
2969
                  }
2970
              } else {
2971
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2972
                      int ch =  target .setIndex(  matchStart ) ;
2973
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
2974
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
2975
                      if (!range.match(ch))  continue;
2976
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
2977
                                                                         matchStart, 1, this.options)))
2978
                          break;
2979
                  }
2980
              }
2981
          }
2982
2983
          /*
2984
           * Straightforward matching.
2985
           */
2986
          else {
2987
              for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
2988
                  if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations, matchStart, 1, this.options)))
2989
                      break;
2990
              }
2991
          }
2992
2993
          if (matchEnd >= 0) {
2994
              if (con.match != null) {
2995
                  con.match.setBeginning(0, matchStart);
2996
                  con.match.setEnd(0, matchEnd);
2997
              }
2998
              con.inuse = false;
2999
              return true;
3000
          } else {
3001
              con.inuse = false;
3002
              return false;
3003
          }
3004
      }
3005
3006
      /**
3007
       * @return -1 when not match; offset of the end of matched string when match.
3008
       */
3009
      private int matchCharacterIterator (Context con, Op op, int offset, int dx, int opts) {
3010
3011
3012
          CharacterIterator target = con.ciTarget;
3013
3014
3015
3016
3017
3018
3019
          while (true) {
3020
              if (op == null)
3021
                  return isSet(opts, XMLSCHEMA_MODE) && offset != con.limit ? -1 : offset;
3022
              if (offset > con.limit || offset < con.start)
3023
                  return -1;
3024
              switch (op.type) {
3025
              case Op.CHAR:
3026
                  if (isSet(opts, IGNORE_CASE)) {
3027
                      int ch = op.getData();
3028
                      if (dx > 0) {
3029
                          if (offset >= con.limit || !matchIgnoreCase(ch,  target .setIndex(  offset ) ))
3030
                              return -1;
3031
                          offset ++;
3032
                      } else {
3033
                          int o1 = offset-1;
3034
                          if (o1 >= con.limit || o1 < 0 || !matchIgnoreCase(ch,  target .setIndex(  o1 ) ))
3035
                              return -1;
3036
                          offset = o1;
3037
                      }
3038
                  } else {
3039
                      int ch = op.getData();
3040
                      if (dx > 0) {
3041
                          if (offset >= con.limit || ch !=  target .setIndex(  offset ) )
3042
                              return -1;
3043
                          offset ++;
3044
                      } else {
3045
                          int o1 = offset-1;
3046
                          if (o1 >= con.limit || o1 < 0 || ch !=  target .setIndex(  o1 ) )
3047
                              return -1;
3048
                          offset = o1;
3049
                      }
3050
                  }
3051
                  op = op.next;
3052
                  break;
3053
3054
              case Op.DOT:
3055
                  if (dx > 0) {
3056
                      if (offset >= con.limit)
3057
                          return -1;
3058
                      int ch =  target .setIndex(  offset ) ;
3059
                      if (isSet(opts, SINGLE_LINE)) {
3060
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
3061
                              offset ++;
3062
                      } else {
3063
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
3064
                              ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  ++offset ) );
3065
                          if (isEOLChar(ch))
3066
                              return -1;
3067
                      }
3068
                      offset ++;
3069
                  } else {
3070
                      int o1 = offset-1;
3071
                      if (o1 >= con.limit || o1 < 0)
3072
                          return -1;
3073
                      int ch =  target .setIndex(  o1 ) ;
3074
                      if (isSet(opts, SINGLE_LINE)) {
3075
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
3076
                              o1 --;
3077
                      } else {
3078
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
3079
                              ch = REUtil.composeFromSurrogates( target .setIndex(  --o1 ) , ch);
3080
                          if (!isEOLChar(ch))
3081
                              return -1;
3082
                      }
3083
                      offset = o1;
3084
                  }
3085
                  op = op.next;
3086
                  break;
3087
3088
              case Op.RANGE:
3089
              case Op.NRANGE:
3090
                  if (dx > 0) {
3091
                      if (offset >= con.limit)
3092
                          return -1;
3093
                      int ch =  target .setIndex(  offset ) ;
3094
                      if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
3095
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  ++offset ) );
3096
                      RangeToken tok = op.getToken();
3097
                      if (isSet(opts, IGNORE_CASE)) {
3098
                          tok = tok.getCaseInsensitiveToken();
3099
                          if (!tok.match(ch)) {
3100
                              if (ch >= 0x10000)  return -1;
3101
                              char uch;
3102
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
3103
                                  && !tok.match(Character.toLowerCase(uch)))
3104
                                  return -1;
3105
                          }
3106
                      } else {
3107
                          if (!tok.match(ch))  return -1;
3108
                      }
3109
                      offset ++;
3110
                  } else {
3111
                      int o1 = offset-1;
3112
                      if (o1 >= con.limit || o1 < 0)
3113
                          return -1;
3114
                      int ch =  target .setIndex(  o1 ) ;
3115
                      if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
3116
                          ch = REUtil.composeFromSurrogates( target .setIndex(  --o1 ) , ch);
3117
                      RangeToken tok = op.getToken();
3118
                      if (isSet(opts, IGNORE_CASE)) {
3119
                          tok = tok.getCaseInsensitiveToken();
3120
                          if (!tok.match(ch)) {
3121
                              if (ch >= 0x10000)  return -1;
3122
                              char uch;
3123
                              if (!tok.match(uch = Character.toUpperCase((char)ch))
3124
                                  && !tok.match(Character.toLowerCase(uch)))
3125
                                  return -1;
3126
                          }
3127
                      } else {
3128
                          if (!tok.match(ch))  return -1;
3129
                      }
3130
                      offset = o1;
3131
                  }
3132
                  op = op.next;
3133
                  break;
3134
3135
              case Op.ANCHOR:
3136
                  boolean go = false;
3137
                  switch (op.getData()) {
3138
                  case '^':
3139
                      if (isSet(opts, MULTIPLE_LINES)) {
3140
                          if (!(offset == con.start
3141
                                || offset > con.start && isEOLChar( target .setIndex(  offset-1 ) )))
3142
                              return -1;
3143
                      } else {
3144
                          if (offset != con.start)
3145
                              return -1;
3146
                      }
3147
                      break;
3148
3149
                  case '@':                         // Internal use only.
3150
                      // The @ always matches line beginnings.
3151
                      if (!(offset == con.start
3152
                            || offset > con.start && isEOLChar( target .setIndex(  offset-1 ) )))
3153
                          return -1;
3154
                      break;
3155
3156
                  case '$':
3157
                      if (isSet(opts, MULTIPLE_LINES)) {
3158
                          if (!(offset == con.limit
3159
                                || offset < con.limit && isEOLChar( target .setIndex(  offset ) )))
3160
                              return -1;
3161
                      } else {
3162
                          if (!(offset == con.limit
3163
                                || offset+1 == con.limit && isEOLChar( target .setIndex(  offset ) )
3164
                                || offset+2 == con.limit &&  target .setIndex(  offset )  == CARRIAGE_RETURN
3165
                                &&  target .setIndex(  offset+1 )  == LINE_FEED))
3166
                              return -1;
3167
                      }
3168
                      break;
3169
3170
                  case 'A':
3171
                      if (offset != con.start)  return -1;
3172
                      break;
3173
3174
                  case 'Z':
3175
                      if (!(offset == con.limit
3176
                            || offset+1 == con.limit && isEOLChar( target .setIndex(  offset ) )
3177
                            || offset+2 == con.limit &&  target .setIndex(  offset )  == CARRIAGE_RETURN
3178
                            &&  target .setIndex(  offset+1 )  == LINE_FEED))
3179
                          return -1;
3180
                      break;
3181
3182
                  case 'z':
3183
                      if (offset != con.limit)  return -1;
3184
                      break;
3185
3186
                  case 'b':
3187
                      if (con.length == 0)  return -1;
3188
                      {
3189
                          int after = getWordType(target, con.start, con.limit, offset, opts);
3190
                          if (after == WT_IGNORE)  return -1;
3191
                          int before = getPreviousWordType(target, con.start, con.limit, offset, opts);
3192
                          if (after == before)  return -1;
3193
                      }
3194
                      break;
3195
3196
                  case 'B':
3197
                      if (con.length == 0)
3198
                          go = true;
3199
                      else {
3200
                          int after = getWordType(target, con.start, con.limit, offset, opts);
3201
                          go = after == WT_IGNORE
3202
                               || after == getPreviousWordType(target, con.start, con.limit, offset, opts);
3203
                      }
3204
                      if (!go)  return -1;
3205
                      break;
3206
3207
                  case '<':
3208
                      if (con.length == 0 || offset == con.limit)  return -1;
3209
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER
3210
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)
3211
                          return -1;
3212
                      break;
3213
3214
                  case '>':
3215
                      if (con.length == 0 || offset == con.start)  return -1;
3216
                      if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER
3217
                          || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)
3218
                          return -1;
3219
                      break;
3220
                  } // switch anchor type
3221
                  op = op.next;
3222
                  break;
3223
3224
              case Op.BACKREFERENCE:
3225
                  {
3226
                      int refno = op.getData();
3227
                      if (refno <= 0 || refno >= this.nofparen)
3228
                          throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);
3229
                      if (con.match.getBeginning(refno) < 0
3230
                          || con.match.getEnd(refno) < 0)
3231
                          return -1;                // ********
3232
                      int o2 = con.match.getBeginning(refno);
3233
                      int literallen = con.match.getEnd(refno)-o2;
3234
                      if (!isSet(opts, IGNORE_CASE)) {
3235
                          if (dx > 0) {
3236
                              if (!regionMatches(target, offset, con.limit, o2, literallen))
3237
                                  return -1;
3238
                              offset += literallen;
3239
                          } else {
3240
                              if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))
3241
                                  return -1;
3242
                              offset -= literallen;
3243
                          }
3244
                      } else {
3245
                          if (dx > 0) {
3246
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
3247
                                  return -1;
3248
                              offset += literallen;
3249
                          } else {
3250
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
3251
                                                           o2, literallen))
3252
                                  return -1;
3253
                              offset -= literallen;
3254
                          }
3255
                      }
3256
                  }
3257
                  op = op.next;
3258
                  break;
3259
              case Op.STRING:
3260
                  {
3261
                      String literal = op.getString();
3262
                      int literallen = literal.length();
3263
                      if (!isSet(opts, IGNORE_CASE)) {
3264
                          if (dx > 0) {
3265
                              if (!regionMatches(target, offset, con.limit, literal, literallen))
3266
                                  return -1;
3267
                              offset += literallen;
3268
                          } else {
3269
                              if (!regionMatches(target, offset-literallen, con.limit, literal, literallen))
3270
                                  return -1;
3271
                              offset -= literallen;
3272
                          }
3273
                      } else {
3274
                          if (dx > 0) {
3275
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen))
3276
                                  return -1;
3277
                              offset += literallen;
3278
                          } else {
3279
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
3280
                                                           literal, literallen))
3281
                                  return -1;
3282
                              offset -= literallen;
3283
                          }
3284
                      }
3285
                  }
3286
                  op = op.next;
3287
                  break;
3288
3289
              case Op.CLOSURE:
3290
                  {
3291
                      /*
3292
                       * Saves current position to avoid
3293
                       * zero-width repeats.
3294
                       */
3295
                      int id = op.getData();
3296
                      if (id >= 0) {
3297
                          int previousOffset = con.offsets[id];
3298
                          if (previousOffset < 0 || previousOffset != offset) {
3299
                              con.offsets[id] = offset;
3300
                          } else {
3301
                              con.offsets[id] = -1;
3302
                              op = op.next;
3303
                              break;
3304
                          }
3305
                      }
3306
                      
3307
                      int ret = this. matchCharacterIterator (con, op.getChild(), offset, dx, opts);
3308
                      if (id >= 0)  con.offsets[id] = -1;
3309
                      if (ret >= 0)  return ret;
3310
                      op = op.next;
3311
                  }
3312
                  break;
3313
3314
              case Op.QUESTION:
3315
                  {
3316
                      int ret = this. matchCharacterIterator (con, op.getChild(), offset, dx, opts);
3317
                      if (ret >= 0)  return ret;
3318
                      op = op.next;
3319
                  }
3320
                  break;
3321
3322
              case Op.NONGREEDYCLOSURE:
3323
              case Op.NONGREEDYQUESTION:
3324
                  {
3325
                      int ret = this. matchCharacterIterator (con, op.next, offset, dx, opts);
3326
                      if (ret >= 0)  return ret;
3327
                      op = op.getChild();
3328
                  }
3329
                  break;
3330
3331
              case Op.UNION:
3332
                  for (int i = 0;  i < op.size();  i ++) {
3333
                      int ret = this. matchCharacterIterator (con, op.elementAt(i), offset, dx, opts);
3334
                      if (DEBUG) {
3335
                          System.err.println("UNION: "+i+", ret="+ret);
3336
                      }
3337
                      if (ret >= 0)  return ret;
3338
                  }
3339
                  return -1;
3340
3341
              case Op.CAPTURE:
3342
                  int refno = op.getData();
3343
                  if (con.match != null && refno > 0) {
3344
                      int save = con.match.getBeginning(refno);
3345
                      con.match.setBeginning(refno, offset);
3346
                      int ret = this. matchCharacterIterator (con, op.next, offset, dx, opts);
3347
                      if (ret < 0)  con.match.setBeginning(refno, save);
3348
                      return ret;
3349
                  } else if (con.match != null && refno < 0) {
3350
                      int index = -refno;
3351
                      int save = con.match.getEnd(index);
3352
                      con.match.setEnd(index, offset);
3353
                      int ret = this. matchCharacterIterator (con, op.next, offset, dx, opts);
3354
                      if (ret < 0)  con.match.setEnd(index, save);
3355
                      return ret;
3356
                  }
3357
                  op = op.next;
3358
                  break;
3359
3360
              case Op.LOOKAHEAD:
3361
                  if (0 > this. matchCharacterIterator (con, op.getChild(), offset, 1, opts))  return -1;
3362
                  op = op.next;
3363
                  break;
3364
              case Op.NEGATIVELOOKAHEAD:
3365
                  if (0 <= this. matchCharacterIterator (con, op.getChild(), offset, 1, opts))  return -1;
3366
                  op = op.next;
3367
                  break;
3368
              case Op.LOOKBEHIND:
3369
                  if (0 > this. matchCharacterIterator (con, op.getChild(), offset, -1, opts))  return -1;
3370
                  op = op.next;
3371
                  break;
3372
              case Op.NEGATIVELOOKBEHIND:
3373
                  if (0 <= this. matchCharacterIterator (con, op.getChild(), offset, -1, opts))  return -1;
3374
                  op = op.next;
3375
                  break;
3376
3377
              case Op.INDEPENDENT:
3378
                  {
3379
                      int ret = this. matchCharacterIterator (con, op.getChild(), offset, dx, opts);
3380
                      if (ret < 0)  return ret;
3381
                      offset = ret;
3382
                      op = op.next;
3383
                  }
3384
                  break;
3385
3386
              case Op.MODIFIER:
3387
                  {
3388
                      int localopts = opts;
3389
                      localopts |= op.getData();
3390
                      localopts &= ~op.getData2();
3391
                      //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16));
3392
                      int ret = this. matchCharacterIterator (con, op.getChild(), offset, dx, localopts);
3393
                      if (ret < 0)  return ret;
3394
                      offset = ret;
3395
                      op = op.next;
3396
                  }
3397
                  break;
3398
3399
              case Op.CONDITION:
3400
                  {
3401
                      Op.ConditionOp cop = (Op.ConditionOp)op;
3402
                      boolean matchp = false;
3403
                      if (cop.refNumber > 0) {
3404
                          if (cop.refNumber >= this.nofparen)
3405
                              throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber);
3406
                          matchp = con.match.getBeginning(cop.refNumber) >= 0
3407
                                   && con.match.getEnd(cop.refNumber) >= 0;
3408
                      } else {
3409
                          matchp = 0 <= this. matchCharacterIterator (con, cop.condition, offset, dx, opts);
3410
                      }
3411
3412
                      if (matchp) {
3413
                          op = cop.yes;
3414
                      } else if (cop.no != null) {
3415
                          op = cop.no;
3416
                      } else {
3417
                          op = cop.next;
3418
                      }
3419
                  }
3420
                  break;
3421
3422
              default:
3423
                  throw new RuntimeException("Unknown operation type: "+op.type);
3424
              } // switch (op.type)
3425
          } // while
3426
      }
3427
3428
      private static final int getPreviousWordType(CharacterIterator  target, int begin, int end,
3429
                                                   int offset, int opts) {
3430
          int ret = getWordType(target, begin, end, --offset, opts);
3431
          while (ret == WT_IGNORE)
3432
              ret = getWordType(target, begin, end, --offset, opts);
3433
          return ret;
3434
      }
3435
3436
      private static final int getWordType(CharacterIterator  target, int begin, int end,
3437
                                           int offset, int opts) {
3438
          if (offset < begin || offset >= end)  return WT_OTHER;
3439
          return getWordType0( target .setIndex(  offset ) , opts);
3440
      }
3441
3442
3443
3444
      private static final boolean regionMatches(CharacterIterator  target, int offset, int limit,
3445
                                                 String part, int partlen) {
3446
          if (offset < 0)  return false;
3447
          if (limit-offset < partlen)
3448
              return false;
3449
          int i = 0;
3450
          while (partlen-- > 0) {
3451
              if ( target .setIndex(  offset++ )  != part.charAt(i++))
3452
                  return false;
3453
          }
3454
          return true;
3455
      }
3456
3457
      private static final boolean regionMatches(CharacterIterator  target, int offset, int limit,
3458
                                                 int offset2, int partlen) {
3459
          if (offset < 0)  return false;
3460
          if (limit-offset < partlen)
3461
              return false;
3462
          int i = offset2;
3463
          while (partlen-- > 0) {
3464
              if ( target .setIndex(  offset++ )  !=  target .setIndex(  i++ ) )
3465
                  return false;
3466
          }
3467
          return true;
3468
      }
3469
3470
      /**
3471
       * @see java.lang.String#regionMatches
3472
       */
3473
      private static final boolean regionMatchesIgnoreCase(CharacterIterator  target, int offset, int limit,
3474
                                                           String part, int partlen) {
3475
          if (offset < 0)  return false;
3476
          if (limit-offset < partlen)
3477
              return false;
3478
          int i = 0;
3479
          while (partlen-- > 0) {
3480
              char ch1 =  target .setIndex(  offset++ ) ;
3481
              char ch2 = part.charAt(i++);
3482
              if (ch1 == ch2)
3483
                  continue;
3484
              char uch1 = Character.toUpperCase(ch1);
3485
              char uch2 = Character.toUpperCase(ch2);
3486
              if (uch1 == uch2)
3487
                  continue;
3488
              if (Character.toLowerCase(uch1) != Character.toLowerCase(uch2))
3489
                  return false;
3490
          }
3491
          return true;
3492
      }
3493
3494
      private static final boolean regionMatchesIgnoreCase(CharacterIterator  target, int offset, int limit,
3495
                                                           int offset2, int partlen) {
3496
          if (offset < 0)  return false;
3497
          if (limit-offset < partlen)
3498
              return false;
3499
          int i = offset2;
3500
          while (partlen-- > 0) {
3501
              char ch1 =  target .setIndex(  offset++ ) ;
3502
              char ch2 =  target .setIndex(  i++ ) ;
3503
              if (ch1 == ch2)
3504
                  continue;
3505
              char uch1 = Character.toUpperCase(ch1);
3506
              char uch2 = Character.toUpperCase(ch2);
3507
              if (uch1 == uch2)
3508
                  continue;
3509
              if (Character.toLowerCase(uch1) != Character.toLowerCase(uch2))
3510
                  return false;
3511
          }
3512
          return true;
3513
      }
3514
3515
3516
3517
3518
      // ================================================================
3519
3520
      /**
3521
       * A regular expression.
3522
       * @serial
3523
       */
3524
      String regex;
3525
      /**
3526
       * @serial
3527
       */
3528
      int options;
3529
3530
      /**
3531
       * The number of parenthesis in the regular expression.
3532
       * @serial
3533
       */
3534
      int nofparen;
3535
      /**
3536
       * Internal representation of the regular expression.
3537
       * @serial
3538
       */
3539
      Token tokentree;
3540
3541
      boolean hasBackReferences = false;
3542
3543
      transient int minlength;
3544
      transient Op operations = null;
3545
      transient int numberOfClosures;
3546
      transient Context context = null;
3547
      transient RangeToken firstChar = null;
3548
3549
      transient String fixedString = null;
3550
      transient int fixedStringOptions;
3551
      transient BMPattern fixedStringTable = null;
3552
      transient boolean fixedStringOnly = false;
3553
3554
3555
      static final class Context {
3556
          CharacterIterator ciTarget;
3557
          String strTarget;
3558
          char[] charTarget;
3559
          int start;
3560
          int limit;
3561
          int length;
3562
          Match match;
3563
          boolean inuse = false;
3564
          int[] offsets;
3565
3566
          Context() {
3567
          }
3568
3569
          private void resetCommon(int nofclosures) {
3570
              this.length = this.limit-this.start;
3571
              this.inuse = true;
3572
              this.match = null;
3573
              if (this.offsets == null || this.offsets.length != nofclosures)
3574
                  this.offsets = new int[nofclosures];
3575
              for (int i = 0;  i < nofclosures;  i ++)  this.offsets[i] = -1;
3576
          }
3577
          void reset(CharacterIterator target, int start, int limit, int nofclosures) {
3578
              this.ciTarget = target;
3579
              this.start = start;
3580
              this.limit = limit;
3581
              this.resetCommon(nofclosures);
3582
          }
3583
          void reset(String target, int start, int limit, int nofclosures) {
3584
              this.strTarget = target;
3585
              this.start = start;
3586
              this.limit = limit;
3587
              this.resetCommon(nofclosures);
3588
          }
3589
          void reset(char[] target, int start, int limit, int nofclosures) {
3590
              this.charTarget = target;
3591
              this.start = start;
3592
              this.limit = limit;
3593
              this.resetCommon(nofclosures);
3594
          }
3595
      }
3596
3597
      /**
3598
       * Prepares for matching.  This method is called just before starting matching.
3599
       */
3600
      void prepare() {
3601
          if (Op.COUNT)  Op.nofinstances = 0;
3602
          this.compile(this.tokentree);
3603
          /*
3604
          if  (this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) { // .*
3605
              Op anchor = Op.createAnchor(isSet(this.options, SINGLE_LINE) ? 'A' : '@');
3606
              anchor.next = this.operations;
3607
              this.operations = anchor;
3608
          }
3609
          */
3610
          if (Op.COUNT)  System.err.println("DEBUG: The number of operations: "+Op.nofinstances);
3611
3612
          this.minlength = this.tokentree.getMinLength();
3613
3614
          this.firstChar = null;
3615
          if (!isSet(this.options, PROHIBIT_HEAD_CHARACTER_OPTIMIZATION)
3616
              && !isSet(this.options, XMLSCHEMA_MODE)) {
3617
              RangeToken firstChar = Token.createRange();
3618
              int fresult = this.tokentree.analyzeFirstCharacter(firstChar, this.options);
3619
              if (fresult == Token.FC_TERMINAL) {
3620
                  firstChar.compactRanges();
3621
                  this.firstChar = firstChar;
3622
                  if (DEBUG)
3623
                      System.err.println("DEBUG: Use the first character optimization: "+firstChar);
3624
              }
3625
          }
3626
3627
          if (this.operations != null
3628
              && (this.operations.type == Op.STRING || this.operations.type == Op.CHAR)
3629
              && this.operations.next == null) {
3630
              if (DEBUG)
3631
                  System.err.print(" *** Only fixed string! *** ");
3632
              this.fixedStringOnly = true;
3633
              if (this.operations.type == Op.STRING)
3634
                  this.fixedString = this.operations.getString();
3635
              else if (this.operations.getData() >= 0x10000) { // Op.CHAR
3636
                  this.fixedString = REUtil.decomposeToSurrogates(this.operations.getData());
3637
              } else {
3638
                  char[] ac = new char[1];
3639
                  ac[0] = (char)this.operations.getData();
3640
                  this.fixedString = new String(ac);
3641
              }
3642
              this.fixedStringOptions = this.options;
3643
              this.fixedStringTable = new BMPattern(this.fixedString, 256,
3644
                                                    isSet(this.fixedStringOptions, IGNORE_CASE));
3645
          } else if (!isSet(this.options, PROHIBIT_FIXED_STRING_OPTIMIZATION)
3646
                     && !isSet(this.options, XMLSCHEMA_MODE)) {
3647
              Token.FixedStringContainer container = new Token.FixedStringContainer();
3648
              this.tokentree.findFixedString(container, this.options);
3649
              this.fixedString = container.token == null ? null : container.token.getString();
3650
              this.fixedStringOptions = container.options;
3651
              if (this.fixedString != null && this.fixedString.length() < 2)
3652
                  this.fixedString = null;
3653
              // This pattern has a fixed string of which length is more than one.
3654
              if (this.fixedString != null) {
3655
                  this.fixedStringTable = new BMPattern(this.fixedString, 256,
3656
                                                        isSet(this.fixedStringOptions, IGNORE_CASE));
3657
                  if (DEBUG) {
3658
                      System.err.println("DEBUG: The longest fixed string: "+this.fixedString.length()
3659
                                         +"/" //+this.fixedString
3660
                                         +"/"+REUtil.createOptionString(this.fixedStringOptions));
3661
                      System.err.print("String: ");
3662
                      REUtil.dumpString(this.fixedString);
3663
                  }
3664
              }
3665
          }
3666
      }
3667
3668
      /**
3669
       * An option.
3670
       * If you specify this option, <span class="REGEX"><kbd>(</kbd><var>X</var><kbd>)</kbd></span>
3671
       * captures matched text, and <span class="REGEX"><kbd>(:?</kbd><var>X</var><kbd>)</kbd></span>
3672
       * does not capture.
3673
       *
3674
       * @see #RegularExpression(java.lang.String,int)
3675
       * @see #setPattern(java.lang.String,int)
3676
      static final int MARK_PARENS = 1<<0;
3677
       */
3678
3679
      /**
3680
       * "i"
3681
       */
3682
      static final int IGNORE_CASE = 1<<1;
3683
3684
      /**
3685
       * "s"
3686
       */
3687
      static final int SINGLE_LINE = 1<<2;
3688
3689
      /**
3690
       * "m"
3691
       */
3692
      static final int MULTIPLE_LINES = 1<<3;
3693
3694
      /**
3695
       * "x"
3696
       */
3697
      static final int EXTENDED_COMMENT = 1<<4;
3698
3699
      /**
3700
       * This option redefines <span class="REGEX"><kbd>\d \D \w \W \s \S</kbd></span>.
3701
       *
3702
       * @see #RegularExpression(java.lang.String,int)
3703
       * @see #setPattern(java.lang.String,int)
3704
       * @see #UNICODE_WORD_BOUNDARY
3705
       */
3706
      static final int USE_UNICODE_CATEGORY = 1<<5; // "u"
3707
3708
      /**
3709
       * An option.
3710
       * This enables to process locale-independent word boundary for <span class="REGEX"><kbd>\b \B \&lt; \></kbd></span>.
3711
       * <p>By default, the engine considers a position between a word character
3712
       * (<span class="REGEX"><Kbd>\w</kbd></span>) and a non word character
3713
       * is a word boundary.
3714
       * <p>By this option, the engine checks word boundaries with the method of
3715
       * 'Unicode Regular Expression Guidelines' Revision 4.
3716
       *
3717
       * @see #RegularExpression(java.lang.String,int)
3718
       * @see #setPattern(java.lang.String,int)
3719
       */
3720
      static final int UNICODE_WORD_BOUNDARY = 1<<6; // "w"
3721
3722
      /**
3723
       * "H"
3724
       */
3725
      static final int PROHIBIT_HEAD_CHARACTER_OPTIMIZATION = 1<<7;
3726
      /**
3727
       * "F"
3728
       */
3729
      static final int PROHIBIT_FIXED_STRING_OPTIMIZATION = 1<<8;
3730
      /**
3731
       * "X". XML Schema mode.
3732
       */
3733
      static final int XMLSCHEMA_MODE = 1<<9;
3734
      /**
3735
       * ",".
3736
       */
3737
      static final int SPECIAL_COMMA = 1<<10;
3738
3739
3740
      private static final boolean isSet(int options, int flag) {
3741
          return (options & flag) == flag;
3742
      }
3743
3744
      /**
3745
       * Creates a new RegularExpression instance.
3746
       *
3747
       * @param regex A regular expression
3748
       * @exception org.apache.xerces.utils.regex.ParseException <VAR>regex</VAR> is not conforming to the syntax.
3749
       */
3750
      public RegularExpression(String regex) throws ParseException {
3751
          this.setPattern(regex, null);
3752
      }
3753
3754
      /**
3755
       * Creates a new RegularExpression instance with options.
3756
       *
3757
       * @param regex A regular expression
3758
       * @param options A String consisted of "i" "m" "s" "u" "w" "," "X"
3759
       * @exception org.apache.xerces.utils.regex.ParseException <VAR>regex</VAR> is not conforming to the syntax.
3760
       */
3761
      public RegularExpression(String regex, String options) throws ParseException {
3762
          this.setPattern(regex, options);
3763
      }
3764
3765
      RegularExpression(String regex, Token tok, int parens, boolean hasBackReferences, int options) {
3766
          this.regex = regex;
3767
          this.tokentree = tok;
3768
          this.nofparen = parens;
3769
          this.options = options;
3770
          this.hasBackReferences = hasBackReferences;
3771
      }
3772
3773
      /**
3774
       *
3775
       */
3776
      public void setPattern(String newPattern) throws ParseException {
3777
          this.setPattern(newPattern, this.options);
3778
      }
3779
3780
      private void setPattern(String newPattern, int options) throws ParseException {
3781
          this.regex = newPattern;
3782
          this.options = options;
3783
          RegexParser rp = RegularExpression.isSet(this.options, RegularExpression.XMLSCHEMA_MODE)
3784
                           ? new ParserForXMLSchema() : new RegexParser();
3785
          this.tokentree = rp.parse(this.regex, this.options);
3786
          this.nofparen = rp.parennumber;
3787
          this.hasBackReferences = rp.hasBackReferences;
3788
3789
          this.operations = null;
3790
          this.context = null;
3791
      }
3792
      /**
3793
       *
3794
       */
3795
      public void setPattern(String newPattern, String options) throws ParseException {
3796
          this.setPattern(newPattern, REUtil.parseOptions(options));
3797
      }
3798
3799
      /**
3800
       *
3801
       */
3802
      public String getPattern() {
3803
          return this.regex;
3804
      }
3805
3806
      /**
3807
       * Represents this instence in String.
3808
       */
3809
      public String toString() {
3810
          return this.tokentree.toString(this.options);
3811
      }
3812
3813
      /**
3814
       * Returns a option string.
3815
       * The order of letters in it may be different from a string specified
3816
       * in a constructor or <code>setPattern()</code>.
3817
       *
3818
       * @see #RegularExpression(String, String)
3819
       * @see #setPattern(java.lang.String,java.lang.String)
3820
       */
3821
      public String getOptions() {
3822
          return REUtil.createOptionString(this.options);
3823
      }
3824
3825
      /**
3826
       *  Return true if patterns are the same and the options are equivalent.
3827
       */
3828
      public boolean equals(Object obj) {
3829
          if (obj == null)  return false;
3830
          if (!(obj instanceof RegularExpression))
3831
              return false;
3832
          RegularExpression r = (RegularExpression)obj;
3833
          return this.regex.equals(r.regex) && this.options == r.options;
3834
      }
3835
3836
      boolean equals(String pattern, int options) {
3837
          return this.regex.equals(pattern) && this.options == options;
3838
      }
3839
3840
      /**
3841
       *
3842
       */
3843
      public int hashCode() {
3844
          return (this.regex+"/"+this.getOptions()).hashCode();
3845
      }
3846
3847
      /**
3848
       * Return the number of regular expression groups.
3849
       * This method returns 1 when the regular expression has no capturing-parenthesis.
3850
       *
3851
       */
3852
      public int getNumberOfGroups() {
3853
          return this.nofparen;
3854
      }
3855
3856
      // ================================================================
3857
3858
      private static final int WT_IGNORE = 0;
3859
      private static final int WT_LETTER = 1;
3860
      private static final int WT_OTHER = 2;
3861
      private static final int getWordType0(char ch, int opts) {
3862
          if (!isSet(opts, UNICODE_WORD_BOUNDARY)) {
3863
              if (isSet(opts, USE_UNICODE_CATEGORY)) {
3864
                  return (Token.getRange("IsWord", true).match(ch)) ? WT_LETTER : WT_OTHER;
3865
              }
3866
              return isWordChar(ch) ? WT_LETTER : WT_OTHER;
3867
          }
3868
3869
          switch (Character.getType(ch)) {
3870
          case Character.UPPERCASE_LETTER:      // L
3871
          case Character.LOWERCASE_LETTER:      // L
3872
          case Character.TITLECASE_LETTER:      // L
3873
          case Character.MODIFIER_LETTER:       // L
3874
          case Character.OTHER_LETTER:          // L
3875
          case Character.LETTER_NUMBER:         // N
3876
          case Character.DECIMAL_DIGIT_NUMBER:  // N
3877
          case Character.OTHER_NUMBER:          // N
3878
          case Character.COMBINING_SPACING_MARK: // Mc
3879
              return WT_LETTER;
3880
3881
          case Character.FORMAT:                // Cf
3882
          case Character.NON_SPACING_MARK:      // Mn
3883
          case Character.ENCLOSING_MARK:        // Mc
3884
              return WT_IGNORE;
3885
3886
          case Character.CONTROL:               // Cc
3887
              switch (ch) {
3888
              case '\t':
3889
              case '\n':
3890
              case '\u000B':
3891
              case '\f':
3892
              case '\r':
3893
                  return WT_OTHER;
3894
              default:
3895
                  return WT_IGNORE;
3896
              }
3897
3898
          default:
3899
              return WT_OTHER;
3900
          }
3901
      }
3902
3903
      // ================================================================
3904
3905
      static final int LINE_FEED = 0x000A;
3906
      static final int CARRIAGE_RETURN = 0x000D;
3907
      static final int LINE_SEPARATOR = 0x2028;
3908
      static final int PARAGRAPH_SEPARATOR = 0x2029;
3909
3910
      private static final boolean isEOLChar(int ch) {
3911
          return ch == LINE_FEED || ch == CARRIAGE_RETURN || ch == LINE_SEPARATOR
3912
          || ch == PARAGRAPH_SEPARATOR;
3913
      }
3914
3915
      private static final boolean isWordChar(int ch) { // Legacy word characters
3916
          if (ch == '_')  return true;
3917
          if (ch < '0')  return false;
3918
          if (ch > 'z')  return false;
3919
          if (ch <= '9')  return true;
3920
          if (ch < 'A')  return false;
3921
          if (ch <= 'Z')  return true;
3922
          if (ch < 'a')  return false;
3923
          return true;
3924
      }
3925
3926
      private static final boolean matchIgnoreCase(int chardata, int ch) {
3927
          if (chardata == ch)  return true;
3928
          if (chardata > 0xffff || ch > 0xffff)  return false;
3929
          char uch1 = Character.toUpperCase((char)chardata);
3930
          char uch2 = Character.toUpperCase((char)ch);
3931
          if (uch1 == uch2)  return true;
3932
          return Character.toLowerCase(uch1) == Character.toLowerCase(uch2);
3933
      }
3934
  }
3935
  
3936
  public static class ParseException extends RuntimeException {
3937
    int location;
3938
3939
    /*
3940
    public ParseException(String mes) {
3941
        this(mes, -1);
3942
    }
3943
    */
3944
    /**
3945
     *
3946
     */
3947
    public ParseException(String mes, int location) {
3948
        super(mes);
3949
        this.location = location;
3950
    }
3951
3952
    /**
3953
     *
3954
     * @return -1 if location information is not available.
3955
     */
3956
    public int getLocation() {
3957
        return this.location;
3958
    }
3959
}
3960
3961
  static class Op {
3962
    static final int DOT = 0;
3963
    static final int CHAR = 1;                  // Single character
3964
    static final int RANGE = 3;                 // [a-zA-Z]
3965
    static final int NRANGE = 4;                // [^a-zA-Z]
3966
    static final int ANCHOR = 5;                // ^ $ ...
3967
    static final int STRING = 6;                // literal String 
3968
    static final int CLOSURE = 7;               // X*
3969
    static final int NONGREEDYCLOSURE = 8;      // X*?
3970
    static final int QUESTION = 9;              // X?
3971
    static final int NONGREEDYQUESTION = 10;    // X??
3972
    static final int UNION = 11;                // X|Y
3973
    static final int CAPTURE = 15;              // ( and )
3974
    static final int BACKREFERENCE = 16;        // \1 \2 ...
3975
    static final int LOOKAHEAD = 20;            // (?=...)
3976
    static final int NEGATIVELOOKAHEAD = 21;    // (?!...)
3977
    static final int LOOKBEHIND = 22;           // (?<=...)
3978
    static final int NEGATIVELOOKBEHIND = 23;   // (?<!...)
3979
    static final int INDEPENDENT = 24;          // (?>...)
3980
    static final int MODIFIER = 25;             // (?ims-ims:...)
3981
    static final int CONDITION = 26;            // (?(..)yes|no)
3982
3983
    static int nofinstances = 0;
3984
    static final boolean COUNT = false;
3985
3986
    static Op createDot() {
3987
        if (Op.COUNT)  Op.nofinstances ++;
3988
        return new Op(Op.DOT);
3989
    }
3990
    static CharOp createChar(int data) {
3991
        if (Op.COUNT)  Op.nofinstances ++;
3992
        return new CharOp(Op.CHAR, data);
3993
    }
3994
    static CharOp createAnchor(int data) {
3995
        if (Op.COUNT)  Op.nofinstances ++;
3996
        return new CharOp(Op.ANCHOR, data);
3997
    }
3998
    static CharOp createCapture(int number, Op next) {
3999
        if (Op.COUNT)  Op.nofinstances ++;
4000
        CharOp op = new CharOp(Op.CAPTURE, number);
4001
        op.next = next;
4002
        return op;
4003
    }
4004
    static UnionOp createUnion(int size) {
4005
        if (Op.COUNT)  Op.nofinstances ++;
4006
        //System.err.println("Creates UnionOp");
4007
        return new UnionOp(Op.UNION, size);
4008
    }
4009
    static ChildOp createClosure(int id) {
4010
        if (Op.COUNT)  Op.nofinstances ++;
4011
        return new ModifierOp(Op.CLOSURE, id, -1);
4012
    }
4013
    static ChildOp createNonGreedyClosure() {
4014
        if (Op.COUNT)  Op.nofinstances ++;
4015
        return new ChildOp(Op.NONGREEDYCLOSURE);
4016
    }
4017
    static ChildOp createQuestion(boolean nongreedy) {
4018
        if (Op.COUNT)  Op.nofinstances ++;
4019
        return new ChildOp(nongreedy ? Op.NONGREEDYQUESTION : Op.QUESTION);
4020
    }
4021
    static RangeOp createRange(Token tok) {
4022
        if (Op.COUNT)  Op.nofinstances ++;
4023
        return new RangeOp(Op.RANGE, tok);
4024
    }
4025
    static ChildOp createLook(int type, Op next, Op branch) {
4026
        if (Op.COUNT)  Op.nofinstances ++;
4027
        ChildOp op = new ChildOp(type);
4028
        op.setChild(branch);
4029
        op.next = next;
4030
        return op;
4031
    }
4032
    static CharOp createBackReference(int refno) {
4033
        if (Op.COUNT)  Op.nofinstances ++;
4034
        return new CharOp(Op.BACKREFERENCE, refno);
4035
    }
4036
    static StringOp createString(String literal) {
4037
        if (Op.COUNT)  Op.nofinstances ++;
4038
        return new StringOp(Op.STRING, literal);
4039
    }
4040
    static ChildOp createIndependent(Op next, Op branch) {
4041
        if (Op.COUNT)  Op.nofinstances ++;
4042
        ChildOp op = new ChildOp(Op.INDEPENDENT);
4043
        op.setChild(branch);
4044
        op.next = next;
4045
        return op;
4046
    }
4047
    static ModifierOp createModifier(Op next, Op branch, int add, int mask) {
4048
        if (Op.COUNT)  Op.nofinstances ++;
4049
        ModifierOp op = new ModifierOp(Op.MODIFIER, add, mask);
4050
        op.setChild(branch);
4051
        op.next = next;
4052
        return op;
4053
    }
4054
    static ConditionOp createCondition(Op next, int ref, Op conditionflow, Op yesflow, Op noflow) {
4055
        if (Op.COUNT)  Op.nofinstances ++;
4056
        ConditionOp op = new ConditionOp(Op.CONDITION, ref, conditionflow, yesflow, noflow);
4057
        op.next = next;
4058
        return op;
4059
    }
4060
4061
    int type;
4062
    Op next = null;
4063
4064
    protected Op(int type) {
4065
        this.type = type;
4066
    }
4067
4068
    int size() {                                // for UNION
4069
        return 0;
4070
    }
4071
    Op elementAt(int index) {                   // for UNIoN
4072
        throw new RuntimeException("Internal Error: type="+this.type);
4073
    }
4074
    Op getChild() {                             // for CLOSURE, QUESTION
4075
        throw new RuntimeException("Internal Error: type="+this.type);
4076
    }
4077
                                                // ModifierOp
4078
    int getData() {                             // CharOp  for CHAR, BACKREFERENCE, CAPTURE, ANCHOR, 
4079
        throw new RuntimeException("Internal Error: type="+this.type);
4080
    }
4081
    int getData2() {                            // ModifierOp
4082
        throw new RuntimeException("Internal Error: type="+this.type);
4083
    }
4084
    RangeToken getToken() {                     // RANGE, NRANGE
4085
        throw new RuntimeException("Internal Error: type="+this.type);
4086
    }
4087
    String getString() {                        // STRING
4088
        throw new RuntimeException("Internal Error: type="+this.type);
4089
    }
4090
4091
    // ================================================================
4092
    static class CharOp extends Op {
4093
        int charData;
4094
        CharOp(int type, int data) {
4095
            super(type);
4096
            this.charData = data;
4097
        }
4098
        int getData() {
4099
            return this.charData;
4100
        }
4101
    }
4102
4103
    // ================================================================
4104
    static class UnionOp extends Op {
4105
        Vector branches;
4106
        UnionOp(int type, int size) {
4107
            super(type);
4108
            this.branches = new Vector(size);
4109
        }
4110
        void addElement(Op op) {
4111
            this.branches.addElement(op);
4112
        }
4113
        int size() {
4114
            return this.branches.size();
4115
        }
4116
        Op elementAt(int index) {
4117
            return (Op)this.branches.elementAt(index);
4118
        }
4119
    }
4120
4121
    // ================================================================
4122
    static class ChildOp extends Op {
4123
        Op child;
4124
        ChildOp(int type) {
4125
            super(type);
4126
        }
4127
        void setChild(Op child) {
4128
            this.child = child;
4129
        }
4130
        Op getChild() {
4131
            return this.child;
4132
        }
4133
    }
4134
    // ================================================================
4135
    static class ModifierOp extends ChildOp {
4136
        int v1;
4137
        int v2;
4138
        ModifierOp(int type, int v1, int v2) {
4139
            super(type);
4140
            this.v1 = v1;
4141
            this.v2 = v2;
4142
        }
4143
        int getData() {
4144
            return this.v1;
4145
        }
4146
        int getData2() {
4147
            return this.v2;
4148
        }
4149
    }
4150
    // ================================================================
4151
    static class RangeOp extends Op {
4152
        Token tok;
4153
        RangeOp(int type, Token tok) {
4154
            super(type);
4155
            this.tok = tok;
4156
        }
4157
        RangeToken getToken() {
4158
            return (RangeToken)this.tok;
4159
        }
4160
    }
4161
    // ================================================================
4162
    static class StringOp extends Op {
4163
        String string;
4164
        StringOp(int type, String literal) {
4165
            super(type);
4166
            this.string = literal;
4167
        }
4168
        String getString() {
4169
            return this.string;
4170
        }
4171
    }
4172
    // ================================================================
4173
    static class ConditionOp extends Op {
4174
        int refNumber;
4175
        Op condition;
4176
        Op yes;
4177
        Op no;
4178
        ConditionOp(int type, int refno, Op conditionflow, Op yesflow, Op noflow) {
4179
            super(type);
4180
            this.refNumber = refno;
4181
            this.condition = conditionflow;
4182
            this.yes = yesflow;
4183
            this.no = noflow;
4184
        }
4185
    }
4186
}
4187
4188
  final static class RangeToken extends Token implements java.io.Serializable {
4189
4190
    int[] ranges;
4191
    boolean sorted;
4192
    boolean compacted;
4193
    RangeToken icaseCache = null;
4194
    int[] map = null;
4195
    int nonMapIndex;
4196
4197
    RangeToken(int type) {
4198
        super(type);
4199
        this.setSorted(false);
4200
    }
4201
4202
                                                // for RANGE or NRANGE
4203
    protected void addRange(int start, int end) {
4204
        this.icaseCache = null;
4205
        //System.err.println("Token#addRange(): "+start+" "+end);
4206
        int r1, r2;
4207
        if (start <= end) {
4208
            r1 = start;
4209
            r2 = end;
4210
        } else {
4211
            r1 = end;
4212
            r2 = start;
4213
        }
4214
4215
        int pos = 0;
4216
        if (this.ranges == null) {
4217
            this.ranges = new int[2];
4218
            this.ranges[0] = r1;
4219
            this.ranges[1] = r2;
4220
            this.setSorted(true);
4221
        } else {
4222
            pos = this.ranges.length;
4223
            if (this.ranges[pos-1]+1 == r1) {
4224
                this.ranges[pos-1] = r2;
4225
                return;
4226
            }
4227
            int[] temp = new int[pos+2];
4228
            System.arraycopy(this.ranges, 0, temp, 0, pos);
4229
            this.ranges = temp;
4230
            if (this.ranges[pos-1] >= r1)
4231
                this.setSorted(false);
4232
            this.ranges[pos++] = r1;
4233
            this.ranges[pos] = r2;
4234
            if (!this.sorted)
4235
                this.sortRanges();
4236
        }
4237
    }
4238
4239
    private final boolean isSorted() {
4240
        return this.sorted;
4241
    }
4242
    private final void setSorted(boolean sort) {
4243
        this.sorted = sort;
4244
        if (!sort)  this.compacted = false;
4245
    }
4246
    private final boolean isCompacted() {
4247
        return this.compacted;
4248
    }
4249
    private final void setCompacted() {
4250
        this.compacted = true;
4251
    }
4252
4253
    protected void sortRanges() {
4254
        if (this.isSorted())
4255
            return;
4256
        if (this.ranges == null)
4257
            return;
4258
        //System.err.println("Do sorting: "+this.ranges.length);
4259
4260
                                                // Bubble sort
4261
                                                // Why? -- In many cases,
4262
                                                //         this.ranges has few elements.
4263
        for (int i = this.ranges.length-4;  i >= 0;  i -= 2) {
4264
            for (int j = 0;  j <= i;  j += 2) {
4265
                if (this.ranges[j] > this.ranges[j+2]
4266
                    || this.ranges[j] == this.ranges[j+2] && this.ranges[j+1] > this.ranges[j+3]) {
4267
                    int tmp;
4268
                    tmp = this.ranges[j+2];
4269
                    this.ranges[j+2] = this.ranges[j];
4270
                    this.ranges[j] = tmp;
4271
                    tmp = this.ranges[j+3];
4272
                    this.ranges[j+3] = this.ranges[j+1];
4273
                    this.ranges[j+1] = tmp;
4274
                }
4275
            }
4276
        }
4277
        this.setSorted(true);
4278
    }
4279
4280
    /**
4281
     * this.ranges is sorted.
4282
     */
4283
    protected void compactRanges() {
4284
        boolean DEBUG = false;
4285
        if (this.ranges == null || this.ranges.length <= 2)
4286
            return;
4287
        if (this.isCompacted())
4288
            return;
4289
        int base = 0;                           // Index of writing point
4290
        int target = 0;                         // Index of processing point
4291
4292
        while (target < this.ranges.length) {
4293
            if (base != target) {
4294
                this.ranges[base] = this.ranges[target++];
4295
                this.ranges[base+1] = this.ranges[target++];
4296
            } else
4297
                target += 2;
4298
            int baseend = this.ranges[base+1];
4299
            while (target < this.ranges.length) {
4300
                if (baseend+1 < this.ranges[target])
4301
                    break;
4302
                if (baseend+1 == this.ranges[target]) {
4303
                    if (DEBUG)
4304
                        System.err.println("Token#compactRanges(): Compaction: ["+this.ranges[base]
4305
                                           +", "+this.ranges[base+1]
4306
                                           +"], ["+this.ranges[target]
4307
                                           +", "+this.ranges[target+1]
4308
                                           +"] -> ["+this.ranges[base]
4309
                                           +", "+this.ranges[target+1]
4310
                                           +"]");
4311
                    this.ranges[base+1] = this.ranges[target+1];
4312
                    baseend = this.ranges[base+1];
4313
                    target += 2;
4314
                } else if (baseend >= this.ranges[target+1]) {
4315
                    if (DEBUG)
4316
                        System.err.println("Token#compactRanges(): Compaction: ["+this.ranges[base]
4317
                                           +", "+this.ranges[base+1]
4318
                                           +"], ["+this.ranges[target]
4319
                                           +", "+this.ranges[target+1]
4320
                                           +"] -> ["+this.ranges[base]
4321
                                           +", "+this.ranges[base+1]
4322
                                           +"]");
4323
                    target += 2;
4324
                } else if (baseend < this.ranges[target+1]) {
4325
                    if (DEBUG)
4326
                        System.err.println("Token#compactRanges(): Compaction: ["+this.ranges[base]
4327
                                           +", "+this.ranges[base+1]
4328
                                           +"], ["+this.ranges[target]
4329
                                           +", "+this.ranges[target+1]
4330
                                           +"] -> ["+this.ranges[base]
4331
                                           +", "+this.ranges[target+1]
4332
                                           +"]");
4333
                    this.ranges[base+1] = this.ranges[target+1];
4334
                    baseend = this.ranges[base+1];
4335
                    target += 2;
4336
                } else {
4337
                    throw new RuntimeException("Token#compactRanges(): Internel Error: ["
4338
                                               +this.ranges[base]
4339
                                               +","+this.ranges[base+1]
4340
                                               +"] ["+this.ranges[target]
4341
                                               +","+this.ranges[target+1]+"]");
4342
                }
4343
            } // while
4344
            base += 2;
4345
        }
4346
4347
        if (base != this.ranges.length) {
4348
            int[] result = new int[base];
4349
            System.arraycopy(this.ranges, 0, result, 0, base);
4350
            this.ranges = result;
4351
        }
4352
        this.setCompacted();
4353
    }
4354
4355
    protected void mergeRanges(Token token) {
4356
        RangeToken tok = (RangeToken)token;
4357
        this.sortRanges();
4358
        tok.sortRanges();
4359
        if (tok.ranges == null)
4360
            return;
4361
        this.icaseCache = null;
4362
        this.setSorted(true);
4363
        if (this.ranges == null) {
4364
            this.ranges = new int[tok.ranges.length];
4365
            System.arraycopy(tok.ranges, 0, this.ranges, 0, tok.ranges.length);
4366
            return;
4367
        }
4368
        int[] result = new int[this.ranges.length+tok.ranges.length];
4369
        for (int i = 0, j = 0, k = 0;  i < this.ranges.length || j < tok.ranges.length;) {
4370
            if (i >= this.ranges.length) {
4371
                result[k++] = tok.ranges[j++];
4372
                result[k++] = tok.ranges[j++];
4373
            } else if (j >= tok.ranges.length) {
4374
                result[k++] = this.ranges[i++];
4375
                result[k++] = this.ranges[i++];
4376
            } else if (tok.ranges[j] < this.ranges[i]
4377
                       || tok.ranges[j] == this.ranges[i] && tok.ranges[j+1] < this.ranges[i+1]) {
4378
                result[k++] = tok.ranges[j++];
4379
                result[k++] = tok.ranges[j++];
4380
            } else {
4381
                result[k++] = this.ranges[i++];
4382
                result[k++] = this.ranges[i++];
4383
            }
4384
        }
4385
        this.ranges = result;
4386
    }
4387
4388
    protected void subtractRanges(Token token) {
4389
        if (token.type == NRANGE) {
4390
            this.intersectRanges(token);
4391
            return;
4392
        }
4393
        RangeToken tok = (RangeToken)token;
4394
        if (tok.ranges == null || this.ranges == null)
4395
            return;
4396
        this.icaseCache = null;
4397
        this.sortRanges();
4398
        this.compactRanges();
4399
        tok.sortRanges();
4400
        tok.compactRanges();
4401
4402
        //System.err.println("Token#substractRanges(): Entry: "+this.ranges.length+", "+tok.ranges.length);
4403
4404
        int[] result = new int[this.ranges.length+tok.ranges.length];
4405
        int wp = 0, src = 0, sub = 0;
4406
        while (src < this.ranges.length && sub < tok.ranges.length) {
4407
            int srcbegin = this.ranges[src];
4408
            int srcend = this.ranges[src+1];
4409
            int subbegin = tok.ranges[sub];
4410
            int subend = tok.ranges[sub+1];
4411
            if (srcend < subbegin) {            // Not overlapped
4412
                                                // src: o-----o
4413
                                                // sub:         o-----o
4414
                                                // res: o-----o
4415
                                                // Reuse sub
4416
                result[wp++] = this.ranges[src++];
4417
                result[wp++] = this.ranges[src++];
4418
            } else if (srcend >= subbegin
4419
                       && srcbegin <= subend) { // Overlapped
4420
                                                // src:    o--------o
4421
                                                // sub:  o----o
4422
                                                // sub:      o----o
4423
                                                // sub:          o----o
4424
                                                // sub:  o------------o
4425
                if (subbegin <= srcbegin && srcend <= subend) {
4426
                                                // src:    o--------o
4427
                                                // sub:  o------------o
4428
                                                // res: empty
4429
                                                // Reuse sub
4430
                    src += 2;
4431
                } else if (subbegin <= srcbegin) {
4432
                                                // src:    o--------o
4433
                                                // sub:  o----o
4434
                                                // res:       o-----o
4435
                                                // Reuse src(=res)
4436
                    this.ranges[src] = subend+1;
4437
                    sub += 2;
4438
                } else if (srcend <= subend) {
4439
                                                // src:    o--------o
4440
                                                // sub:          o----o
4441
                                                // res:    o-----o
4442
                                                // Reuse sub
4443
                    result[wp++] = srcbegin;
4444
                    result[wp++] = subbegin-1;
4445
                    src += 2;
4446
                } else {
4447
                                                // src:    o--------o
4448
                                                // sub:      o----o
4449
                                                // res:    o-o    o-o
4450
                                                // Reuse src(=right res)
4451
                    result[wp++] = srcbegin;
4452
                    result[wp++] = subbegin-1;
4453
                    this.ranges[src] = subend+1;
4454
                    sub += 2;
4455
                }
4456
            } else if (subend < srcbegin) {
4457
                                                // Not overlapped
4458
                                                // src:          o-----o
4459
                                                // sub: o----o
4460
                sub += 2;
4461
            } else {
4462
                throw new RuntimeException("Token#subtractRanges(): Internal Error: ["+this.ranges[src]
4463
                                           +","+this.ranges[src+1]
4464
                                           +"] - ["+tok.ranges[sub]
4465
                                           +","+tok.ranges[sub+1]
4466
                                           +"]");
4467
            }
4468
        }
4469
        while (src < this.ranges.length) {
4470
            result[wp++] = this.ranges[src++];
4471
            result[wp++] = this.ranges[src++];
4472
        }
4473
        this.ranges = new int[wp];
4474
        System.arraycopy(result, 0, this.ranges, 0, wp);
4475
                                                // this.ranges is sorted and compacted.
4476
    }
4477
4478
    /**
4479
     * @param tok Ignore whether it is NRANGE or not.
4480
     */
4481
    protected void intersectRanges(Token token) {
4482
        RangeToken tok = (RangeToken)token;
4483
        if (tok.ranges == null || this.ranges == null)
4484
            return;
4485
        this.icaseCache = null;
4486
        this.sortRanges();
4487
        this.compactRanges();
4488
        tok.sortRanges();
4489
        tok.compactRanges();
4490
4491
        int[] result = new int[this.ranges.length+tok.ranges.length];
4492
        int wp = 0, src1 = 0, src2 = 0;
4493
        while (src1 < this.ranges.length && src2 < tok.ranges.length) {
4494
            int src1begin = this.ranges[src1];
4495
            int src1end = this.ranges[src1+1];
4496
            int src2begin = tok.ranges[src2];
4497
            int src2end = tok.ranges[src2+1];
4498
            if (src1end < src2begin) {          // Not overlapped
4499
                                                // src1: o-----o
4500
                                                // src2:         o-----o
4501
                                                // res:  empty
4502
                                                // Reuse src2
4503
                src1 += 2;
4504
            } else if (src1end >= src2begin
4505
                       && src1begin <= src2end) { // Overlapped
4506
                                                // src1:    o--------o
4507
                                                // src2:  o----o
4508
                                                // src2:      o----o
4509
                                                // src2:          o----o
4510
                                                // src2:  o------------o
4511
                if (src2begin <= src2begin && src1end <= src2end) {
4512
                                                // src1:    o--------o
4513
                                                // src2:  o------------o
4514
                                                // res:     o--------o
4515
                                                // Reuse src2
4516
                    result[wp++] = src1begin;
4517
                    result[wp++] = src1end;
4518
                    src1 += 2;
4519
                } else if (src2begin <= src1begin) {
4520
                                                // src1:    o--------o
4521
                                                // src2:  o----o
4522
                                                // res:     o--o
4523
                                                // Reuse the rest of src1
4524
                    result[wp++] = src1begin;
4525
                    result[wp++] = src2end;
4526
                    this.ranges[src1] = src2end+1;
4527
                    src2 += 2;
4528
                } else if (src1end <= src2end) {
4529
                                                // src1:    o--------o
4530
                                                // src2:          o----o
4531
                                                // res:           o--o
4532
                                                // Reuse src2
4533
                    result[wp++] = src2begin;
4534
                    result[wp++] = src1end;
4535
                    src1 += 2;
4536
                } else {
4537
                                                // src1:    o--------o
4538
                                                // src2:      o----o
4539
                                                // res:       o----o
4540
                                                // Reuse the rest of src1
4541
                    result[wp++] = src2begin;
4542
                    result[wp++] = src2end;
4543
                    this.ranges[src1] = src2end+1;
4544
                }
4545
            } else if (src2end < src1begin) {
4546
                                                // Not overlapped
4547
                                                // src1:          o-----o
4548
                                                // src2: o----o
4549
                src2 += 2;
4550
            } else {
4551
                throw new RuntimeException("Token#intersectRanges(): Internal Error: ["
4552
                                           +this.ranges[src1]
4553
                                           +","+this.ranges[src1+1]
4554
                                           +"] & ["+tok.ranges[src2]
4555
                                           +","+tok.ranges[src2+1]
4556
                                           +"]");
4557
            }
4558
        }
4559
        while (src1 < this.ranges.length) {
4560
            result[wp++] = this.ranges[src1++];
4561
            result[wp++] = this.ranges[src1++];
4562
        }
4563
        this.ranges = new int[wp];
4564
        System.arraycopy(result, 0, this.ranges, 0, wp);
4565
                                                // this.ranges is sorted and compacted.
4566
    }
4567
4568
    /**
4569
     * for RANGE: Creates complement.
4570
     * for NRANGE: Creates the same meaning RANGE.
4571
     */
4572
    static Token complementRanges(Token token) {
4573
        if (token.type != RANGE && token.type != NRANGE)
4574
            throw new IllegalArgumentException("Token#complementRanges(): must be RANGE: "+token.type);
4575
        RangeToken tok = (RangeToken)token;
4576
        tok.sortRanges();
4577
        tok.compactRanges();
4578
        int len = tok.ranges.length+2;
4579
        if (tok.ranges[0] == 0)
4580
            len -= 2;
4581
        int last = tok.ranges[tok.ranges.length-1];
4582
        if (last == UTF16_MAX)
4583
            len -= 2;
4584
        RangeToken ret = Token.createRange();
4585
        ret.ranges = new int[len];
4586
        int wp = 0;
4587
        if (tok.ranges[0] > 0) {
4588
            ret.ranges[wp++] = 0;
4589
            ret.ranges[wp++] = tok.ranges[0]-1;
4590
        }
4591
        for (int i = 1;  i < tok.ranges.length-2;  i += 2) {
4592
            ret.ranges[wp++] = tok.ranges[i]+1;
4593
            ret.ranges[wp++] = tok.ranges[i+1]-1;
4594
        }
4595
        if (last != UTF16_MAX) {
4596
            ret.ranges[wp++] = last+1;
4597
            ret.ranges[wp] = UTF16_MAX;
4598
        }
4599
        ret.setCompacted();
4600
        return ret;
4601
    }
4602
4603
    synchronized RangeToken getCaseInsensitiveToken() {
4604
        if (this.icaseCache != null)
4605
            return this.icaseCache;
4606
            
4607
        RangeToken uppers = this.type == Token.RANGE ? Token.createRange() : Token.createNRange();
4608
        for (int i = 0;  i < this.ranges.length;  i += 2) {
4609
            for (int ch = this.ranges[i];  ch <= this.ranges[i+1];  ch ++) {
4610
                if (ch > 0xffff)
4611
                    uppers.addRange(ch, ch);
4612
                else {
4613
                    char uch = Character.toUpperCase((char)ch);
4614
                    uppers.addRange(uch, uch);
4615
                }
4616
            }
4617
        }
4618
        RangeToken lowers = this.type == Token.RANGE ? Token.createRange() : Token.createNRange();
4619
        for (int i = 0;  i < uppers.ranges.length;  i += 2) {
4620
            for (int ch = uppers.ranges[i];  ch <= uppers.ranges[i+1];  ch ++) {
4621
                if (ch > 0xffff)
4622
                    lowers.addRange(ch, ch);
4623
                else {
4624
                    char uch = Character.toUpperCase((char)ch);
4625
                    lowers.addRange(uch, uch);
4626
                }
4627
            }
4628
        }
4629
        lowers.mergeRanges(uppers);
4630
        lowers.mergeRanges(this);
4631
        lowers.compactRanges();
4632
4633
        this.icaseCache = lowers;
4634
        return lowers;
4635
    }
4636
4637
    void dumpRanges() {
4638
        System.err.print("RANGE: ");
4639
        if (this.ranges == null)
4640
            System.err.println(" NULL");
4641
        for (int i = 0;  i < this.ranges.length;  i += 2) {
4642
            System.err.print("["+this.ranges[i]+","+this.ranges[i+1]+"] ");
4643
        }
4644
        System.err.println("");
4645
    }
4646
4647
    boolean match(int ch) {
4648
        if (this.map == null)  this.createMap();
4649
        boolean ret;
4650
        if (this.type == RANGE) {
4651
            if (ch < MAPSIZE)
4652
                return (this.map[ch/32] & (1<<(ch&0x1f))) != 0;
4653
            ret = false;
4654
            for (int i = this.nonMapIndex;  i < this.ranges.length;  i += 2) {
4655
                if (this.ranges[i] <= ch && ch <= this.ranges[i+1])
4656
                    return true;
4657
            }
4658
        } else {
4659
            if (ch < MAPSIZE)
4660
                return (this.map[ch/32] & (1<<(ch&0x1f))) == 0;
4661
            ret = true;
4662
            for (int i = this.nonMapIndex;  i < this.ranges.length;  i += 2) {
4663
                if (this.ranges[i] <= ch && ch <= this.ranges[i+1])
4664
                    return false;
4665
            }
4666
        }
4667
        return ret;
4668
    }
4669
4670
    private static final int MAPSIZE = 256;
4671
    private void createMap() {
4672
        int asize = MAPSIZE/32;                 // 32 is the number of bits in `int'.
4673
        this.map = new int[asize];
4674
        this.nonMapIndex = this.ranges.length;
4675
        for (int i = 0;  i < asize;  i ++)  this.map[i] = 0;
4676
        for (int i = 0;  i < this.ranges.length;  i += 2) {
4677
            int s = this.ranges[i];
4678
            int e = this.ranges[i+1];
4679
            if (s < MAPSIZE) {
4680
                for (int j = s;  j <= e && j < MAPSIZE;  j ++)
4681
                    this.map[j/32] |= 1<<(j&0x1f); // s&0x1f : 0-31
4682
            } else {
4683
                this.nonMapIndex = i;
4684
                break;
4685
            }
4686
            if (e >= MAPSIZE) {
4687
                this.nonMapIndex = i;
4688
                break;
4689
            }
4690
        }
4691
        //for (int i = 0;  i < asize;  i ++)  System.err.println("Map: "+Integer.toString(this.map[i], 16));
4692
    }
4693
4694
    public String toString(int options) {
4695
        String ret;
4696
        if (this.type == RANGE) {
4697
            if (this == Token.token_dot)
4698
                ret = ".";
4699
            else if (this == Token.token_0to9)
4700
                ret = "\\d";
4701
            else if (this == Token.token_wordchars)
4702
                ret = "\\w";
4703
            else if (this == Token.token_spaces)
4704
                ret = "\\s";
4705
            else {
4706
                StringBuffer sb = new StringBuffer();
4707
                sb.append("[");
4708
                for (int i = 0;  i < this.ranges.length;  i += 2) {
4709
                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(",");
4710
                    if (this.ranges[i] == this.ranges[i+1]) {
4711
                        sb.append(escapeCharInCharClass(this.ranges[i]));
4712
                    } else {
4713
                        sb.append(escapeCharInCharClass(this.ranges[i]));
4714
                        sb.append('-');
4715
                        sb.append(escapeCharInCharClass(this.ranges[i+1]));
4716
                    }
4717
                }
4718
                sb.append("]");
4719
                ret = sb.toString();
4720
            }
4721
        } else {
4722
            if (this == Token.token_not_0to9)
4723
                ret = "\\D";
4724
            else if (this == Token.token_not_wordchars)
4725
                ret = "\\W";
4726
            else if (this == Token.token_not_spaces)
4727
                ret = "\\S";
4728
            else {
4729
                StringBuffer sb = new StringBuffer();
4730
                sb.append("[^");
4731
                for (int i = 0;  i < this.ranges.length;  i += 2) {
4732
                    if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0)  sb.append(",");
4733
                    if (this.ranges[i] == this.ranges[i+1]) {
4734
                        sb.append(escapeCharInCharClass(this.ranges[i]));
4735
                    } else {
4736
                        sb.append(escapeCharInCharClass(this.ranges[i]));
4737
                        sb.append('-');
4738
                        sb.append(escapeCharInCharClass(this.ranges[i+1]));
4739
                    }
4740
                }
4741
                sb.append("]");
4742
                ret = sb.toString();
4743
            }
4744
        }
4745
        return ret;
4746
    }
4747
4748
    private static String escapeCharInCharClass(int ch) {
4749
        String ret;
4750
        switch (ch) {
4751
          case '[':  case ']':  case '-':  case '^':
4752
          case ',':  case '\\':
4753
            ret = "\\"+(char)ch;
4754
            break;
4755
          case '\f':  ret = "\\f";  break;
4756
          case '\n':  ret = "\\n";  break;
4757
          case '\r':  ret = "\\r";  break;
4758
          case '\t':  ret = "\\t";  break;
4759
          case 0x1b:  ret = "\\e";  break;
4760
          //case 0x0b:  ret = "\\v";  break;
4761
          default:
4762
            if (ch < 0x20) {
4763
                String pre = "0"+Integer.toHexString(ch);
4764
                ret = "\\x"+pre.substring(pre.length()-2, pre.length());
4765
            } else if (ch >= 0x10000) {
4766
                String pre = "0"+Integer.toHexString(ch);
4767
                ret = "\\v"+pre.substring(pre.length()-6, pre.length());
4768
            } else
4769
                ret = ""+(char)ch;
4770
        }
4771
        return ret;
4772
    }
4773
4774
}
4775
4776
  static class RegexParser {
4777
      static final int T_CHAR = 0;
4778
      static final int T_EOF = 1;
4779
      static final int T_OR = 2;                  // '|'
4780
      static final int T_STAR = 3;                // '*'
4781
      static final int T_PLUS = 4;                // '+'
4782
      static final int T_QUESTION = 5;            // '?'
4783
      static final int T_LPAREN = 6;              // '('
4784
      static final int T_RPAREN = 7;              // ')'
4785
      static final int T_DOT = 8;                 // '.'
4786
      static final int T_LBRACKET = 9;            // '['
4787
      static final int T_BACKSOLIDUS = 10;        // '\'
4788
      static final int T_CARET = 11;              // '^'
4789
      static final int T_DOLLAR = 12;             // '$'
4790
      static final int T_LPAREN2 = 13;            // '(?:'
4791
      static final int T_LOOKAHEAD = 14;          // '(?='
4792
      static final int T_NEGATIVELOOKAHEAD = 15;  // '(?!'
4793
      static final int T_LOOKBEHIND = 16;         // '(?<='
4794
      static final int T_NEGATIVELOOKBEHIND = 17; // '(?<!'
4795
      static final int T_INDEPENDENT = 18;        // '(?>'
4796
      static final int T_SET_OPERATIONS = 19;     // '(?['
4797
      static final int T_POSIX_CHARCLASS_START = 20; // '[:' in a character class
4798
      static final int T_COMMENT = 21;            // '(?#'
4799
      static final int T_MODIFIERS = 22;          // '(?' [\-,a-z,A-Z]
4800
      static final int T_CONDITION = 23;          // '(?('
4801
      static final int T_XMLSCHEMA_CC_SUBTRACTION = 24; // '-[' in a character class
4802
4803
      static class ReferencePosition {
4804
          int refNumber;
4805
          int position;
4806
          ReferencePosition(int n, int pos) {
4807
              this.refNumber = n;
4808
              this.position = pos;
4809
          }
4810
      }
4811
4812
      int offset;
4813
      String regex;
4814
      int regexlen;
4815
      int options;
4816
      ResourceBundle resources;
4817
      int chardata;
4818
      int nexttoken;
4819
      static protected final int S_NORMAL = 0;
4820
      static protected final int S_INBRACKETS = 1;
4821
      static protected final int S_INXBRACKETS = 2;
4822
      int context = S_NORMAL;
4823
      int parennumber = 1;
4824
      boolean hasBackReferences;
4825
      Vector references = null;
4826
4827
      public RegexParser() {
4828
          //this.setLocale(Locale.getDefault());
4829
      }
4830
      public RegexParser(Locale locale) {
4831
          //this.setLocale(locale);
4832
      }
4833
4834
      public void setLocale(Locale locale) {
4835
      }
4836
4837
      final ParseException ex(String key, int loc) {
4838
          return new ParseException(EcorePlugin.INSTANCE.getString(key), loc);
4839
      }
4840
4841
      private final boolean isSet(int flag) {
4842
          return (this.options & flag) == flag;
4843
      }
4844
4845
      synchronized Token parse(String regex, int options) throws ParseException {
4846
          this.options = options;
4847
          this.offset = 0;
4848
          this.setContext(S_NORMAL);
4849
          this.parennumber = 1;
4850
          this.hasBackReferences = false;
4851
          this.regex = regex;
4852
          if (this.isSet(RegularExpression.EXTENDED_COMMENT))
4853
              this.regex = REUtil.stripExtendedComment(this.regex);
4854
          this.regexlen = this.regex.length();
4855
4856
4857
          this.next();
4858
          Token ret = this.parseRegex();
4859
          if (this.offset != this.regexlen)
4860
              throw ex("parser.parse.1", this.offset);
4861
          if (this.references != null) {
4862
              for (int i = 0;  i < this.references.size();  i ++) {
4863
                  ReferencePosition position = (ReferencePosition)this.references.elementAt(i);
4864
                  if (this.parennumber <= position.refNumber)
4865
                      throw ex("parser.parse.2", position.position);
4866
              }
4867
              this.references.removeAllElements();
4868
          }
4869
          return ret;
4870
      }
4871
4872
      /*
4873
      public RegularExpression createRegex(String regex, int options) throws ParseException {
4874
          Token tok = this.parse(regex, options);
4875
          return new RegularExpression(regex, tok, this.parennumber, this.hasBackReferences, options);
4876
      }
4877
      */
4878
4879
      protected final void setContext(int con) {
4880
          this.context = con;
4881
      }
4882
4883
      final int read() {
4884
          return this.nexttoken;
4885
      }
4886
4887
      final void next() {
4888
          if (this.offset >= this.regexlen) {
4889
              this.chardata = -1;
4890
              this.nexttoken = T_EOF;
4891
              return;
4892
          }
4893
4894
          int ret;
4895
          int ch = this.regex.charAt(this.offset++);
4896
          this.chardata = ch;
4897
4898
          if (this.context == S_INBRACKETS) {
4899
              // In a character class, this.chardata has one character, that is to say,
4900
              // a pair of surrogates is composed and stored to this.chardata.
4901
              switch (ch) {
4902
                case '\\':
4903
                  ret = T_BACKSOLIDUS;
4904
                  if (this.offset >= this.regexlen)
4905
                      throw ex("parser.next.1", this.offset-1);
4906
                  this.chardata = this.regex.charAt(this.offset++);
4907
                  break;
4908
4909
                case '-':
4910
                  if (this.isSet(RegularExpression.XMLSCHEMA_MODE)
4911
                      && this.offset < this.regexlen && this.regex.charAt(this.offset) == '[') {
4912
                      this.offset++;
4913
                      ret = T_XMLSCHEMA_CC_SUBTRACTION;
4914
                  } else
4915
                      ret = T_CHAR;
4916
                  break;
4917
4918
                case '[':
4919
                  if (!this.isSet(RegularExpression.XMLSCHEMA_MODE)
4920
                      && this.offset < this.regexlen && this.regex.charAt(this.offset) == ':') {
4921
                      this.offset++;
4922
                      ret = T_POSIX_CHARCLASS_START;
4923
                      break;
4924
                  } // Through down
4925
                default:
4926
                  if (REUtil.isHighSurrogate(ch) && this.offset < this.regexlen) {
4927
                      int low = this.regex.charAt(this.offset);
4928
                      if (REUtil.isLowSurrogate(low)) {
4929
                          this.chardata = REUtil.composeFromSurrogates(ch, low);
4930
                          this.offset ++;
4931
                      }
4932
                  }
4933
                  ret = T_CHAR;
4934
              }
4935
              this.nexttoken = ret;
4936
              return;
4937
          }
4938
4939
          switch (ch) {
4940
            case '|': ret = T_OR;             break;
4941
            case '*': ret = T_STAR;           break;
4942
            case '+': ret = T_PLUS;           break;
4943
            case '?': ret = T_QUESTION;       break;
4944
            case ')': ret = T_RPAREN;         break;
4945
            case '.': ret = T_DOT;            break;
4946
            case '[': ret = T_LBRACKET;       break;
4947
            case '^': ret = T_CARET;          break;
4948
            case '$': ret = T_DOLLAR;         break;
4949
            case '(':
4950
              ret = T_LPAREN;
4951
              if (this.offset >= this.regexlen)
4952
                  break;
4953
              if (this.regex.charAt(this.offset) != '?')
4954
                  break;
4955
              if (++this.offset >= this.regexlen)
4956
                  throw ex("parser.next.2", this.offset-1);
4957
              ch = this.regex.charAt(this.offset++);
4958
              switch (ch) {
4959
                case ':':  ret = T_LPAREN2;            break;
4960
                case '=':  ret = T_LOOKAHEAD;          break;
4961
                case '!':  ret = T_NEGATIVELOOKAHEAD;  break;
4962
                case '[':  ret = T_SET_OPERATIONS;     break;
4963
                case '>':  ret = T_INDEPENDENT;        break;
4964
                case '<':
4965
                  if (this.offset >= this.regexlen)
4966
                      throw ex("parser.next.2", this.offset-3);
4967
                  ch = this.regex.charAt(this.offset++);
4968
                  if (ch == '=') {
4969
                      ret = T_LOOKBEHIND;
4970
                  } else if (ch == '!') {
4971
                      ret = T_NEGATIVELOOKBEHIND;
4972
                  } else
4973
                      throw ex("parser.next.3", this.offset-3);
4974
                  break;
4975
                case '#':
4976
                  while (this.offset < this.regexlen) {
4977
                      ch = this.regex.charAt(this.offset++);
4978
                      if (ch == ')')  break;
4979
                  }
4980
                  if (ch != ')')
4981
                      throw ex("parser.next.4", this.offset-1);
4982
                  ret = T_COMMENT;
4983
                  break;
4984
                default:
4985
                  if (ch == '-' || 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z') {// Options
4986
                      this.offset --;
4987
                      ret = T_MODIFIERS;
4988
                      break;
4989
                  } else if (ch == '(') {         // conditional
4990
                      ret = T_CONDITION;          // this.offsets points the next of '('.
4991
                      break;
4992
                  }
4993
                  throw ex("parser.next.2", this.offset-2);
4994
              }
4995
              break;
4996
              
4997
            case '\\':
4998
              ret = T_BACKSOLIDUS;
4999
              if (this.offset >= this.regexlen)
5000
                  throw ex("parser.next.1", this.offset-1);
5001
              this.chardata = this.regex.charAt(this.offset++);
5002
              break;
5003
5004
            default:
5005
              ret = T_CHAR;
5006
          }
5007
          this.nexttoken = ret;
5008
      }
5009
5010
      /**
5011
       * regex ::= term (`|` term)*
5012
       * term ::= factor+
5013
       * factor ::= ('^' | '$' | '\A' | '\Z' | '\z' | '\b' | '\B' | '\<' | '\>'
5014
       *            | atom (('*' | '+' | '?' | minmax ) '?'? )?)
5015
       *            | '(?=' regex ')'  | '(?!' regex ')'  | '(?&lt;=' regex ')'  | '(?&lt;!' regex ')'
5016
       * atom ::= char | '.' | range | '(' regex ')' | '(?:' regex ')' | '\' [0-9]
5017
       *          | '\w' | '\W' | '\d' | '\D' | '\s' | '\S' | category-block 
5018
       */
5019
      Token parseRegex() throws ParseException {
5020
          Token tok = this.parseTerm();
5021
          Token parent = null;
5022
          while (this.read() == T_OR) {
5023
              this.next();                    // '|'
5024
              if (parent == null) {
5025
                  parent = Token.createUnion();
5026
                  parent.addChild(tok);
5027
                  tok = parent;
5028
              }
5029
              tok.addChild(this.parseTerm());
5030
          }
5031
          return tok;
5032
      }
5033
5034
      /**
5035
       * term ::= factor+
5036
       */
5037
      Token parseTerm() throws ParseException {
5038
          int ch = this.read();
5039
          if (ch == T_OR || ch == T_RPAREN || ch == T_EOF) {
5040
              return Token.createEmpty();
5041
          } else {
5042
              Token tok = this.parseFactor();
5043
              Token concat = null;
5044
              while ((ch = this.read()) != T_OR && ch != T_RPAREN && ch != T_EOF) {
5045
                  if (concat == null) {
5046
                      concat = Token.createConcat();
5047
                      concat.addChild(tok);
5048
                      tok = concat;
5049
                  }
5050
                  concat.addChild(this.parseFactor());
5051
                  //tok = Token.createConcat(tok, this.parseFactor());
5052
              }
5053
              return tok;
5054
          }
5055
      }
5056
5057
      // ----------------------------------------------------------------
5058
5059
      Token processCaret() throws ParseException {
5060
          this.next();
5061
          return Token.token_linebeginning;
5062
      }
5063
      Token processDollar() throws ParseException {
5064
          this.next();
5065
          return Token.token_lineend;
5066
      }
5067
      Token processLookahead() throws ParseException {
5068
          this.next();
5069
          Token tok = Token.createLook(Token.LOOKAHEAD, this.parseRegex());
5070
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5071
          this.next();                            // ')'
5072
          return tok;
5073
      }
5074
      Token processNegativelookahead() throws ParseException {
5075
          this.next();
5076
          Token tok = Token.createLook(Token.NEGATIVELOOKAHEAD, this.parseRegex());
5077
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5078
          this.next();                            // ')'
5079
          return tok;
5080
      }
5081
      Token processLookbehind() throws ParseException {
5082
          this.next();
5083
          Token tok = Token.createLook(Token.LOOKBEHIND, this.parseRegex());
5084
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5085
          this.next();                            // ')'
5086
          return tok;
5087
      }
5088
      Token processNegativelookbehind() throws ParseException {
5089
          this.next();
5090
          Token tok = Token.createLook(Token.NEGATIVELOOKBEHIND, this.parseRegex());
5091
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5092
          this.next();                    // ')'
5093
          return tok;
5094
      }
5095
      Token processBacksolidus_A() throws ParseException {
5096
          this.next();
5097
          return Token.token_stringbeginning;
5098
      }
5099
      Token processBacksolidus_Z() throws ParseException {
5100
          this.next();
5101
          return Token.token_stringend2;
5102
      }
5103
      Token processBacksolidus_z() throws ParseException {
5104
          this.next();
5105
          return Token.token_stringend;
5106
      }
5107
      Token processBacksolidus_b() throws ParseException {
5108
          this.next();
5109
          return Token.token_wordedge;
5110
      }
5111
      Token processBacksolidus_B() throws ParseException {
5112
          this.next();
5113
          return Token.token_not_wordedge;
5114
      }
5115
      Token processBacksolidus_lt() throws ParseException {
5116
          this.next();
5117
          return Token.token_wordbeginning;
5118
      }
5119
      Token processBacksolidus_gt() throws ParseException {
5120
          this.next();
5121
          return Token.token_wordend;
5122
      }
5123
      Token processStar(Token tok) throws ParseException {
5124
          this.next();
5125
          if (this.read() == T_QUESTION) {
5126
              this.next();
5127
              return Token.createNGClosure(tok);
5128
          } else
5129
              return Token.createClosure(tok);
5130
      }
5131
      Token processPlus(Token tok) throws ParseException {
5132
          // X+ -> XX*
5133
          this.next();
5134
          if (this.read() == T_QUESTION) {
5135
              this.next();
5136
              return Token.createConcat(tok, Token.createNGClosure(tok));
5137
          } else
5138
              return Token.createConcat(tok, Token.createClosure(tok));
5139
      }
5140
      Token processQuestion(Token tok) throws ParseException {
5141
          // X? -> X|
5142
          this.next();
5143
          Token par = Token.createUnion();
5144
          if (this.read() == T_QUESTION) {
5145
              this.next();
5146
              par.addChild(Token.createEmpty());
5147
              par.addChild(tok);
5148
          } else {
5149
              par.addChild(tok);
5150
              par.addChild(Token.createEmpty());
5151
          }
5152
          return par;
5153
      }
5154
      boolean checkQuestion(int off) {
5155
          return off < this.regexlen && this.regex.charAt(off) == '?';
5156
      }
5157
      Token processParen() throws ParseException {
5158
          this.next();
5159
          int p = this.parennumber++;
5160
          Token tok = Token.createParen(this.parseRegex(), p);
5161
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5162
          this.next();                            // Skips ')'
5163
          return tok;
5164
      }
5165
      Token processParen2() throws ParseException {
5166
          this.next();
5167
          Token tok = Token.createParen(this.parseRegex(), 0);
5168
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5169
          this.next();                            // Skips ')'
5170
          return tok;
5171
      }
5172
      Token processCondition() throws ParseException {
5173
                                                  // this.offset points the next of '('
5174
          if (this.offset+1 >= this.regexlen)  throw ex("parser.factor.4", this.offset);
5175
                                                  // Parses a condition.
5176
          int refno = -1;
5177
          Token condition = null;
5178
          int ch = this.regex.charAt(this.offset);
5179
          if ('1' <= ch && ch <= '9') {
5180
              refno = ch-'0';
5181
              this.hasBackReferences = true;
5182
              if (this.references == null)  this.references = new Vector();
5183
              this.references.addElement(new ReferencePosition(refno, this.offset));
5184
              this.offset ++;
5185
              if (this.regex.charAt(this.offset) != ')')  throw ex("parser.factor.1", this.offset);
5186
              this.offset ++;
5187
          } else {
5188
              if (ch == '?')  this.offset --; // Points '('.
5189
              this.next();
5190
              condition = this.parseFactor();
5191
              switch (condition.type) {
5192
                case Token.LOOKAHEAD:
5193
                case Token.NEGATIVELOOKAHEAD:
5194
                case Token.LOOKBEHIND:
5195
                case Token.NEGATIVELOOKBEHIND:
5196
                  break;
5197
                case Token.ANCHOR:
5198
                  if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5199
                  break;
5200
                default:
5201
                  throw ex("parser.factor.5", this.offset);
5202
              }
5203
          }
5204
                                                  // Parses yes/no-patterns.
5205
          this.next();
5206
          Token yesPattern = this.parseRegex();
5207
          Token noPattern = null;
5208
          if (yesPattern.type == Token.UNION) {
5209
              if (yesPattern.size() != 2)  throw ex("parser.factor.6", this.offset);
5210
              noPattern = yesPattern.getChild(1);
5211
              yesPattern = yesPattern.getChild(0);
5212
          }
5213
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5214
          this.next();
5215
          return Token.createCondition(refno, condition, yesPattern, noPattern);
5216
      }
5217
      Token processModifiers() throws ParseException {
5218
                                                  // this.offset points the next of '?'.
5219
                                                  // modifiers ::= [imsw]* ('-' [imsw]*)? ':'
5220
          int add = 0, mask = 0, ch = -1;
5221
          while (this.offset < this.regexlen) {
5222
              ch = this.regex.charAt(this.offset);
5223
              int v = REUtil.getOptionValue(ch);
5224
              if (v == 0)  break;                 // '-' or ':'?
5225
              add |= v;
5226
              this.offset ++;
5227
          }
5228
          if (this.offset >= this.regexlen)  throw ex("parser.factor.2", this.offset-1);
5229
          if (ch == '-') {
5230
              this.offset ++;
5231
              while (this.offset < this.regexlen) {
5232
                  ch = this.regex.charAt(this.offset);
5233
                  int v = REUtil.getOptionValue(ch);
5234
                  if (v == 0)  break;             // ':'?
5235
                  mask |= v;
5236
                  this.offset ++;
5237
              }
5238
              if (this.offset >= this.regexlen)  throw ex("parser.factor.2", this.offset-1);
5239
          }
5240
          Token tok;
5241
          if (ch == ':') {
5242
              this.offset ++;
5243
              this.next();
5244
              tok = Token.createModifierGroup(this.parseRegex(), add, mask);
5245
              if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5246
              this.next();
5247
          } else if (ch == ')') {                 // such as (?-i)
5248
              this.offset ++;
5249
              this.next();
5250
              tok = Token.createModifierGroup(this.parseRegex(), add, mask);
5251
          } else
5252
              throw ex("parser.factor.3", this.offset);
5253
5254
          return tok;
5255
      }
5256
      Token processIndependent() throws ParseException {
5257
          this.next();
5258
          Token tok = Token.createLook(Token.INDEPENDENT, this.parseRegex());
5259
          if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);
5260
          this.next();                            // Skips ')'
5261
          return tok;
5262
      }
5263
      Token processBacksolidus_c() throws ParseException {
5264
          int ch2;                                // Must be in 0x0040-0x005f
5265
          if (this.offset >= this.regexlen
5266
              || ((ch2 = this.regex.charAt(this.offset++)) & 0xffe0) != 0x0040)
5267
              throw ex("parser.atom.1", this.offset-1);
5268
          this.next();
5269
          return Token.createChar(ch2-0x40);
5270
      }
5271
      Token processBacksolidus_C() throws ParseException {
5272
          throw ex("parser.process.1", this.offset);
5273
      }
5274
      Token processBacksolidus_i() throws ParseException {
5275
          Token tok = Token.createChar('i');
5276
          this.next();
5277
          return tok;
5278
      }
5279
      Token processBacksolidus_I() throws ParseException {
5280
          throw ex("parser.process.1", this.offset);
5281
      }
5282
      Token processBacksolidus_g() throws ParseException {
5283
          this.next();
5284
          return Token.getGraphemePattern();
5285
      }
5286
      Token processBacksolidus_X() throws ParseException {
5287
          this.next();
5288
          return Token.getCombiningCharacterSequence();
5289
      }
5290
      Token processBackreference() throws ParseException {
5291
          int refnum = this.chardata-'0';
5292
          Token tok = Token.createBackReference(refnum);
5293
          this.hasBackReferences = true;
5294
          if (this.references == null)  this.references = new Vector();
5295
          this.references.addElement(new ReferencePosition(refnum, this.offset-2));
5296
          this.next();
5297
          return tok;
5298
      }
5299
5300
      // ----------------------------------------------------------------
5301
5302
      /**
5303
       * factor ::= ('^' | '$' | '\A' | '\Z' | '\z' | '\b' | '\B' | '\<' | '\>'
5304
       *            | atom (('*' | '+' | '?' | minmax ) '?'? )?)
5305
       *            | '(?=' regex ')'  | '(?!' regex ')'  | '(?&lt;=' regex ')'  | '(?&lt;!' regex ')'
5306
       *            | '(?#' [^)]* ')'
5307
       * minmax ::= '{' min (',' max?)? '}'
5308
       * min ::= [0-9]+
5309
       * max ::= [0-9]+
5310
       */
5311
      Token parseFactor() throws ParseException {        
5312
          int ch = this.read();
5313
          Token tok;
5314
          switch (ch) {
5315
            case T_CARET:         return this.processCaret();
5316
            case T_DOLLAR:        return this.processDollar();
5317
            case T_LOOKAHEAD:     return this.processLookahead();
5318
            case T_NEGATIVELOOKAHEAD: return this.processNegativelookahead();
5319
            case T_LOOKBEHIND:    return this.processLookbehind();
5320
            case T_NEGATIVELOOKBEHIND: return this.processNegativelookbehind();
5321
5322
            case T_COMMENT:
5323
              this.next();
5324
              return Token.createEmpty();
5325
5326
            case T_BACKSOLIDUS:
5327
              switch (this.chardata) {
5328
                case 'A': return this.processBacksolidus_A();
5329
                case 'Z': return this.processBacksolidus_Z();
5330
                case 'z': return this.processBacksolidus_z();
5331
                case 'b': return this.processBacksolidus_b();
5332
                case 'B': return this.processBacksolidus_B();
5333
                case '<': return this.processBacksolidus_lt();
5334
                case '>': return this.processBacksolidus_gt();
5335
              }
5336
                                                  // through down
5337
          }
5338
          tok = this.parseAtom();
5339
          ch = this.read();
5340
          switch (ch) {
5341
            case T_STAR:  return this.processStar(tok);
5342
            case T_PLUS:  return this.processPlus(tok);
5343
            case T_QUESTION: return this.processQuestion(tok);
5344
            case T_CHAR:
5345
              if (this.chardata == '{' && this.offset < this.regexlen) {
5346
5347
                  int off = this.offset;          // this.offset -> next of '{'
5348
                  int min = 0, max = -1;
5349
5350
                  if ((ch = this.regex.charAt(off++)) >= '0' && ch <= '9') {
5351
5352
                      min = ch -'0';
5353
                      while (off < this.regexlen
5354
                             && (ch = this.regex.charAt(off++)) >= '0' && ch <= '9') {
5355
                          min = min*10 +ch-'0';
5356
                          if (min < 0)
5357
                              throw ex("parser.quantifier.5", this.offset);
5358
                      }
5359
                  }
5360
                  else {
5361
                      throw ex("parser.quantifier.1", this.offset);
5362
                  }
5363
5364
                  max = min;
5365
                  if (ch == ',') {
5366
5367
                     if (off >= this.regexlen) {
5368
                         throw ex("parser.quantifier.3", this.offset);
5369
                     }
5370
                     else if ((ch = this.regex.charAt(off++)) >= '0' && ch <= '9') {                       
5371
5372
                          max = ch -'0';       // {min,max}
5373
                          while (off < this.regexlen
5374
                                 && (ch = this.regex.charAt(off++)) >= '0'
5375
                                 && ch <= '9') {
5376
                              max = max*10 +ch-'0';
5377
                              if (max < 0)
5378
                                  throw ex("parser.quantifier.5", this.offset);
5379
                          }
5380
5381
                          if (min > max)
5382
                              throw ex("parser.quantifier.4", this.offset);
5383
                     }
5384
                     else { // assume {min,}
5385
                          max = -1;           
5386
                      }
5387
                  }
5388
5389
                 if (ch != '}')
5390
                     throw ex("parser.quantifier.2", this.offset);
5391
5392
                 if (this.checkQuestion(off)) {  // off -> next of '}'
5393
                      tok = Token.createNGClosure(tok);
5394
                      this.offset = off+1;
5395
                  } else {
5396
                      tok = Token.createClosure(tok);
5397
                      this.offset = off;
5398
                  }
5399
5400
                  tok.setMin(min);
5401
                  tok.setMax(max);
5402
                  //System.err.println("CLOSURE: "+min+", "+max);
5403
                  this.next();
5404
              }
5405
          }
5406
          return tok;
5407
      }
5408
5409
      /**
5410
       * atom ::= char | '.' | char-class | '(' regex ')' | '(?:' regex ')' | '\' [0-9]
5411
       *          | '\w' | '\W' | '\d' | '\D' | '\s' | '\S' | category-block
5412
       *          | '(?>' regex ')'
5413
       * char ::= '\\' | '\' [efnrt] | bmp-code | character-1
5414
       */
5415
      Token parseAtom() throws ParseException {
5416
          int ch = this.read();
5417
          Token tok = null;
5418
          switch (ch) {
5419
            case T_LPAREN:        return this.processParen();
5420
            case T_LPAREN2:       return this.processParen2(); // '(?:'
5421
            case T_CONDITION:     return this.processCondition(); // '(?('
5422
            case T_MODIFIERS:     return this.processModifiers(); // (?modifiers ... )
5423
            case T_INDEPENDENT:   return this.processIndependent();
5424
            case T_DOT:
5425
              this.next();                    // Skips '.'
5426
              tok = Token.token_dot;
5427
              break;
5428
5429
              /**
5430
               * char-class ::= '[' ( '^'? range ','?)+ ']'
5431
               * range ::= '\d' | '\w' | '\s' | category-block | range-char
5432
               *           | range-char '-' range-char
5433
               * range-char ::= '\[' | '\]' | '\\' | '\' [,-efnrtv] | bmp-code | character-2
5434
               * bmp-char ::= '\' 'u' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]
5435
               */
5436
            case T_LBRACKET:      return this.parseCharacterClass(true);
5437
            case T_SET_OPERATIONS: return this.parseSetOperations();
5438
5439
            case T_BACKSOLIDUS:
5440
              switch (this.chardata) {
5441
                case 'd':  case 'D':
5442
                case 'w':  case 'W':
5443
                case 's':  case 'S':
5444
                  tok = this.getTokenForShorthand(this.chardata);
5445
                  this.next();
5446
                  return tok;
5447
5448
                case 'e':  case 'f':  case 'n':  case 'r':
5449
                case 't':  case 'u':  case 'v':  case 'x':
5450
                  {
5451
                      int ch2 = this.decodeEscaped();
5452
                      if (ch2 < 0x10000) {
5453
                          tok = Token.createChar(ch2);
5454
                      } else {
5455
                          tok = Token.createString(REUtil.decomposeToSurrogates(ch2));
5456
                      }
5457
                  }
5458
                  break;
5459
5460
                case 'c': return this.processBacksolidus_c();
5461
                case 'C': return this.processBacksolidus_C();
5462
                case 'i': return this.processBacksolidus_i();
5463
                case 'I': return this.processBacksolidus_I();
5464
                case 'g': return this.processBacksolidus_g();
5465
                case 'X': return this.processBacksolidus_X();
5466
                case '1':  case '2':  case '3':  case '4':
5467
                case '5':  case '6':  case '7':  case '8':  case '9':
5468
                  return this.processBackreference();
5469
5470
                case 'P':
5471
                case 'p':
5472
                  int pstart = this.offset;
5473
                  tok = processBacksolidus_pP(this.chardata);
5474
                  if (tok == null)  throw this.ex("parser.atom.5", pstart);
5475
                  break;
5476
5477
                default:
5478
                  tok = Token.createChar(this.chardata);
5479
              }
5480
              this.next();
5481
              break;
5482
5483
            case T_CHAR:
5484
              if (this.chardata == ']' || this.chardata == '{' || this.chardata == '}')
5485
                  throw this.ex("parser.atom.4", this.offset-1);
5486
              tok = Token.createChar(this.chardata);
5487
              int high = this.chardata;
5488
              this.next();
5489
              if (REUtil.isHighSurrogate(high)
5490
                  && this.read() == T_CHAR && REUtil.isLowSurrogate(this.chardata)) {
5491
                  char[] sur = new char[2];
5492
                  sur[0] = (char)high;
5493
                  sur[1] = (char)this.chardata;
5494
                  tok = Token.createParen(Token.createString(new String(sur)), 0);
5495
                  this.next();
5496
              }
5497
              break;
5498
5499
            default:
5500
              throw this.ex("parser.atom.4", this.offset-1);
5501
          }
5502
          return tok;
5503
      }
5504
5505
      protected RangeToken processBacksolidus_pP(int c) throws ParseException {
5506
5507
          this.next();
5508
          if (this.read() != T_CHAR || this.chardata != '{')
5509
              throw this.ex("parser.atom.2", this.offset-1);
5510
5511
          // handle category escape
5512
          boolean positive = c == 'p';
5513
          int namestart = this.offset;
5514
          int nameend = this.regex.indexOf('}', namestart);
5515
5516
          if (nameend < 0)
5517
              throw this.ex("parser.atom.3", this.offset);
5518
5519
          String pname = this.regex.substring(namestart, nameend);
5520
          this.offset = nameend+1;
5521
5522
          return Token.getRange(pname, positive, this.isSet(RegularExpression.XMLSCHEMA_MODE));
5523
      }
5524
5525
      int processCIinCharacterClass(RangeToken tok, int c) {
5526
          return this.decodeEscaped();
5527
      }
5528
5529
      /**
5530
       * char-class ::= '[' ( '^'? range ','?)+ ']'
5531
       * range ::= '\d' | '\w' | '\s' | category-block | range-char
5532
       *           | range-char '-' range-char
5533
       * range-char ::= '\[' | '\]' | '\\' | '\' [,-efnrtv] | bmp-code | character-2
5534
       * bmp-code ::= '\' 'u' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]
5535
       */
5536
      protected RangeToken parseCharacterClass(boolean useNrange) throws ParseException {
5537
          this.setContext(S_INBRACKETS);
5538
          this.next();                            // '['
5539
          boolean nrange = false;
5540
          RangeToken base = null;
5541
          RangeToken tok;
5542
          if (this.read() == T_CHAR && this.chardata == '^') {
5543
              nrange = true;
5544
              this.next();                        // '^'
5545
              if (useNrange) {
5546
                  tok = Token.createNRange();
5547
              } else {
5548
                  base = Token.createRange();
5549
                  base.addRange(0, Token.UTF16_MAX);
5550
                  tok = Token.createRange();
5551
              }
5552
          } else {
5553
              tok = Token.createRange();
5554
          }
5555
          int type;
5556
          boolean firstloop = true;
5557
          while ((type = this.read()) != T_EOF) {
5558
              if (type == T_CHAR && this.chardata == ']' && !firstloop)
5559
                  break;
5560
              firstloop = false;
5561
              int c = this.chardata;
5562
              boolean end = false;
5563
              if (type == T_BACKSOLIDUS) {
5564
                  switch (c) {
5565
                    case 'd':  case 'D':
5566
                    case 'w':  case 'W':
5567
                    case 's':  case 'S':
5568
                      tok.mergeRanges(this.getTokenForShorthand(c));
5569
                      end = true;
5570
                      break;
5571
5572
                    case 'i':  case 'I':
5573
                    case 'c':  case 'C':
5574
                      c = this.processCIinCharacterClass(tok, c);
5575
                      if (c < 0)  end = true;
5576
                      break;
5577
                      
5578
                    case 'p':
5579
                    case 'P':
5580
                      int pstart = this.offset;
5581
                      RangeToken tok2 = this.processBacksolidus_pP(c);
5582
                      if (tok2 == null)  throw this.ex("parser.atom.5", pstart);
5583
                      tok.mergeRanges(tok2);
5584
                      end = true;
5585
                      break;
5586
5587
                    default:
5588
                      c = this.decodeEscaped();
5589
                  } // \ + c
5590
              } // backsolidus
5591
                                                  // POSIX Character class such as [:alnum:]
5592
              else if (type == T_POSIX_CHARCLASS_START) {
5593
                  int nameend = this.regex.indexOf(':', this.offset);
5594
                  if (nameend < 0) throw this.ex("parser.cc.1", this.offset);
5595
                  boolean positive = true;
5596
                  if (this.regex.charAt(this.offset) == '^') {
5597
                      this.offset ++;
5598
                      positive = false;
5599
                  }
5600
                  String name = this.regex.substring(this.offset, nameend);
5601
                  RangeToken range = Token.getRange(name, positive,
5602
                                                    this.isSet(RegularExpression.XMLSCHEMA_MODE));
5603
                  if (range == null)  throw this.ex("parser.cc.3", this.offset);
5604
                  tok.mergeRanges(range);
5605
                  end = true;
5606
                  if (nameend+1 >= this.regexlen || this.regex.charAt(nameend+1) != ']')
5607
                      throw this.ex("parser.cc.1", nameend);
5608
                  this.offset = nameend+2;
5609
              }
5610
              this.next();
5611
              if (!end) {                         // if not shorthands...
5612
                  if (this.read() != T_CHAR || this.chardata != '-') { // Here is no '-'.
5613
                      tok.addRange(c, c);
5614
                  } else {
5615
                      this.next(); // Skips '-'
5616
                      if ((type = this.read()) == T_EOF)  throw this.ex("parser.cc.2", this.offset);
5617
                      if (type == T_CHAR && this.chardata == ']') {
5618
                          tok.addRange(c, c);
5619
                          tok.addRange('-', '-');
5620
                      } else {
5621
                          int rangeend = this.chardata;
5622
                          if (type == T_BACKSOLIDUS)
5623
                              rangeend = this.decodeEscaped();
5624
                          this.next();
5625
                          tok.addRange(c, rangeend);
5626
                      }
5627
                  }
5628
              }
5629
              if (this.isSet(RegularExpression.SPECIAL_COMMA)
5630
                  && this.read() == T_CHAR && this.chardata == ',')
5631
                  this.next();
5632
          }
5633
          if (this.read() == T_EOF)
5634
              throw this.ex("parser.cc.2", this.offset);
5635
          if (!useNrange && nrange) {
5636
              base.subtractRanges(tok);
5637
              tok = base;
5638
          }
5639
          tok.sortRanges();
5640
          tok.compactRanges();
5641
          //tok.dumpRanges();
5642
          /*
5643
          if (this.isSet(RegularExpression.IGNORE_CASE))
5644
              tok = RangeToken.createCaseInsensitiveToken(tok);
5645
          */
5646
          this.setContext(S_NORMAL);
5647
          this.next();                    // Skips ']'
5648
5649
          return tok;
5650
      }
5651
5652
      /**
5653
       * '(?[' ... ']' (('-' | '+' | '&') '[' ... ']')? ')'
5654
       */
5655
      protected RangeToken parseSetOperations() throws ParseException {
5656
          RangeToken tok = this.parseCharacterClass(false);
5657
          int type;
5658
          while ((type = this.read()) != T_RPAREN) {
5659
              int ch = this.chardata;
5660
              if (type == T_CHAR && (ch == '-' || ch == '&')
5661
                  || type == T_PLUS) {
5662
                  this.next();
5663
                  if (this.read() != T_LBRACKET) throw ex("parser.ope.1", this.offset-1);
5664
                  RangeToken t2 = this.parseCharacterClass(false);
5665
                  if (type == T_PLUS)
5666
                      tok.mergeRanges(t2);
5667
                  else if (ch == '-')
5668
                      tok.subtractRanges(t2);
5669
                  else if (ch == '&')
5670
                      tok.intersectRanges(t2);
5671
                  else
5672
                      throw new RuntimeException("ASSERT");
5673
              } else {
5674
                  throw ex("parser.ope.2", this.offset-1);
5675
              }
5676
          }
5677
          this.next();
5678
          return tok;
5679
      }
5680
5681
      Token getTokenForShorthand(int ch) {
5682
          Token tok;
5683
          switch (ch) {
5684
            case 'd':
5685
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5686
                  ? Token.getRange("Nd", true) : Token.token_0to9;
5687
              break;
5688
            case 'D':
5689
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5690
                  ? Token.getRange("Nd", false) : Token.token_not_0to9;
5691
              break;
5692
            case 'w':
5693
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5694
                  ? Token.getRange("IsWord", true) : Token.token_wordchars;
5695
              break;
5696
            case 'W':
5697
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5698
                  ? Token.getRange("IsWord", false) : Token.token_not_wordchars;
5699
              break;
5700
            case 's':
5701
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5702
                  ? Token.getRange("IsSpace", true) : Token.token_spaces;
5703
              break;
5704
            case 'S':
5705
              tok = this.isSet(RegularExpression.USE_UNICODE_CATEGORY)
5706
                  ? Token.getRange("IsSpace", false) : Token.token_not_spaces;
5707
              break;
5708
5709
            default:
5710
              throw new RuntimeException("Internal Error: shorthands: \\u"+Integer.toString(ch, 16));
5711
          }
5712
          return tok;
5713
      }
5714
5715
      /**
5716
       */
5717
      int decodeEscaped() throws ParseException {
5718
          if (this.read() != T_BACKSOLIDUS)  throw ex("parser.next.1", this.offset-1);
5719
          int c = this.chardata;
5720
          switch (c) {
5721
            case 'e':  c = 0x1b;  break; // ESCAPE U+001B
5722
            case 'f':  c = '\f';  break; // FORM FEED U+000C
5723
            case 'n':  c = '\n';  break; // LINE FEED U+000A
5724
            case 'r':  c = '\r';  break; // CRRIAGE RETURN U+000D
5725
            case 't':  c = '\t';  break; // HORIZONTAL TABULATION U+0009
5726
            //case 'v':  c = 0x0b;  break; // VERTICAL TABULATION U+000B
5727
            case 'x':
5728
              this.next();
5729
              if (this.read() != T_CHAR)  throw ex("parser.descape.1", this.offset-1);
5730
              if (this.chardata == '{') {
5731
                  int v1 = 0;
5732
                  int uv = 0;
5733
                  do {
5734
                      this.next();
5735
                      if (this.read() != T_CHAR)  throw ex("parser.descape.1", this.offset-1);
5736
                      if ((v1 = hexChar(this.chardata)) < 0)
5737
                          break;
5738
                      if (uv > uv*16) throw ex("parser.descape.2", this.offset-1);
5739
                      uv = uv*16+v1;
5740
                  } while (true);
5741
                  if (this.chardata != '}')  throw ex("parser.descape.3", this.offset-1);
5742
                  if (uv > Token.UTF16_MAX)  throw ex("parser.descape.4", this.offset-1);
5743
                  c = uv;
5744
              } else {
5745
                  int v1 = 0;
5746
                  if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5747
                      throw ex("parser.descape.1", this.offset-1);
5748
                  int uv = v1;
5749
                  this.next();
5750
                  if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5751
                      throw ex("parser.descape.1", this.offset-1);
5752
                  uv = uv*16+v1;
5753
                  c = uv;
5754
              }
5755
              break;
5756
5757
            case 'u':
5758
              int v1 = 0;
5759
              this.next();
5760
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5761
                  throw ex("parser.descape.1", this.offset-1);
5762
              int uv = v1;
5763
              this.next();
5764
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5765
                  throw ex("parser.descape.1", this.offset-1);
5766
              uv = uv*16+v1;
5767
              this.next();
5768
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5769
                  throw ex("parser.descape.1", this.offset-1);
5770
              uv = uv*16+v1;
5771
              this.next();
5772
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5773
                  throw ex("parser.descape.1", this.offset-1);
5774
              uv = uv*16+v1;
5775
              c = uv;
5776
              break;
5777
5778
            case 'v':
5779
              this.next();
5780
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5781
                  throw ex("parser.descape.1", this.offset-1);
5782
              uv = v1;
5783
              this.next();
5784
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5785
                  throw ex("parser.descape.1", this.offset-1);
5786
              uv = uv*16+v1;
5787
              this.next();
5788
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5789
                  throw ex("parser.descape.1", this.offset-1);
5790
              uv = uv*16+v1;
5791
              this.next();
5792
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5793
                  throw ex("parser.descape.1", this.offset-1);
5794
              uv = uv*16+v1;
5795
              this.next();
5796
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5797
                  throw ex("parser.descape.1", this.offset-1);
5798
              uv = uv*16+v1;
5799
              this.next();
5800
              if (this.read() != T_CHAR || (v1 = hexChar(this.chardata)) < 0)
5801
                  throw ex("parser.descape.1", this.offset-1);
5802
              uv = uv*16+v1;
5803
              if (uv > Token.UTF16_MAX)  throw ex("parser.descappe.4", this.offset-1);
5804
              c = uv;
5805
              break;
5806
            case 'A':
5807
            case 'Z':
5808
            case 'z':
5809
              throw ex("parser.descape.5", this.offset-2);
5810
            default:
5811
          }
5812
          return c;
5813
      }
5814
5815
      static private final int hexChar(int ch) {
5816
          if (ch < '0')  return -1;
5817
          if (ch > 'f')  return -1;
5818
          if (ch <= '9')  return ch-'0';
5819
          if (ch < 'A')  return -1;
5820
          if (ch <= 'F')  return ch-'A'+10;
5821
          if (ch < 'a')  return -1;
5822
          return ch-'a'+10;
5823
      }
5824
  }
5825
5826
5827
  static class Token implements java.io.Serializable {
5828
      static final boolean COUNTTOKENS = true;
5829
      static int tokens = 0;
5830
5831
      static final int CHAR = 0;                  // Literal char
5832
      static final int DOT = 11;                  // .
5833
      static final int CONCAT = 1;                // XY
5834
      static final int UNION = 2;                 // X|Y|Z
5835
      static final int CLOSURE = 3;               // X*
5836
      static final int RANGE = 4;                 // [a-zA-Z] etc.
5837
      static final int NRANGE = 5;                // [^a-zA-Z] etc.
5838
      static final int PAREN = 6;                 // (X) or (?:X)
5839
      static final int EMPTY = 7;                 //
5840
      static final int ANCHOR = 8;                // ^ $ \b \B \< \> \A \Z \z
5841
      static final int NONGREEDYCLOSURE = 9;      // *? +?
5842
      static final int STRING = 10;               // strings
5843
      static final int BACKREFERENCE = 12;        // back references
5844
      static final int LOOKAHEAD = 20;            // (?=...)
5845
      static final int NEGATIVELOOKAHEAD = 21;    // (?!...)
5846
      static final int LOOKBEHIND = 22;           // (?<=...)
5847
      static final int NEGATIVELOOKBEHIND = 23;   // (?<!...)
5848
      static final int INDEPENDENT = 24;          // (?>...)
5849
      static final int MODIFIERGROUP = 25;        // (?ims-ims:...)
5850
      static final int CONDITION = 26;            // (?(...)yes|no)
5851
5852
      static final int UTF16_MAX = 0x10ffff;
5853
5854
      int type;
5855
5856
      static Token token_dot;
5857
      static Token token_0to9;
5858
      static Token token_wordchars;
5859
      static Token token_not_0to9;
5860
      static Token token_not_wordchars;
5861
      static Token token_spaces;
5862
      static Token token_not_spaces;
5863
      static Token token_empty;
5864
      static Token token_linebeginning;
5865
      static Token token_linebeginning2;
5866
      static Token token_lineend;
5867
      static Token token_stringbeginning;
5868
      static Token token_stringend;
5869
      static Token token_stringend2;
5870
      static Token token_wordedge;
5871
      static Token token_not_wordedge;
5872
      static Token token_wordbeginning;
5873
      static Token token_wordend;
5874
      static {
5875
          Token.token_empty = new Token(Token.EMPTY);
5876
5877
          Token.token_linebeginning = Token.createAnchor('^');
5878
          Token.token_linebeginning2 = Token.createAnchor('@');
5879
          Token.token_lineend = Token.createAnchor('$');
5880
          Token.token_stringbeginning = Token.createAnchor('A');
5881
          Token.token_stringend = Token.createAnchor('z');
5882
          Token.token_stringend2 = Token.createAnchor('Z');
5883
          Token.token_wordedge = Token.createAnchor('b');
5884
          Token.token_not_wordedge = Token.createAnchor('B');
5885
          Token.token_wordbeginning = Token.createAnchor('<');
5886
          Token.token_wordend = Token.createAnchor('>');
5887
5888
          Token.token_dot = new Token(Token.DOT);
5889
5890
          Token.token_0to9 = Token.createRange();
5891
          Token.token_0to9.addRange('0', '9');
5892
          Token.token_wordchars = Token.createRange();
5893
          Token.token_wordchars.addRange('0', '9');
5894
          Token.token_wordchars.addRange('A', 'Z');
5895
          Token.token_wordchars.addRange('_', '_');
5896
          Token.token_wordchars.addRange('a', 'z');
5897
          Token.token_spaces = Token.createRange();
5898
          Token.token_spaces.addRange('\t', '\t');
5899
          Token.token_spaces.addRange('\n', '\n');
5900
          Token.token_spaces.addRange('\f', '\f');
5901
          Token.token_spaces.addRange('\r', '\r');
5902
          Token.token_spaces.addRange(' ', ' ');
5903
5904
          Token.token_not_0to9 = Token.complementRanges(Token.token_0to9);
5905
          Token.token_not_wordchars = Token.complementRanges(Token.token_wordchars);
5906
          Token.token_not_spaces = Token.complementRanges(Token.token_spaces);
5907
      }
5908
5909
      static Token.ParenToken createLook(int type, Token child) {
5910
          if (COUNTTOKENS)  Token.tokens ++;
5911
          return new Token.ParenToken(type, child, 0);
5912
      }
5913
      static Token.ParenToken createParen(Token child, int pnumber) {
5914
          if (COUNTTOKENS)  Token.tokens ++;
5915
          return new Token.ParenToken(Token.PAREN, child, pnumber);
5916
      }
5917
      static Token.ClosureToken createClosure(Token tok) {
5918
          if (COUNTTOKENS)  Token.tokens ++;
5919
          return new Token.ClosureToken(Token.CLOSURE, tok);
5920
      }
5921
      static Token.ClosureToken createNGClosure(Token tok) {
5922
          if (COUNTTOKENS)  Token.tokens ++;
5923
          return new Token.ClosureToken(Token.NONGREEDYCLOSURE, tok);
5924
      }
5925
      static Token.ConcatToken createConcat(Token tok1, Token tok2) {
5926
          if (COUNTTOKENS)  Token.tokens ++;
5927
          return new Token.ConcatToken(tok1, tok2);
5928
      }
5929
      static Token.UnionToken createConcat() {
5930
          if (COUNTTOKENS)  Token.tokens ++;
5931
          return new Token.UnionToken(Token.CONCAT); // *** It is not a bug.
5932
      }
5933
      static Token.UnionToken createUnion() {
5934
          if (COUNTTOKENS)  Token.tokens ++;
5935
          return new Token.UnionToken(Token.UNION);
5936
      }
5937
      static Token createEmpty() {
5938
          return Token.token_empty;
5939
      }
5940
      static RangeToken createRange() {
5941
          if (COUNTTOKENS)  Token.tokens ++;
5942
          return new RangeToken(Token.RANGE);
5943
      }
5944
      static RangeToken createNRange() {
5945
          if (COUNTTOKENS)  Token.tokens ++;
5946
          return new RangeToken(Token.NRANGE);
5947
      }
5948
      static Token.CharToken createChar(int ch) {
5949
          if (COUNTTOKENS)  Token.tokens ++;
5950
          return new Token.CharToken(Token.CHAR, ch);
5951
      }
5952
      static private Token.CharToken createAnchor(int ch) {
5953
          if (COUNTTOKENS)  Token.tokens ++;
5954
          return new Token.CharToken(Token.ANCHOR, ch);
5955
      }
5956
      static Token.StringToken createBackReference(int refno) {
5957
          if (COUNTTOKENS)  Token.tokens ++;
5958
          return new Token.StringToken(Token.BACKREFERENCE, null, refno);
5959
      }
5960
      static Token.StringToken createString(String str) {
5961
          if (COUNTTOKENS)  Token.tokens ++;
5962
          return new Token.StringToken(Token.STRING, str, 0);
5963
      }
5964
      static Token.ModifierToken createModifierGroup(Token child, int add, int mask) {
5965
          if (COUNTTOKENS)  Token.tokens ++;
5966
          return new Token.ModifierToken(child, add, mask);
5967
      }
5968
      static Token.ConditionToken createCondition(int refno, Token condition,
5969
                                                  Token yespat, Token nopat) {
5970
          if (COUNTTOKENS)  Token.tokens ++;
5971
          return new Token.ConditionToken(refno, condition, yespat, nopat);
5972
      }
5973
5974
      protected Token(int type) {
5975
          this.type = type;
5976
      }
5977
5978
      /**
5979
       * A number of children.
5980
       */
5981
      int size() {
5982
          return 0;
5983
      }
5984
      Token getChild(int index) {
5985
          return null;
5986
      }
5987
      void addChild(Token tok) {
5988
          throw new RuntimeException("Not supported.");
5989
      }
5990
5991
                                                  // for RANGE or NRANGE
5992
      protected void addRange(int start, int end) {
5993
          throw new RuntimeException("Not supported.");
5994
      }
5995
      protected void sortRanges() {
5996
          throw new RuntimeException("Not supported.");
5997
      }
5998
      protected void compactRanges() {
5999
          throw new RuntimeException("Not supported.");
6000
      }
6001
      protected void mergeRanges(Token tok) {
6002
          throw new RuntimeException("Not supported.");
6003
      }
6004
      protected void subtractRanges(Token tok) {
6005
          throw new RuntimeException("Not supported.");
6006
      }
6007
      protected void intersectRanges(Token tok) {
6008
          throw new RuntimeException("Not supported.");
6009
      }
6010
      static Token complementRanges(Token tok) {
6011
          return RangeToken.complementRanges(tok);
6012
      }
6013
6014
6015
      void setMin(int min) {                      // for CLOSURE
6016
      }
6017
      void setMax(int max) {                      // for CLOSURE
6018
      }
6019
      int getMin() {                              // for CLOSURE
6020
          return -1;
6021
      }
6022
      int getMax() {                              // for CLOSURE
6023
          return -1;
6024
      }
6025
      int getReferenceNumber() {                  // for STRING
6026
          return 0;
6027
      }
6028
      String getString() {                        // for STRING
6029
          return null;
6030
      }
6031
6032
      int getParenNumber() {
6033
          return 0;
6034
      }
6035
      int getChar() {
6036
          return -1;
6037
      }
6038
6039
      public String toString() {
6040
          return this.toString(0);
6041
      }
6042
      public String toString(int options) {
6043
          return this.type == Token.DOT ? "." : "";
6044
      }
6045
6046
      /**
6047
       * How many characters are needed?
6048
       */
6049
      final int getMinLength() {
6050
          switch (this.type) {
6051
            case CONCAT:
6052
              int sum = 0;
6053
              for (int i = 0;  i < this.size();  i ++)
6054
                  sum += this.getChild(i).getMinLength();
6055
              return sum;
6056
6057
            case CONDITION:
6058
            case UNION:
6059
              if (this.size() == 0)
6060
                  return 0;
6061
              int ret = this.getChild(0).getMinLength();
6062
              for (int i = 1;  i < this.size();  i ++) {
6063
                  int min = this.getChild(i).getMinLength();
6064
                  if (min < ret)  ret = min;
6065
              }
6066
              return ret;
6067
6068
            case CLOSURE:
6069
            case NONGREEDYCLOSURE:
6070
              if (this.getMin() >= 0)
6071
                  return this.getMin() * this.getChild(0).getMinLength();
6072
              return 0;
6073
6074
            case EMPTY:
6075
            case ANCHOR:
6076
              return 0;
6077
6078
            case DOT:
6079
            case CHAR:
6080
            case RANGE:
6081
            case NRANGE:
6082
              return 1;
6083
6084
            case INDEPENDENT:
6085
            case PAREN:
6086
            case MODIFIERGROUP:
6087
              return this.getChild(0).getMinLength();
6088
6089
            case BACKREFERENCE:
6090
              return 0;                           // *******
6091
6092
            case STRING:
6093
              return this.getString().length();
6094
6095
            case LOOKAHEAD:
6096
            case NEGATIVELOOKAHEAD:
6097
            case LOOKBEHIND:
6098
            case NEGATIVELOOKBEHIND:
6099
              return 0;                           // ***** Really?
6100
6101
            default:
6102
              throw new RuntimeException("Token#getMinLength(): Invalid Type: "+this.type);
6103
          }
6104
      }
6105
6106
      final int getMaxLength() {
6107
          switch (this.type) {
6108
            case CONCAT:
6109
              int sum = 0;
6110
              for (int i = 0;  i < this.size();  i ++) {
6111
                  int d = this.getChild(i).getMaxLength();
6112
                  if (d < 0)  return -1;
6113
                  sum += d;
6114
              }
6115
              return sum;
6116
6117
            case CONDITION:
6118
            case UNION:
6119
              if (this.size() == 0)
6120
                  return 0;
6121
              int ret = this.getChild(0).getMaxLength();
6122
              for (int i = 1;  ret >= 0 && i < this.size();  i ++) {
6123
                  int max = this.getChild(i).getMaxLength();
6124
                  if (max < 0) {                  // infinity
6125
                      ret = -1;
6126
                      break;
6127
                  }
6128
                  if (max > ret)  ret = max;
6129
              }
6130
              return ret;
6131
6132
            case CLOSURE:
6133
            case NONGREEDYCLOSURE:
6134
              if (this.getMax() >= 0)
6135
                                                  // When this.child.getMaxLength() < 0,
6136
                                                  // this returns minus value
6137
                  return this.getMax() * this.getChild(0).getMaxLength();
6138
              return -1;
6139
6140
            case EMPTY:
6141
            case ANCHOR:
6142
              return 0;
6143
6144
            case CHAR:
6145
              return 1;
6146
            case DOT:
6147
            case RANGE:
6148
            case NRANGE:
6149
              return 2;
6150
6151
            case INDEPENDENT:
6152
            case PAREN:
6153
            case MODIFIERGROUP:
6154
              return this.getChild(0).getMaxLength();
6155
6156
            case BACKREFERENCE:
6157
              return -1;                          // ******
6158
6159
            case STRING:
6160
              return this.getString().length();
6161
6162
            case LOOKAHEAD:
6163
            case NEGATIVELOOKAHEAD:
6164
            case LOOKBEHIND:
6165
            case NEGATIVELOOKBEHIND:
6166
              return 0;                           // ***** Really?
6167
6168
            default:
6169
              throw new RuntimeException("Token#getMaxLength(): Invalid Type: "+this.type);
6170
          }
6171
      }
6172
6173
      static final int FC_CONTINUE = 0;
6174
      static final int FC_TERMINAL = 1;
6175
      static final int FC_ANY = 2;
6176
      private static final boolean isSet(int options, int flag) {
6177
          return (options & flag) == flag;
6178
      }
6179
      final int analyzeFirstCharacter(RangeToken result, int options) {
6180
          switch (this.type) {
6181
            case CONCAT:
6182
              int ret = FC_CONTINUE;
6183
              for (int i = 0;  i < this.size();  i ++)
6184
                  if ((ret = this.getChild(i).analyzeFirstCharacter(result, options)) != FC_CONTINUE)
6185
                      break;
6186
              return ret;
6187
6188
            case UNION:
6189
              if (this.size() == 0)
6190
                  return FC_CONTINUE;
6191
              /*
6192
               *  a|b|c -> FC_TERMINAL
6193
               *  a|.|c -> FC_ANY
6194
               *  a|b|  -> FC_CONTINUE
6195
               */
6196
              int ret2 = FC_CONTINUE;
6197
              boolean hasEmpty = false;
6198
              for (int i = 0;  i < this.size();  i ++) {
6199
                  ret2 = this.getChild(i).analyzeFirstCharacter(result, options);
6200
                  if (ret2 == FC_ANY)
6201
                      break;
6202
                  else if (ret2 == FC_CONTINUE)
6203
                      hasEmpty = true;
6204
              }
6205
              return hasEmpty ? FC_CONTINUE : ret2;
6206
6207
            case CONDITION:
6208
              int ret3 = this.getChild(0).analyzeFirstCharacter(result, options);
6209
              if (this.size() == 1)  return FC_CONTINUE;
6210
              if (ret3 == FC_ANY)  return ret3;
6211
              int ret4 = this.getChild(1).analyzeFirstCharacter(result, options);
6212
              if (ret4 == FC_ANY)  return ret4;
6213
              return ret3 == FC_CONTINUE || ret4 == FC_CONTINUE ? FC_CONTINUE : FC_TERMINAL;
6214
6215
            case CLOSURE:
6216
            case NONGREEDYCLOSURE:
6217
              this.getChild(0).analyzeFirstCharacter(result, options);
6218
              return FC_CONTINUE;
6219
6220
            case EMPTY:
6221
            case ANCHOR:
6222
              return FC_CONTINUE;
6223
6224
            case CHAR:
6225
              int ch = this.getChar();
6226
              result.addRange(ch, ch);
6227
              if (ch < 0x10000 && isSet(options, RegularExpression.IGNORE_CASE)) {
6228
                  ch = Character.toUpperCase((char)ch);
6229
                  result.addRange(ch, ch);
6230
                  ch = Character.toLowerCase((char)ch);
6231
                  result.addRange(ch, ch);
6232
              }
6233
              return FC_TERMINAL;
6234
6235
            case DOT:                             // ****
6236
              if (isSet(options, RegularExpression.SINGLE_LINE)) {
6237
                  return FC_CONTINUE;             // **** We can not optimize.
6238
              } else {
6239
                  return FC_CONTINUE;
6240
                  /*
6241
                  result.addRange(0, RegularExpression.LINE_FEED-1);
6242
                  result.addRange(RegularExpression.LINE_FEED+1, RegularExpression.CARRIAGE_RETURN-1);
6243
                  result.addRange(RegularExpression.CARRIAGE_RETURN+1,
6244
                                  RegularExpression.LINE_SEPARATOR-1);
6245
                  result.addRange(RegularExpression.PARAGRAPH_SEPARATOR+1, UTF16_MAX);
6246
                  return 1;
6247
                  */
6248
              }
6249
6250
            case RANGE:
6251
              if (isSet(options, RegularExpression.IGNORE_CASE)) {
6252
                  result.mergeRanges(((RangeToken)this).getCaseInsensitiveToken());
6253
              } else {
6254
                  result.mergeRanges(this);
6255
              }
6256
              return FC_TERMINAL;
6257
6258
            case NRANGE:                          // ****
6259
              if (isSet(options, RegularExpression.IGNORE_CASE)) {
6260
                  result.mergeRanges(Token.complementRanges(((RangeToken)this).getCaseInsensitiveToken()));
6261
              } else {
6262
                  result.mergeRanges(Token.complementRanges(this));
6263
              }
6264
              return FC_TERMINAL;
6265
6266
            case INDEPENDENT:
6267
            case PAREN:
6268
              return this.getChild(0).analyzeFirstCharacter(result, options);
6269
6270
            case MODIFIERGROUP:
6271
              options |= ((ModifierToken)this).getOptions();
6272
              options &= ~((ModifierToken)this).getOptionsMask();
6273
              return this.getChild(0).analyzeFirstCharacter(result, options);
6274
6275
            case BACKREFERENCE:
6276
              result.addRange(0, UTF16_MAX);  // **** We can not optimize.
6277
              return FC_ANY;
6278
6279
            case STRING:
6280
              int cha = this.getString().charAt(0);
6281
              int ch2;
6282
              if (REUtil.isHighSurrogate(cha)
6283
                  && this.getString().length() >= 2
6284
                  && REUtil.isLowSurrogate((ch2 = this.getString().charAt(1))))
6285
                  cha = REUtil.composeFromSurrogates(cha, ch2);
6286
              result.addRange(cha, cha);
6287
              if (cha < 0x10000 && isSet(options, RegularExpression.IGNORE_CASE)) {
6288
                  cha = Character.toUpperCase((char)cha);
6289
                  result.addRange(cha, cha);
6290
                  cha = Character.toLowerCase((char)cha);
6291
                  result.addRange(cha, cha);
6292
              }
6293
              return FC_TERMINAL;
6294
6295
            case LOOKAHEAD:
6296
            case NEGATIVELOOKAHEAD:
6297
            case LOOKBEHIND:
6298
            case NEGATIVELOOKBEHIND:
6299
              return FC_CONTINUE;
6300
6301
            default:
6302
              throw new RuntimeException("Token#analyzeHeadCharacter(): Invalid Type: "+this.type);
6303
          }
6304
      }
6305
6306
      private final boolean isShorterThan(Token tok) {
6307
          if (tok == null)  return false;
6308
          /*
6309
          int mylength;
6310
          if (this.type == STRING)  mylength = this.getString().length();
6311
          else if (this.type == CHAR)  mylength = this.getChar() >= 0x10000 ? 2 : 1;
6312
          else throw new RuntimeException("Internal Error: Illegal type: "+this.type);
6313
          int otherlength;
6314
          if (tok.type == STRING)  otherlength = tok.getString().length();
6315
          else if (tok.type == CHAR)  otherlength = tok.getChar() >= 0x10000 ? 2 : 1;
6316
          else throw new RuntimeException("Internal Error: Illegal type: "+tok.type);
6317
          */
6318
          int mylength;
6319
          if (this.type == STRING)  mylength = this.getString().length();
6320
          else throw new RuntimeException("Internal Error: Illegal type: "+this.type);
6321
          int otherlength;
6322
          if (tok.type == STRING)  otherlength = tok.getString().length();
6323
          else throw new RuntimeException("Internal Error: Illegal type: "+tok.type);
6324
          return mylength < otherlength;
6325
      }
6326
6327
      static class FixedStringContainer {
6328
          Token token = null;
6329
          int options = 0;
6330
          FixedStringContainer() {
6331
          }
6332
      }
6333
6334
      final void findFixedString(FixedStringContainer container, int options) {
6335
          switch (this.type) {
6336
            case CONCAT:
6337
              Token prevToken = null;
6338
              int prevOptions = 0;
6339
              for (int i = 0;  i < this.size();  i ++) {
6340
                  this.getChild(i).findFixedString(container, options);
6341
                  if (prevToken == null || prevToken.isShorterThan(container.token)) {
6342
                      prevToken = container.token;
6343
                      prevOptions = container.options;
6344
                  }
6345
              }
6346
              container.token = prevToken;
6347
              container.options = prevOptions;
6348
              return;
6349
6350
            case UNION:
6351
            case CLOSURE:
6352
            case NONGREEDYCLOSURE:
6353
            case EMPTY:
6354
            case ANCHOR:
6355
            case RANGE:
6356
            case DOT:
6357
            case NRANGE:
6358
            case BACKREFERENCE:
6359
            case LOOKAHEAD:
6360
            case NEGATIVELOOKAHEAD:
6361
            case LOOKBEHIND:
6362
            case NEGATIVELOOKBEHIND:
6363
            case CONDITION:
6364
              container.token = null;
6365
              return;
6366
6367
            case CHAR:                            // Ignore CHAR tokens.
6368
              container.token = null;             // **
6369
              return;                             // **
6370
6371
            case STRING:
6372
              container.token = this;
6373
              container.options = options;
6374
              return;
6375
6376
            case INDEPENDENT:
6377
            case PAREN:
6378
              this.getChild(0).findFixedString(container, options);
6379
              return;
6380
6381
            case MODIFIERGROUP:
6382
              options |= ((ModifierToken)this).getOptions();
6383
              options &= ~((ModifierToken)this).getOptionsMask();
6384
              this.getChild(0).findFixedString(container, options);
6385
              return;
6386
6387
            default:
6388
              throw new RuntimeException("Token#findFixedString(): Invalid Type: "+this.type);
6389
          }
6390
      }
6391
6392
      boolean match(int ch) {
6393
          throw new RuntimeException("NFAArrow#match(): Internal error: "+this.type);
6394
      }
6395
6396
      // ------------------------------------------------------
6397
      private final static Hashtable categories = new Hashtable();
6398
      private final static Hashtable categories2 = new Hashtable();
6399
      private static final String[] categoryNames = {
6400
          "Cn", "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Me", "Mc", "Nd",
6401
          "Nl", "No", "Zs", "Zl", "Zp", "Cc", "Cf", null, "Co", "Cs",
6402
          "Pd", "Ps", "Pe", "Pc", "Po", "Sm", "Sc", "Sk", "So", // 28
6403
          "Pi", "Pf",  // 29, 30
6404
          "L", "M", "N", "Z", "C", "P", "S",      // 31-37
6405
      };
6406
6407
      // Schema Rec. {Datatypes} - Punctuation 
6408
      static final int CHAR_INIT_QUOTE  = 29;     // Pi - initial quote
6409
      static final int CHAR_FINAL_QUOTE = 30;     // Pf - final quote
6410
      static final int CHAR_LETTER = 31;
6411
      static final int CHAR_MARK = 32;
6412
      static final int CHAR_NUMBER = 33;
6413
      static final int CHAR_SEPARATOR = 34;
6414
      static final int CHAR_OTHER = 35;
6415
      static final int CHAR_PUNCTUATION = 36;
6416
      static final int CHAR_SYMBOL = 37;
6417
      
6418
      //blockNames in UNICODE 3.1 that supported by XML Schema REC             
6419
      private static final String[] blockNames = {
6420
          /*0000..007F;*/ "Basic Latin",
6421
          /*0080..00FF;*/ "Latin-1 Supplement",
6422
          /*0100..017F;*/ "Latin Extended-A",
6423
          /*0180..024F;*/ "Latin Extended-B",
6424
          /*0250..02AF;*/ "IPA Extensions",
6425
          /*02B0..02FF;*/ "Spacing Modifier Letters",
6426
          /*0300..036F;*/ "Combining Diacritical Marks",
6427
          /*0370..03FF;*/ "Greek",
6428
          /*0400..04FF;*/ "Cyrillic",
6429
          /*0530..058F;*/ "Armenian",
6430
          /*0590..05FF;*/ "Hebrew",
6431
          /*0600..06FF;*/ "Arabic",
6432
          /*0700..074F;*/ "Syriac",  
6433
          /*0780..07BF;*/ "Thaana",
6434
          /*0900..097F;*/ "Devanagari",
6435
          /*0980..09FF;*/ "Bengali",
6436
          /*0A00..0A7F;*/ "Gurmukhi",
6437
          /*0A80..0AFF;*/ "Gujarati",
6438
          /*0B00..0B7F;*/ "Oriya",
6439
          /*0B80..0BFF;*/ "Tamil",
6440
          /*0C00..0C7F;*/ "Telugu",
6441
          /*0C80..0CFF;*/ "Kannada",
6442
          /*0D00..0D7F;*/ "Malayalam",
6443
          /*0D80..0DFF;*/ "Sinhala",
6444
          /*0E00..0E7F;*/ "Thai",
6445
          /*0E80..0EFF;*/ "Lao",
6446
          /*0F00..0FFF;*/ "Tibetan",
6447
          /*1000..109F;*/ "Myanmar", 
6448
          /*10A0..10FF;*/ "Georgian",
6449
          /*1100..11FF;*/ "Hangul Jamo",
6450
          /*1200..137F;*/ "Ethiopic",
6451
          /*13A0..13FF;*/ "Cherokee",
6452
          /*1400..167F;*/ "Unified Canadian Aboriginal Syllabics",
6453
          /*1680..169F;*/ "Ogham",
6454
          /*16A0..16FF;*/ "Runic",
6455
          /*1780..17FF;*/ "Khmer",
6456
          /*1800..18AF;*/ "Mongolian",
6457
          /*1E00..1EFF;*/ "Latin Extended Additional",
6458
          /*1F00..1FFF;*/ "Greek Extended",
6459
          /*2000..206F;*/ "General Punctuation",
6460
          /*2070..209F;*/ "Superscripts and Subscripts",
6461
          /*20A0..20CF;*/ "Currency Symbols",
6462
          /*20D0..20FF;*/ "Combining Marks for Symbols",
6463
          /*2100..214F;*/ "Letterlike Symbols",
6464
          /*2150..218F;*/ "Number Forms",
6465
          /*2190..21FF;*/ "Arrows",
6466
          /*2200..22FF;*/ "Mathematical Operators",
6467
          /*2300..23FF;*/ "Miscellaneous Technical",
6468
          /*2400..243F;*/ "Control Pictures",
6469
          /*2440..245F;*/ "Optical Character Recognition",
6470
          /*2460..24FF;*/ "Enclosed Alphanumerics",
6471
          /*2500..257F;*/ "Box Drawing",
6472
          /*2580..259F;*/ "Block Elements",
6473
          /*25A0..25FF;*/ "Geometric Shapes",
6474
          /*2600..26FF;*/ "Miscellaneous Symbols",
6475
          /*2700..27BF;*/ "Dingbats",
6476
          /*2800..28FF;*/ "Braille Patterns",
6477
          /*2E80..2EFF;*/ "CJK Radicals Supplement",
6478
          /*2F00..2FDF;*/ "Kangxi Radicals",
6479
          /*2FF0..2FFF;*/ "Ideographic Description Characters",
6480
          /*3000..303F;*/ "CJK Symbols and Punctuation",
6481
          /*3040..309F;*/ "Hiragana",
6482
          /*30A0..30FF;*/ "Katakana",
6483
          /*3100..312F;*/ "Bopomofo",
6484
          /*3130..318F;*/ "Hangul Compatibility Jamo",
6485
          /*3190..319F;*/ "Kanbun",
6486
          /*31A0..31BF;*/ "Bopomofo Extended",
6487
          /*3200..32FF;*/ "Enclosed CJK Letters and Months",
6488
          /*3300..33FF;*/ "CJK Compatibility",
6489
          /*3400..4DB5;*/ "CJK Unified Ideographs Extension A",
6490
          /*4E00..9FFF;*/ "CJK Unified Ideographs",
6491
          /*A000..A48F;*/ "Yi Syllables",
6492
          /*A490..A4CF;*/ "Yi Radicals",
6493
          /*AC00..D7A3;*/ "Hangul Syllables",
6494
          /*E000..F8FF;*/ "Private Use",
6495
          /*F900..FAFF;*/ "CJK Compatibility Ideographs",
6496
          /*FB00..FB4F;*/ "Alphabetic Presentation Forms",
6497
          /*FB50..FDFF;*/ "Arabic Presentation Forms-A",
6498
          /*FE20..FE2F;*/ "Combining Half Marks",
6499
          /*FE30..FE4F;*/ "CJK Compatibility Forms",
6500
          /*FE50..FE6F;*/ "Small Form Variants",
6501
          /*FE70..FEFE;*/ "Arabic Presentation Forms-B",
6502
          /*FEFF..FEFF;*/ "Specials",
6503
          /*FF00..FFEF;*/ "Halfwidth and Fullwidth Forms",
6504
           //missing Specials add manually
6505
          /*10300..1032F;*/ "Old Italic",   // 84
6506
          /*10330..1034F;*/ "Gothic",
6507
          /*10400..1044F;*/ "Deseret",
6508
          /*1D000..1D0FF;*/ "Byzantine Musical Symbols",
6509
          /*1D100..1D1FF;*/ "Musical Symbols",
6510
          /*1D400..1D7FF;*/ "Mathematical Alphanumeric Symbols",
6511
          /*20000..2A6D6;*/ "CJK Unified Ideographs Extension B",
6512
          /*2F800..2FA1F;*/ "CJK Compatibility Ideographs Supplement",
6513
          /*E0000..E007F;*/ "Tags",
6514
          //missing 2 private use add manually
6515
6516
      };
6517
      //ADD THOSE MANUALLY
6518
      //F0000..FFFFD; "Private Use",
6519
      //100000..10FFFD; "Private Use"
6520
      //FFF0..FFFD; "Specials", 
6521
      static final String blockRanges = 
6522
         "\u0000\u007F\u0080\u00FF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F"
6523
          +"\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF"
6524
          +"\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF"
6525
          +"\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF"
6526
          +"\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF"
6527
          +"\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF"
6528
          +"\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF"
6529
          +"\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F"
6530
          +"\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF"
6531
          +"\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF"
6532
          +"\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF";
6533
      static final int[] nonBMPBlockRanges = {
6534
          0x10300, 0x1032F,       // 84
6535
          0x10330, 0x1034F,
6536
          0x10400, 0x1044F,
6537
          0x1D000, 0x1D0FF,
6538
          0x1D100, 0x1D1FF,
6539
          0x1D400, 0x1D7FF,
6540
          0x20000, 0x2A6D6,
6541
          0x2F800, 0x2FA1F,
6542
          0xE0000, 0xE007F
6543
      };
6544
      private static final int NONBMP_BLOCK_START = 84;
6545
6546
      static protected RangeToken getRange(String name, boolean positive) {
6547
          if (Token.categories.size() == 0) {
6548
              synchronized (Token.categories) {
6549
                  Token[] ranges = new Token[Token.categoryNames.length];
6550
                  for (int i = 0;  i < ranges.length;  i ++) {
6551
                      ranges[i] = Token.createRange();
6552
                  }
6553
                  int type;
6554
                  for (int i = 0;  i < 0x10000;  i ++) {
6555
                      type = Character.getType((char)i);
6556
                      if (type == Character.START_PUNCTUATION || 
6557
                          type == Character.END_PUNCTUATION) {
6558
                          //build table of Pi values
6559
                          if (i == 0x00AB || i == 0x2018 || i == 0x201B || i == 0x201C ||
6560
                              i == 0x201F || i == 0x2039) {
6561
                              type = CHAR_INIT_QUOTE;
6562
                          }
6563
                          //build table of Pf values
6564
                          if (i == 0x00BB || i == 0x2019 || i == 0x201D || i == 0x203A ) {
6565
                              type = CHAR_FINAL_QUOTE;
6566
                          }
6567
                      }
6568
                      ranges[type].addRange(i, i);
6569
                      switch (type) {
6570
                        case Character.UPPERCASE_LETTER:
6571
                        case Character.LOWERCASE_LETTER:
6572
                        case Character.TITLECASE_LETTER:
6573
                        case Character.MODIFIER_LETTER:
6574
                        case Character.OTHER_LETTER:
6575
                          type = CHAR_LETTER;
6576
                          break;
6577
                        case Character.NON_SPACING_MARK:
6578
                        case Character.COMBINING_SPACING_MARK:
6579
                        case Character.ENCLOSING_MARK:
6580
                          type = CHAR_MARK;
6581
                          break;
6582
                        case Character.DECIMAL_DIGIT_NUMBER:
6583
                        case Character.LETTER_NUMBER:
6584
                        case Character.OTHER_NUMBER:
6585
                          type = CHAR_NUMBER;
6586
                          break;
6587
                        case Character.SPACE_SEPARATOR:
6588
                        case Character.LINE_SEPARATOR:
6589
                        case Character.PARAGRAPH_SEPARATOR:
6590
                          type = CHAR_SEPARATOR;
6591
                          break;
6592
                        case Character.CONTROL:
6593
                        case Character.FORMAT:
6594
                        case Character.SURROGATE:
6595
                        case Character.PRIVATE_USE:
6596
                        case Character.UNASSIGNED:
6597
                          type = CHAR_OTHER;
6598
                          break;
6599
                        case Character.CONNECTOR_PUNCTUATION:
6600
                        case Character.DASH_PUNCTUATION:
6601
                        case Character.START_PUNCTUATION:
6602
                        case Character.END_PUNCTUATION:
6603
                        case CHAR_INIT_QUOTE:
6604
                        case CHAR_FINAL_QUOTE:
6605
                        case Character.OTHER_PUNCTUATION:
6606
                          type = CHAR_PUNCTUATION;
6607
                          break;
6608
                        case Character.MATH_SYMBOL:
6609
                        case Character.CURRENCY_SYMBOL:
6610
                        case Character.MODIFIER_SYMBOL:
6611
                        case Character.OTHER_SYMBOL:
6612
                          type = CHAR_SYMBOL;
6613
                          break;
6614
                        default:
6615
                          throw new RuntimeException("org.apache.xerces.utils.regex.Token#getRange(): Unknown Unicode category: "+type);
6616
                      }
6617
                      ranges[type].addRange(i, i);
6618
                  } // for all characters
6619
                  ranges[Character.UNASSIGNED].addRange(0x10000, Token.UTF16_MAX);
6620
6621
                  for (int i = 0;  i < ranges.length;  i ++) {
6622
                      if (Token.categoryNames[i] != null) {
6623
                          if (i == Character.UNASSIGNED) { // Unassigned
6624
                              ranges[i].addRange(0x10000, Token.UTF16_MAX);
6625
                          }
6626
                          Token.categories.put(Token.categoryNames[i], ranges[i]);
6627
                          Token.categories2.put(Token.categoryNames[i],
6628
                                                Token.complementRanges(ranges[i]));
6629
                      }
6630
                  }
6631
                  //REVISIT: do we really need to support block names as in Unicode 3.1
6632
                  //         or we can just create all the names in IsBLOCKNAME format (XML Schema REC)?
6633
                  //
6634
                  StringBuffer buffer = new StringBuffer(50);
6635
                  for (int i = 0;  i < Token.blockNames.length;  i ++) {
6636
                      Token r1 = Token.createRange();
6637
                      int location;
6638
                      if (i < NONBMP_BLOCK_START) {
6639
                          location = i*2;
6640
                          int rstart = Token.blockRanges.charAt(location);
6641
                          int rend = Token.blockRanges.charAt(location+1);
6642
                          //DEBUGING
6643
                          //System.out.println(n+" " +Integer.toHexString(rstart)
6644
                          //                     +"-"+ Integer.toHexString(rend));
6645
                          r1.addRange(rstart, rend);
6646
                      } else {
6647
                          location = (i - NONBMP_BLOCK_START) * 2;
6648
                          r1.addRange(Token.nonBMPBlockRanges[location],
6649
                                      Token.nonBMPBlockRanges[location + 1]);
6650
                      }
6651
                      String n = Token.blockNames[i];
6652
                      if (n.equals("Specials"))
6653
                          r1.addRange(0xfff0, 0xfffd);
6654
                      if (n.equals("Private Use")) {
6655
                          r1.addRange(0xF0000,0xFFFFD);
6656
                          r1.addRange(0x100000,0x10FFFD);
6657
                      }
6658
                      Token.categories.put(n, r1);
6659
                      Token.categories2.put(n, Token.complementRanges(r1));
6660
                      buffer.setLength(0);
6661
                      buffer.append("Is");
6662
                      if (n.indexOf(' ') >= 0) {
6663
                          for (int ci = 0;  ci < n.length();  ci ++)
6664
                              if (n.charAt(ci) != ' ')  buffer.append(n.charAt(ci));
6665
                      }
6666
                      else {
6667
                          buffer.append(n);
6668
                      }
6669
                      Token.setAlias(buffer.toString(), n, true);
6670
                  }
6671
6672
                  // TR#18 1.2
6673
                  Token.setAlias("ASSIGNED", "Cn", false);
6674
                  Token.setAlias("UNASSIGNED", "Cn", true);
6675
                  Token all = Token.createRange();
6676
                  all.addRange(0, Token.UTF16_MAX);
6677
                  Token.categories.put("ALL", all);
6678
                  Token.categories2.put("ALL", Token.complementRanges(all));
6679
                  Token.registerNonXS("ASSIGNED");
6680
                  Token.registerNonXS("UNASSIGNED");
6681
                  Token.registerNonXS("ALL");
6682
6683
                  Token isalpha = Token.createRange();
6684
                  isalpha.mergeRanges(ranges[Character.UPPERCASE_LETTER]); // Lu
6685
                  isalpha.mergeRanges(ranges[Character.LOWERCASE_LETTER]); // Ll
6686
                  isalpha.mergeRanges(ranges[Character.OTHER_LETTER]); // Lo
6687
                  Token.categories.put("IsAlpha", isalpha);
6688
                  Token.categories2.put("IsAlpha", Token.complementRanges(isalpha));
6689
                  Token.registerNonXS("IsAlpha");
6690
6691
                  Token isalnum = Token.createRange();
6692
                  isalnum.mergeRanges(isalpha);   // Lu Ll Lo
6693
                  isalnum.mergeRanges(ranges[Character.DECIMAL_DIGIT_NUMBER]); // Nd
6694
                  Token.categories.put("IsAlnum", isalnum);
6695
                  Token.categories2.put("IsAlnum", Token.complementRanges(isalnum));
6696
                  Token.registerNonXS("IsAlnum");
6697
6698
                  Token isspace = Token.createRange();
6699
                  isspace.mergeRanges(Token.token_spaces);
6700
                  isspace.mergeRanges(ranges[CHAR_SEPARATOR]); // Z
6701
                  Token.categories.put("IsSpace", isspace);
6702
                  Token.categories2.put("IsSpace", Token.complementRanges(isspace));
6703
                  Token.registerNonXS("IsSpace");
6704
6705
                  Token isword = Token.createRange();
6706
                  isword.mergeRanges(isalnum);     // Lu Ll Lo Nd
6707
                  isword.addRange('_', '_');
6708
                  Token.categories.put("IsWord", isword);
6709
                  Token.categories2.put("IsWord", Token.complementRanges(isword));
6710
                  Token.registerNonXS("IsWord");
6711
6712
                  Token isascii = Token.createRange();
6713
                  isascii.addRange(0, 127);
6714
                  Token.categories.put("IsASCII", isascii);
6715
                  Token.categories2.put("IsASCII", Token.complementRanges(isascii));
6716
                  Token.registerNonXS("IsASCII");
6717
6718
                  Token isnotgraph = Token.createRange();
6719
                  isnotgraph.mergeRanges(ranges[CHAR_OTHER]);
6720
                  isnotgraph.addRange(' ', ' ');
6721
                  Token.categories.put("IsGraph", Token.complementRanges(isnotgraph));
6722
                  Token.categories2.put("IsGraph", isnotgraph);
6723
                  Token.registerNonXS("IsGraph");
6724
6725
                  Token isxdigit = Token.createRange();
6726
                  isxdigit.addRange('0', '9');
6727
                  isxdigit.addRange('A', 'F');
6728
                  isxdigit.addRange('a', 'f');
6729
                  Token.categories.put("IsXDigit", Token.complementRanges(isxdigit));
6730
                  Token.categories2.put("IsXDigit", isxdigit);
6731
                  Token.registerNonXS("IsXDigit");
6732
6733
                  Token.setAlias("IsDigit", "Nd", true);
6734
                  Token.setAlias("IsUpper", "Lu", true);
6735
                  Token.setAlias("IsLower", "Ll", true);
6736
                  Token.setAlias("IsCntrl", "C", true);
6737
                  Token.setAlias("IsPrint", "C", false);
6738
                  Token.setAlias("IsPunct", "P", true);
6739
                  Token.registerNonXS("IsDigit");
6740
                  Token.registerNonXS("IsUpper");
6741
                  Token.registerNonXS("IsLower");
6742
                  Token.registerNonXS("IsCntrl");
6743
                  Token.registerNonXS("IsPrint");
6744
                  Token.registerNonXS("IsPunct");
6745
6746
                  Token.setAlias("alpha", "IsAlpha", true);
6747
                  Token.setAlias("alnum", "IsAlnum", true);
6748
                  Token.setAlias("ascii", "IsASCII", true);
6749
                  Token.setAlias("cntrl", "IsCntrl", true);
6750
                  Token.setAlias("digit", "IsDigit", true);
6751
                  Token.setAlias("graph", "IsGraph", true);
6752
                  Token.setAlias("lower", "IsLower", true);
6753
                  Token.setAlias("print", "IsPrint", true);
6754
                  Token.setAlias("punct", "IsPunct", true);
6755
                  Token.setAlias("space", "IsSpace", true);
6756
                  Token.setAlias("upper", "IsUpper", true);
6757
                  Token.setAlias("word", "IsWord", true); // Perl extension
6758
                  Token.setAlias("xdigit", "IsXDigit", true);
6759
                  Token.registerNonXS("alpha");
6760
                  Token.registerNonXS("alnum");
6761
                  Token.registerNonXS("ascii");
6762
                  Token.registerNonXS("cntrl");
6763
                  Token.registerNonXS("digit");
6764
                  Token.registerNonXS("graph");
6765
                  Token.registerNonXS("lower");
6766
                  Token.registerNonXS("print");
6767
                  Token.registerNonXS("punct");
6768
                  Token.registerNonXS("space");
6769
                  Token.registerNonXS("upper");
6770
                  Token.registerNonXS("word");
6771
                  Token.registerNonXS("xdigit");
6772
              } // synchronized
6773
          } // if null
6774
          RangeToken tok = positive ? (RangeToken)Token.categories.get(name)
6775
              : (RangeToken)Token.categories2.get(name);
6776
          //if (tok == null) System.out.println(name);
6777
          return tok;
6778
      }
6779
      static protected RangeToken getRange(String name, boolean positive, boolean xs) {
6780
          RangeToken range = Token.getRange(name, positive);
6781
          if (xs && range != null && Token.isRegisterNonXS(name))
6782
              range = null;
6783
          return range;
6784
      }
6785
6786
      static Hashtable nonxs = null;
6787
      /**
6788
       * This method is called by only getRange().
6789
       * So this method need not MT-safe.
6790
       */
6791
      static protected void registerNonXS(String name) {
6792
          if (Token.nonxs == null)
6793
              Token.nonxs = new Hashtable();
6794
          Token.nonxs.put(name, name);
6795
      }
6796
      static protected boolean isRegisterNonXS(String name) {
6797
          if (Token.nonxs == null)
6798
              return false;
6799
          //DEBUG
6800
          //System.err.println("isRegisterNonXS: "+name);
6801
          return Token.nonxs.containsKey(name);
6802
      }
6803
6804
      private static void setAlias(String newName, String name, boolean positive) {
6805
          Token t1 = (Token)Token.categories.get(name);
6806
          Token t2 = (Token)Token.categories2.get(name);
6807
          if (positive) {
6808
              Token.categories.put(newName, t1);
6809
              Token.categories2.put(newName, t2);
6810
          } else {
6811
              Token.categories2.put(newName, t1);
6812
              Token.categories.put(newName, t2);
6813
          }
6814
      }
6815
6816
      // ------------------------------------------------------
6817
6818
      static final String viramaString =
6819
      "\u094D"// ;DEVANAGARI SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6820
      +"\u09CD"//;BENGALI SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6821
      +"\u0A4D"//;GURMUKHI SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6822
      +"\u0ACD"//;GUJARATI SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6823
      +"\u0B4D"//;ORIYA SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6824
      +"\u0BCD"//;TAMIL SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6825
      +"\u0C4D"//;TELUGU SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6826
      +"\u0CCD"//;KANNADA SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6827
      +"\u0D4D"//;MALAYALAM SIGN VIRAMA;Mn;9;ON;;;;;N;;;;;
6828
      +"\u0E3A"//;THAI CHARACTER PHINTHU;Mn;9;ON;;;;;N;THAI VOWEL SIGN PHINTHU;;;;
6829
      +"\u0F84";//;TIBETAN MARK HALANTA;Mn;9;ON;;;;;N;TIBETAN VIRAMA;;;;
6830
6831
      static private Token token_grapheme = null;
6832
      static synchronized Token getGraphemePattern() {
6833
          if (Token.token_grapheme != null)
6834
              return Token.token_grapheme;
6835
6836
          Token base_char = Token.createRange();  // [{ASSIGNED}]-[{M},{C}]
6837
          base_char.mergeRanges(Token.getRange("ASSIGNED", true));
6838
          base_char.subtractRanges(Token.getRange("M", true));
6839
          base_char.subtractRanges(Token.getRange("C", true));
6840
6841
          Token virama = Token.createRange();
6842
          for (int i = 0;  i < Token.viramaString.length();  i ++) {
6843
              virama.addRange(i, i);
6844
          }
6845
6846
          Token combiner_wo_virama = Token.createRange();
6847
          combiner_wo_virama.mergeRanges(Token.getRange("M", true));
6848
          combiner_wo_virama.addRange(0x1160, 0x11ff); // hangul_medial and hangul_final
6849
          combiner_wo_virama.addRange(0xff9e, 0xff9f); // extras
6850
6851
          Token left = Token.createUnion();       // base_char?
6852
          left.addChild(base_char);
6853
          left.addChild(Token.token_empty);
6854
6855
          Token foo = Token.createUnion();
6856
          foo.addChild(Token.createConcat(virama, Token.getRange("L", true)));
6857
          foo.addChild(combiner_wo_virama);
6858
6859
          foo = Token.createClosure(foo);
6860
6861
          foo = Token.createConcat(left, foo);
6862
6863
          Token.token_grapheme = foo;
6864
          return Token.token_grapheme;
6865
      }
6866
6867
      /**
6868
       * Combing Character Sequence in Perl 5.6.
6869
       */
6870
      static private Token token_ccs = null;
6871
      static synchronized Token getCombiningCharacterSequence() {
6872
          if (Token.token_ccs != null)
6873
              return Token.token_ccs;
6874
6875
          Token foo = Token.createClosure(Token.getRange("M", true)); // \pM*
6876
          foo = Token.createConcat(Token.getRange("M", false), foo); // \PM + \pM*
6877
          Token.token_ccs = foo;
6878
          return Token.token_ccs;
6879
      }
6880
6881
      // ------------------------------------------------------
6882
6883
      // ------------------------------------------------------
6884
      /**
6885
       * This class represents a node in parse tree.
6886
       */
6887
      static class StringToken extends Token implements java.io.Serializable {
6888
          String string;
6889
          int refNumber;
6890
6891
          StringToken(int type, String str, int n) {
6892
              super(type);
6893
              this.string = str;
6894
              this.refNumber = n;
6895
          }
6896
6897
          int getReferenceNumber() {              // for STRING
6898
              return this.refNumber;
6899
          }
6900
          String getString() {                    // for STRING
6901
              return this.string;
6902
          }
6903
          
6904
          public String toString(int options) {
6905
              if (this.type == BACKREFERENCE)
6906
                  return "\\"+this.refNumber;
6907
              else
6908
                  return REUtil.quoteMeta(this.string);
6909
          }
6910
      }
6911
6912
      /**
6913
       * This class represents a node in parse tree.
6914
       */
6915
      static class ConcatToken extends Token implements java.io.Serializable {
6916
          Token child;
6917
          Token child2;
6918
          
6919
          ConcatToken(Token t1, Token t2) {
6920
              super(Token.CONCAT);
6921
              this.child = t1;
6922
              this.child2 = t2;
6923
          }
6924
6925
          int size() {
6926
              return 2;
6927
          }
6928
          Token getChild(int index) {
6929
              return index == 0 ? this.child : this.child2;
6930
          }
6931
6932
          public String toString(int options) {
6933
              String ret;
6934
              if (this.child2.type == CLOSURE && this.child2.getChild(0) == this.child) {
6935
                  ret = this.child.toString(options)+"+";
6936
              } else if (this.child2.type == NONGREEDYCLOSURE && this.child2.getChild(0) == this.child) {
6937
                  ret = this.child.toString(options)+"+?";
6938
              } else
6939
                  ret = this.child.toString(options)+this.child2.toString(options);
6940
              return ret;
6941
          }
6942
      }
6943
6944
      /**
6945
       * This class represents a node in parse tree.
6946
       */
6947
      static class CharToken extends Token implements java.io.Serializable {
6948
          int chardata;
6949
6950
          CharToken(int type, int ch) {
6951
              super(type);
6952
              this.chardata = ch;
6953
          }
6954
6955
          int getChar() {
6956
              return this.chardata;
6957
          }
6958
6959
          public String toString(int options) {
6960
              String ret;
6961
              switch (this.type) {
6962
                case CHAR:
6963
                  switch (this.chardata) {
6964
                    case '|':  case '*':  case '+':  case '?':
6965
                    case '(':  case ')':  case '.':  case '[':
6966
                    case '{':  case '\\':
6967
                      ret = "\\"+(char)this.chardata;
6968
                      break;
6969
                    case '\f':  ret = "\\f";  break;
6970
                    case '\n':  ret = "\\n";  break;
6971
                    case '\r':  ret = "\\r";  break;
6972
                    case '\t':  ret = "\\t";  break;
6973
                    case 0x1b:  ret = "\\e";  break;
6974
                      //case 0x0b:  ret = "\\v";  break;
6975
                    default:
6976
                      if (this.chardata >= 0x10000) {
6977
                          String pre = "0"+Integer.toHexString(this.chardata);
6978
                          ret = "\\v"+pre.substring(pre.length()-6, pre.length());
6979
                      } else
6980
                          ret = ""+(char)this.chardata;
6981
                  }
6982
                  break;
6983
6984
                case ANCHOR:
6985
                  if (this == Token.token_linebeginning || this == Token.token_lineend)
6986
                      ret = ""+(char)this.chardata;
6987
                  else 
6988
                      ret = "\\"+(char)this.chardata;
6989
                  break;
6990
6991
                default:
6992
                  ret = null;
6993
              }
6994
              return ret;
6995
          }
6996
6997
          boolean match(int ch) {
6998
              if (this.type == CHAR) {
6999
                  return ch == this.chardata;
7000
              } else
7001
                  throw new RuntimeException("NFAArrow#match(): Internal error: "+this.type);
7002
          }
7003
      }
7004
7005
      /**
7006
       * This class represents a node in parse tree.
7007
       */
7008
      static class ClosureToken extends Token implements java.io.Serializable {
7009
          int min;
7010
          int max;
7011
          Token child;
7012
7013
          ClosureToken(int type, Token tok) {
7014
              super(type);
7015
              this.child = tok;
7016
              this.setMin(-1);
7017
              this.setMax(-1);
7018
          }
7019
7020
          int size() {
7021
              return 1;
7022
          }
7023
          Token getChild(int index) {
7024
              return this.child;
7025
          }
7026
7027
          final void setMin(int min) {
7028
              this.min = min;
7029
          }
7030
          final void setMax(int max) {
7031
              this.max = max;
7032
          }
7033
          final int getMin() {
7034
              return this.min;
7035
          }
7036
          final int getMax() {
7037
              return this.max;
7038
          }
7039
7040
          public String toString(int options) {
7041
              String ret;
7042
              if (this.type == CLOSURE) {
7043
                  if (this.getMin() < 0 && this.getMax() < 0) {
7044
                      ret = this.child.toString(options)+"*";
7045
                  } else if (this.getMin() == this.getMax()) {
7046
                      ret = this.child.toString(options)+"{"+this.getMin()+"}";
7047
                  } else if (this.getMin() >= 0 && this.getMax() >= 0) {
7048
                      ret = this.child.toString(options)+"{"+this.getMin()+","+this.getMax()+"}";
7049
                  } else if (this.getMin() >= 0 && this.getMax() < 0) {
7050
                      ret = this.child.toString(options)+"{"+this.getMin()+",}";
7051
                  } else
7052
                      throw new RuntimeException("Token#toString(): CLOSURE "
7053
                                                 +this.getMin()+", "+this.getMax());
7054
              } else {
7055
                  if (this.getMin() < 0 && this.getMax() < 0) {
7056
                      ret = this.child.toString(options)+"*?";
7057
                  } else if (this.getMin() == this.getMax()) {
7058
                      ret = this.child.toString(options)+"{"+this.getMin()+"}?";
7059
                  } else if (this.getMin() >= 0 && this.getMax() >= 0) {
7060
                      ret = this.child.toString(options)+"{"+this.getMin()+","+this.getMax()+"}?";
7061
                  } else if (this.getMin() >= 0 && this.getMax() < 0) {
7062
                      ret = this.child.toString(options)+"{"+this.getMin()+",}?";
7063
                  } else
7064
                      throw new RuntimeException("Token#toString(): NONGREEDYCLOSURE "
7065
                                                 + this.getMin() + ", " + this.getMax());
7066
        }
7067
        return ret;
7068
      }
7069
    }
7070
7071
    /**
7072
     * This class represents a node in parse tree.
7073
     */
7074
    static class ParenToken extends Token implements java.io.Serializable
7075
    {
7076
      Token child;
7077
7078
      int parennumber;
7079
7080
      ParenToken(int type, Token tok, int paren)
7081
      {
7082
        super(type);
7083
        this.child = tok;
7084
        this.parennumber = paren;
7085
      }
7086
7087
      int size()
7088
      {
7089
        return 1;
7090
      }
7091
7092
      Token getChild(int index)
7093
      {
7094
        return this.child;
7095
      }
7096
7097
      int getParenNumber()
7098
      {
7099
        return this.parennumber;
7100
      }
7101
7102
      public String toString(int options)
7103
      {
7104
        String ret = null;
7105
        switch (this.type)
7106
        {
7107
          case PAREN:
7108
            if (this.parennumber == 0)
7109
            {
7110
              ret = "(?:" + this.child.toString(options) + ")";
7111
            }
7112
            else
7113
            {
7114
              ret = "(" + this.child.toString(options) + ")";
7115
            }
7116
            break;
7117
7118
          case LOOKAHEAD:
7119
            ret = "(?=" + this.child.toString(options) + ")";
7120
            break;
7121
          case NEGATIVELOOKAHEAD:
7122
            ret = "(?!" + this.child.toString(options) + ")";
7123
            break;
7124
          case LOOKBEHIND:
7125
            ret = "(?<=" + this.child.toString(options) + ")";
7126
            break;
7127
          case NEGATIVELOOKBEHIND:
7128
            ret = "(?<!" + this.child.toString(options) + ")";
7129
            break;
7130
          case INDEPENDENT:
7131
            ret = "(?>" + this.child.toString(options) + ")";
7132
            break;
7133
        }
7134
        return ret;
7135
      }
7136
    }
7137
7138
    /**
7139
     * (?(condition)yes-pattern|no-pattern)
7140
     */
7141
    static class ConditionToken extends Token implements java.io.Serializable
7142
    {
7143
      int refNumber;
7144
7145
      Token condition;
7146
7147
      Token yes;
7148
7149
      Token no;
7150
7151
      ConditionToken(int refno, Token cond, Token yespat, Token nopat)
7152
      {
7153
        super(Token.CONDITION);
7154
        this.refNumber = refno;
7155
        this.condition = cond;
7156
        this.yes = yespat;
7157
        this.no = nopat;
7158
      }
7159
7160
      int size()
7161
      {
7162
        return this.no == null ? 1 : 2;
7163
      }
7164
7165
      Token getChild(int index)
7166
      {
7167
        if (index == 0)
7168
          return this.yes;
7169
        if (index == 1)
7170
          return this.no;
7171
        throw new RuntimeException("Internal Error: " + index);
7172
      }
7173
7174
      public String toString(int options)
7175
      {
7176
        String ret;
7177
        if (refNumber > 0)
7178
        {
7179
          ret = "(?(" + refNumber + ")";
7180
        }
7181
        else if (this.condition.type == Token.ANCHOR)
7182
        {
7183
          ret = "(?(" + this.condition + ")";
7184
        }
7185
        else
7186
        {
7187
          ret = "(?" + this.condition;
7188
        }
7189
7190
        if (this.no == null)
7191
        {
7192
          ret += this.yes + ")";
7193
        }
7194
        else
7195
        {
7196
          ret += this.yes + "|" + this.no + ")";
7197
        }
7198
        return ret;
7199
      }
7200
    }
7201
7202
    /**
7203
     * (ims-ims: .... )
7204
     */
7205
    static class ModifierToken extends Token implements java.io.Serializable
7206
    {
7207
      Token child;
7208
7209
      int add;
7210
7211
      int mask;
7212
7213
      ModifierToken(Token tok, int add, int mask)
7214
      {
7215
        super(Token.MODIFIERGROUP);
7216
        this.child = tok;
7217
        this.add = add;
7218
        this.mask = mask;
7219
      }
7220
7221
      int size()
7222
      {
7223
        return 1;
7224
      }
7225
7226
      Token getChild(int index)
7227
      {
7228
        return this.child;
7229
      }
7230
7231
      int getOptions()
7232
      {
7233
        return this.add;
7234
      }
7235
7236
      int getOptionsMask()
7237
      {
7238
        return this.mask;
7239
      }
7240
7241
      public String toString(int options)
7242
      {
7243
        return "(?" + (this.add == 0 ? "" : REUtil.createOptionString(this.add))
7244
            + (this.mask == 0 ? "" : REUtil.createOptionString(this.mask)) + ":" + this.child.toString(options) + ")";
7245
      }
7246
    }
7247
7248
    /**
7249
     * This class represents a node in parse tree.
7250
     * for UNION or CONCAT.
7251
     */
7252
    static class UnionToken extends Token implements java.io.Serializable
7253
    {
7254
      Vector children;
7255
7256
      UnionToken(int type)
7257
      {
7258
        super(type);
7259
      }
7260
7261
      void addChild(Token tok)
7262
      {
7263
        if (tok == null)
7264
          return;
7265
        if (this.children == null)
7266
          this.children = new Vector();
7267
        if (this.type == UNION)
7268
        {
7269
          this.children.addElement(tok);
7270
          return;
7271
        }
7272
        // This is CONCAT, and new child is CONCAT.
7273
        if (tok.type == CONCAT)
7274
        {
7275
          for (int i = 0; i < tok.size(); i++)
7276
            this.addChild(tok.getChild(i)); // Recursion
7277
          return;
7278
        }
7279
        int size = this.children.size();
7280
        if (size == 0)
7281
        {
7282
          this.children.addElement(tok);
7283
          return;
7284
        }
7285
        Token previous = (Token)this.children.elementAt(size - 1);
7286
        if (!((previous.type == CHAR || previous.type == STRING) && (tok.type == CHAR || tok.type == STRING)))
7287
        {
7288
          this.children.addElement(tok);
7289
          return;
7290
        }
7291
7292
        //System.err.println("Merge '"+previous+"' and '"+tok+"'.");
7293
7294
        StringBuffer buffer;
7295
        int nextMaxLength = (tok.type == CHAR ? 2 : tok.getString().length());
7296
        if (previous.type == CHAR)
7297
        { // Replace previous token by STRING
7298
          buffer = new StringBuffer(2 + nextMaxLength);
7299
          int ch = previous.getChar();
7300
          if (ch >= 0x10000)
7301
            buffer.append(REUtil.decomposeToSurrogates(ch));
7302
          else
7303
            buffer.append((char)ch);
7304
          previous = Token.createString(null);
7305
          this.children.setElementAt(previous, size - 1);
7306
        }
7307
        else
7308
        { // STRING
7309
          buffer = new StringBuffer(previous.getString().length() + nextMaxLength);
7310
          buffer.append(previous.getString());
7311
        }
7312
7313
        if (tok.type == CHAR)
7314
        {
7315
          int ch = tok.getChar();
7316
          if (ch >= 0x10000)
7317
            buffer.append(REUtil.decomposeToSurrogates(ch));
7318
          else
7319
            buffer.append((char)ch);
7320
        }
7321
        else
7322
        {
7323
          buffer.append(tok.getString());
7324
        }
7325
7326
        ((StringToken)previous).string = new String(buffer);
7327
      }
7328
7329
      int size()
7330
      {
7331
        return this.children == null ? 0 : this.children.size();
7332
      }
7333
7334
      Token getChild(int index)
7335
      {
7336
        return (Token)this.children.elementAt(index);
7337
      }
7338
7339
      public String toString(int options)
7340
      {
7341
        String ret;
7342
        if (this.type == CONCAT)
7343
        {
7344
          if (this.children.size() == 2)
7345
          {
7346
            Token ch = this.getChild(0);
7347
            Token ch2 = this.getChild(1);
7348
            if (ch2.type == CLOSURE && ch2.getChild(0) == ch)
7349
            {
7350
              ret = ch.toString(options) + "+";
7351
            }
7352
            else if (ch2.type == NONGREEDYCLOSURE && ch2.getChild(0) == ch)
7353
            {
7354
              ret = ch.toString(options) + "+?";
7355
            }
7356
            else
7357
              ret = ch.toString(options) + ch2.toString(options);
7358
          }
7359
          else
7360
          {
7361
            StringBuffer sb = new StringBuffer();
7362
            for (int i = 0; i < this.children.size(); i++)
7363
            {
7364
              sb.append(((Token)this.children.elementAt(i)).toString(options));
7365
            }
7366
            ret = new String(sb);
7367
          }
7368
          return ret;
7369
        }
7370
        if (this.children.size() == 2 && this.getChild(1).type == EMPTY)
7371
        {
7372
          ret = this.getChild(0).toString(options) + "?";
7373
        }
7374
        else if (this.children.size() == 2 && this.getChild(0).type == EMPTY)
7375
        {
7376
          ret = this.getChild(1).toString(options) + "??";
7377
        }
7378
        else
7379
        {
7380
          StringBuffer sb = new StringBuffer();
7381
          sb.append(((Token)this.children.elementAt(0)).toString(options));
7382
          for (int i = 1; i < this.children.size(); i++)
7383
          {
7384
            sb.append('|');
7385
            sb.append(((Token)this.children.elementAt(i)).toString(options));
7386
          }
7387
          ret = new String(sb);
7388
        }
7389
        return ret;
7390
      }
7391
    }
7392
  }
7393
7394
  /**
7395
   * A regular expression parser for the XML Shema.
7396
   *
7397
   * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
7398
   * @version $Id: RegEx.java,v 1.8.4.1 2007/08/14 18:18:44 emerks Exp $
7399
   */
7400
  static class ParserForXMLSchema extends RegexParser
7401
  {
7402
7403
    public ParserForXMLSchema()
7404
    {
7405
      //this.setLocale(Locale.getDefault());
7406
    }
7407
7408
    public ParserForXMLSchema(Locale locale)
7409
    {
7410
      //this.setLocale(locale);
7411
    }
7412
7413
    Token processCaret() throws ParseException
7414
    {
7415
      this.next();
7416
      return Token.createChar('^');
7417
    }
7418
7419
    Token processDollar() throws ParseException
7420
    {
7421
      this.next();
7422
      return Token.createChar('$');
7423
    }
7424
7425
    Token processLookahead() throws ParseException
7426
    {
7427
      throw ex("parser.process.1", this.offset);
7428
    }
7429
7430
    Token processNegativelookahead() throws ParseException
7431
    {
7432
      throw ex("parser.process.1", this.offset);
7433
    }
7434
7435
    Token processLookbehind() throws ParseException
7436
    {
7437
      throw ex("parser.process.1", this.offset);
7438
    }
7439
7440
    Token processNegativelookbehind() throws ParseException
7441
    {
7442
      throw ex("parser.process.1", this.offset);
7443
    }
7444
7445
    Token processBacksolidus_A() throws ParseException
7446
    {
7447
      throw ex("parser.process.1", this.offset);
7448
    }
7449
7450
    Token processBacksolidus_Z() throws ParseException
7451
    {
7452
      throw ex("parser.process.1", this.offset);
7453
    }
7454
7455
    Token processBacksolidus_z() throws ParseException
7456
    {
7457
      throw ex("parser.process.1", this.offset);
7458
    }
7459
7460
    Token processBacksolidus_b() throws ParseException
7461
    {
7462
      throw ex("parser.process.1", this.offset);
7463
    }
7464
7465
    Token processBacksolidus_B() throws ParseException
7466
    {
7467
      throw ex("parser.process.1", this.offset);
7468
    }
7469
7470
    Token processBacksolidus_lt() throws ParseException
7471
    {
7472
      throw ex("parser.process.1", this.offset);
7473
    }
7474
7475
    Token processBacksolidus_gt() throws ParseException
7476
    {
7477
      throw ex("parser.process.1", this.offset);
7478
    }
7479
7480
    Token processStar(Token tok) throws ParseException
7481
    {
7482
      this.next();
7483
      return Token.createClosure(tok);
7484
    }
7485
7486
    Token processPlus(Token tok) throws ParseException
7487
    {
7488
      // X+ -> XX*
7489
      this.next();
7490
      return Token.createConcat(tok, Token.createClosure(tok));
7491
    }
7492
7493
    Token processQuestion(Token tok) throws ParseException
7494
    {
7495
      // X? -> X|
7496
      this.next();
7497
      Token par = Token.createUnion();
7498
      par.addChild(tok);
7499
      par.addChild(Token.createEmpty());
7500
      return par;
7501
    }
7502
7503
    boolean checkQuestion(int off)
7504
    {
7505
      return false;
7506
    }
7507
7508
    Token processParen() throws ParseException
7509
    {
7510
      this.next();
7511
      Token tok = Token.createParen(this.parseRegex(), 0);
7512
      if (this.read() != T_RPAREN)
7513
        throw ex("parser.factor.1", this.offset - 1);
7514
      this.next(); // Skips ')'
7515
      return tok;
7516
    }
7517
7518
    Token processParen2() throws ParseException
7519
    {
7520
      throw ex("parser.process.1", this.offset);
7521
    }
7522
7523
    Token processCondition() throws ParseException
7524
    {
7525
      throw ex("parser.process.1", this.offset);
7526
    }
7527
7528
    Token processModifiers() throws ParseException
7529
    {
7530
      throw ex("parser.process.1", this.offset);
7531
    }
7532
7533
    Token processIndependent() throws ParseException
7534
    {
7535
      throw ex("parser.process.1", this.offset);
7536
    }
7537
7538
    Token processBacksolidus_c() throws ParseException
7539
    {
7540
      this.next();
7541
      return this.getTokenForShorthand('c');
7542
    }
7543
7544
    Token processBacksolidus_C() throws ParseException
7545
    {
7546
      this.next();
7547
      return this.getTokenForShorthand('C');
7548
    }
7549
7550
    Token processBacksolidus_i() throws ParseException
7551
    {
7552
      this.next();
7553
      return this.getTokenForShorthand('i');
7554
    }
7555
7556
    Token processBacksolidus_I() throws ParseException
7557
    {
7558
      this.next();
7559
      return this.getTokenForShorthand('I');
7560
    }
7561
7562
    Token processBacksolidus_g() throws ParseException
7563
    {
7564
      throw this.ex("parser.process.1", this.offset - 2);
7565
    }
7566
7567
    Token processBacksolidus_X() throws ParseException
7568
    {
7569
      throw ex("parser.process.1", this.offset - 2);
7570
    }
7571
7572
    Token processBackreference() throws ParseException
7573
    {
7574
      throw ex("parser.process.1", this.offset - 4);
7575
    }
7576
7577
    int processCIinCharacterClass(RangeToken tok, int c)
7578
    {
7579
      tok.mergeRanges(this.getTokenForShorthand(c));
7580
      return -1;
7581
    }
7582
7583
    /**
7584
     * Parses a character-class-expression, not a character-class-escape.
7585
     *
7586
     * c-c-expression   ::= '[' c-group ']'
7587
     * c-group          ::= positive-c-group | negative-c-group | c-c-subtraction
7588
     * positive-c-group ::= (c-range | c-c-escape)+
7589
     * negative-c-group ::= '^' positive-c-group
7590
     * c-c-subtraction  ::= (positive-c-group | negative-c-group) subtraction
7591
     * subtraction      ::= '-' c-c-expression
7592
     * c-range          ::= single-range | from-to-range
7593
     * single-range     ::= multi-c-escape | category-c-escape | block-c-escape | <any XML char>
7594
     * cc-normal-c      ::= <any character except [, ], \>
7595
     * from-to-range    ::= cc-normal-c '-' cc-normal-c
7596
     *
7597
     * @param useNrage Ignored.
7598
     * @return This returns no NrageToken.
7599
     */
7600
    protected RangeToken parseCharacterClass(boolean useNrange) throws ParseException
7601
    {
7602
      this.setContext(S_INBRACKETS);
7603
      this.next(); // '['
7604
      boolean nrange = false;
7605
      RangeToken base = null;
7606
      RangeToken tok;
7607
      if (this.read() == T_CHAR && this.chardata == '^')
7608
      {
7609
        nrange = true;
7610
        this.next(); // '^'
7611
        base = Token.createRange();
7612
        base.addRange(0, Token.UTF16_MAX);
7613
        tok = Token.createRange();
7614
      }
7615
      else
7616
      {
7617
        tok = Token.createRange();
7618
      }
7619
      int type;
7620
      boolean firstloop = true;
7621
      while ((type = this.read()) != T_EOF)
7622
      { // Don't use 'cotinue' for this loop.
7623
        // single-range | from-to-range | subtraction
7624
        if (type == T_CHAR && this.chardata == ']' && !firstloop)
7625
        {
7626
          if (nrange)
7627
          {
7628
            base.subtractRanges(tok);
7629
            tok = base;
7630
          }
7631
          break;
7632
        }
7633
        int c = this.chardata;
7634
        boolean end = false;
7635
        if (type == T_BACKSOLIDUS)
7636
        {
7637
          switch (c)
7638
          {
7639
            case 'd':
7640
            case 'D':
7641
            case 'w':
7642
            case 'W':
7643
            case 's':
7644
            case 'S':
7645
              tok.mergeRanges(this.getTokenForShorthand(c));
7646
              end = true;
7647
              break;
7648
7649
            case 'i':
7650
            case 'I':
7651
            case 'c':
7652
            case 'C':
7653
              c = this.processCIinCharacterClass(tok, c);
7654
              if (c < 0)
7655
                end = true;
7656
              break;
7657
7658
            case 'p':
7659
            case 'P':
7660
              int pstart = this.offset;
7661
              RangeToken tok2 = this.processBacksolidus_pP(c);
7662
              if (tok2 == null)
7663
                throw this.ex("parser.atom.5", pstart);
7664
              tok.mergeRanges(tok2);
7665
              end = true;
7666
              break;
7667
7668
            default:
7669
              c = this.decodeEscaped();
7670
          } // \ + c
7671
        } // backsolidus
7672
        else if (type == T_XMLSCHEMA_CC_SUBTRACTION && !firstloop)
7673
        {
7674
          // Subraction
7675
          if (nrange)
7676
          {
7677
            base.subtractRanges(tok);
7678
            tok = base;
7679
          }
7680
          RangeToken range2 = this.parseCharacterClass(false);
7681
          tok.subtractRanges(range2);
7682
          if (this.read() != T_CHAR || this.chardata != ']')
7683
            throw this.ex("parser.cc.5", this.offset);
7684
          break; // Exit this loop
7685
        }
7686
        this.next();
7687
        if (!end)
7688
        { // if not shorthands...
7689
          if (type == T_CHAR)
7690
          {
7691
            if (c == '[')
7692
              throw this.ex("parser.cc.6", this.offset - 2);
7693
            if (c == ']')
7694
              throw this.ex("parser.cc.7", this.offset - 2);
7695
            if (c == '-' && !firstloop && chardata != ']')
7696
              throw this.ex("parser.cc.8", this.offset - 2);
7697
          }
7698
          if (this.read() != T_CHAR || this.chardata != '-' || c == '-' && firstloop)
7699
          { // Here is no '-'.
7700
            tok.addRange(c, c);
7701
          }
7702
          else
7703
          { // Found '-'
7704
            // Is this '-' is a from-to token??
7705
            this.next(); // Skips '-'
7706
            if ((type = this.read()) == T_EOF)
7707
              throw this.ex("parser.cc.2", this.offset);
7708
            // c '-' ']' -> '-' is a single-range.
7709
            if (type == T_CHAR && this.chardata == ']') 
7710
            { // if - is at the last position of the group
7711
              tok.addRange(c, c);
7712
              tok.addRange('-', '-');
7713
            }
7714
            else if ((type == T_CHAR && this.chardata == ']') || type == T_XMLSCHEMA_CC_SUBTRACTION)
7715
            {
7716
              throw this.ex("parser.cc.8", this.offset - 1);
7717
            }
7718
            else
7719
            {
7720
              int rangeend = this.chardata;
7721
              if (type == T_CHAR)
7722
              {
7723
                if (rangeend == '[')
7724
                  throw this.ex("parser.cc.6", this.offset - 1);
7725
                if (rangeend == ']')
7726
                  throw this.ex("parser.cc.7", this.offset - 1);
7727
                if (rangeend == '-')
7728
                  throw this.ex("parser.cc.8", this.offset - 1);
7729
              }
7730
              else if (type == T_BACKSOLIDUS)
7731
                rangeend = this.decodeEscaped();
7732
              this.next();
7733
7734
              if (c > rangeend)
7735
                throw this.ex("parser.ope.3", this.offset - 1);
7736
              tok.addRange(c, rangeend);
7737
            }
7738
          }
7739
        }
7740
        firstloop = false;
7741
      }
7742
      if (this.read() == T_EOF)
7743
        throw this.ex("parser.cc.2", this.offset);
7744
      tok.sortRanges();
7745
      tok.compactRanges();
7746
      //tok.dumpRanges();
7747
      this.setContext(S_NORMAL);
7748
      this.next(); // Skips ']'
7749
7750
      return tok;
7751
    }
7752
7753
    protected RangeToken parseSetOperations() throws ParseException
7754
    {
7755
      throw this.ex("parser.process.1", this.offset);
7756
    }
7757
7758
    Token getTokenForShorthand(int ch)
7759
    {
7760
      switch (ch)
7761
      {
7762
        case 'd':
7763
          return ParserForXMLSchema.getRange("xml:isDigit", true);
7764
        case 'D':
7765
          return ParserForXMLSchema.getRange("xml:isDigit", false);
7766
        case 'w':
7767
          return ParserForXMLSchema.getRange("xml:isWord", true);
7768
        case 'W':
7769
          return ParserForXMLSchema.getRange("xml:isWord", false);
7770
        case 's':
7771
          return ParserForXMLSchema.getRange("xml:isSpace", true);
7772
        case 'S':
7773
          return ParserForXMLSchema.getRange("xml:isSpace", false);
7774
        case 'c':
7775
          return ParserForXMLSchema.getRange("xml:isNameChar", true);
7776
        case 'C':
7777
          return ParserForXMLSchema.getRange("xml:isNameChar", false);
7778
        case 'i':
7779
          return ParserForXMLSchema.getRange("xml:isInitialNameChar", true);
7780
        case 'I':
7781
          return ParserForXMLSchema.getRange("xml:isInitialNameChar", false);
7782
        default:
7783
          throw new RuntimeException("Internal Error: shorthands: \\u" + Integer.toString(ch, 16));
7784
      }
7785
    }
7786
7787
    int decodeEscaped() throws ParseException
7788
    {
7789
      if (this.read() != T_BACKSOLIDUS)
7790
        throw ex("parser.next.1", this.offset - 1);
7791
      int c = this.chardata;
7792
      switch (c)
7793
      {
7794
        case 'n':
7795
          c = '\n';
7796
          break; // LINE FEED U+000A
7797
        case 'r':
7798
          c = '\r';
7799
          break; // CRRIAGE RETURN U+000D
7800
        case 't':
7801
          c = '\t';
7802
          break; // HORIZONTAL TABULATION U+0009
7803
        case '\\':
7804
        case '|':
7805
        case '.':
7806
        case '^':
7807
        case '-':
7808
        case '?':
7809
        case '*':
7810
        case '+':
7811
        case '{':
7812
        case '}':
7813
        case '(':
7814
        case ')':
7815
        case '[':
7816
        case ']':
7817
          break; // return actucal char
7818
        default:
7819
          throw ex("parser.process.1", this.offset - 2);
7820
      }
7821
      return c;
7822
    }
7823
7824
    static private Hashtable ranges = null;
7825
7826
    static private Hashtable ranges2 = null;
7827
7828
    static synchronized protected RangeToken getRange(String name, boolean positive)
7829
    {
7830
      if (ranges == null)
7831
      {
7832
        ranges = new Hashtable();
7833
        ranges2 = new Hashtable();
7834
7835
        Token tok = Token.createRange();
7836
        setupRange(tok, SPACES);
7837
        ranges.put("xml:isSpace", tok);
7838
        ranges2.put("xml:isSpace", Token.complementRanges(tok));
7839
7840
        tok = Token.createRange();
7841
        setupRange(tok, DIGITS);
7842
        ranges.put("xml:isDigit", tok);
7843
        ranges2.put("xml:isDigit", Token.complementRanges(tok));
7844
7845
        tok = Token.createRange();
7846
        setupRange(tok, DIGITS);
7847
        ranges.put("xml:isDigit", tok);
7848
        ranges2.put("xml:isDigit", Token.complementRanges(tok));
7849
7850
        tok = Token.createRange();
7851
        setupRange(tok, LETTERS);
7852
        tok.mergeRanges((Token)ranges.get("xml:isDigit"));
7853
        ranges.put("xml:isWord", tok);
7854
        ranges2.put("xml:isWord", Token.complementRanges(tok));
7855
7856
        tok = Token.createRange();
7857
        setupRange(tok, NAMECHARS);
7858
        ranges.put("xml:isNameChar", tok);
7859
        ranges2.put("xml:isNameChar", Token.complementRanges(tok));
7860
7861
        tok = Token.createRange();
7862
        setupRange(tok, LETTERS);
7863
        tok.addRange('_', '_');
7864
        tok.addRange(':', ':');
7865
        ranges.put("xml:isInitialNameChar", tok);
7866
        ranges2.put("xml:isInitialNameChar", Token.complementRanges(tok));
7867
      }
7868
      RangeToken tok = positive ? (RangeToken)ranges.get(name) : (RangeToken)ranges2.get(name);
7869
      return tok;
7870
    }
7871
7872
    static void setupRange(Token range, String src)
7873
    {
7874
      int len = src.length();
7875
      for (int i = 0; i < len; i += 2)
7876
        range.addRange(src.charAt(i), src.charAt(i + 1));
7877
    }
7878
7879
    private static final String SPACES = "\t\n\r\r  ";
7880
7881
    private static final String NAMECHARS = "\u002d\u002e\u0030\u003a\u0041\u005a\u005f\u005f\u0061\u007a\u00b7\u00b7\u00c0\u00d6"
7882
        + "\u00d8\u00f6\u00f8\u0131\u0134\u013e\u0141\u0148\u014a\u017e\u0180\u01c3\u01cd\u01f0"
7883
        + "\u01f4\u01f5\u01fa\u0217\u0250\u02a8\u02bb\u02c1\u02d0\u02d1\u0300\u0345\u0360\u0361"
7884
        + "\u0386\u038a\u038c\u038c\u038e\u03a1\u03a3\u03ce\u03d0\u03d6\u03da\u03da\u03dc\u03dc"
7885
        + "\u03de\u03de\u03e0\u03e0\u03e2\u03f3\u0401\u040c\u040e\u044f\u0451\u045c\u045e\u0481"
7886
        + "\u0483\u0486\u0490\u04c4\u04c7\u04c8\u04cb\u04cc\u04d0\u04eb\u04ee\u04f5\u04f8\u04f9"
7887
        + "\u0531\u0556\u0559\u0559\u0561\u0586\u0591\u05a1\u05a3\u05b9\u05bb\u05bd\u05bf\u05bf"
7888
        + "\u05c1\u05c2\u05c4\u05c4\u05d0\u05ea\u05f0\u05f2\u0621\u063a\u0640\u0652\u0660\u0669"
7889
        + "\u0670\u06b7\u06ba\u06be\u06c0\u06ce\u06d0\u06d3\u06d5\u06e8\u06ea\u06ed\u06f0\u06f9"
7890
        + "\u0901\u0903\u0905\u0939\u093c\u094d\u0951\u0954\u0958\u0963\u0966\u096f\u0981\u0983"
7891
        + "\u0985\u098c\u098f\u0990\u0993\u09a8\u09aa\u09b0\u09b2\u09b2\u09b6\u09b9\u09bc\u09bc"
7892
        + "\u09be\u09c4\u09c7\u09c8\u09cb\u09cd\u09d7\u09d7\u09dc\u09dd\u09df\u09e3\u09e6\u09f1"
7893
        + "\u0a02\u0a02\u0a05\u0a0a\u0a0f\u0a10\u0a13\u0a28\u0a2a\u0a30\u0a32\u0a33\u0a35\u0a36"
7894
        + "\u0a38\u0a39\u0a3c\u0a3c\u0a3e\u0a42\u0a47\u0a48\u0a4b\u0a4d\u0a59\u0a5c\u0a5e\u0a5e"
7895
        + "\u0a66\u0a74\u0a81\u0a83\u0a85\u0a8b\u0a8d\u0a8d\u0a8f\u0a91\u0a93\u0aa8\u0aaa\u0ab0"
7896
        + "\u0ab2\u0ab3\u0ab5\u0ab9\u0abc\u0ac5\u0ac7\u0ac9\u0acb\u0acd\u0ae0\u0ae0\u0ae6\u0aef"
7897
        + "\u0b01\u0b03\u0b05\u0b0c\u0b0f\u0b10\u0b13\u0b28\u0b2a\u0b30\u0b32\u0b33\u0b36\u0b39"
7898
        + "\u0b3c\u0b43\u0b47\u0b48\u0b4b\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f\u0b61\u0b66\u0b6f"
7899
        + "\u0b82\u0b83\u0b85\u0b8a\u0b8e\u0b90\u0b92\u0b95\u0b99\u0b9a\u0b9c\u0b9c\u0b9e\u0b9f"
7900
        + "\u0ba3\u0ba4\u0ba8\u0baa\u0bae\u0bb5\u0bb7\u0bb9\u0bbe\u0bc2\u0bc6\u0bc8\u0bca\u0bcd"
7901
        + "\u0bd7\u0bd7\u0be7\u0bef\u0c01\u0c03\u0c05\u0c0c\u0c0e\u0c10\u0c12\u0c28\u0c2a\u0c33"
7902
        + "\u0c35\u0c39\u0c3e\u0c44\u0c46\u0c48\u0c4a\u0c4d\u0c55\u0c56\u0c60\u0c61\u0c66\u0c6f"
7903
        + "\u0c82\u0c83\u0c85\u0c8c\u0c8e\u0c90\u0c92\u0ca8\u0caa\u0cb3\u0cb5\u0cb9\u0cbe\u0cc4"
7904
        + "\u0cc6\u0cc8\u0cca\u0ccd\u0cd5\u0cd6\u0cde\u0cde\u0ce0\u0ce1\u0ce6\u0cef\u0d02\u0d03"
7905
        + "\u0d05\u0d0c\u0d0e\u0d10\u0d12\u0d28\u0d2a\u0d39\u0d3e\u0d43\u0d46\u0d48\u0d4a\u0d4d"
7906
        + "\u0d57\u0d57\u0d60\u0d61\u0d66\u0d6f\u0e01\u0e2e\u0e30\u0e3a\u0e40\u0e4e\u0e50\u0e59"
7907
        + "\u0e81\u0e82\u0e84\u0e84\u0e87\u0e88\u0e8a\u0e8a\u0e8d\u0e8d\u0e94\u0e97\u0e99\u0e9f"
7908
        + "\u0ea1\u0ea3\u0ea5\u0ea5\u0ea7\u0ea7\u0eaa\u0eab\u0ead\u0eae\u0eb0\u0eb9\u0ebb\u0ebd"
7909
        + "\u0ec0\u0ec4\u0ec6\u0ec6\u0ec8\u0ecd\u0ed0\u0ed9\u0f18\u0f19\u0f20\u0f29\u0f35\u0f35"
7910
        + "\u0f37\u0f37\u0f39\u0f39\u0f3e\u0f47\u0f49\u0f69\u0f71\u0f84\u0f86\u0f8b\u0f90\u0f95"
7911
        + "\u0f97\u0f97\u0f99\u0fad\u0fb1\u0fb7\u0fb9\u0fb9\u10a0\u10c5\u10d0\u10f6\u1100\u1100"
7912
        + "\u1102\u1103\u1105\u1107\u1109\u1109\u110b\u110c\u110e\u1112\u113c\u113c\u113e\u113e"
7913
        + "\u1140\u1140\u114c\u114c\u114e\u114e\u1150\u1150\u1154\u1155\u1159\u1159\u115f\u1161"
7914
        + "\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116d\u116e\u1172\u1173\u1175\u1175"
7915
        + "\u119e\u119e\u11a8\u11a8\u11ab\u11ab\u11ae\u11af\u11b7\u11b8\u11ba\u11ba\u11bc\u11c2"
7916
        + "\u11eb\u11eb\u11f0\u11f0\u11f9\u11f9\u1e00\u1e9b\u1ea0\u1ef9\u1f00\u1f15\u1f18\u1f1d"
7917
        + "\u1f20\u1f45\u1f48\u1f4d\u1f50\u1f57\u1f59\u1f59\u1f5b\u1f5b\u1f5d\u1f5d\u1f5f\u1f7d"
7918
        + "\u1f80\u1fb4\u1fb6\u1fbc\u1fbe\u1fbe\u1fc2\u1fc4\u1fc6\u1fcc\u1fd0\u1fd3\u1fd6\u1fdb"
7919
        + "\u1fe0\u1fec\u1ff2\u1ff4\u1ff6\u1ffc\u20d0\u20dc\u20e1\u20e1\u2126\u2126\u212a\u212b"
7920
        + "\u212e\u212e\u2180\u2182\u3005\u3005\u3007\u3007\u3021\u302f\u3031\u3035\u3041\u3094"
7921
        + "\u3099\u309a\u309d\u309e\u30a1\u30fa\u30fc\u30fe\u3105\u312c\u4e00\u9fa5\uac00\ud7a3" + "";
7922
7923
    private static final String LETTERS = "\u0041\u005a\u0061\u007a\u00c0\u00d6\u00d8\u00f6\u00f8\u0131\u0134\u013e\u0141\u0148"
7924
        + "\u014a\u017e\u0180\u01c3\u01cd\u01f0\u01f4\u01f5\u01fa\u0217\u0250\u02a8\u02bb\u02c1"
7925
        + "\u0386\u0386\u0388\u038a\u038c\u038c\u038e\u03a1\u03a3\u03ce\u03d0\u03d6\u03da\u03da"
7926
        + "\u03dc\u03dc\u03de\u03de\u03e0\u03e0\u03e2\u03f3\u0401\u040c\u040e\u044f\u0451\u045c"
7927
        + "\u045e\u0481\u0490\u04c4\u04c7\u04c8\u04cb\u04cc\u04d0\u04eb\u04ee\u04f5\u04f8\u04f9"
7928
        + "\u0531\u0556\u0559\u0559\u0561\u0586\u05d0\u05ea\u05f0\u05f2\u0621\u063a\u0641\u064a"
7929
        + "\u0671\u06b7\u06ba\u06be\u06c0\u06ce\u06d0\u06d3\u06d5\u06d5\u06e5\u06e6\u0905\u0939"
7930
        + "\u093d\u093d\u0958\u0961\u0985\u098c\u098f\u0990\u0993\u09a8\u09aa\u09b0\u09b2\u09b2"
7931
        + "\u09b6\u09b9\u09dc\u09dd\u09df\u09e1\u09f0\u09f1\u0a05\u0a0a\u0a0f\u0a10\u0a13\u0a28"
7932
        + "\u0a2a\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59\u0a5c\u0a5e\u0a5e\u0a72\u0a74"
7933
        + "\u0a85\u0a8b\u0a8d\u0a8d\u0a8f\u0a91\u0a93\u0aa8\u0aaa\u0ab0\u0ab2\u0ab3\u0ab5\u0ab9"
7934
        + "\u0abd\u0abd\u0ae0\u0ae0\u0b05\u0b0c\u0b0f\u0b10\u0b13\u0b28\u0b2a\u0b30\u0b32\u0b33"
7935
        + "\u0b36\u0b39\u0b3d\u0b3d\u0b5c\u0b5d\u0b5f\u0b61\u0b85\u0b8a\u0b8e\u0b90\u0b92\u0b95"
7936
        + "\u0b99\u0b9a\u0b9c\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8\u0baa\u0bae\u0bb5\u0bb7\u0bb9"
7937
        + "\u0c05\u0c0c\u0c0e\u0c10\u0c12\u0c28\u0c2a\u0c33\u0c35\u0c39\u0c60\u0c61\u0c85\u0c8c"
7938
        + "\u0c8e\u0c90\u0c92\u0ca8\u0caa\u0cb3\u0cb5\u0cb9\u0cde\u0cde\u0ce0\u0ce1\u0d05\u0d0c"
7939
        + "\u0d0e\u0d10\u0d12\u0d28\u0d2a\u0d39\u0d60\u0d61\u0e01\u0e2e\u0e30\u0e30\u0e32\u0e33"
7940
        + "\u0e40\u0e45\u0e81\u0e82\u0e84\u0e84\u0e87\u0e88\u0e8a\u0e8a\u0e8d\u0e8d\u0e94\u0e97"
7941
        + "\u0e99\u0e9f\u0ea1\u0ea3\u0ea5\u0ea5\u0ea7\u0ea7\u0eaa\u0eab\u0ead\u0eae\u0eb0\u0eb0"
7942
        + "\u0eb2\u0eb3\u0ebd\u0ebd\u0ec0\u0ec4\u0f40\u0f47\u0f49\u0f69\u10a0\u10c5\u10d0\u10f6"
7943
        + "\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110b\u110c\u110e\u1112\u113c\u113c"
7944
        + "\u113e\u113e\u1140\u1140\u114c\u114c\u114e\u114e\u1150\u1150\u1154\u1155\u1159\u1159"
7945
        + "\u115f\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116d\u116e\u1172\u1173"
7946
        + "\u1175\u1175\u119e\u119e\u11a8\u11a8\u11ab\u11ab\u11ae\u11af\u11b7\u11b8\u11ba\u11ba"
7947
        + "\u11bc\u11c2\u11eb\u11eb\u11f0\u11f0\u11f9\u11f9\u1e00\u1e9b\u1ea0\u1ef9\u1f00\u1f15"
7948
        + "\u1f18\u1f1d\u1f20\u1f45\u1f48\u1f4d\u1f50\u1f57\u1f59\u1f59\u1f5b\u1f5b\u1f5d\u1f5d"
7949
        + "\u1f5f\u1f7d\u1f80\u1fb4\u1fb6\u1fbc\u1fbe\u1fbe\u1fc2\u1fc4\u1fc6\u1fcc\u1fd0\u1fd3"
7950
        + "\u1fd6\u1fdb\u1fe0\u1fec\u1ff2\u1ff4\u1ff6\u1ffc\u2126\u2126\u212a\u212b\u212e\u212e"
7951
        + "\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30a1\u30fa\u3105\u312c\u4e00\u9fa5" + "\uac00\ud7a3";
7952
7953
    private static final String DIGITS = "\u0030\u0039\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF"
7954
        + "\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9" + "\u0F20\u0F29";
7955
  }
7956
7957
}
(-)src/org/eclipse/emf/ecore/xml/type/internal/DataValue.java (-169 / +170 lines)
Lines 74-83 Link Here
74
package org.eclipse.emf.ecore.xml.type.internal;
74
package org.eclipse.emf.ecore.xml.type.internal;
75
75
76
76
77
import java.io.IOException;
77
//import java.io.IOException;
78
import java.io.Serializable;
78
import java.io.Serializable;
79
import java.util.Arrays;
79
import java.util.Arrays;
80
import java.util.Hashtable;
80
import java.util.HashMap;
81
81
82
/**
82
/**
83
 * NOTE: this class is for internal use only.
83
 * NOTE: this class is for internal use only.
Lines 179-185 Link Here
179
  public static String encode(byte[] binaryData) {
179
  public static String encode(byte[] binaryData) {
180
180
181
      // This implementation was changed to not introduce multi line content.
181
      // This implementation was changed to not introduce multi line content.
182
    
182
183
      if (binaryData == null)
183
      if (binaryData == null)
184
          return null;
184
          return null;
185
185
Lines 187-193 Link Here
187
      if (lengthDataBits == 0) {
187
      if (lengthDataBits == 0) {
188
          return "";
188
          return "";
189
      }
189
      }
190
      
190
191
      int      fewerThan24bits   = lengthDataBits%TWENTYFOURBITGROUP;
191
      int      fewerThan24bits   = lengthDataBits%TWENTYFOURBITGROUP;
192
      int      numberTriplets    = lengthDataBits/TWENTYFOURBITGROUP;
192
      int      numberTriplets    = lengthDataBits/TWENTYFOURBITGROUP;
193
      int      numberQuartet     = fewerThan24bits != 0 ? numberTriplets+1 : numberTriplets;
193
      int      numberQuartet     = fewerThan24bits != 0 ? numberTriplets+1 : numberTriplets;
Lines 261-267 Link Here
261
      }
261
      }
262
262
263
      //encodedData[encodedIndex] = 0xa;
263
      //encodedData[encodedIndex] = 0xa;
264
      
264
265
      return new String(encodedData);
265
      return new String(encodedData);
266
  }
266
  }
267
267
Lines 279-285 Link Here
279
      char[] base64Data = encoded.toCharArray();
279
      char[] base64Data = encoded.toCharArray();
280
      // remove white spaces
280
      // remove white spaces
281
      int len = removeWhiteSpace(base64Data);
281
      int len = removeWhiteSpace(base64Data);
282
      
282
283
      if (len%FOURBYTE != 0) {
283
      if (len%FOURBYTE != 0) {
284
          return null;//should be divisible by four
284
          return null;//should be divisible by four
285
      }
285
      }
Lines 361-367 Link Here
361
361
362
  /**
362
  /**
363
   * remove WhiteSpace from MIME containing encoded Base64 data.
363
   * remove WhiteSpace from MIME containing encoded Base64 data.
364
   * 
364
   *
365
   * @param data  the byte array of base64 data (with WS)
365
   * @param data  the byte array of base64 data (with WS)
366
   * @return      the new length
366
   * @return      the new length
367
   */
367
   */
Lines 468-474 Link Here
468
}
468
}
469
469
470
/*
470
/*
471
 * EncodingMap is a convenience class which handles conversions between 
471
 * EncodingMap is a convenience class which handles conversions between
472
 * IANA encoding names and Java encoding names, and vice versa. The
472
 * IANA encoding names and Java encoding names, and vice versa. The
473
 * encoding names used in XML instance documents <strong>must</strong>
473
 * encoding names used in XML instance documents <strong>must</strong>
474
 * be the IANA encoding names specified or one of the aliases for those names
474
 * be the IANA encoding names specified or one of the aliases for those names
Lines 910-916 Link Here
910
 *      </TD>
910
 *      </TD>
911
 *  </TR>
911
 *  </TR>
912
 * </TABLE>
912
 * </TABLE>
913
 * 
913
 *
914
 * @author TAMURA Kent, IBM
914
 * @author TAMURA Kent, IBM
915
 * @author Andy Clark, IBM
915
 * @author Andy Clark, IBM
916
 */
916
 */
Lines 921-930 Link Here
921
    //
921
    //
922
922
923
    /** fIANA2JavaMap */
923
    /** fIANA2JavaMap */
924
    protected final static Hashtable fIANA2JavaMap = new Hashtable();
924
    protected final static HashMap fIANA2JavaMap = new HashMap();
925
925
926
    /** fJava2IANAMap */
926
    /** fJava2IANAMap */
927
    protected final static Hashtable fJava2IANAMap = new Hashtable();
927
    protected final static HashMap fJava2IANAMap = new HashMap();
928
928
929
    //
929
    //
930
    // Static initialization
930
    // Static initialization
Lines 992-998 Link Here
992
        fIANA2JavaMap.put("CP500",    "CP500");
992
        fIANA2JavaMap.put("CP500",    "CP500");
993
        fIANA2JavaMap.put("CSIBM500",    "CP500");
993
        fIANA2JavaMap.put("CSIBM500",    "CP500");
994
        fIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
994
        fIANA2JavaMap.put("EBCDIC-CP-CH",    "CP500");
995
        fIANA2JavaMap.put("EBCDIC-CP-BE",    "CP500"); 
995
        fIANA2JavaMap.put("EBCDIC-CP-BE",    "CP500");
996
        fIANA2JavaMap.put("IBM775",    "CP775");
996
        fIANA2JavaMap.put("IBM775",    "CP775");
997
        fIANA2JavaMap.put("CP775",    "CP775");
997
        fIANA2JavaMap.put("CP775",    "CP775");
998
        fIANA2JavaMap.put("CSPC775BALTIC",    "CP775");
998
        fIANA2JavaMap.put("CSPC775BALTIC",    "CP775");
Lines 1142-1148 Link Here
1142
        fIANA2JavaMap.put("WINDOWS-1258",   "Cp1258");
1142
        fIANA2JavaMap.put("WINDOWS-1258",   "Cp1258");
1143
        fIANA2JavaMap.put("TIS-620",   "TIS620");
1143
        fIANA2JavaMap.put("TIS-620",   "TIS620");
1144
1144
1145
        fIANA2JavaMap.put("ISO-8859-1",      "ISO8859_1"); 
1145
        fIANA2JavaMap.put("ISO-8859-1",      "ISO8859_1");
1146
        fIANA2JavaMap.put("ISO-IR-100",      "ISO8859_1");
1146
        fIANA2JavaMap.put("ISO-IR-100",      "ISO8859_1");
1147
        fIANA2JavaMap.put("ISO_8859-1",      "ISO8859_1");
1147
        fIANA2JavaMap.put("ISO_8859-1",      "ISO8859_1");
1148
        fIANA2JavaMap.put("LATIN1",      "ISO8859_1");
1148
        fIANA2JavaMap.put("LATIN1",      "ISO8859_1");
Lines 1151-1184 Link Here
1151
        fIANA2JavaMap.put("IBM819",      "ISO8859_1");
1151
        fIANA2JavaMap.put("IBM819",      "ISO8859_1");
1152
        fIANA2JavaMap.put("CP819",      "ISO8859_1");
1152
        fIANA2JavaMap.put("CP819",      "ISO8859_1");
1153
1153
1154
        fIANA2JavaMap.put("ISO-8859-2",      "ISO8859_2"); 
1154
        fIANA2JavaMap.put("ISO-8859-2",      "ISO8859_2");
1155
        fIANA2JavaMap.put("ISO-IR-101",      "ISO8859_2");
1155
        fIANA2JavaMap.put("ISO-IR-101",      "ISO8859_2");
1156
        fIANA2JavaMap.put("ISO_8859-2",      "ISO8859_2");
1156
        fIANA2JavaMap.put("ISO_8859-2",      "ISO8859_2");
1157
        fIANA2JavaMap.put("LATIN2",      "ISO8859_2");
1157
        fIANA2JavaMap.put("LATIN2",      "ISO8859_2");
1158
        fIANA2JavaMap.put("CSISOLATIN2",      "ISO8859_2");
1158
        fIANA2JavaMap.put("CSISOLATIN2",      "ISO8859_2");
1159
        fIANA2JavaMap.put("L2",      "ISO8859_2");
1159
        fIANA2JavaMap.put("L2",      "ISO8859_2");
1160
1160
1161
        fIANA2JavaMap.put("ISO-8859-3",      "ISO8859_3"); 
1161
        fIANA2JavaMap.put("ISO-8859-3",      "ISO8859_3");
1162
        fIANA2JavaMap.put("ISO-IR-109",      "ISO8859_3");
1162
        fIANA2JavaMap.put("ISO-IR-109",      "ISO8859_3");
1163
        fIANA2JavaMap.put("ISO_8859-3",      "ISO8859_3");
1163
        fIANA2JavaMap.put("ISO_8859-3",      "ISO8859_3");
1164
        fIANA2JavaMap.put("LATIN3",      "ISO8859_3");
1164
        fIANA2JavaMap.put("LATIN3",      "ISO8859_3");
1165
        fIANA2JavaMap.put("CSISOLATIN3",      "ISO8859_3");
1165
        fIANA2JavaMap.put("CSISOLATIN3",      "ISO8859_3");
1166
        fIANA2JavaMap.put("L3",      "ISO8859_3");
1166
        fIANA2JavaMap.put("L3",      "ISO8859_3");
1167
1167
1168
        fIANA2JavaMap.put("ISO-8859-4",      "ISO8859_4"); 
1168
        fIANA2JavaMap.put("ISO-8859-4",      "ISO8859_4");
1169
        fIANA2JavaMap.put("ISO-IR-110",      "ISO8859_4");
1169
        fIANA2JavaMap.put("ISO-IR-110",      "ISO8859_4");
1170
        fIANA2JavaMap.put("ISO_8859-4",      "ISO8859_4");
1170
        fIANA2JavaMap.put("ISO_8859-4",      "ISO8859_4");
1171
        fIANA2JavaMap.put("LATIN4",      "ISO8859_4");
1171
        fIANA2JavaMap.put("LATIN4",      "ISO8859_4");
1172
        fIANA2JavaMap.put("CSISOLATIN4",      "ISO8859_4");
1172
        fIANA2JavaMap.put("CSISOLATIN4",      "ISO8859_4");
1173
        fIANA2JavaMap.put("L4",      "ISO8859_4");
1173
        fIANA2JavaMap.put("L4",      "ISO8859_4");
1174
1174
1175
        fIANA2JavaMap.put("ISO-8859-5",      "ISO8859_5"); 
1175
        fIANA2JavaMap.put("ISO-8859-5",      "ISO8859_5");
1176
        fIANA2JavaMap.put("ISO-IR-144",      "ISO8859_5");
1176
        fIANA2JavaMap.put("ISO-IR-144",      "ISO8859_5");
1177
        fIANA2JavaMap.put("ISO_8859-5",      "ISO8859_5");
1177
        fIANA2JavaMap.put("ISO_8859-5",      "ISO8859_5");
1178
        fIANA2JavaMap.put("CYRILLIC",      "ISO8859_5");
1178
        fIANA2JavaMap.put("CYRILLIC",      "ISO8859_5");
1179
        fIANA2JavaMap.put("CSISOLATINCYRILLIC",      "ISO8859_5");
1179
        fIANA2JavaMap.put("CSISOLATINCYRILLIC",      "ISO8859_5");
1180
1180
1181
        fIANA2JavaMap.put("ISO-8859-6",      "ISO8859_6"); 
1181
        fIANA2JavaMap.put("ISO-8859-6",      "ISO8859_6");
1182
        fIANA2JavaMap.put("ISO-IR-127",      "ISO8859_6");
1182
        fIANA2JavaMap.put("ISO-IR-127",      "ISO8859_6");
1183
        fIANA2JavaMap.put("ISO_8859-6",      "ISO8859_6");
1183
        fIANA2JavaMap.put("ISO_8859-6",      "ISO8859_6");
1184
        fIANA2JavaMap.put("ECMA-114",      "ISO8859_6");
1184
        fIANA2JavaMap.put("ECMA-114",      "ISO8859_6");
Lines 1186-1192 Link Here
1186
        fIANA2JavaMap.put("ARABIC",      "ISO8859_6");
1186
        fIANA2JavaMap.put("ARABIC",      "ISO8859_6");
1187
        fIANA2JavaMap.put("CSISOLATINARABIC",      "ISO8859_6");
1187
        fIANA2JavaMap.put("CSISOLATINARABIC",      "ISO8859_6");
1188
1188
1189
        fIANA2JavaMap.put("ISO-8859-7",      "ISO8859_7"); 
1189
        fIANA2JavaMap.put("ISO-8859-7",      "ISO8859_7");
1190
        fIANA2JavaMap.put("ISO-IR-126",      "ISO8859_7");
1190
        fIANA2JavaMap.put("ISO-IR-126",      "ISO8859_7");
1191
        fIANA2JavaMap.put("ISO_8859-7",      "ISO8859_7");
1191
        fIANA2JavaMap.put("ISO_8859-7",      "ISO8859_7");
1192
        fIANA2JavaMap.put("ELOT_928",      "ISO8859_7");
1192
        fIANA2JavaMap.put("ELOT_928",      "ISO8859_7");
Lines 1195-1208 Link Here
1195
        fIANA2JavaMap.put("CSISOLATINGREEK",      "ISO8859_7");
1195
        fIANA2JavaMap.put("CSISOLATINGREEK",      "ISO8859_7");
1196
        fIANA2JavaMap.put("GREEK8",      "ISO8859_7");
1196
        fIANA2JavaMap.put("GREEK8",      "ISO8859_7");
1197
1197
1198
        fIANA2JavaMap.put("ISO-8859-8",      "ISO8859_8"); 
1198
        fIANA2JavaMap.put("ISO-8859-8",      "ISO8859_8");
1199
        fIANA2JavaMap.put("ISO-8859-8-I",      "ISO8859_8"); // added since this encoding only differs w.r.t. presentation 
1199
        fIANA2JavaMap.put("ISO-8859-8-I",      "ISO8859_8"); // added since this encoding only differs w.r.t. presentation
1200
        fIANA2JavaMap.put("ISO-IR-138",      "ISO8859_8");
1200
        fIANA2JavaMap.put("ISO-IR-138",      "ISO8859_8");
1201
        fIANA2JavaMap.put("ISO_8859-8",      "ISO8859_8");
1201
        fIANA2JavaMap.put("ISO_8859-8",      "ISO8859_8");
1202
        fIANA2JavaMap.put("HEBREW",      "ISO8859_8");
1202
        fIANA2JavaMap.put("HEBREW",      "ISO8859_8");
1203
        fIANA2JavaMap.put("CSISOLATINHEBREW",      "ISO8859_8");
1203
        fIANA2JavaMap.put("CSISOLATINHEBREW",      "ISO8859_8");
1204
1204
1205
        fIANA2JavaMap.put("ISO-8859-9",      "ISO8859_9"); 
1205
        fIANA2JavaMap.put("ISO-8859-9",      "ISO8859_9");
1206
        fIANA2JavaMap.put("ISO-IR-148",      "ISO8859_9");
1206
        fIANA2JavaMap.put("ISO-IR-148",      "ISO8859_9");
1207
        fIANA2JavaMap.put("ISO_8859-9",      "ISO8859_9");
1207
        fIANA2JavaMap.put("ISO_8859-9",      "ISO8859_9");
1208
        fIANA2JavaMap.put("LATIN5",      "ISO8859_9");
1208
        fIANA2JavaMap.put("LATIN5",      "ISO8859_9");
Lines 1211-1217 Link Here
1211
1211
1212
        fIANA2JavaMap.put("KOI8-R",          "KOI8_R");
1212
        fIANA2JavaMap.put("KOI8-R",          "KOI8_R");
1213
        fIANA2JavaMap.put("CSKOI8R",          "KOI8_R");
1213
        fIANA2JavaMap.put("CSKOI8R",          "KOI8_R");
1214
        fIANA2JavaMap.put("US-ASCII",        "ASCII"); 
1214
        fIANA2JavaMap.put("US-ASCII",        "ASCII");
1215
        fIANA2JavaMap.put("ISO-IR-6",        "ASCII");
1215
        fIANA2JavaMap.put("ISO-IR-6",        "ASCII");
1216
        fIANA2JavaMap.put("ANSI_X3.4-1986",        "ASCII");
1216
        fIANA2JavaMap.put("ANSI_X3.4-1986",        "ASCII");
1217
        fIANA2JavaMap.put("ISO_646.IRV:1991",        "ASCII");
1217
        fIANA2JavaMap.put("ISO_646.IRV:1991",        "ASCII");
Lines 1226-1233 Link Here
1226
        fIANA2JavaMap.put("UTF-16BE",           "UnicodeBig");
1226
        fIANA2JavaMap.put("UTF-16BE",           "UnicodeBig");
1227
        fIANA2JavaMap.put("UTF-16LE",           "UnicodeLittle");
1227
        fIANA2JavaMap.put("UTF-16LE",           "UnicodeLittle");
1228
1228
1229
        // support for 1047, as proposed to be added to the 
1229
        // support for 1047, as proposed to be added to the
1230
        // IANA registry in 
1230
        // IANA registry in
1231
        // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0049.html
1231
        // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0049.html
1232
        fIANA2JavaMap.put("IBM-1047",    "Cp1047");
1232
        fIANA2JavaMap.put("IBM-1047",    "Cp1047");
1233
        fIANA2JavaMap.put("IBM1047",    "Cp1047");
1233
        fIANA2JavaMap.put("IBM1047",    "Cp1047");
Lines 1284-1290 Link Here
1284
        // REVISIT:
1284
        // REVISIT:
1285
        //   j:CNS11643 -> EUC-TW?
1285
        //   j:CNS11643 -> EUC-TW?
1286
        //   ISO-2022-CN? ISO-2022-CN-EXT?
1286
        //   ISO-2022-CN? ISO-2022-CN-EXT?
1287
                                                
1287
1288
        // add Java to IANA encoding mappings
1288
        // add Java to IANA encoding mappings
1289
        //fJava2IANAMap.put("8859_1",    "US-ASCII"); // ?
1289
        //fJava2IANAMap.put("8859_1",    "US-ASCII"); // ?
1290
        fJava2IANAMap.put("ISO8859_1",    "ISO-8859-1");
1290
        fJava2IANAMap.put("ISO8859_1",    "ISO-8859-1");
Lines 1376-1393 Link Here
1376
1376
1377
    /**
1377
    /**
1378
     * Adds an IANA to Java encoding name mapping.
1378
     * Adds an IANA to Java encoding name mapping.
1379
     * 
1379
     *
1380
     * @param ianaEncoding The IANA encoding name.
1380
     * @param ianaEncoding The IANA encoding name.
1381
     * @param javaEncoding The Java encoding name.
1381
     * @param javaEncoding The Java encoding name.
1382
     */
1382
     */
1383
    public static void putIANA2JavaMapping(String ianaEncoding, 
1383
    public static void putIANA2JavaMapping(String ianaEncoding,
1384
                                           String javaEncoding) {
1384
                                           String javaEncoding) {
1385
        fIANA2JavaMap.put(ianaEncoding, javaEncoding);
1385
        fIANA2JavaMap.put(ianaEncoding, javaEncoding);
1386
    } // putIANA2JavaMapping(String,String)
1386
    } // putIANA2JavaMapping(String,String)
1387
1387
1388
    /**
1388
    /**
1389
     * Returns the Java encoding name for the specified IANA encoding name.
1389
     * Returns the Java encoding name for the specified IANA encoding name.
1390
     * 
1390
     *
1391
     * @param ianaEncoding The IANA encoding name.
1391
     * @param ianaEncoding The IANA encoding name.
1392
     */
1392
     */
1393
    public static String getIANA2JavaMapping(String ianaEncoding) {
1393
    public static String getIANA2JavaMapping(String ianaEncoding) {
Lines 1396-1402 Link Here
1396
1396
1397
    /**
1397
    /**
1398
     * Removes an IANA to Java encoding name mapping.
1398
     * Removes an IANA to Java encoding name mapping.
1399
     * 
1399
     *
1400
     * @param ianaEncoding The IANA encoding name.
1400
     * @param ianaEncoding The IANA encoding name.
1401
     */
1401
     */
1402
    public static String removeIANA2JavaMapping(String ianaEncoding) {
1402
    public static String removeIANA2JavaMapping(String ianaEncoding) {
Lines 1405-1422 Link Here
1405
1405
1406
    /**
1406
    /**
1407
     * Adds a Java to IANA encoding name mapping.
1407
     * Adds a Java to IANA encoding name mapping.
1408
     * 
1408
     *
1409
     * @param javaEncoding The Java encoding name.
1409
     * @param javaEncoding The Java encoding name.
1410
     * @param ianaEncoding The IANA encoding name.
1410
     * @param ianaEncoding The IANA encoding name.
1411
     */
1411
     */
1412
    public static void putJava2IANAMapping(String javaEncoding, 
1412
    public static void putJava2IANAMapping(String javaEncoding,
1413
                                           String ianaEncoding) {
1413
                                           String ianaEncoding) {
1414
        fJava2IANAMap.put(javaEncoding, ianaEncoding);
1414
        fJava2IANAMap.put(javaEncoding, ianaEncoding);
1415
    } // putJava2IANAMapping(String,String)
1415
    } // putJava2IANAMapping(String,String)
1416
1416
1417
    /**
1417
    /**
1418
     * Returns the IANA encoding name for the specified Java encoding name.
1418
     * Returns the IANA encoding name for the specified Java encoding name.
1419
     * 
1419
     *
1420
     * @param javaEncoding The Java encoding name.
1420
     * @param javaEncoding The Java encoding name.
1421
     */
1421
     */
1422
    public static String getJava2IANAMapping(String javaEncoding) {
1422
    public static String getJava2IANAMapping(String javaEncoding) {
Lines 1425-1431 Link Here
1425
1425
1426
    /**
1426
    /**
1427
     * Removes a Java to IANA encoding name mapping.
1427
     * Removes a Java to IANA encoding name mapping.
1428
     * 
1428
     *
1429
     * @param javaEncoding The Java encoding name.
1429
     * @param javaEncoding The Java encoding name.
1430
     */
1430
     */
1431
    public static String removeJava2IANAMapping(String javaEncoding) {
1431
    public static String removeJava2IANAMapping(String javaEncoding) {
Lines 1442-1460 Link Here
1442
* string and fragment) that may constitute a URI.
1442
* string and fragment) that may constitute a URI.
1443
* <p>
1443
* <p>
1444
* Parsing of a URI specification is done according to the URI
1444
* Parsing of a URI specification is done according to the URI
1445
* syntax described in 
1445
* syntax described in
1446
* <a href="http://www.ietf.org/rfc/rfc2396.txt?number=2396">RFC 2396</a>,
1446
* <a href="http://www.ietf.org/rfc/rfc2396.txt?number=2396">RFC 2396</a>,
1447
* and amended by
1447
* and amended by
1448
* <a href="http://www.ietf.org/rfc/rfc2732.txt?number=2732">RFC 2732</a>. 
1448
* <a href="http://www.ietf.org/rfc/rfc2732.txt?number=2732">RFC 2732</a>.
1449
* <p>
1449
* <p>
1450
* Every absolute URI consists of a scheme, followed by a colon (':'), 
1450
* Every absolute URI consists of a scheme, followed by a colon (':'),
1451
* followed by a scheme-specific part. For URIs that follow the 
1451
* followed by a scheme-specific part. For URIs that follow the
1452
* "generic URI" syntax, the scheme-specific part begins with two 
1452
* "generic URI" syntax, the scheme-specific part begins with two
1453
* slashes ("//") and may be followed by an authority segment (comprised 
1453
* slashes ("//") and may be followed by an authority segment (comprised
1454
* of user information, host, and port), path segment, query segment 
1454
* of user information, host, and port), path segment, query segment
1455
* and fragment. Note that RFC 2396 no longer specifies the use of the 
1455
* and fragment. Note that RFC 2396 no longer specifies the use of the
1456
* parameters segment and excludes the "user:password" syntax as part of 
1456
* parameters segment and excludes the "user:password" syntax as part of
1457
* the authority segment. If "user:password" appears in a URI, the entire 
1457
* the authority segment. If "user:password" appears in a URI, the entire
1458
* user/password string is stored as userinfo.
1458
* user/password string is stored as userinfo.
1459
* <p>
1459
* <p>
1460
* For URIs that do not follow the "generic URI" syntax (e.g. mailto),
1460
* For URIs that do not follow the "generic URI" syntax (e.g. mailto),
Lines 1471-1477 Link Here
1471
*
1471
*
1472
**********************************************************************/
1472
**********************************************************************/
1473
 public static final class URI implements Serializable {
1473
 public static final class URI implements Serializable {
1474
   
1474
1475
1475
1476
  /*******************************************************************
1476
  /*******************************************************************
1477
  * MalformedURIExceptions are thrown in the process of building a URI
1477
  * MalformedURIExceptions are thrown in the process of building a URI
Lines 1479-1485 Link Here
1479
  * invalid URI specification.
1479
  * invalid URI specification.
1480
  *
1480
  *
1481
  ********************************************************************/
1481
  ********************************************************************/
1482
  public static class MalformedURIException extends IOException {
1482
  public static class MalformedURIException extends IllegalArgumentException {
1483
1483
1484
   /******************************************************************
1484
   /******************************************************************
1485
    * Constructs a <code>MalformedURIException</code> with no specified
1485
    * Constructs a <code>MalformedURIException</code> with no specified
Lines 1501-1555 Link Here
1501
  }
1501
  }
1502
1502
1503
  private static final byte [] fgLookupTable = new byte[128];
1503
  private static final byte [] fgLookupTable = new byte[128];
1504
  
1504
1505
  /**
1505
  /**
1506
   * Character Classes
1506
   * Character Classes
1507
   */
1507
   */
1508
  
1508
1509
  /** reserved characters ;/?:@&=+$,[] */
1509
  /** reserved characters ;/?:@&=+$,[] */
1510
  //RFC 2732 added '[' and ']' as reserved characters
1510
  //RFC 2732 added '[' and ']' as reserved characters
1511
  private static final int RESERVED_CHARACTERS = 0x01;
1511
  private static final int RESERVED_CHARACTERS = 0x01;
1512
  
1512
1513
  /** URI punctuation mark characters: -_.!~*'() - these, combined with
1513
  /** URI punctuation mark characters: -_.!~*'() - these, combined with
1514
      alphanumerics, constitute the "unreserved" characters */
1514
      alphanumerics, constitute the "unreserved" characters */
1515
  private static final int MARK_CHARACTERS = 0x02;
1515
  private static final int MARK_CHARACTERS = 0x02;
1516
  
1516
1517
  /** scheme can be composed of alphanumerics and these characters: +-. */
1517
  /** scheme can be composed of alphanumerics and these characters: +-. */
1518
  private static final int SCHEME_CHARACTERS = 0x04;
1518
  private static final int SCHEME_CHARACTERS = 0x04;
1519
  
1519
1520
  /** userinfo can be composed of unreserved, escaped and these
1520
  /** userinfo can be composed of unreserved, escaped and these
1521
      characters: ;:&=+$, */
1521
      characters: ;:&=+$, */
1522
  private static final int USERINFO_CHARACTERS = 0x08;
1522
  private static final int USERINFO_CHARACTERS = 0x08;
1523
  
1523
1524
  /** ASCII letter characters */
1524
  /** ASCII letter characters */
1525
  private static final int ASCII_ALPHA_CHARACTERS = 0x10;
1525
  private static final int ASCII_ALPHA_CHARACTERS = 0x10;
1526
  
1526
1527
  /** ASCII digit characters */
1527
  /** ASCII digit characters */
1528
  private static final int ASCII_DIGIT_CHARACTERS = 0x20;
1528
  private static final int ASCII_DIGIT_CHARACTERS = 0x20;
1529
  
1529
1530
  /** ASCII hex characters */
1530
  /** ASCII hex characters */
1531
  private static final int ASCII_HEX_CHARACTERS = 0x40;
1531
  private static final int ASCII_HEX_CHARACTERS = 0x40;
1532
  
1532
1533
  /** Path characters */
1533
  /** Path characters */
1534
  private static final int PATH_CHARACTERS = 0x80;
1534
  private static final int PATH_CHARACTERS = 0x80;
1535
1535
1536
  /** Mask for alpha-numeric characters */
1536
  /** Mask for alpha-numeric characters */
1537
  private static final int MASK_ALPHA_NUMERIC = ASCII_ALPHA_CHARACTERS | ASCII_DIGIT_CHARACTERS;
1537
  private static final int MASK_ALPHA_NUMERIC = ASCII_ALPHA_CHARACTERS | ASCII_DIGIT_CHARACTERS;
1538
  
1538
1539
  /** Mask for unreserved characters */
1539
  /** Mask for unreserved characters */
1540
  private static final int MASK_UNRESERVED_MASK = MASK_ALPHA_NUMERIC | MARK_CHARACTERS;
1540
  private static final int MASK_UNRESERVED_MASK = MASK_ALPHA_NUMERIC | MARK_CHARACTERS;
1541
  
1541
1542
  /** Mask for URI allowable characters except for % */
1542
  /** Mask for URI allowable characters except for % */
1543
  private static final int MASK_URI_CHARACTER = MASK_UNRESERVED_MASK | RESERVED_CHARACTERS;
1543
  private static final int MASK_URI_CHARACTER = MASK_UNRESERVED_MASK | RESERVED_CHARACTERS;
1544
  
1544
1545
  /** Mask for scheme characters */
1545
  /** Mask for scheme characters */
1546
  private static final int MASK_SCHEME_CHARACTER = MASK_ALPHA_NUMERIC | SCHEME_CHARACTERS;
1546
  private static final int MASK_SCHEME_CHARACTER = MASK_ALPHA_NUMERIC | SCHEME_CHARACTERS;
1547
  
1547
1548
  /** Mask for userinfo characters */
1548
  /** Mask for userinfo characters */
1549
  private static final int MASK_USERINFO_CHARACTER = MASK_UNRESERVED_MASK | USERINFO_CHARACTERS;
1549
  private static final int MASK_USERINFO_CHARACTER = MASK_UNRESERVED_MASK | USERINFO_CHARACTERS;
1550
  
1550
1551
  /** Mask for path characters */
1551
  /** Mask for path characters */
1552
  private static final int MASK_PATH_CHARACTER = MASK_UNRESERVED_MASK | PATH_CHARACTERS; 
1552
  private static final int MASK_PATH_CHARACTER = MASK_UNRESERVED_MASK | PATH_CHARACTERS;
1553
1553
1554
  static {
1554
  static {
1555
      // Add ASCII Digits and ASCII Hex Numbers
1555
      // Add ASCII Digits and ASCII Hex Numbers
Lines 1607-1613 Link Here
1607
      fgLookupTable['+'] |= USERINFO_CHARACTERS;
1607
      fgLookupTable['+'] |= USERINFO_CHARACTERS;
1608
      fgLookupTable['$'] |= USERINFO_CHARACTERS;
1608
      fgLookupTable['$'] |= USERINFO_CHARACTERS;
1609
      fgLookupTable[','] |= USERINFO_CHARACTERS;
1609
      fgLookupTable[','] |= USERINFO_CHARACTERS;
1610
      
1610
1611
      // Add Path Characters
1611
      // Add Path Characters
1612
      fgLookupTable[';'] |= PATH_CHARACTERS;
1612
      fgLookupTable[';'] |= PATH_CHARACTERS;
1613
      fgLookupTable['/'] |= PATH_CHARACTERS;
1613
      fgLookupTable['/'] |= PATH_CHARACTERS;
Lines 1639-1645 Link Here
1639
1639
1640
  /** If specified, stores the port for this URI; otherwise -1 */
1640
  /** If specified, stores the port for this URI; otherwise -1 */
1641
  private int m_port = -1;
1641
  private int m_port = -1;
1642
  
1642
1643
  /** If specified, stores the registry based authority for this URI; otherwise -1 */
1643
  /** If specified, stores the registry based authority for this URI; otherwise -1 */
1644
  private String m_regAuthority = null;
1644
  private String m_regAuthority = null;
1645
1645
Lines 1857-1866 Link Here
1857
  */
1857
  */
1858
  private void initialize(URI p_base, String p_uriSpec)
1858
  private void initialize(URI p_base, String p_uriSpec)
1859
                         throws MalformedURIException {
1859
                         throws MalformedURIException {
1860
    
1860
1861
    String uriSpec = p_uriSpec;
1861
    String uriSpec = p_uriSpec;
1862
    int uriSpecLen = (uriSpec != null) ? uriSpec.length() : 0;
1862
    int uriSpecLen = (uriSpec != null) ? uriSpec.length() : 0;
1863
  
1863
1864
    if (p_base == null && uriSpecLen == 0) {
1864
    if (p_base == null && uriSpecLen == 0) {
1865
      throw new MalformedURIException(
1865
      throw new MalformedURIException(
1866
                  "Cannot initialize URI with empty parameters.");
1866
                  "Cannot initialize URI with empty parameters.");
Lines 1884-1891 Link Here
1884
        int slashIdx = uriSpec.lastIndexOf('/', searchFrom);
1884
        int slashIdx = uriSpec.lastIndexOf('/', searchFrom);
1885
        int queryIdx = uriSpec.lastIndexOf('?', searchFrom);
1885
        int queryIdx = uriSpec.lastIndexOf('?', searchFrom);
1886
        int fragmentIdx = uriSpec.lastIndexOf('#', searchFrom);
1886
        int fragmentIdx = uriSpec.lastIndexOf('#', searchFrom);
1887
       
1887
1888
        if (colonIdx < 2 || slashIdx != -1 || 
1888
        if (colonIdx < 2 || slashIdx != -1 ||
1889
            queryIdx != -1 || fragmentIdx != -1) {
1889
            queryIdx != -1 || fragmentIdx != -1) {
1890
            // A standalone base is a valid URI according to spec
1890
            // A standalone base is a valid URI according to spec
1891
            if (colonIdx == 0 || (p_base == null && fragmentIdx != 0)) {
1891
            if (colonIdx == 0 || (p_base == null && fragmentIdx != 0)) {
Lines 1895-1916 Link Here
1895
        else {
1895
        else {
1896
            initializeScheme(uriSpec);
1896
            initializeScheme(uriSpec);
1897
            index = m_scheme.length()+1;
1897
            index = m_scheme.length()+1;
1898
            
1898
1899
            // Neither 'scheme:' or 'scheme:#fragment' are valid URIs.
1899
            // Neither 'scheme:' or 'scheme:#fragment' are valid URIs.
1900
            if (colonIdx == uriSpecLen - 1 || uriSpec.charAt(colonIdx+1) == '#') {
1900
            if (colonIdx == uriSpecLen - 1 || uriSpec.charAt(colonIdx+1) == '#') {
1901
              throw new MalformedURIException("Scheme specific part cannot be empty."); 
1901
              throw new MalformedURIException("Scheme specific part cannot be empty.");
1902
            }
1902
            }
1903
        }
1903
        }
1904
    }
1904
    }
1905
    else if (p_base == null && uriSpec.indexOf('#') != 0) {
1905
    else if (p_base == null && uriSpec.indexOf('#') != 0) {
1906
        throw new MalformedURIException("No scheme found in URI.");    
1906
        throw new MalformedURIException("No scheme found in URI.");
1907
    }
1907
    }
1908
1908
1909
    // Two slashes means we may have authority, but definitely means we're either
1909
    // Two slashes means we may have authority, but definitely means we're either
1910
    // matching net_path or abs_path. These two productions are ambiguous in that
1910
    // matching net_path or abs_path. These two productions are ambiguous in that
1911
    // every net_path (except those containing an IPv6Reference) is an abs_path. 
1911
    // every net_path (except those containing an IPv6Reference) is an abs_path.
1912
    // RFC 2396 resolves this ambiguity by applying a greedy left most matching rule. 
1912
    // RFC 2396 resolves this ambiguity by applying a greedy left most matching rule.
1913
    // Try matching net_path first, and if that fails we don't have authority so 
1913
    // Try matching net_path first, and if that fails we don't have authority so
1914
    // then attempt to match abs_path.
1914
    // then attempt to match abs_path.
1915
    //
1915
    //
1916
    // net_path = "//" authority [ abs_path ]
1916
    // net_path = "//" authority [ abs_path ]
Lines 2105-2116 Link Here
2105
  * for this URI from a URI string spec.
2105
  * for this URI from a URI string spec.
2106
  *
2106
  *
2107
  * @param p_uriSpec the URI specification (cannot be null)
2107
  * @param p_uriSpec the URI specification (cannot be null)
2108
  * 
2108
  *
2109
  * @return true if the given string matched server or registry
2109
  * @return true if the given string matched server or registry
2110
  * based authority
2110
  * based authority
2111
  */
2111
  */
2112
  private boolean initializeAuthority(String p_uriSpec) {
2112
  private boolean initializeAuthority(String p_uriSpec) {
2113
    
2113
2114
    int index = 0;
2114
    int index = 0;
2115
    int start = 0;
2115
    int start = 0;
2116
    int end = p_uriSpec.length();
2116
    int end = p_uriSpec.length();
Lines 2131-2137 Link Here
2131
      index++;
2131
      index++;
2132
    }
2132
    }
2133
2133
2134
    // host is everything up to last ':', or up to 
2134
    // host is everything up to last ':', or up to
2135
    // and including ']' if followed by ':'.
2135
    // and including ']' if followed by ':'.
2136
    String host = null;
2136
    String host = null;
2137
    start = index;
2137
    start = index;
Lines 2186-2192 Link Here
2186
        }
2186
        }
2187
      }
2187
      }
2188
    }
2188
    }
2189
    
2189
2190
    if (isValidServerBasedAuthority(host, port, userinfo)) {
2190
    if (isValidServerBasedAuthority(host, port, userinfo)) {
2191
      m_host = host;
2191
      m_host = host;
2192
      m_port = port;
2192
      m_port = port;
Lines 2203-2227 Link Here
2203
    }
2203
    }
2204
    return false;
2204
    return false;
2205
  }
2205
  }
2206
  
2206
2207
  /**
2207
  /**
2208
   * Determines whether the components host, port, and user info
2208
   * Determines whether the components host, port, and user info
2209
   * are valid as a server authority.
2209
   * are valid as a server authority.
2210
   * 
2210
   *
2211
   * @param host the host component of authority
2211
   * @param host the host component of authority
2212
   * @param port the port number component of authority
2212
   * @param port the port number component of authority
2213
   * @param userinfo the user info component of authority
2213
   * @param userinfo the user info component of authority
2214
   * 
2214
   *
2215
   * @return true if the given host, port, and userinfo compose
2215
   * @return true if the given host, port, and userinfo compose
2216
   * a valid server authority
2216
   * a valid server authority
2217
   */
2217
   */
2218
  private boolean isValidServerBasedAuthority(String host, int port, String userinfo) {
2218
  private boolean isValidServerBasedAuthority(String host, int port, String userinfo) {
2219
    
2219
2220
    // Check if the host is well formed.
2220
    // Check if the host is well formed.
2221
    if (!isWellFormedAddress(host)) {
2221
    if (!isWellFormedAddress(host)) {
2222
      return false;
2222
      return false;
2223
    }
2223
    }
2224
    
2224
2225
    // Check that port is well formed if it exists.
2225
    // Check that port is well formed if it exists.
2226
    // REVISIT: There's no restriction on port value ranges, but
2226
    // REVISIT: There's no restriction on port value ranges, but
2227
    // perform the same check as in setPort to be consistent. Pass
2227
    // perform the same check as in setPort to be consistent. Pass
Lines 2229-2235 Link Here
2229
    if (port < -1 || port > 65535) {
2229
    if (port < -1 || port > 65535) {
2230
      return false;
2230
      return false;
2231
    }
2231
    }
2232
    
2232
2233
    // Check that userinfo is well formed if it exists.
2233
    // Check that userinfo is well formed if it exists.
2234
    if (userinfo != null) {
2234
    if (userinfo != null) {
2235
      // Userinfo can contain alphanumerics, mark characters, escaped
2235
      // Userinfo can contain alphanumerics, mark characters, escaped
Lines 2255-2276 Link Here
2255
    }
2255
    }
2256
    return true;
2256
    return true;
2257
  }
2257
  }
2258
  
2258
2259
  /**
2259
  /**
2260
   * Determines whether the given string is a registry based authority.
2260
   * Determines whether the given string is a registry based authority.
2261
   * 
2261
   *
2262
   * @param authority the authority component of a URI
2262
   * @param authority the authority component of a URI
2263
   * 
2263
   *
2264
   * @return true if the given string is a registry based authority
2264
   * @return true if the given string is a registry based authority
2265
   */
2265
   */
2266
  private boolean isValidRegistryBasedAuthority(String authority) {
2266
  private boolean isValidRegistryBasedAuthority(String authority) {
2267
    int index = 0;
2267
    int index = 0;
2268
    int end = authority.length();
2268
    int end = authority.length();
2269
    char testChar;
2269
    char testChar;
2270
    
2270
2271
    while (index < end) {
2271
    while (index < end) {
2272
      testChar = authority.charAt(index);
2272
      testChar = authority.charAt(index);
2273
      
2273
2274
      // check for valid escape sequence
2274
      // check for valid escape sequence
2275
      if (testChar == '%') {
2275
      if (testChar == '%') {
2276
        if (index+2 >= end ||
2276
        if (index+2 >= end ||
Lines 2289-2295 Link Here
2289
    }
2289
    }
2290
    return true;
2290
    return true;
2291
  }
2291
  }
2292
    
2292
2293
 /**
2293
 /**
2294
  * Initialize the path for this URI from a URI string spec.
2294
  * Initialize the path for this URI from a URI string spec.
2295
  *
2295
  *
Lines 2314-2326 Link Here
2314
    if (start < end) {
2314
    if (start < end) {
2315
      // RFC 2732 only allows '[' and ']' to appear in the opaque part.
2315
      // RFC 2732 only allows '[' and ']' to appear in the opaque part.
2316
      if (getScheme() == null || p_uriSpec.charAt(start) == '/') {
2316
      if (getScheme() == null || p_uriSpec.charAt(start) == '/') {
2317
      
2317
2318
            // Scan path.
2318
            // Scan path.
2319
            // abs_path = "/"  path_segments
2319
            // abs_path = "/"  path_segments
2320
            // rel_path = rel_segment [ abs_path ]
2320
            // rel_path = rel_segment [ abs_path ]
2321
            while (index < end) {
2321
            while (index < end) {
2322
                testChar = p_uriSpec.charAt(index);
2322
                testChar = p_uriSpec.charAt(index);
2323
            
2323
2324
                // check for valid escape sequence
2324
                // check for valid escape sequence
2325
                if (testChar == '%') {
2325
                if (testChar == '%') {
2326
                    if (index+2 >= end ||
2326
                    if (index+2 >= end ||
Lines 2344-2359 Link Here
2344
            }
2344
            }
2345
        }
2345
        }
2346
        else {
2346
        else {
2347
            
2347
2348
            // Scan opaque part.
2348
            // Scan opaque part.
2349
            // opaque_part = uric_no_slash *uric
2349
            // opaque_part = uric_no_slash *uric
2350
            while (index < end) {
2350
            while (index < end) {
2351
                testChar = p_uriSpec.charAt(index);
2351
                testChar = p_uriSpec.charAt(index);
2352
            
2352
2353
                if (testChar == '?' || testChar == '#') {
2353
                if (testChar == '?' || testChar == '#') {
2354
                    break;
2354
                    break;
2355
                }
2355
                }
2356
                
2356
2357
                // check for valid escape sequence
2357
                // check for valid escape sequence
2358
                if (testChar == '%') {
2358
                if (testChar == '%') {
2359
                    if (index+2 >= end ||
2359
                    if (index+2 >= end ||
Lines 2366-2372 Link Here
2366
                }
2366
                }
2367
                // If the scheme specific part is opaque, it can contain '['
2367
                // If the scheme specific part is opaque, it can contain '['
2368
                // and ']'. uric_no_slash wasn't modified by RFC 2732, which
2368
                // and ']'. uric_no_slash wasn't modified by RFC 2732, which
2369
                // I've interpreted as an error in the spec, since the 
2369
                // I've interpreted as an error in the spec, since the
2370
                // production should be equivalent to (uric - '/'), and uric
2370
                // production should be equivalent to (uric - '/'), and uric
2371
                // contains '[' and ']'. - mrglavas
2371
                // contains '[' and ']'. - mrglavas
2372
                else if (!isURICharacter(testChar)) {
2372
                else if (!isURICharacter(testChar)) {
Lines 2452-2458 Link Here
2452
2452
2453
    if (m_host != null || m_regAuthority != null) {
2453
    if (m_host != null || m_regAuthority != null) {
2454
      schemespec.append("//");
2454
      schemespec.append("//");
2455
    
2455
2456
      // Server based authority.
2456
      // Server based authority.
2457
      if (m_host != null) {
2457
      if (m_host != null) {
2458
2458
Lines 2460-2468 Link Here
2460
          schemespec.append(m_userinfo);
2460
          schemespec.append(m_userinfo);
2461
          schemespec.append('@');
2461
          schemespec.append('@');
2462
        }
2462
        }
2463
        
2463
2464
        schemespec.append(m_host);
2464
        schemespec.append(m_host);
2465
        
2465
2466
        if (m_port != -1) {
2466
        if (m_port != -1) {
2467
          schemespec.append(':');
2467
          schemespec.append(':');
2468
          schemespec.append(m_port);
2468
          schemespec.append(m_port);
Lines 2517-2526 Link Here
2517
  public int getPort() {
2517
  public int getPort() {
2518
    return m_port;
2518
    return m_port;
2519
  }
2519
  }
2520
  
2520
2521
  /**
2521
  /**
2522
   * Get the registry based authority for this URI.
2522
   * Get the registry based authority for this URI.
2523
   * 
2523
   *
2524
   * @return the registry based authority (null if not specified).
2524
   * @return the registry based authority (null if not specified).
2525
   */
2525
   */
2526
  public String getRegBasedAuthority() {
2526
  public String getRegBasedAuthority() {
Lines 2658-2664 Link Here
2658
 /**
2658
 /**
2659
  * <p>Set the host for this URI. If null is passed in, the userinfo
2659
  * <p>Set the host for this URI. If null is passed in, the userinfo
2660
  * field is also set to null and the port is set to -1.</p>
2660
  * field is also set to null and the port is set to -1.</p>
2661
  * 
2661
  *
2662
  * <p>Note: This method overwrites registry based authority if it
2662
  * <p>Note: This method overwrites registry based authority if it
2663
  * previously existed in this URI.</p>
2663
  * previously existed in this URI.</p>
2664
  *
2664
  *
Lines 2707-2737 Link Here
2707
    }
2707
    }
2708
    m_port = p_port;
2708
    m_port = p_port;
2709
  }
2709
  }
2710
  
2710
2711
  /**
2711
  /**
2712
   * <p>Sets the registry based authority for this URI.</p>
2712
   * <p>Sets the registry based authority for this URI.</p>
2713
   * 
2713
   *
2714
   * <p>Note: This method overwrites server based authority
2714
   * <p>Note: This method overwrites server based authority
2715
   * if it previously existed in this URI.</p>
2715
   * if it previously existed in this URI.</p>
2716
   * 
2716
   *
2717
   * @param authority the registry based authority for this URI
2717
   * @param authority the registry based authority for this URI
2718
   * 
2718
   *
2719
   * @exception MalformedURIException it authority is not a
2719
   * @exception MalformedURIException it authority is not a
2720
   * well formed registry based authority
2720
   * well formed registry based authority
2721
   */
2721
   */
2722
  public void setRegBasedAuthority(String authority) 
2722
  public void setRegBasedAuthority(String authority)
2723
    throws MalformedURIException {
2723
    throws MalformedURIException {
2724
2724
2725
    if (authority == null) {
2725
    if (authority == null) {
2726
      m_regAuthority = null;
2726
      m_regAuthority = null;
2727
      return;
2727
      return;
2728
    }
2728
    }
2729
  // reg_name = 1*( unreserved | escaped | "$" | "," | 
2729
  // reg_name = 1*( unreserved | escaped | "$" | "," |
2730
  //            ";" | ":" | "@" | "&" | "=" | "+" )
2730
  //            ";" | ":" | "@" | "&" | "=" | "+" )
2731
    else if (authority.length() < 1 ||
2731
    else if (authority.length() < 1 ||
2732
      !isValidRegistryBasedAuthority(authority) ||
2732
      !isValidRegistryBasedAuthority(authority) ||
2733
      authority.indexOf('/') != -1) {
2733
      authority.indexOf('/') != -1) {
2734
      throw new MalformedURIException("Registry based authority is not well formed.");        
2734
      throw new MalformedURIException("Registry based authority is not well formed.");
2735
    }
2735
    }
2736
    m_regAuthority = authority;
2736
    m_regAuthority = authority;
2737
    m_host = null;
2737
    m_host = null;
Lines 2973-2986 Link Here
2973
2973
2974
 /**
2974
 /**
2975
  * Determine whether a string is syntactically capable of representing
2975
  * Determine whether a string is syntactically capable of representing
2976
  * a valid IPv4 address, IPv6 reference or the domain name of a network host. 
2976
  * a valid IPv4 address, IPv6 reference or the domain name of a network host.
2977
  * A valid IPv4 address consists of four decimal digit groups separated by a
2977
  * A valid IPv4 address consists of four decimal digit groups separated by a
2978
  * '.'. Each group must consist of one to three digits. See RFC 2732 Section 3,
2978
  * '.'. Each group must consist of one to three digits. See RFC 2732 Section 3,
2979
  * and RFC 2373 Section 2.2, for the definition of IPv6 references. A hostname 
2979
  * and RFC 2373 Section 2.2, for the definition of IPv6 references. A hostname
2980
  * consists of domain labels (each of which must begin and end with an alphanumeric 
2980
  * consists of domain labels (each of which must begin and end with an alphanumeric
2981
  * but may contain '-') separated & by a '.'. See RFC 2396 Section 3.2.2.
2981
  * but may contain '-') separated & by a '.'. See RFC 2396 Section 3.2.2.
2982
  *
2982
  *
2983
  * @return true if the string is a syntactically valid IPv4 address, 
2983
  * @return true if the string is a syntactically valid IPv4 address,
2984
  * IPv6 reference or hostname
2984
  * IPv6 reference or hostname
2985
  */
2985
  */
2986
  public static boolean isWellFormedAddress(String address) {
2986
  public static boolean isWellFormedAddress(String address) {
Lines 2992-3006 Link Here
2992
    if (addrLength == 0) {
2992
    if (addrLength == 0) {
2993
      return false;
2993
      return false;
2994
    }
2994
    }
2995
    
2995
2996
    // Check if the host is a valid IPv6reference.
2996
    // Check if the host is a valid IPv6reference.
2997
    if (address.startsWith("[")) {
2997
    if (address.startsWith("[")) {
2998
      return isWellFormedIPv6Reference(address);
2998
      return isWellFormedIPv6Reference(address);
2999
    }
2999
    }
3000
3000
3001
    // Cannot start with a '.', '-', or end with a '-'.
3001
    // Cannot start with a '.', '-', or end with a '-'.
3002
    if (address.startsWith(".") || 
3002
    if (address.startsWith(".") ||
3003
        address.startsWith("-") || 
3003
        address.startsWith("-") ||
3004
        address.endsWith("-")) {
3004
        address.endsWith("-")) {
3005
      return false;
3005
      return false;
3006
    }
3006
    }
Lines 3020-3033 Link Here
3020
      // hostname      = *( domainlabel "." ) toplabel [ "." ]
3020
      // hostname      = *( domainlabel "." ) toplabel [ "." ]
3021
      // domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
3021
      // domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
3022
      // toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
3022
      // toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
3023
      
3023
3024
      // RFC 2396 states that hostnames take the form described in 
3024
      // RFC 2396 states that hostnames take the form described in
3025
      // RFC 1034 (Section 3) and RFC 1123 (Section 2.1). According
3025
      // RFC 1034 (Section 3) and RFC 1123 (Section 2.1). According
3026
      // to RFC 1034, hostnames are limited to 255 characters.
3026
      // to RFC 1034, hostnames are limited to 255 characters.
3027
      if (addrLength > 255) {
3027
      if (addrLength > 255) {
3028
        return false;
3028
        return false;
3029
      }
3029
      }
3030
      
3030
3031
      // domain labels can contain alphanumerics and '-"
3031
      // domain labels can contain alphanumerics and '-"
3032
      // but must start and end with an alphanumeric
3032
      // but must start and end with an alphanumeric
3033
      char testChar;
3033
      char testChar;
Lines 3055-3066 Link Here
3055
    }
3055
    }
3056
    return true;
3056
    return true;
3057
  }
3057
  }
3058
  
3058
3059
  /**
3059
  /**
3060
   * <p>Determines whether a string is an IPv4 address as defined by 
3060
   * <p>Determines whether a string is an IPv4 address as defined by
3061
   * RFC 2373, and under the further constraint that it must be a 32-bit
3061
   * RFC 2373, and under the further constraint that it must be a 32-bit
3062
   * address. Though not expressed in the grammar, in order to satisfy 
3062
   * address. Though not expressed in the grammar, in order to satisfy
3063
   * the 32-bit address constraint, each segment of the address cannot 
3063
   * the 32-bit address constraint, each segment of the address cannot
3064
   * be greater than 255 (8 bits of information).</p>
3064
   * be greater than 255 (8 bits of information).</p>
3065
   *
3065
   *
3066
   * <p><code>IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT</code></p>
3066
   * <p><code>IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT</code></p>
Lines 3068-3074 Link Here
3068
   * @return true if the string is a syntactically valid IPv4 address
3068
   * @return true if the string is a syntactically valid IPv4 address
3069
   */
3069
   */
3070
  public static boolean isWellFormedIPv4Address(String address) {
3070
  public static boolean isWellFormedIPv4Address(String address) {
3071
      
3071
3072
      int addrLength = address.length();
3072
      int addrLength = address.length();
3073
      char testChar;
3073
      char testChar;
3074
      int numDots = 0;
3074
      int numDots = 0;
Lines 3078-3084 Link Here
3078
      // any dot separator is preceded and followed by a digit and
3078
      // any dot separator is preceded and followed by a digit and
3079
      // 3) that we find 3 dots
3079
      // 3) that we find 3 dots
3080
      //
3080
      //
3081
      // RFC 2732 amended RFC 2396 by replacing the definition 
3081
      // RFC 2732 amended RFC 2396 by replacing the definition
3082
      // of IPv4address with the one defined by RFC 2373. - mrglavas
3082
      // of IPv4address with the one defined by RFC 2373. - mrglavas
3083
      //
3083
      //
3084
      // IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
3084
      // IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
Lines 3087-3093 Link Here
3087
      for (int i = 0; i < addrLength; i++) {
3087
      for (int i = 0; i < addrLength; i++) {
3088
        testChar = address.charAt(i);
3088
        testChar = address.charAt(i);
3089
        if (testChar == '.') {
3089
        if (testChar == '.') {
3090
          if ((i > 0 && !isDigit(address.charAt(i-1))) || 
3090
          if ((i > 0 && !isDigit(address.charAt(i-1))) ||
3091
              (i+1 < addrLength && !isDigit(address.charAt(i+1)))) {
3091
              (i+1 < addrLength && !isDigit(address.charAt(i+1)))) {
3092
            return false;
3092
            return false;
3093
          }
3093
          }
Lines 3108-3116 Link Here
3108
        else if (numDigits == 3) {
3108
        else if (numDigits == 3) {
3109
          char first = address.charAt(i-2);
3109
          char first = address.charAt(i-2);
3110
          char second = address.charAt(i-1);
3110
          char second = address.charAt(i-1);
3111
          if (!(first < '2' || 
3111
          if (!(first < '2' ||
3112
               (first == '2' && 
3112
               (first == '2' &&
3113
               (second < '5' || 
3113
               (second < '5' ||
3114
               (second == '5' && testChar <= '5'))))) {
3114
               (second == '5' && testChar <= '5'))))) {
3115
            return false;
3115
            return false;
3116
          }
3116
          }
Lines 3118-3134 Link Here
3118
      }
3118
      }
3119
      return (numDots == 3);
3119
      return (numDots == 3);
3120
  }
3120
  }
3121
  
3121
3122
  /**
3122
  /**
3123
   * <p>Determines whether a string is an IPv6 reference as defined
3123
   * <p>Determines whether a string is an IPv6 reference as defined
3124
   * by RFC 2732, where IPv6address is defined in RFC 2373. The 
3124
   * by RFC 2732, where IPv6address is defined in RFC 2373. The
3125
   * IPv6 address is parsed according to Section 2.2 of RFC 2373,
3125
   * IPv6 address is parsed according to Section 2.2 of RFC 2373,
3126
   * with the additional constraint that the address be composed of
3126
   * with the additional constraint that the address be composed of
3127
   * 128 bits of information.</p>
3127
   * 128 bits of information.</p>
3128
   *
3128
   *
3129
   * <p><code>IPv6reference = "[" IPv6address "]"</code></p>
3129
   * <p><code>IPv6reference = "[" IPv6address "]"</code></p>
3130
   *
3130
   *
3131
   * <p>Note: The BNF expressed in RFC 2373 Appendix B does not 
3131
   * <p>Note: The BNF expressed in RFC 2373 Appendix B does not
3132
   * accurately describe section 2.2, and was in fact removed from
3132
   * accurately describe section 2.2, and was in fact removed from
3133
   * RFC 3513, the successor of RFC 2373.</p>
3133
   * RFC 3513, the successor of RFC 2373.</p>
3134
   *
3134
   *
Lines 3139-3154 Link Here
3139
      int addrLength = address.length();
3139
      int addrLength = address.length();
3140
      int index = 1;
3140
      int index = 1;
3141
      int end = addrLength-1;
3141
      int end = addrLength-1;
3142
      
3142
3143
      // Check if string is a potential match for IPv6reference.
3143
      // Check if string is a potential match for IPv6reference.
3144
      if (!(addrLength > 2 && address.charAt(0) == '[' 
3144
      if (!(addrLength > 2 && address.charAt(0) == '['
3145
          && address.charAt(end) == ']')) {
3145
          && address.charAt(end) == ']')) {
3146
          return false;
3146
          return false;
3147
      }
3147
      }
3148
      
3148
3149
      // Counter for the number of 16-bit sections read in the address.
3149
      // Counter for the number of 16-bit sections read in the address.
3150
      int [] counter = new int[1];
3150
      int [] counter = new int[1];
3151
      
3151
3152
      // Scan hex sequence before possible '::' or IPv4 address.
3152
      // Scan hex sequence before possible '::' or IPv4 address.
3153
      index = scanHexSequence(address, index, end, counter);
3153
      index = scanHexSequence(address, index, end, counter);
3154
      if (index == -1) {
3154
      if (index == -1) {
Lines 3158-3164 Link Here
3158
      else if (index == end) {
3158
      else if (index == end) {
3159
          return (counter[0] == 8);
3159
          return (counter[0] == 8);
3160
      }
3160
      }
3161
      
3161
3162
      if (index+1 < end && address.charAt(index) == ':') {
3162
      if (index+1 < end && address.charAt(index) == ':') {
3163
          if (address.charAt(index+1) == ':') {
3163
          if (address.charAt(index+1) == ':') {
3164
              // '::' represents at least one 16-bit group of zeros.
3164
              // '::' represents at least one 16-bit group of zeros.
Lines 3172-3205 Link Here
3172
              }
3172
              }
3173
          }
3173
          }
3174
          // If the second character wasn't ':', in order to be valid,
3174
          // If the second character wasn't ':', in order to be valid,
3175
          // the remainder of the string must match IPv4Address, 
3175
          // the remainder of the string must match IPv4Address,
3176
          // and we must have read exactly 6 16-bit groups.
3176
          // and we must have read exactly 6 16-bit groups.
3177
          else {
3177
          else {
3178
              return (counter[0] == 6) && 
3178
              return (counter[0] == 6) &&
3179
                  isWellFormedIPv4Address(address.substring(index+1, end));
3179
                  isWellFormedIPv4Address(address.substring(index+1, end));
3180
          }
3180
          }
3181
      }
3181
      }
3182
      else {
3182
      else {
3183
          return false;
3183
          return false;
3184
      }
3184
      }
3185
      
3185
3186
      // 3. Scan hex sequence after '::'.
3186
      // 3. Scan hex sequence after '::'.
3187
      int prevCount = counter[0];
3187
      int prevCount = counter[0];
3188
      index = scanHexSequence(address, index, end, counter);
3188
      index = scanHexSequence(address, index, end, counter);
3189
3189
3190
      // We've either reached the end of the string, the address ends in
3190
      // We've either reached the end of the string, the address ends in
3191
      // an IPv4 address, or it is invalid. scanHexSequence has already 
3191
      // an IPv4 address, or it is invalid. scanHexSequence has already
3192
      // made sure that we have the right number of bits. 
3192
      // made sure that we have the right number of bits.
3193
      return (index == end) || 
3193
      return (index == end) ||
3194
          (index != -1 && isWellFormedIPv4Address(
3194
          (index != -1 && isWellFormedIPv4Address(
3195
          address.substring((counter[0] > prevCount) ? index+1 : index, end)));
3195
          address.substring((counter[0] > prevCount) ? index+1 : index, end)));
3196
  }
3196
  }
3197
  
3197
3198
  /**
3198
  /**
3199
   * Helper method for isWellFormedIPv6Reference which scans the 
3199
   * Helper method for isWellFormedIPv6Reference which scans the
3200
   * hex sequences of an IPv6 address. It returns the index of the 
3200
   * hex sequences of an IPv6 address. It returns the index of the
3201
   * next character to scan in the address, or -1 if the string 
3201
   * next character to scan in the address, or -1 if the string
3202
   * cannot match a valid IPv6 address. 
3202
   * cannot match a valid IPv6 address.
3203
   *
3203
   *
3204
   * @param address the string to be scanned
3204
   * @param address the string to be scanned
3205
   * @param index the beginning index (inclusive)
3205
   * @param index the beginning index (inclusive)
Lines 3211-3221 Link Here
3211
   * string cannot match a valid IPv6 address
3211
   * string cannot match a valid IPv6 address
3212
   */
3212
   */
3213
  private static int scanHexSequence (String address, int index, int end, int [] counter) {
3213
  private static int scanHexSequence (String address, int index, int end, int [] counter) {
3214
    
3214
3215
      char testChar;
3215
      char testChar;
3216
      int numDigits = 0;
3216
      int numDigits = 0;
3217
      int start = index;
3217
      int start = index;
3218
      
3218
3219
      // Trying to match the following productions:
3219
      // Trying to match the following productions:
3220
      // hexseq = hex4 *( ":" hex4)
3220
      // hexseq = hex4 *( ":" hex4)
3221
      // hex4   = 1*4HEXDIG
3221
      // hex4   = 1*4HEXDIG
Lines 3247-3253 Link Here
3247
        }
3247
        }
3248
      }
3248
      }
3249
      return (numDigits > 0 && ++counter[0] <= 8) ? end : -1;
3249
      return (numDigits > 0 && ++counter[0] <= 8) ? end : -1;
3250
  } 
3250
  }
3251
3251
3252
3252
3253
 /**
3253
 /**
Lines 3288-3294 Link Here
3288
  }
3288
  }
3289
3289
3290
 /**
3290
 /**
3291
  * Determine whether a char is a URI character (reserved or 
3291
  * Determine whether a char is a URI character (reserved or
3292
  * unreserved, not including '%' for escaped octets).
3292
  * unreserved, not including '%' for escaped octets).
3293
  *
3293
  *
3294
  * @return true if the char is a URI character, false otherwise
3294
  * @return true if the char is a URI character, false otherwise
Lines 3314-3323 Link Here
3314
  private static boolean isUserinfoCharacter (char p_char) {
3314
  private static boolean isUserinfoCharacter (char p_char) {
3315
      return (p_char <= 'z' && (fgLookupTable[p_char] & MASK_USERINFO_CHARACTER) != 0);
3315
      return (p_char <= 'z' && (fgLookupTable[p_char] & MASK_USERINFO_CHARACTER) != 0);
3316
  }
3316
  }
3317
  
3317
3318
 /**
3318
 /**
3319
  * Determine whether a char is a path character.
3319
  * Determine whether a char is a path character.
3320
  * 
3320
  *
3321
  * @return true if the char is a path character, false otherwise
3321
  * @return true if the char is a path character, false otherwise
3322
  */
3322
  */
3323
  private static boolean isPathCharacter (char p_char) {
3323
  private static boolean isPathCharacter (char p_char) {
Lines 3363-3369 Link Here
3363
  //
3363
  //
3364
  // XML Schema anyURI specific information
3364
  // XML Schema anyURI specific information
3365
  //
3365
  //
3366
  
3366
3367
  // which ASCII characters need to be escaped
3367
  // which ASCII characters need to be escaped
3368
  private static boolean gNeedEscaping[] = new boolean[128];
3368
  private static boolean gNeedEscaping[] = new boolean[128];
3369
  // the first hex character if a character needs to be escaped
3369
  // the first hex character if a character needs to be escaped
Lines 3423-3434 Link Here
3423
          // get UTF-8 bytes for the remaining sub-string
3423
          // get UTF-8 bytes for the remaining sub-string
3424
          byte[] bytes = null;
3424
          byte[] bytes = null;
3425
          byte b;
3425
          byte b;
3426
          try {
3426
//          try {
3427
              bytes = anyURI.substring(i).getBytes("UTF-8");
3427
//        	  bytes = anyURI.substring(i).getBytes();
3428
          } catch (java.io.UnsupportedEncodingException e) {
3428
//              bytes = anyURI.substring(i).getBytes("UTF-8");
3429
              // should never happen
3429
//          } catch (java.io.UnsupportedEncodingException e) {
3430
              return anyURI;
3430
//              // should never happen
3431
          }
3431
//              return anyURI;
3432
//          }
3432
          len = bytes.length;
3433
          len = bytes.length;
3433
3434
3434
          // for each byte
3435
          // for each byte
Lines 3509-3518 Link Here
3509
3510
3510
     /** Pubid character mask. */
3511
     /** Pubid character mask. */
3511
     public static final int MASK_PUBID = 0x10;
3512
     public static final int MASK_PUBID = 0x10;
3512
     
3513
3513
     /** 
3514
     /**
3514
      * Content character mask. Special characters are those that can
3515
      * Content character mask. Special characters are those that can
3515
      * be considered the start of markup, such as '&lt;' and '&amp;'. 
3516
      * be considered the start of markup, such as '&lt;' and '&amp;'.
3516
      * The various newline characters are considered special as well.
3517
      * The various newline characters are considered special as well.
3517
      * All other valid XML characters can be considered content.
3518
      * All other valid XML characters can be considered content.
3518
      * <p>
3519
      * <p>
Lines 3531-3540 Link Here
3531
     //
3532
     //
3532
3533
3533
     static {
3534
     static {
3534
         
3535
3535
         // Initializing the Character Flag Array
3536
         // Initializing the Character Flag Array
3536
         // Code generated by: XMLCharGenerator.
3537
         // Code generated by: XMLCharGenerator.
3537
         
3538
3538
         CHARS[9] = 35;
3539
         CHARS[9] = 35;
3539
         CHARS[10] = 19;
3540
         CHARS[10] = 19;
3540
         CHARS[13] = 19;
3541
         CHARS[13] = 19;
Lines 4351-4357 Link Here
4351
         }
4352
         }
4352
         return true;
4353
         return true;
4353
     } // isValidName(String):boolean
4354
     } // isValidName(String):boolean
4354
     
4355
4355
4356
4356
     /*
4357
     /*
4357
      * from the namespace rec
4358
      * from the namespace rec
Lines 4387-4393 Link Here
4387
      * in the XML 1.0 Recommendation
4388
      * in the XML 1.0 Recommendation
4388
      *
4389
      *
4389
      * @param nmtoken string to check
4390
      * @param nmtoken string to check
4390
      * @return true if nmtoken is a valid Nmtoken 
4391
      * @return true if nmtoken is a valid Nmtoken
4391
      */
4392
      */
4392
     public static boolean isValidNmtoken(String nmtoken) {
4393
     public static boolean isValidNmtoken(String nmtoken) {
4393
         if (nmtoken.length() == 0)
4394
         if (nmtoken.length() == 0)
Lines 4478-4490 Link Here
4478
   public static final boolean isDigit(char ch) {
4479
   public static final boolean isDigit(char ch) {
4479
       return ch >= '0' && ch <= '9';
4480
       return ch >= '0' && ch <= '9';
4480
   }
4481
   }
4481
   
4482
4482
   // if the character is in the range 0x30 ~ 0x39, return its int value (0~9),
4483
   // if the character is in the range 0x30 ~ 0x39, return its int value (0~9),
4483
   // otherwise, return -1
4484
   // otherwise, return -1
4484
   public static final int getDigit(char ch) {
4485
   public static final int getDigit(char ch) {
4485
       return isDigit(ch) ? ch - '0' : -1;
4486
       return isDigit(ch) ? ch - '0' : -1;
4486
   }
4487
   }
4487
   
4488
4488
} // interface TypeValidator
4489
} // interface TypeValidator
4489
4490
4490
}
4491
}
(-)src/org/eclipse/emf/ecore/xml/type/internal/XMLDuration.java (-400 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLDuration.java,v 1.4.4.1 2007/09/06 18:24:36 emerks Exp $
16
 *
17
 * ---------------------------------------------------------------------
18
 *
19
 * The Apache Software License, Version 1.1
20
 *
21
 *
22
 * Copyright (c) 1999-2004 The Apache Software Foundation.  All rights
23
 * reserved.
24
 *
25
 * Redistribution and use in source and binary forms, with or without
26
 * modification, are permitted provided that the following conditions
27
 * are met:
28
 *
29
 * 1. Redistributions of source code must retain the above copyright
30
 *    notice, this list of conditions and the following disclaimer.
31
 *
32
 * 2. Redistributions in binary form must reproduce the above copyright
33
 *    notice, this list of conditions and the following disclaimer in
34
 *    the documentation and/or other materials provided with the
35
 *    distribution.
36
 *
37
 * 3. The end-user documentation included with the redistribution,
38
 *    if any, must include the following acknowledgment:
39
 *       "This product includes software developed by the
40
 *        Apache Software Foundation (http://www.apache.org/)."
41
 *    Alternately, this acknowledgment may appear in the software itself,
42
 *    if and wherever such third-party acknowledgments normally appear.
43
 *
44
 * 4. The names "Xerces" and "Apache Software Foundation" must
45
 *    not be used to endorse or promote products derived from this
46
 *    software without prior written permission. For written
47
 *    permission, please contact apache@apache.org.
48
 *
49
 * 5. Products derived from this software may not be called "Apache",
50
 *    nor may "Apache" appear in their name, without prior written
51
 *    permission of the Apache Software Foundation.
52
 *
53
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
54
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
57
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
60
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
61
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
62
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
63
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64
 * SUCH DAMAGE.
65
 * ====================================================================
66
 *
67
 * This software consists of voluntary contributions made by many
68
 * individuals on behalf of the Apache Software Foundation and was
69
 * originally based on software copyright (c) 1999-2003, International
70
 * Business Machines, Inc., http://www.apache.org.  For more
71
 * information on the Apache Software Foundation, please see
72
 * <http://www.apache.org/>.
73
 */
74
package org.eclipse.emf.ecore.xml.type.internal;
75
76
import org.eclipse.emf.ecore.xml.type.InvalidDatatypeValueException;
77
import org.eclipse.emf.ecore.xml.type.internal.DataValue.TypeValidator;
78
79
80
/**
81
 * Representation for the <a href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">W3C XML Schema 1.0</a>
82
 * duration datatype.
83
 * 
84
 * NOTE: this class is for internal use only. 
85
 * Later this class will be replaced by JAXP 1.3 javax.xml.datatype.Duration class.
86
 * This class is based on Apache Xerces2 2.6.2 parser implementation of date/time validation.
87
 */
88
public final class XMLDuration {
89
90
   private final String ERROR_MESSAGE="The 'duration' value is invalid: ";
91
    // order-relation on duration is a partial order. The dates below are used to
92
    // for comparison of 2 durations, based on the fact that
93
    // duration x and y is x<=y iff s+x<=s+y
94
    // see 3.2.6 duration W3C schema datatype specs
95
    //
96
    // the dates are in format: {CCYY,MM,DD, H, S, M, MS, timezone}
97
    private final static int[][] DATETIMES= {
98
        {1696, 9, 1, 0, 0, 0, 0, 'Z'},
99
        {1697, 2, 1, 0, 0, 0, 0, 'Z'},
100
        {1903, 3, 1, 0, 0, 0, 0, 'Z'},
101
        {1903, 7, 1, 0, 0, 0, 0, 'Z'}};
102
    
103
    private int hashCode = 0;
104
    
105
    final int[] dateValue;
106
    
107
    final String valueString;
108
109
    public XMLDuration(String value)
110
    {
111
      this.dateValue = parse(value);
112
      valueString = value;
113
    }
114
    
115
    public boolean equals(Object obj)
116
    {
117
      if (!(obj instanceof XMLDuration))
118
        return false;
119
      int[] odata = ((XMLDuration)obj).dateValue;
120
      return compareDates(dateValue, odata, true) == 0;
121
    }
122
    
123
    public int hashCode()
124
    {
125
      if (hashCode == 0)
126
      {
127
        int[] temp = addDuration(dateValue, DATETIMES[0], new int[XMLCalendar.TOTAL_SIZE]);
128
        for (int i=0;i<XMLCalendar.TOTAL_SIZE;i++)
129
        {
130
          hashCode^=temp[i];
131
        }
132
      }
133
      return hashCode;
134
    }
135
    
136
    // the parameters are in compiled form (from getActualValue)
137
    public static int compare(XMLDuration value1, XMLDuration value2)
138
    {
139
      return compareDates(value1.dateValue, value2.dateValue, true);
140
    }//compare()
141
142
143
    /**
144
     * Parses, validates and computes normalized version of duration object
145
     *
146
     * @param str    The lexical representation of duration object PnYn MnDTnH nMnS
147
     * @return normalized date representation
148
     * @exception InvalidDatatypeValueException Invalid lexical representation
149
     */
150
    private int[] parse(String str) throws InvalidDatatypeValueException{
151
        int len = str.length();
152
        int[] date=new int[XMLCalendar.TOTAL_SIZE];
153
154
        int start = 0;
155
        char c=str.charAt(start++);
156
        if ( c!='P' && c!='-' ) {
157
            throw new InvalidDatatypeValueException(ERROR_MESSAGE+str);
158
        }
159
        else {
160
            date[XMLCalendar.utc]=(c=='-')?'-':0;
161
            if ( c=='-' && str.charAt(start++)!='P' ) {
162
                throw new InvalidDatatypeValueException(ERROR_MESSAGE+str);
163
            }
164
        }
165
166
        int negate = 1;
167
        //negative duration
168
        if ( date[XMLCalendar.utc]=='-' ) {
169
            negate = -1;
170
171
        }
172
        //at least one number and designator must be seen after P
173
        boolean designator = false;
174
175
        int endDate = XMLCalendar.indexOf (str, start, len, 'T');
176
        if ( endDate == -1 ) {
177
            endDate = len;
178
        }
179
        //find 'Y'
180
        int end = XMLCalendar.indexOf (str, start, endDate, 'Y');
181
        if ( end!=-1 ) {
182
            //scan year
183
            date[XMLCalendar.CY]=negate * XMLCalendar.parseInt(str,start,end);
184
            start = end+1;
185
            designator = true;
186
        }
187
188
        end = XMLCalendar.indexOf (str, start, endDate, 'M');
189
        if ( end!=-1 ) {
190
            //scan month
191
            date[XMLCalendar.M]=negate * XMLCalendar.parseInt(str,start,end);
192
            start = end+1;
193
            designator = true;
194
        }
195
196
        end = XMLCalendar.indexOf (str, start, endDate, 'D');
197
        if ( end!=-1 ) {
198
            //scan day
199
            date[XMLCalendar.D]=negate * XMLCalendar.parseInt(str,start,end);
200
            start = end+1;
201
            designator = true;
202
        }
203
204
        if ( len == endDate && start!=len ) {
205
            throw new InvalidDatatypeValueException(ERROR_MESSAGE+str);
206
        }
207
        if ( len !=endDate ) {
208
209
            end = XMLCalendar.indexOf (str, ++start, len, 'H');
210
            if ( end!=-1 ) {
211
                //scan hours
212
                date[XMLCalendar.h]=negate * XMLCalendar.parseInt(str,start,end);
213
                start=end+1;
214
                designator = true;
215
            }
216
217
            end = XMLCalendar.indexOf (str, start, len, 'M');
218
            if ( end!=-1 ) {
219
                //scan min
220
                date[XMLCalendar.m]=negate * XMLCalendar.parseInt(str,start,end);
221
                start=end+1;
222
                designator = true;
223
            }
224
225
            end = XMLCalendar.indexOf (str, start, len, 'S');
226
            if ( end!=-1 ) {
227
                //scan seconds
228
                int mlsec = XMLCalendar.indexOf (str, start, end, '.');
229
                if ( mlsec >0 ) {
230
                    date[XMLCalendar.s]  = negate * XMLCalendar.parseInt (str, start, mlsec);
231
                    date[XMLCalendar.ms] = negate * XMLCalendar.parseInt (str, mlsec+1, end);
232
                }
233
                else {
234
                    date[XMLCalendar.s]=negate * XMLCalendar.parseInt(str, start,end);
235
                }
236
                start=end+1;
237
                designator = true;
238
            }
239
            // no additional data shouls appear after last item
240
            // P1Y1M1DT is illigal value as well
241
            if ( start != len || str.charAt(--start)=='T' ) {
242
                throw new InvalidDatatypeValueException(ERROR_MESSAGE+str);
243
            }
244
        }
245
246
        if ( !designator ) {
247
            throw new InvalidDatatypeValueException(ERROR_MESSAGE+str);
248
        }
249
250
        return date;
251
    }
252
253
    /**
254
     * Compares 2 given durations. (refer to W3C Schema Datatypes "3.2.6 duration")
255
     *
256
     * @param date1  Unnormalized duration
257
     * @param date2  Unnormalized duration
258
     * @param strict (min/max)Exclusive strict == true ( LESS_THAN ) or ( GREATER_THAN )
259
     *               (min/max)Inclusive strict == false (LESS_EQUAL) or (GREATER_EQUAL)
260
     * @return INDETERMINATE if the order relationship between date1 and date2 is indeterminate. 
261
     * EQUAL if the order relation between date1 and date2 is EQUAL.  
262
     * If the strict parameter is true, return LESS_THAN if date1 is less than date2 and
263
     * return GREATER_THAN if date1 is greater than date2. 
264
     * If the strict parameter is false, return LESS_THAN if date1 is less than OR equal to date2 and
265
     * return GREATER_THAN if date1 is greater than OR equal to date2 
266
     */
267
    protected  static short compareDates(int[] date1, int[] date2, boolean strict) {
268
269
        //REVISIT: this is unoptimazed vs of comparing 2 durations
270
        //         Algorithm is described in 3.2.6.2 W3C Schema Datatype specs
271
        //
272
273
        //add constA to both durations
274
        short resultA, resultB= TypeValidator.INDETERMINATE;
275
276
        //try and see if the objects are equal
277
        resultA = XMLCalendar.compareOrder (date1, date2);
278
        if ( resultA == 0 ) {
279
            return 0;
280
        }
281
282
        int[][] result = new int[2][XMLCalendar.TOTAL_SIZE];
283
284
        //long comparison algorithm is required
285
        int[] tempA = addDuration (date1, DATETIMES[0], result[0]);
286
        int[] tempB = addDuration (date2, DATETIMES[0], result[1]);
287
        resultA =  XMLCalendar.compareOrder(tempA, tempB);
288
        if ( resultA == TypeValidator.INDETERMINATE ) {
289
            return TypeValidator.INDETERMINATE;
290
        }
291
292
        tempA = addDuration(date1, DATETIMES[1], result[0]);
293
        tempB = addDuration(date2, DATETIMES[1], result[1]);
294
        resultB = XMLCalendar.compareOrder(tempA, tempB);
295
        resultA = compareResults(resultA, resultB, strict);
296
        if (resultA == TypeValidator.INDETERMINATE) {
297
            return TypeValidator.INDETERMINATE;
298
        }
299
300
        tempA = addDuration(date1, DATETIMES[2], result[0]);
301
        tempB = addDuration(date2, DATETIMES[2], result[1]);
302
        resultB = XMLCalendar.compareOrder(tempA, tempB);
303
        resultA = compareResults(resultA, resultB, strict);
304
        if (resultA == TypeValidator.INDETERMINATE) {
305
            return TypeValidator.INDETERMINATE;
306
        }
307
308
        tempA = addDuration(date1, DATETIMES[3], result[0]);
309
        tempB = addDuration(date2, DATETIMES[3], result[1]);
310
        resultB = XMLCalendar.compareOrder(tempA, tempB);
311
        resultA = compareResults(resultA, resultB, strict);
312
313
        return resultA;
314
    }
315
316
    private static short compareResults(short resultA, short resultB, boolean strict){
317
318
      if ( resultB == TypeValidator.INDETERMINATE ) {
319
            return TypeValidator.INDETERMINATE;
320
        }
321
        else if ( resultA!=resultB && strict ) {
322
            return TypeValidator.INDETERMINATE;
323
        }
324
        else if ( resultA!=resultB && !strict ) {
325
            if ( resultA!=0 && resultB!=0 ) {
326
                return TypeValidator.INDETERMINATE;
327
            }
328
            else {
329
                return (resultA!=0)?resultA:resultB;
330
            }
331
        }
332
        return resultA;
333
    }
334
335
    private static int[] addDuration(int[] date, int[] addto, int[] duration) {
336
337
        //REVISIT: some code could be shared between normalize() and this method,
338
        //         however is it worth moving it? The structures are different...
339
        //
340
341
        XMLCalendar.resetDateObj(duration);
342
        //add months (may be modified additionaly below)
343
        int temp = addto[XMLCalendar.M] + date[XMLCalendar.M];
344
        duration[XMLCalendar.M] = XMLCalendar.modulo (temp, 1, 13);
345
        int carry = XMLCalendar.fQuotient (temp, 1, 13);
346
347
        //add years (may be modified additionaly below)
348
        duration[XMLCalendar.CY]=addto[XMLCalendar.CY] + date[XMLCalendar.CY] + carry;
349
        
350
        //add milliseconds
351
        temp = addto[XMLCalendar.ms] + date[XMLCalendar.ms];
352
        carry = XMLCalendar.fQuotient(temp, 1000);
353
        duration[XMLCalendar.ms] = XMLCalendar.mod(temp, 1000, carry);
354
355
356
        //add seconds
357
        temp = addto[XMLCalendar.s] + date[XMLCalendar.s];
358
        carry = XMLCalendar.fQuotient (temp, 60);
359
        duration[XMLCalendar.s] =  XMLCalendar.mod(temp, 60, carry);
360
361
        //add minutes
362
        temp = addto[XMLCalendar.m] +date[XMLCalendar.m] + carry;
363
        carry = XMLCalendar.fQuotient (temp, 60);
364
        duration[XMLCalendar.m]= XMLCalendar.mod(temp, 60, carry);
365
366
        //add hours
367
        temp = addto[XMLCalendar.h] + date[XMLCalendar.h] + carry;
368
        carry = XMLCalendar.fQuotient(temp, 24);
369
        duration[XMLCalendar.h] = XMLCalendar.mod(temp, 24, carry);
370
371
372
        duration[XMLCalendar.D]=addto[XMLCalendar.D] + date[XMLCalendar.D] + carry;
373
374
        while ( true ) {
375
376
            temp=XMLCalendar.maxDayInMonthFor(duration[XMLCalendar.CY], duration[XMLCalendar.M]);
377
            if ( duration[XMLCalendar.D] < 1 ) { //original duration was negative
378
                duration[XMLCalendar.D] = duration[XMLCalendar.D] + XMLCalendar.maxDayInMonthFor(duration[XMLCalendar.CY], duration[XMLCalendar.M]-1);
379
                carry=-1;
380
            }
381
            else if ( duration[XMLCalendar.D] > temp ) {
382
                duration[XMLCalendar.D] = duration[XMLCalendar.D] - temp;
383
                carry=1;
384
            }
385
            else {
386
                break;
387
            }
388
            temp = duration[XMLCalendar.M]+carry;
389
            duration[XMLCalendar.M] = XMLCalendar.modulo(temp, 1, 13);
390
            duration[XMLCalendar.CY] = duration[XMLCalendar.CY]+XMLCalendar.fQuotient(temp, 1, 13);
391
        }
392
393
        duration[XMLCalendar.utc]='Z';
394
        return duration;
395
    }
396
397
    public String toString() {
398
      return valueString;
399
    }
400
}
(-)src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java (-53 / +58 lines)
Lines 16-24 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.impl;
17
package org.eclipse.emf.ecore.impl;
18
18
19
19
//XXX GWT CHANGE
20
import java.math.BigDecimal;
20
//import java.math.BigDecimal;
21
import java.math.BigInteger;
21
//import java.math.BigInteger;
22
import java.util.Date;
22
import java.util.Date;
23
import java.util.Map;
23
import java.util.Map;
24
24
Lines 211-229 Link Here
211
   */
211
   */
212
  private EClass eStringToStringMapEntryEClass = null;
212
  private EClass eStringToStringMapEntryEClass = null;
213
213
214
  /**
214
//XXX GWT CHANGE No Big-Value
215
   * <!-- begin-user-doc -->
215
//  /**
216
   * <!-- end-user-doc -->
216
//   * <!-- begin-user-doc -->
217
   * @generated
217
//   * <!-- end-user-doc -->
218
   */
218
//   * @generated
219
  private EDataType eBigDecimalEDataType = null;
219
//   */
220
220
//  private EDataType eBigDecimalEDataType = null;
221
  /**
221
//
222
   * <!-- begin-user-doc -->
222
//  /**
223
   * <!-- end-user-doc -->
223
//   * <!-- begin-user-doc -->
224
   * @generated
224
//   * <!-- end-user-doc -->
225
   */
225
//   * @generated
226
  private EDataType eBigIntegerEDataType = null;
226
//   */
227
//  private EDataType eBigIntegerEDataType = null;
227
228
228
  /**
229
  /**
229
   * <!-- begin-user-doc -->
230
   * <!-- begin-user-doc -->
Lines 1275-1299 Link Here
1275
    return (EAttribute)eStringToStringMapEntryEClass.getEStructuralFeatures().get(1);
1276
    return (EAttribute)eStringToStringMapEntryEClass.getEStructuralFeatures().get(1);
1276
  }
1277
  }
1277
1278
1278
  /**
1279
//XXX GWT CHANGE
1279
   * <!-- begin-user-doc -->
1280
//  /**
1280
   * <!-- end-user-doc -->
1281
//   * <!-- begin-user-doc -->
1281
   * @generated
1282
//   * <!-- end-user-doc -->
1282
   */
1283
//   * @generated
1283
  public EDataType getEBigDecimal()
1284
//   */
1284
  {
1285
//  public EDataType getEBigDecimal()
1285
    return eBigDecimalEDataType;
1286
//  {
1286
  }
1287
//    return eBigDecimalEDataType;
1287
1288
//  }
1288
  /**
1289
//
1289
   * <!-- begin-user-doc -->
1290
//  /**
1290
   * <!-- end-user-doc -->
1291
//   * <!-- begin-user-doc -->
1291
   * @generated
1292
//   * <!-- end-user-doc -->
1292
   */
1293
//   * @generated
1293
  public EDataType getEBigInteger()
1294
//   */
1294
  {
1295
//  public EDataType getEBigInteger()
1295
    return eBigIntegerEDataType;
1296
//  {
1296
  }
1297
//    return eBigIntegerEDataType;
1298
//  }
1297
1299
1298
  /**
1300
  /**
1299
   * <!-- begin-user-doc -->
1301
   * <!-- begin-user-doc -->
Lines 1798-1805 Link Here
1798
    createEAttribute(eStringToStringMapEntryEClass, ESTRING_TO_STRING_MAP_ENTRY__VALUE);
1800
    createEAttribute(eStringToStringMapEntryEClass, ESTRING_TO_STRING_MAP_ENTRY__VALUE);
1799
1801
1800
    // Create data types
1802
    // Create data types
1801
    eBigDecimalEDataType = createEDataType(EBIG_DECIMAL);
1803
//XXX GWT CHANGE No Big-Values
1802
    eBigIntegerEDataType = createEDataType(EBIG_INTEGER);
1804
//    eBigDecimalEDataType = createEDataType(EBIG_DECIMAL);
1805
//    eBigIntegerEDataType = createEDataType(EBIG_INTEGER);
1803
    eBooleanEDataType = createEDataType(EBOOLEAN);
1806
    eBooleanEDataType = createEDataType(EBOOLEAN);
1804
    eBooleanObjectEDataType = createEDataType(EBOOLEAN_OBJECT);
1807
    eBooleanObjectEDataType = createEDataType(EBOOLEAN_OBJECT);
1805
    eByteEDataType = createEDataType(EBYTE);
1808
    eByteEDataType = createEDataType(EBYTE);
Lines 2062-2069 Link Here
2062
    initEAttribute(getEStringToStringMapEntry_Value(), ecorePackage.getEString(), "value", null, 0, 1, Map.Entry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
2065
    initEAttribute(getEStringToStringMapEntry_Value(), ecorePackage.getEString(), "value", null, 0, 1, Map.Entry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
2063
2066
2064
    // Initialize data types
2067
    // Initialize data types
2065
    initEDataType(eBigDecimalEDataType, BigDecimal.class, "EBigDecimal", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2068
//XXX GWT CHANGE No Big-Value
2066
    initEDataType(eBigIntegerEDataType, BigInteger.class, "EBigInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2069
//    initEDataType(eBigDecimalEDataType, BigDecimal.class, "EBigDecimal", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2070
//    initEDataType(eBigIntegerEDataType, BigInteger.class, "EBigInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2067
    initEDataType(eBooleanEDataType, boolean.class, "EBoolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2071
    initEDataType(eBooleanEDataType, boolean.class, "EBoolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2068
    initEDataType(eBooleanObjectEDataType, Boolean.class, "EBooleanObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2072
    initEDataType(eBooleanObjectEDataType, Boolean.class, "EBooleanObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2069
    initEDataType(eByteEDataType, byte.class, "EByte", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2073
    initEDataType(eByteEDataType, byte.class, "EByte", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
Lines 2108-2127 Link Here
2108
  protected void createExtendedMetaDataAnnotations()
2112
  protected void createExtendedMetaDataAnnotations()
2109
  {
2113
  {
2110
    String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";		
2114
    String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";		
2111
    addAnnotation
2115
//XXX GWT CHANGE No Big-Values
2112
      (eBigDecimalEDataType, 
2116
//    addAnnotation
2113
       source, 
2117
//      (eBigDecimalEDataType,
2114
       new String[] 
2118
//       source,
2115
       {
2119
//       new String[]
2116
       "baseType", "http://www.w3.org/2001/XMLSchema#decimal"
2120
//       {
2117
       });		
2121
//       "baseType", "http://www.w3.org/2001/XMLSchema#decimal"
2118
    addAnnotation
2122
//       });
2119
      (eBigIntegerEDataType, 
2123
//    addAnnotation
2120
       source, 
2124
//      (eBigIntegerEDataType,
2121
       new String[] 
2125
//       source,
2122
       {
2126
//       new String[]
2123
       "baseType", "http://www.w3.org/2001/XMLSchema#integer"
2127
//       {
2124
       });		
2128
//       "baseType", "http://www.w3.org/2001/XMLSchema#integer"
2129
//       });
2125
    addAnnotation
2130
    addAnnotation
2126
      (eBooleanEDataType, 
2131
      (eBooleanEDataType, 
2127
       source, 
2132
       source, 
(-)src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java (-8 / +10 lines)
Lines 2041-2050 Link Here
2041
2041
2042
    protected void validate(Object object)
2042
    protected void validate(Object object)
2043
    {
2043
    {
2044
      if (!dataClass.isInstance(object))
2044
//FIXME GWT CHANGE No isInstance check     
2045
      {
2045
//      if (!dataClass.isInstance(object))
2046
        throw new ClassCastException("The value of type '" + object.getClass() + "' must be of type '" + dataClass + "'");
2046
//      {
2047
      }
2047
//        throw new ClassCastException("The value of type '" + Util.getClassNameAsString(object) + "' must be of type '" + dataClass + "'");
2048
//      }
2048
    }
2049
    }
2049
  }
2050
  }
2050
2051
Lines 2190-2199 Link Here
2190
2191
2191
    protected void validate(Object object)
2192
    protected void validate(Object object)
2192
    {
2193
    {
2193
      if (!dataClass.isInstance(object))
2194
//FIXME GWT CHANGE No Reflection     
2194
      {
2195
//      if (!dataClass.isInstance(object))
2195
        throw new ClassCastException("The value of type '" + object.getClass() + "' must be of type '" + dataClass + "'");
2196
//      {
2196
      }
2197
//        throw new ClassCastException("The value of type '" + Util.getClassNameAsString(object) + "' must be of type '" + dataClass + "'");
2198
//      }
2197
    }
2199
    }
2198
  }
2200
  }
2199
2201
(-)src/org/eclipse/emf/ecore/impl/EPackageImpl.java (-33 / +38 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.impl;
17
package org.eclipse.emf.ecore.impl;
18
18
19
19
//XXX GWT CHANGE No reflection
20
import java.lang.reflect.Method;
20
//import java.lang.reflect.Method;
21
import java.util.Collection;
21
import java.util.Collection;
22
import java.util.HashMap;
22
import java.util.HashMap;
23
import java.util.Iterator;
23
import java.util.Iterator;
Lines 678-697 Link Here
678
    Resource resource = eResource();
678
    Resource resource = eResource();
679
    if (resource == null) 
679
    if (resource == null) 
680
    {
680
    {
681
      if (resourceFactory == null)
681
    	System.err.println("EPackageImpl#createResource(String) is not implemented in GWT");
682
      {
682
    	throw new UnsupportedOperationException();
683
        try
683
//FIXME GWT CHANGE No Reflection
684
        {
684
//      if (resourceFactory == null)
685
          resourceFactory = (Resource.Factory)CommonPlugin.loadClass("org.eclipse.emf.ecore.xmi", "org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl").newInstance();
685
//      {
686
        }
686
//        try
687
        catch (Throwable exception)
687
//        {
688
        {
688
//          resourceFactory = (Resource.Factory)CommonPlugin.loadClass("org.eclipse.emf.ecore.xmi", "org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl").newInstance();
689
          resourceFactory = new ResourceFactoryImpl();
689
//        }
690
        }
690
//        catch (Throwable exception)
691
      }
691
//        {
692
      URI actualURI = URI.createURI(uri);
692
//          resourceFactory = new ResourceFactoryImpl();
693
      resource =  resourceFactory.createResource(actualURI);
693
//        }
694
      resource.getContents().add(this);
694
//      }
695
//      URI actualURI = URI.createURI(uri);
696
//      resource =  resourceFactory.createResource(actualURI);
697
//      resource.getContents().add(this);
695
    }
698
    }
696
    return resource;
699
    return resource;
697
  }
700
  }
Lines 1424-1446 Link Here
1424
1427
1425
  protected void fixEEnumLiterals(EEnum eEnum)
1428
  protected void fixEEnumLiterals(EEnum eEnum)
1426
  {
1429
  {
1427
    Class enumClass = eEnum.getInstanceClass();
1430
	  throw new UnsupportedOperationException();
1428
    
1431
//XXX GWT CHANGE No Reflection
1429
    try
1432
//    Class enumClass = eEnum.getInstanceClass();
1430
    {
1433
//
1431
      Method getter = enumClass.getMethod("get", new Class[] { Integer.TYPE });
1434
//    try
1432
1435
//    {
1433
      for (Iterator i = eEnum.getELiterals().iterator(); i.hasNext(); )
1436
//      Method getter = enumClass.getMethod("get", new Class[] { Integer.TYPE });
1434
      {
1437
//
1435
        EEnumLiteral eEnumLiteral = (EEnumLiteral)i.next();
1438
//      for (Iterator i = eEnum.getELiterals().iterator(); i.hasNext(); )
1436
        Enumerator instance = (Enumerator)getter.invoke(null, new Object[] { new Integer(eEnumLiteral.getValue()) });
1439
//      {
1437
        eEnumLiteral.setInstance(instance);
1440
//        EEnumLiteral eEnumLiteral = (EEnumLiteral)i.next();
1438
      }
1441
//        Enumerator instance = (Enumerator)getter.invoke(null, new Object[] { new Integer(eEnumLiteral.getValue()) });
1439
    }
1442
//        eEnumLiteral.setInstance(instance);
1440
    catch (Exception e)
1443
//      }
1441
    {
1444
//    }
1442
      // Do nothing
1445
//    catch (Exception e)
1443
    }
1446
//    {
1447
//      // Do nothing
1448
//    }
1444
  }
1449
  }
1445
1450
1446
  protected BasicExtendedMetaData.EPackageExtendedMetaData ePackageExtendedMetaData;
1451
  protected BasicExtendedMetaData.EPackageExtendedMetaData ePackageExtendedMetaData;
(-)src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java (-39 / +45 lines)
Lines 16-25 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.impl;
17
package org.eclipse.emf.ecore.impl;
18
18
19
19
//XXX GWT CHANGE No Big-Values
20
import java.math.BigDecimal;
20
//import java.math.BigDecimal;
21
import java.math.BigInteger;
21
//import java.math.BigInteger;
22
import java.text.ParseException;
22
//import java.text.ParseException;
23
import java.util.Date;
23
import java.util.Date;
24
import java.util.Map;
24
import java.util.Map;
25
25
Lines 112-121 Link Here
112
  {
112
  {
113
    switch (eDataType.getClassifierID())
113
    switch (eDataType.getClassifierID())
114
    {
114
    {
115
      case EcorePackage.EBIG_DECIMAL:
115
//XXX GWT CHANGE BigInteger and Decimal not available
116
        return createEBigDecimalFromString(eDataType, initialValue);
116
//      case EcorePackage.EBIG_DECIMAL:
117
      case EcorePackage.EBIG_INTEGER:
117
//        return createEBigDecimalFromString(eDataType, initialValue);
118
        return createEBigIntegerFromString(eDataType, initialValue);
118
//      case EcorePackage.EBIG_INTEGER:
119
//        return createEBigIntegerFromString(eDataType, initialValue);
119
      case EcorePackage.EBOOLEAN:
120
      case EcorePackage.EBOOLEAN:
120
        return createEBooleanFromString(eDataType, initialValue);
121
        return createEBooleanFromString(eDataType, initialValue);
121
      case EcorePackage.EBOOLEAN_OBJECT:
122
      case EcorePackage.EBOOLEAN_OBJECT:
Lines 172-181 Link Here
172
  {
173
  {
173
    switch (eDataType.getClassifierID())
174
    switch (eDataType.getClassifierID())
174
    {
175
    {
175
      case EcorePackage.EBIG_DECIMAL:
176
//XXX GWT CHANGE BigInteger and Decimal not available
176
        return convertEBigDecimalToString(eDataType, instanceValue);
177
//      case EcorePackage.EBIG_DECIMAL:
177
      case EcorePackage.EBIG_INTEGER:
178
//        return convertEBigDecimalToString(eDataType, instanceValue);
178
        return convertEBigIntegerToString(eDataType, instanceValue);
179
//      case EcorePackage.EBIG_INTEGER:
180
//        return convertEBigIntegerToString(eDataType, instanceValue);
179
      case EcorePackage.EBOOLEAN:
181
      case EcorePackage.EBOOLEAN:
180
        return convertEBooleanToString(eDataType, instanceValue);
182
        return convertEBooleanToString(eDataType, instanceValue);
181
      case EcorePackage.EBOOLEAN_OBJECT:
183
      case EcorePackage.EBOOLEAN_OBJECT:
Lines 442-448 Link Here
442
      {
444
      {
443
        return EDATE_FORMATS[i].parse(initialValue);
445
        return EDATE_FORMATS[i].parse(initialValue);
444
      }
446
      }
445
      catch (ParseException parseException)
447
//XXX GWT CHANGE gwt-widgets is through IllegalArgument Exception
448
      catch (IllegalArgumentException parseException)
446
      {
449
      {
447
        exception = parseException;
450
        exception = parseException;
448
      }
451
      }
Lines 549-563 Link Here
549
    return eStringToStringMapEntry;
552
    return eStringToStringMapEntry;
550
  }
553
  }
551
554
552
  /**
555
//XXX GWT CHANGE No BigDecimal
553
   * <!-- begin-user-doc -->
556
//  /**
554
   * <!-- end-user-doc -->
557
//   * <!-- begin-user-doc -->
555
   * @generated NOT
558
//   * <!-- end-user-doc -->
556
   */
559
//   * @generated NOT
557
  public BigDecimal createEBigDecimalFromString(EDataType eDataType, String initialValue)
560
//   */
558
  {
561
//  public BigDecimal createEBigDecimalFromString(EDataType eDataType, String initialValue)
559
    return initialValue == null ? null : new BigDecimal(initialValue);
562
//  {
560
  }
563
//    return initialValue == null ? null : new BigDecimal(initialValue);
564
//  }
561
565
562
  /**
566
  /**
563
   * <!-- begin-user-doc -->
567
   * <!-- begin-user-doc -->
Lines 569-583 Link Here
569
    return instanceValue == null ? null : instanceValue.toString();
573
    return instanceValue == null ? null : instanceValue.toString();
570
  }
574
  }
571
575
572
  /**
576
//XXX GWT CHANGE No BigDecimal
573
   * <!-- begin-user-doc -->
577
//  /**
574
   * <!-- end-user-doc -->
578
//   * <!-- begin-user-doc -->
575
   * @generated NOT
579
//   * <!-- end-user-doc -->
576
   */
580
//   * @generated NOT
577
  public BigInteger createEBigIntegerFromString(EDataType eDataType, String initialValue)
581
//   */
578
  {
582
//  public BigInteger createEBigIntegerFromString(EDataType eDataType, String initialValue)
579
    return initialValue == null ? null : new BigInteger(initialValue);
583
//  {
580
  }
584
//    return initialValue == null ? null : new BigInteger(initialValue);
585
//  }
581
586
582
  /**
587
  /**
583
   * <!-- begin-user-doc -->
588
   * <!-- begin-user-doc -->
Lines 957-964 Link Here
957
   */
962
   */
958
  public Class createEJavaClassFromString(EDataType metaObject, String initialValue) 
963
  public Class createEJavaClassFromString(EDataType metaObject, String initialValue) 
959
  {
964
  {
960
    try
965
//    try
961
    {
966
//    {
962
      if (initialValue == null) return null;
967
      if (initialValue == null) return null;
963
      else if ("boolean".equals(initialValue)) return boolean.class;
968
      else if ("boolean".equals(initialValue)) return boolean.class;
964
      else if ("byte".equals(initialValue)) return byte.class;
969
      else if ("byte".equals(initialValue)) return byte.class;
Lines 968-979 Link Here
968
      else if ("int".equals(initialValue)) return int.class;
973
      else if ("int".equals(initialValue)) return int.class;
969
      else if ("long".equals(initialValue)) return long.class;
974
      else if ("long".equals(initialValue)) return long.class;
970
      else if ("short".equals(initialValue)) return short.class;
975
      else if ("short".equals(initialValue)) return short.class;
971
      else return Class.forName(initialValue);
976
//      else return Class.forName(initialValue);
972
    }
977
      else throw new UnsupportedOperationException();
973
    catch (ClassNotFoundException e)
978
//    }
974
    {
979
//    catch (ClassNotFoundException e)
975
      throw new WrappedException(e);
980
//    {
976
    }
981
//      throw new WrappedException(e);
982
//    }
977
  }
983
  }
978
984
979
  /**
985
  /**
(-)src/org/eclipse/emf/ecore/impl/EClassifierImpl.java (-58 / +66 lines)
Lines 147-152 Link Here
147
   */
147
   */
148
  public boolean isInstance(Object object)
148
  public boolean isInstance(Object object)
149
  {
149
  {
150
//FIXME GWT CHANGE Integer.TYPE, ..
150
    if (object != null)
151
    if (object != null)
151
    {
152
    {
152
      Class instanceClass = getInstanceClass();
153
      Class instanceClass = getInstanceClass();
Lines 154-195 Link Here
154
      {
155
      {
155
        if (instanceClass.isPrimitive())
156
        if (instanceClass.isPrimitive())
156
        {
157
        {
157
          if (instanceClass == Boolean.TYPE)
158
          if (instanceClass == boolean.class)
158
          {
159
          {
159
            return object instanceof Boolean;
160
            return object instanceof Boolean;
160
          }
161
          }
161
          else if (instanceClass == Integer.TYPE)
162
          else if (instanceClass == int.class)
162
          {
163
          {
163
            return object instanceof Integer;
164
            return object instanceof Integer;
164
          }
165
          }
165
          else if (instanceClass == Float.TYPE)
166
          else if (instanceClass == float.class)
166
          {
167
          {
167
            return object instanceof Float;
168
            return object instanceof Float;
168
          }
169
          }
169
          else if (instanceClass == Byte.TYPE)
170
          else if (instanceClass == byte.class)
170
          {
171
          {
171
            return object instanceof Byte;
172
            return object instanceof Byte;
172
          }
173
          }
173
          else if (instanceClass == Character.TYPE)
174
          else if (instanceClass == char.class)
174
          {
175
          {
175
            return object instanceof Character;
176
            return object instanceof Character;
176
          }
177
          }
177
          else if (instanceClass == Double.TYPE)
178
          else if (instanceClass == double.class)
178
          {
179
          {
179
            return object instanceof Double;
180
            return object instanceof Double;
180
          }
181
          }
181
          else if (instanceClass == Short.TYPE)
182
          else if (instanceClass == short.class)
182
          {
183
          {
183
            return object instanceof Short;
184
            return object instanceof Short;
184
          }
185
          }
185
          else if (instanceClass == Long.TYPE)
186
          else if (instanceClass == long.class)
186
          {
187
          {
187
            return object instanceof Long;
188
            return object instanceof Long;
188
          }
189
          }
189
        }
190
        }
190
        else
191
        else
191
        {
192
        {
192
          return instanceClass.isInstance(object);
193
//FIXME GWT CHANGE No isInstance available
194
//          return instanceClass.isInstance(object);
195
          return true;
193
        }
196
        }
194
      }
197
      }
195
      else if (object instanceof EObject)
198
      else if (object instanceof EObject)
Lines 267-273 Link Here
267
      instanceClassName = generatedInstanceClassName;
270
      instanceClassName = generatedInstanceClassName;
268
      generatedInstanceClassName = null;
271
      generatedInstanceClassName = null;
269
    }
272
    }
270
    setInstanceClassNameGen(value == null ? null : value.intern());
273
    //FIXME GWT CHANGE String.intern not available
274
    setInstanceClassNameGen(value == null ? null : value);
271
    if (instanceClass != null)
275
    if (instanceClass != null)
272
    {
276
    {
273
      setInstanceClassGen(null);
277
      setInstanceClassGen(null);
Lines 313-330 Link Here
313
  {
317
  {
314
    if (instanceClass == null && (instanceClassName != null || generatedInstanceClassName != null))
318
    if (instanceClass == null && (instanceClassName != null || generatedInstanceClassName != null))
315
    {
319
    {
316
      try
320
//      try
317
      {
321
//      {
318
        setInstanceClassGen(getClassForName(getInstanceClassName()));
322
        setInstanceClassGen(getClassForName(getInstanceClassName()));
319
      }
323
//      }
320
      catch (ClassNotFoundException e)
324
//      catch (ClassNotFoundException e)
321
      {
325
//      {
322
        Class primitiveClass = getPrimitiveOrArrayClass();
326
//        Class primitiveClass = getPrimitiveOrArrayClass();
323
        if (primitiveClass != null)
327
//        if (primitiveClass != null)
324
          setInstanceClassGen(primitiveClass);
328
//          setInstanceClassGen(primitiveClass);
325
        else
329
//        else
326
          throw new WrappedException(e);
330
//          throw new WrappedException(e);
327
      }
331
//      }
328
    }
332
    }
329
    return getInstanceClassGen();
333
    return getInstanceClassGen();
330
  }
334
  }
Lines 335-344 Link Here
335
   * used. Since the package may be model-specific code in another plug-in, its class loader may be able to see classes
339
   * used. Since the package may be model-specific code in another plug-in, its class loader may be able to see classes
336
   * that Ecore's can't.
340
   * that Ecore's can't.
337
   */
341
   */
338
  protected Class getClassForName(String name) throws ClassNotFoundException
342
  protected Class getClassForName(String name) /*throws ClassNotFoundException*/
339
  {
343
  {
340
    EPackage p = getEPackage();
344
    EPackage p = getEPackage();
341
    return p != null ? Class.forName(name, true, p.getClass().getClassLoader()) : Class.forName(name);
345
//FIXME GWT CHANGE When is this called
346
//    return p != null ? Class.forName(name, true, p.getClass().getClassLoader()) : Class.forName(name);
347
	  throw new UnsupportedOperationException();
342
  }
348
  }
343
  
349
  
344
  protected Class getPrimitiveOrArrayClass() 
350
  protected Class getPrimitiveOrArrayClass() 
Lines 371-400 Link Here
371
        result.append(componentClassName);
377
        result.append(componentClassName);
372
        result.append(';');
378
        result.append(';');
373
      }
379
      }
374
      try
380
//FIXME GWT CHANGE No dynamic loading
375
      {
381
//      try
382
//      {
376
        return getClassForName(result.toString());
383
        return getClassForName(result.toString());
377
      }
384
//      }
378
      catch (ClassNotFoundException e) {}
385
//      catch (ClassNotFoundException e) {}
379
    }
386
    }
380
    else
387
    else
381
    {
388
    {
382
      if (className.equals("boolean"))
389
      if (className.equals("boolean"))
383
        return java.lang.Boolean.TYPE;
390
        return boolean.class;
384
      else if (className.equals("byte"))
391
      else if (className.equals("byte"))
385
        return java.lang.Byte.TYPE;
392
        return byte.class;
386
      else if (className.equals("char"))
393
      else if (className.equals("char"))
387
        return java.lang.Character.TYPE;
394
        return char.class;
388
      else if (className.equals("double"))
395
      else if (className.equals("double"))
389
        return java.lang.Double.TYPE;
396
        return double.class;
390
      else if (className.equals("float"))
397
      else if (className.equals("float"))
391
        return java.lang.Float.TYPE;
398
        return float.class;
392
      else if (className.equals("int"))
399
      else if (className.equals("int"))
393
        return java.lang.Integer.TYPE;
400
        return int.class;
394
      else if (className.equals("long"))
401
      else if (className.equals("long"))
395
        return java.lang.Long.TYPE;
402
        return long.class;
396
      else if (className.equals("short"))
403
      else if (className.equals("short"))
397
        return java.lang.Short.TYPE;
404
        return short.class;
398
    }
405
    }
399
    return null;
406
    return null;
400
  }
407
  }
Lines 408-436 Link Here
408
415
409
  public void setInstanceClass(Class value)
416
  public void setInstanceClass(Class value)
410
  {
417
  {
411
    if (value == null)
418
//FIXME GWT CHANGE Is this really needed
412
    {
419
//    if (value == null)
413
      setInstanceClassNameGen(null);
420
//    {
414
    }
421
//      setInstanceClassNameGen(null);
415
    else if (value.isArray())
422
//    }
416
    {
423
//    else if (value.isArray())
417
      String indices = "[]";
424
//    {
418
      for (Class component = value.getComponentType(); ; component = component.getComponentType())
425
//      String indices = "[]";
419
      {
426
//      for (Class component = value.getComponentType(); ; component = component.getComponentType())
420
        if (!component.isArray())
427
//      {
421
        {
428
//        if (!component.isArray())
422
          setInstanceClassNameGen((component.getName() + indices).intern());
429
//        {
423
          break;
430
//          setInstanceClassNameGen((component.getName() + indices).intern());
424
        }
431
//          break;
425
        indices += "[]";
432
//        }
426
      }
433
//        indices += "[]";
427
    }
434
//      }
428
    else
435
//    }
429
    {
436
//    else
430
      setInstanceClassNameGen(value.getName().intern());
437
//    {
431
    }
438
//      setInstanceClassNameGen(value.getName().intern());
432
439
//    }
433
    setInstanceClassGen(value);
440
//
441
//    setInstanceClassGen(value);
434
  }
442
  }
435
443
436
  /**
444
  /**
(-)src/org/eclipse/emf/ecore/impl/EFactoryImpl.java (-79 / +86 lines)
Lines 16-29 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.impl;
17
package org.eclipse.emf.ecore.impl;
18
18
19
19
//XXX GWT CHANGE REFLECTION NOT AVAILABLE
20
import java.lang.reflect.Constructor;
20
//import java.lang.reflect.Constructor;
21
import java.lang.reflect.InvocationTargetException;
21
//import java.lang.reflect.InvocationTargetException;
22
import java.lang.reflect.Method;
22
//import java.lang.reflect.Method;
23
import java.text.DateFormat;
23
//import java.text.DateFormat;
24
import java.text.FieldPosition;
24
//import java.text.FieldPosition;
25
import java.text.ParseException;
25
//import java.text.ParseException;
26
import java.text.SimpleDateFormat;
26
//import java.text.SimpleDateFormat;
27
import java.util.ArrayList;
27
import java.util.ArrayList;
28
import java.util.Collection;
28
import java.util.Collection;
29
import java.util.Date;
29
import java.util.Date;
Lines 45-50 Link Here
45
import org.eclipse.emf.ecore.util.ExtendedMetaData;
45
import org.eclipse.emf.ecore.util.ExtendedMetaData;
46
import org.eclipse.emf.ecore.util.InternalEList;
46
import org.eclipse.emf.ecore.util.InternalEList;
47
import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil;
47
import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil;
48
//XXX GWT CHANGE use gwt-widget SimpleDateFormat
49
import org.gwtwidgets.client.util.SimpleDateFormat;
48
50
49
51
50
/**
52
/**
Lines 347-423 Link Here
347
        {
349
        {
348
          return EDATE_FORMATS[i].parse(stringValue);
350
          return EDATE_FORMATS[i].parse(stringValue);
349
        }
351
        }
350
        catch (ParseException parseException)
352
//XXX GWT CHANGE gwtwidgets format throws an IllegalArgumentException
353
        catch (IllegalArgumentException parseException)
351
        {
354
        {
352
        }
355
        }
353
      }
356
      }
354
      throw new IllegalArgumentException("The value '" + stringValue + "' is not a date formatted string of the form yyyy-MM-dd'T'HH:mm:ss'.'SSSZ or a valid subset thereof");
357
      throw new IllegalArgumentException("The value '" + stringValue + "' is not a date formatted string of the form yyyy-MM-dd'T'HH:mm:ss'.'SSSZ or a valid subset thereof");
355
    }
358
    }
356
359
357
    Class stringClass = String.class;
360
//FIXME GWT CHANGE No reflection available
358
    Class[] signature = { stringClass };
361
    throw new IllegalArgumentException("Reflection is not available");
359
360
    Constructor ctor = null;
361
    try
362
    {
363
      ctor = c.getConstructor(signature);
364
    }
365
    catch (NoSuchMethodException e)
366
    {
367
    }
368
    Exception formatException = null;
369
    try
370
    {
371
      if (ctor != null)
372
      {
373
        Object[] ctorArgs = {stringValue};
374
        return ctor.newInstance(ctorArgs);
375
      }
376
    }
377
    catch (InstantiationException e)
378
    {
379
      formatException = e;
380
    }
381
    catch (InvocationTargetException e)
382
    {
383
      formatException = e;
384
    }
385
    catch (IllegalAccessException e)
386
    {
387
      formatException = e;
388
    }
389
    
390
    Method valueOf = null;
391
    try
392
    {
393
      valueOf = c.getMethod("valueOf", signature);
394
    }
395
    catch (NoSuchMethodException e)
396
    {
397
    }
398
362
399
    try
363
//    Class stringClass = String.class;
400
    {
364
//    Class[] signature = { stringClass };
401
      if (valueOf != null)
365
//
402
      {
366
//    Constructor ctor = null;
403
        Object[] valueOfArgs = {stringValue};
367
//    try
404
        return valueOf.invoke(null, valueOfArgs);
368
//    {
405
      }
369
//      ctor = c.getConstructor(signature);
406
    }
370
//    }
407
    catch (IllegalArgumentException e)
371
//    catch (NoSuchMethodException e)
408
    {
372
//    {
409
      formatException = e;
373
//    }
410
    }
374
//    Exception formatException = null;
411
    catch (InvocationTargetException e)
375
//    try
412
    {
376
//    {
413
      formatException = e;
377
//      if (ctor != null)
414
    }
378
//      {
415
    catch (IllegalAccessException e)
379
//        Object[] ctorArgs = {stringValue};
416
    {
380
//        return ctor.newInstance(ctorArgs);
417
      formatException = e;
381
//      }
418
    }
382
//    }
419
    String exceptionString = (formatException != null) ? formatException.toString() : "";
383
//    catch (InstantiationException e)
420
    throw new IllegalArgumentException("The value '" + stringValue + "' is invalid. " + exceptionString);
384
//    {
385
//      formatException = e;
386
//    }
387
//    catch (InvocationTargetException e)
388
//    {
389
//      formatException = e;
390
//    }
391
//    catch (IllegalAccessException e)
392
//    {
393
//      formatException = e;
394
//    }
395
//
396
//    Method valueOf = null;
397
//    try
398
//    {
399
//      valueOf = c.getMethod("valueOf", signature);
400
//    }
401
//    catch (NoSuchMethodException e)
402
//    {
403
//    }
404
//
405
//    try
406
//    {
407
//      if (valueOf != null)
408
//      {
409
//        Object[] valueOfArgs = {stringValue};
410
//        return valueOf.invoke(null, valueOfArgs);
411
//      }
412
//    }
413
//    catch (IllegalArgumentException e)
414
//    {
415
//      formatException = e;
416
//    }
417
//    catch (InvocationTargetException e)
418
//    {
419
//      formatException = e;
420
//    }
421
//    catch (IllegalAccessException e)
422
//    {
423
//      formatException = e;
424
//    }
425
//    String exceptionString = (formatException != null) ? formatException.toString() : "";
426
//    throw new IllegalArgumentException("The value '" + stringValue + "' is invalid. " + exceptionString);
421
  }
427
  }
422
428
423
  /**
429
  /**
Lines 555-572 Link Here
555
      super(pattern);
561
      super(pattern);
556
    }
562
    }
557
    
563
    
558
    public synchronized Date parse(String source) throws ParseException
564
//XXX GWT No Exception because gwtwidget is only throwing ParseException
565
    public synchronized Date parse(String source)
559
    {
566
    {
560
      return super.parse(source);
567
      return super.parse(source);
561
    }
568
    }
562
    
569
//FIXME Not available
563
    public synchronized StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
570
//    public synchronized StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
564
    {
571
//    {
565
      return super.format(date, toAppendTo, fieldPosition);
572
//      return super.format(date, toAppendTo, fieldPosition);
566
    }
573
//    }
567
  }
574
  }
568
  
575
  
569
  protected static final DateFormat [] EDATE_FORMATS = 
576
  protected static final SimpleDateFormat [] EDATE_FORMATS =
570
  {
577
  {
571
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ"),
578
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ"),
572
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS"),
579
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS"),
(-)src/org/eclipse/emf/ecore/impl/EEnumImpl.java (-1 / +3 lines)
Lines 102-108 Link Here
102
      Class instanceClass = getInstanceClass();
102
      Class instanceClass = getInstanceClass();
103
      if (instanceClass != null)
103
      if (instanceClass != null)
104
      {
104
      {
105
        return instanceClass.isInstance(object);
105
        throw new UnsupportedOperationException();
106
//FIXME GWT CHANGE
107
//        return instanceClass.isInstance(object);
106
      }
108
      }
107
      else
109
      else
108
      {
110
      {
(-)src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java (-7 / +8 lines)
Lines 88-106 Link Here
88
      defaultValue = null;
88
      defaultValue = null;
89
      if (instanceClass != null && instanceClass.isPrimitive())
89
      if (instanceClass != null && instanceClass.isPrimitive())
90
      {
90
      {
91
        if (instanceClass == Boolean.TYPE)
91
//XXX GWT CHANGE No Integer.TYPE, ...
92
        if (instanceClass == boolean.class)
92
          defaultValue = Boolean.FALSE;
93
          defaultValue = Boolean.FALSE;
93
        else if (instanceClass == Integer.TYPE)
94
        else if (instanceClass == int.class)
94
          defaultValue = new Integer(0);
95
          defaultValue = new Integer(0);
95
        else if (instanceClass == Float.TYPE)
96
        else if (instanceClass == float.class)
96
          defaultValue = new Float(0.0F);
97
          defaultValue = new Float(0.0F);
97
        else if (instanceClass == Double.TYPE)
98
        else if (instanceClass == double.class)
98
          defaultValue = new Double(0.0);
99
          defaultValue = new Double(0.0);
99
        else if (instanceClass == Long.TYPE)
100
        else if (instanceClass == long.class)
100
          defaultValue = new Long(0);
101
          defaultValue = new Long(0);
101
        else if (instanceClass == Short.TYPE)
102
        else if (instanceClass == short.class)
102
          defaultValue = new Short((short)0);
103
          defaultValue = new Short((short)0);
103
        else if (instanceClass == Byte.TYPE)
104
        else if (instanceClass == byte.class)
104
          defaultValue = new Byte((byte)0);
105
          defaultValue = new Byte((byte)0);
105
        else // if (instanceClass == Character.TYPE)
106
        else // if (instanceClass == Character.TYPE)
106
          defaultValue = new Character('\u0000');
107
          defaultValue = new Character('\u0000');
(-)src/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java (-58 / +67 lines)
Lines 22-28 Link Here
22
import java.util.Iterator;
22
import java.util.Iterator;
23
import java.util.Map;
23
import java.util.Map;
24
import java.util.Set;
24
import java.util.Set;
25
import java.util.WeakHashMap;
26
25
27
import org.eclipse.emf.common.EMFPlugin;
26
import org.eclipse.emf.common.EMFPlugin;
28
import org.eclipse.emf.ecore.EFactory;
27
import org.eclipse.emf.ecore.EFactory;
Lines 43-49 Link Here
43
  {
42
  {
44
    try
43
    try
45
    {
44
    {
46
      String className = System.getProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE");
45
//FIXME GWT CHANGE
46
//      String className = System.getProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE");
47
    	String className = null;
47
      if (className == null)
48
      if (className == null)
48
      {
49
      {
49
        if (EcorePlugin.getDefaultRegistryImplementation() != null)
50
        if (EcorePlugin.getDefaultRegistryImplementation() != null)
Lines 61-67 Link Here
61
      }
62
      }
62
      else
63
      else
63
      {
64
      {
64
        return (EPackage.Registry)Class.forName(className).newInstance();
65
    	  throw new UnsupportedOperationException();
66
//        return (EPackage.Registry)Class.forName(className).newInstance();
65
      }
67
      }
66
    }
68
    }
67
    catch (Exception exception)
69
    catch (Exception exception)
Lines 200-243 Link Here
200
  /**
202
  /**
201
   * A map from class loader to its associated registry.
203
   * A map from class loader to its associated registry.
202
   */
204
   */
203
  protected static Map classLoaderToRegistryMap = new WeakHashMap();
205
//XXX GWT CHANGE No WeakHashMap available
206
  protected static Map classLoaderToRegistryMap = new HashMap();
204
207
205
  /**
208
  /**
206
   * Returns the package registry associated with the given class loader.
209
   * Returns the package registry associated with the given class loader.
207
   * @param classLoader the class loader.
210
   * @param classLoader the class loader.
208
   * @return the package registry associated with the given class loader.
211
   * @return the package registry associated with the given class loader.
209
   */
212
   */
210
  public static synchronized EPackage.Registry getRegistry(ClassLoader classLoader)
213
//FIXME GWT CHANGE No ClassLoaders
211
  {
214
//  public static synchronized EPackage.Registry getRegistry(ClassLoader classLoader)
212
    EPackage.Registry result = (EPackage.Registry)classLoaderToRegistryMap.get(classLoader);
215
//  {
213
    if (result == null)
216
//    EPackage.Registry result = (EPackage.Registry)classLoaderToRegistryMap.get(classLoader);
214
    {
217
//    if (result == null)
215
      if (classLoader == null)
218
//    {
216
      {
219
//      if (classLoader == null)
217
        result = null;  
220
//      {
218
      }
221
//        result = null;  
219
      else
222
//      }
220
      {
223
//      else
221
        result = new EPackageRegistryImpl(getRegistry(classLoader.getParent()));
224
//      {
222
        classLoaderToRegistryMap.put(classLoader, result);
225
//        result = new EPackageRegistryImpl(getRegistry(classLoader.getParent()));
223
      }
226
//        classLoaderToRegistryMap.put(classLoader, result);
224
    }
227
//      }
225
    return result;
228
//    }
226
  }
229
//    return result;
230
//  }
227
231
228
  /**
232
  /**
229
   * A package registry implementation that delegates to a class loader specific registry.
233
   * A package registry implementation that delegates to a class loader specific registry.
230
   */
234
   */
231
  public static class Delegator implements EPackage.Registry
235
  public static class Delegator implements EPackage.Registry
232
  {
236
  {
233
    protected EPackage.Registry delegateRegistry(ClassLoader classLoader)
237
//FIXME GWT CHANGE No ClassLoader
234
    {
238
//    protected EPackage.Registry delegateRegistry(ClassLoader classLoader)
235
      return getRegistry(classLoader);
239
//    {
236
    }
240
//      return getRegistry(classLoader);
241
//    }
237
242
238
    protected EPackage.Registry delegateRegistry()
243
    protected EPackage.Registry delegateRegistry()
239
    {
244
    {
240
      return delegateRegistry(Thread.currentThread().getContextClassLoader());
245
//FIXME GWT CHANGE No Thread things available
246
    	throw new UnsupportedOperationException();
247
//      return delegateRegistry(Thread.currentThread().getContextClassLoader());
241
    }
248
    }
242
249
243
    public EPackage getEPackage(String key)
250
    public EPackage getEPackage(String key)
Lines 284-323 Link Here
284
      } 
291
      } 
285
      else 
292
      else 
286
      {
293
      {
287
        String valueClassName = valueClass.getName();
294
//FIXME GWT CHANGE No ClassLoaders available
288
295
//        String valueClassName = valueClass.getName();
289
        // Find the uppermost classloader in the hierarchy that can load the class.
296
//
290
        //
297
//        // Find the uppermost classloader in the hierarchy that can load the class.
291
        ClassLoader result = Thread.currentThread().getContextClassLoader();
298
//        //
292
        for (ClassLoader classLoader = result.getParent(); classLoader != null; classLoader = classLoader.getParent())
299
//        ClassLoader result = Thread.currentThread().getContextClassLoader();
293
        {
300
//        for (ClassLoader classLoader = result.getParent(); classLoader != null; classLoader = classLoader.getParent())
294
          try 
301
//        {
295
          {
302
//          try
296
            Class loadedClass = classLoader.loadClass(valueClassName);
303
//          {
297
            if (loadedClass == valueClass) 
304
//            Class loadedClass = classLoader.loadClass(valueClassName);
298
            {
305
//            if (loadedClass == valueClass)
299
              result = classLoader;
306
//            {
300
            } 
307
//              result = classLoader;
301
            else 
308
//            }
302
            {
309
//            else
303
              // The class address was not equal, so we don't want this classloader,
310
//            {
304
              // but instead want the last result that was able to load the class.
311
//              // The class address was not equal, so we don't want this classloader,
305
              //
312
//              // but instead want the last result that was able to load the class.
306
              break;
313
//              //
307
            }
314
//              break;
308
          } 
315
//            }
309
          catch (ClassNotFoundException exception) 
316
//          }
310
          {
317
//          catch (ClassNotFoundException exception)
311
            // We can't find the class, so we don't want this classloader,
318
//          {
312
            // but instead want the last result that was able to load the class.
319
//            // We can't find the class, so we don't want this classloader,
313
            //
320
//            // but instead want the last result that was able to load the class.
314
            break;
321
//            //
315
          }
322
//            break;
316
        }
323
//          }
317
324
//        }
325
//
318
        // Register with the upper most classloader that's able to load the class.
326
        // Register with the upper most classloader that's able to load the class.
319
        //
327
        //
320
        return delegateRegistry(result).put(key, value);
328
//        return delegateRegistry(result).put(key, value);
329
        throw new UnsupportedOperationException();
321
      }
330
      }
322
    }
331
    }
323
332
(-)src/org/eclipse/emf/ecore/xml/namespace/util/XMLNamespaceValidator.java (-225 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespaceValidator.java,v 1.3 2006/05/03 19:30:32 davidms Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace.util;
18
19
import java.util.List;
20
import java.util.Map;
21
22
import org.eclipse.emf.common.util.BasicDiagnostic;
23
import org.eclipse.emf.common.util.Diagnostic;
24
import org.eclipse.emf.common.util.DiagnosticChain;
25
26
import org.eclipse.emf.ecore.EPackage;
27
28
import org.eclipse.emf.ecore.util.EObjectValidator;
29
30
import org.eclipse.emf.ecore.xml.namespace.*;
31
32
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
33
34
import org.eclipse.emf.ecore.xml.type.util.XMLTypeValidator;
35
36
/**
37
 * <!-- begin-user-doc -->
38
 * The <b>Validator</b> for the model.
39
 * <!-- end-user-doc -->
40
 * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage
41
 * @generated
42
 */
43
public class XMLNamespaceValidator extends EObjectValidator
44
{
45
  /**
46
   * The cached model package
47
   * <!-- begin-user-doc -->
48
   * <!-- end-user-doc -->
49
   * @generated
50
   */
51
  public static final XMLNamespaceValidator INSTANCE = new XMLNamespaceValidator();
52
53
  /**
54
   * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
55
   * <!-- begin-user-doc -->
56
   * <!-- end-user-doc -->
57
   * @see org.eclipse.emf.common.util.Diagnostic#getSource()
58
   * @see org.eclipse.emf.common.util.Diagnostic#getCode()
59
   * @generated
60
   */
61
  public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecore.xml.namespace";
62
63
  /**
64
   * A constant with a fixed name that can be used as the base value for additional hand written constants.
65
   * <!-- begin-user-doc -->
66
   * <!-- end-user-doc -->
67
   * @generated
68
   */
69
  private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;
70
71
  /**
72
   * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class.
73
   * <!-- begin-user-doc -->
74
   * <!-- end-user-doc -->
75
   * @generated
76
   */
77
  protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;
78
79
  /**
80
   * The cached base package validator.
81
   * <!-- begin-user-doc -->
82
   * <!-- end-user-doc -->
83
   * @generated
84
   */
85
  protected XMLTypeValidator xmlTypeValidator;
86
87
  /**
88
   * Creates an instance of the switch.
89
   * <!-- begin-user-doc -->
90
   * <!-- end-user-doc -->
91
   * @generated
92
   */
93
  public XMLNamespaceValidator()
94
  {
95
    super();
96
    xmlTypeValidator = XMLTypeValidator.INSTANCE;
97
  }
98
99
  /**
100
   * Returns the package of this validator switch.
101
   * <!-- begin-user-doc -->
102
   * <!-- end-user-doc -->
103
   * @generated
104
   */
105
  protected EPackage getEPackage()
106
  {
107
    return XMLNamespacePackage.eINSTANCE;
108
  }
109
110
  /**
111
   * Calls <code>validateXXX</code> for the corresonding classifier of the model.
112
   * <!-- begin-user-doc -->
113
   * <!-- end-user-doc -->
114
   * @generated
115
   */
116
  protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map context)
117
  {
118
    switch (classifierID)
119
    {
120
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT:
121
        return validateXMLNamespaceDocumentRoot((XMLNamespaceDocumentRoot)value, diagnostics, context);
122
      case XMLNamespacePackage.SPACE_TYPE:
123
        return validateSpaceType((SpaceType)value, diagnostics, context);
124
      case XMLNamespacePackage.LANG_TYPE:
125
        return validateLangType((String)value, diagnostics, context);
126
      case XMLNamespacePackage.LANG_TYPE_NULL:
127
        return validateLangTypeNull((String)value, diagnostics, context);
128
      case XMLNamespacePackage.SPACE_TYPE_OBJECT:
129
        return validateSpaceTypeObject((SpaceType)value, diagnostics, context);
130
      default: 
131
        return true;
132
    }
133
  }
134
135
  /**
136
   * <!-- begin-user-doc -->
137
   * <!-- end-user-doc -->
138
   * @generated
139
   */
140
  public boolean validateXMLNamespaceDocumentRoot(XMLNamespaceDocumentRoot xmlNamespaceDocumentRoot, DiagnosticChain diagnostics, Map context)
141
  {
142
    return validate_EveryDefaultConstraint(xmlNamespaceDocumentRoot, diagnostics, context);
143
  }
144
145
  /**
146
   * <!-- begin-user-doc -->
147
   * <!-- end-user-doc -->
148
   * @generated
149
   */
150
  public boolean validateSpaceType(SpaceType spaceType, DiagnosticChain diagnostics, Map context)
151
  {
152
    return true;
153
  }
154
155
  /**
156
   * <!-- begin-user-doc -->
157
   * <!-- end-user-doc -->
158
   * @generated
159
   */
160
  public boolean validateLangType(String langType, DiagnosticChain diagnostics, Map context)
161
  {
162
    boolean result = validateLangType_MemberTypes(langType, diagnostics, context);
163
    return result;
164
  }
165
166
  /**
167
   * Validates the MemberTypes constraint of '<em>Lang Type</em>'.
168
   * <!-- begin-user-doc -->
169
   * <!-- end-user-doc -->
170
   * @generated
171
   */
172
  public boolean validateLangType_MemberTypes(String langType, DiagnosticChain diagnostics, Map context)
173
  {
174
    if (diagnostics != null)
175
    {
176
      BasicDiagnostic tempDiagnostics = new BasicDiagnostic();
177
      if (XMLTypePackage.Literals.LANGUAGE.isInstance(langType))
178
      {
179
        if (xmlTypeValidator.validateLanguage((String)langType, tempDiagnostics, context)) return true;
180
      }
181
      if (XMLNamespacePackage.Literals.LANG_TYPE_NULL.isInstance(langType))
182
      {
183
        if (validateLangTypeNull((String)langType, tempDiagnostics, context)) return true;
184
      }
185
      List children = tempDiagnostics.getChildren();
186
      for (int i = 0; i < children.size(); i++)
187
      {
188
        diagnostics.add((Diagnostic)children.get(i));
189
      }
190
    }
191
    else
192
    {
193
      if (XMLTypePackage.Literals.LANGUAGE.isInstance(langType))
194
      {
195
        if (xmlTypeValidator.validateLanguage((String)langType, null, context)) return true;
196
      }
197
      if (XMLNamespacePackage.Literals.LANG_TYPE_NULL.isInstance(langType))
198
      {
199
        if (validateLangTypeNull((String)langType, null, context)) return true;
200
      }
201
    }
202
    return false;
203
  }
204
205
  /**
206
   * <!-- begin-user-doc -->
207
   * <!-- end-user-doc -->
208
   * @generated
209
   */
210
  public boolean validateLangTypeNull(String langTypeNull, DiagnosticChain diagnostics, Map context)
211
  {
212
    return true;
213
  }
214
215
  /**
216
   * <!-- begin-user-doc -->
217
   * <!-- end-user-doc -->
218
   * @generated
219
   */
220
  public boolean validateSpaceTypeObject(SpaceType spaceTypeObject, DiagnosticChain diagnostics, Map context)
221
  {
222
    return true;
223
  }
224
225
} //XMLNamespaceValidator
(-)src/org/eclipse/emf/ecore/util/EcoreUtil.java (-226 / +229 lines)
Lines 18-28 Link Here
18
18
19
19
20
import java.io.PrintStream;
20
import java.io.PrintStream;
21
import java.security.SecureRandom;
21
//XXX GWT CHANGE
22
//import java.security.SecureRandom;
22
import java.util.ArrayList;
23
import java.util.ArrayList;
23
import java.util.Collection;
24
import java.util.Collection;
24
import java.util.Collections;
25
import java.util.Collections;
25
import java.util.GregorianCalendar;
26
//import java.util.GregorianCalendar;
26
import java.util.HashMap;
27
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.Iterator;
28
import java.util.List;
29
import java.util.List;
Lines 3053-3083 Link Here
3053
    }
3054
    }
3054
    else if (javaClass.isPrimitive())
3055
    else if (javaClass.isPrimitive())
3055
    {
3056
    {
3056
      if (javaClass == Boolean.TYPE)
3057
//FIXME GWT CHANGE
3058
      if (javaClass == boolean.class)
3057
      {
3059
      {
3058
        return Boolean.class;
3060
        return Boolean.class;
3059
      }
3061
      }
3060
      else if (javaClass == Integer.TYPE)
3062
      else if (javaClass == int.class)
3061
      {
3063
      {
3062
        return Integer.class;
3064
        return Integer.class;
3063
      }
3065
      }
3064
      else if (javaClass == Float.TYPE)
3066
      else if (javaClass == float.class)
3065
      {
3067
      {
3066
        return Float.class;
3068
        return Float.class;
3067
      }
3069
      }
3068
      else if (javaClass == Double.TYPE)
3070
      else if (javaClass == double.class)
3069
      {
3071
      {
3070
        return Double.class;
3072
        return Double.class;
3071
      }
3073
      }
3072
      else if (javaClass == Long.TYPE)
3074
      else if (javaClass == long.class)
3073
      {
3075
      {
3074
        return Long.class;
3076
        return Long.class;
3075
      }
3077
      }
3076
      else if (javaClass == Short.TYPE)
3078
      else if (javaClass == short.class)
3077
      {
3079
      {
3078
        return Short.class;
3080
        return Short.class;
3079
      }
3081
      }
3080
      else if (javaClass == Byte.TYPE)
3082
      else if (javaClass == byte.class)
3081
      {
3083
      {
3082
        return Byte.class;
3084
        return Byte.class;
3083
      }
3085
      }
Lines 3285-3353 Link Here
3285
    }
3287
    }
3286
  }
3288
  }
3287
3289
3288
  /**
3290
//FIXME GWT CHANGE
3289
   * Generates a universally unique identifier, 
3291
//  /**
3290
   * i.e., a <a href="ftp://ietf.org/internet-drafts/draft-mealling-uuid-urn-02.txt">UUID</a>.
3292
//   * Generates a universally unique identifier,
3291
   * It encodes the 128 bit UUID in <a href="http://www.ietf.org/rfc/rfc2045.txt">base 64</a>,
3293
//   * i.e., a <a href="ftp://ietf.org/internet-drafts/draft-mealling-uuid-urn-02.txt">UUID</a>.
3292
   * but rather than padding the encoding with two "=" characters, 
3294
//   * It encodes the 128 bit UUID in <a href="http://www.ietf.org/rfc/rfc2045.txt">base 64</a>,
3293
   * it prefixes the encoding with a single "_" character,
3295
//   * but rather than padding the encoding with two "=" characters,
3294
   * to ensure that the result is a valid <a href="http://www.w3.org/TR/xmlschema-2/#ID">ID</a>,
3296
//   * it prefixes the encoding with a single "_" character,
3295
   * i.e., an <a href="http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName">NCName</a>
3297
//   * to ensure that the result is a valid <a href="http://www.w3.org/TR/xmlschema-2/#ID">ID</a>,
3296
   * @return a universally unique identifier.
3298
//   * i.e., an <a href="http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName">NCName</a>
3297
   */
3299
//   * @return a universally unique identifier.
3298
  public static String generateUUID()
3300
//   */
3299
  {
3301
//  public static String generateUUID()
3300
    return UUID.generate();
3302
//  {
3301
  }
3303
//    return UUID.generate();
3302
3304
//  }
3303
  /**
3305
//
3304
   * Generates a universally unique identifier, 
3306
//  /**
3305
   * i.e., a <a href="ftp://ietf.org/internet-drafts/draft-mealling-uuid-urn-02.txt">UUID</a>.
3307
//   * Generates a universally unique identifier,
3306
   * The argument is filled in with the 128 bit UUID and hence must be at least 16 bytes in length.
3308
//   * i.e., a <a href="ftp://ietf.org/internet-drafts/draft-mealling-uuid-urn-02.txt">UUID</a>.
3307
   * @param uuid the value to receive the result.
3309
//   * The argument is filled in with the 128 bit UUID and hence must be at least 16 bytes in length.
3308
   */
3310
//   * @param uuid the value to receive the result.
3309
  public static void generateUUID(byte [] uuid)
3311
//   */
3310
  {
3312
//  public static void generateUUID(byte [] uuid)
3311
    UUID.generate(uuid);
3313
//  {
3312
  }
3314
//    UUID.generate(uuid);
3313
3315
//  }
3314
  private static final class UUID
3316
3315
  {
3317
//  private static final class UUID
3316
    public synchronized static String generate()
3318
//  {
3317
    {
3319
//    public synchronized static String generate()
3318
      updateCurrentTime();
3320
//    {
3319
3321
//      updateCurrentTime();
3320
      // Do a base 64 conversion by turning every 3 bytes into 4 base 64 characters
3322
//
3321
      //
3323
//      // Do a base 64 conversion by turning every 3 bytes into 4 base 64 characters
3322
      for (int i = 0; i < 5; ++i)
3324
//      //
3323
      {
3325
//      for (int i = 0; i < 5; ++i)
3324
        buffer[4 * i + 1] = BASE64_DIGITS[(uuid[i * 3] >> 2) & 0x3F];
3326
//      {
3325
        buffer[4 * i + 2] = BASE64_DIGITS[((uuid[i * 3] << 4) & 0x30) | ((uuid[i * 3 + 1] >> 4) & 0xF)];
3327
//        buffer[4 * i + 1] = BASE64_DIGITS[(uuid[i * 3] >> 2) & 0x3F];
3326
        buffer[4 * i + 3] = BASE64_DIGITS[((uuid[i * 3 + 1] << 2) & 0x3C) | ((uuid[i * 3 + 2] >> 6) & 0x3)];
3328
//        buffer[4 * i + 2] = BASE64_DIGITS[((uuid[i * 3] << 4) & 0x30) | ((uuid[i * 3 + 1] >> 4) & 0xF)];
3327
        buffer[4 * i + 4] = BASE64_DIGITS[uuid[i * 3 + 2] & 0x3F];
3329
//        buffer[4 * i + 3] = BASE64_DIGITS[((uuid[i * 3 + 1] << 2) & 0x3C) | ((uuid[i * 3 + 2] >> 6) & 0x3)];
3328
      }
3330
//        buffer[4 * i + 4] = BASE64_DIGITS[uuid[i * 3 + 2] & 0x3F];
3329
3331
//      }
3330
      // Handle the last byte at the end.
3332
//
3331
      //
3333
//      // Handle the last byte at the end.
3332
      buffer[21] = BASE64_DIGITS[(uuid[15] >> 2) & 0x3F];
3334
//      //
3333
      buffer[22] = BASE64_DIGITS[(uuid[15] << 4) & 0x30];
3335
//      buffer[21] = BASE64_DIGITS[(uuid[15] >> 2) & 0x3F];
3334
3336
//      buffer[22] = BASE64_DIGITS[(uuid[15] << 4) & 0x30];
3335
      return new String(buffer);
3337
//
3336
    }
3338
//      return new String(buffer);
3337
    
3339
//    }
3338
    public synchronized static void generate(byte [] uuid)
3340
//
3339
    {
3341
//    public synchronized static void generate(byte [] uuid)
3340
      updateCurrentTime();
3342
//    {
3341
3343
//      updateCurrentTime();
3342
      for (int i = 0; i < 16; i++)
3344
//
3343
      {
3345
//      for (int i = 0; i < 16; i++)
3344
        uuid[i] = UUID.uuid[i];
3346
//      {
3345
      }
3347
//        uuid[i] = UUID.uuid[i];
3346
    }
3348
//      }
3347
3349
//    }
3348
    private UUID()
3350
3349
    {
3351
//    private UUID()
3350
    }
3352
//    {
3353
//    }
3351
3354
3352
    private static final char[] BASE64_DIGITS = {
3355
    private static final char[] BASE64_DIGITS = {
3353
      'A',
3356
      'A',
Lines 3414-3586 Link Here
3414
      '9',
3417
      '9',
3415
      '-',
3418
      '-',
3416
      '_' };
3419
      '_' };
3420
//FIXME GWT CHANGE
3421
//    /**
3422
//     * An adjustment to convert the Java epoch of Jan 1, 1970 00:00:00 to
3423
//     * the epoch required by the IETF specification, Oct 15, 1582 00:00:00.
3424
//     */
3425
//    private static final long EPOCH_ADJUSTMENT = new GregorianCalendar(1970, 0, 1, 0, 0, 0).getTime().getTime()
3426
//      - new GregorianCalendar(1582, 9, 15, 0, 0, 0).getTime().getTime();
3417
3427
3418
    /**
3428
//    private static long lastTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3419
     * An adjustment to convert the Java epoch of Jan 1, 1970 00:00:00 to
3420
     * the epoch required by the IETF specification, Oct 15, 1582 00:00:00.
3421
     */
3422
    private static final long EPOCH_ADJUSTMENT = new GregorianCalendar(1970, 0, 1, 0, 0, 0).getTime().getTime()
3423
      - new GregorianCalendar(1582, 9, 15, 0, 0, 0).getTime().getTime();
3424
3425
    private static long lastTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3426
3429
3427
    private static short clockSequence;
3430
    private static short clockSequence;
3428
3431
3429
    private static short timeAdjustment;
3432
    private static short timeAdjustment;
3430
    
3433
3431
    private static int sleepTime = 1;
3434
    private static int sleepTime = 1;
3432
3435
3433
    /**
3436
    /**
3434
     * A cached array of bytes representing the UUID. The second 8 bytes
3437
     * A cached array of bytes representing the UUID. The second 8 bytes
3435
     * will be kept the same unless the clock sequence has changed.
3438
     * will be kept the same unless the clock sequence has changed.
3436
     */
3439
     */
3437
    private static final byte[] uuid = new byte [16];
3440
//    private static final byte[] uuid = new byte [16];
3438
3439
    private static final char[] buffer = new char [23];
3440
3441
    static
3442
    {
3443
      SecureRandom random = new SecureRandom();
3444
3445
      clockSequence = (short)random.nextInt(16384);
3446
      updateClockSequence();
3447
3448
      // Generate a 48 bit node identifier; 
3449
      // This is an alternative to the IEEE 802 host address, which is not available in Java.
3450
      //
3451
      byte[] nodeAddress = new byte [6];
3452
3441
3453
      random.nextBytes(nodeAddress);
3442
//    private static final char[] buffer = new char [23];
3454
3455
      // Set the most significant bit of the first octet to 1 so as to distinguish it from IEEE node addresses
3456
      //
3457
      nodeAddress[0] |= (byte)0x80;
3458
3459
      // The node identifier is already in network byte order, 
3460
      // so there is no need to do any byte order reversing.
3461
      //
3462
      for (int i = 0; i < 6; ++i)
3463
      {
3464
        uuid[i + 10] = nodeAddress[i];
3465
      }
3466
3467
      buffer[0] = '_';
3468
    }
3469
3470
    /**
3471
     * Updates the clock sequence portion of the UUID. The clock sequence
3472
     * portion may seem odd, but in the specification, the high order byte
3473
     * comes before the low order byte. The variant is multiplexed into the
3474
     * high order octet of clockseq_hi.
3475
     */
3476
    private static void updateClockSequence()
3477
    {
3478
      // clockseq_hi
3479
      uuid[8] = (byte)(((clockSequence >> 8) & 0x3F) | 0x80);
3480
      // clockseq_low
3481
      uuid[9] = (byte)(clockSequence & 0xFF);
3482
    }
3483
3443
3484
    /**
3444
//    static
3485
     * Updates the UUID with the current time, compensating for the fact
3445
//    {
3486
     * that the clock resolution may be less than 100 ns. The byte array
3446
//      SecureRandom random = new SecureRandom();
3487
     * will have its first eight bytes populated with the time in the
3447
//
3488
     * correct sequence of bytes, as per the specification.
3448
//      clockSequence = (short)random.nextInt(16384);
3489
     */
3449
//      updateClockSequence();
3490
    private static void updateCurrentTime()
3450
//
3491
    {
3451
//      // Generate a 48 bit node identifier;
3492
      // Get the current time in milliseconds since the epoch 
3452
//      // This is an alternative to the IEEE 802 host address, which is not available in Java.
3493
      // and adjust it to match the epoch required by the specification.
3453
//      //
3494
      //
3454
//      byte[] nodeAddress = new byte [6];
3495
      long currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3455
//
3496
3456
//      random.nextBytes(nodeAddress);
3497
      if (lastTime > currentTime)
3457
//
3498
      {
3458
//      // Set the most significant bit of the first octet to 1 so as to distinguish it from IEEE node addresses
3499
        // The system clock has been rewound so the clock sequence must be incremented 
3459
//      //
3500
        // to ensure that a duplicate UUID is not generated.
3460
//      nodeAddress[0] |= (byte)0x80;
3501
        //
3461
//
3502
        ++clockSequence;
3462
//      // The node identifier is already in network byte order,
3503
3463
//      // so there is no need to do any byte order reversing.
3504
        if (16384 == clockSequence)
3464
//      //
3505
        {
3465
//      for (int i = 0; i < 6; ++i)
3506
          clockSequence = 0;
3466
//      {
3507
        }
3467
//        uuid[i + 10] = nodeAddress[i];
3508
3468
//      }
3509
        updateClockSequence();
3469
//
3510
      }
3470
//      buffer[0] = '_';
3511
      else if (lastTime == currentTime)
3471
//    }
3512
      {
3472
3513
        // The system time hasn't changed so add some increment of 100s of nanoseconds to guarantee uniqueness.
3473
//    /**
3514
        //
3474
//     * Updates the clock sequence portion of the UUID. The clock sequence
3515
        ++timeAdjustment;
3475
//     * portion may seem odd, but in the specification, the high order byte
3516
3476
//     * comes before the low order byte. The variant is multiplexed into the
3517
        if (timeAdjustment > 9999)
3477
//     * high order octet of clockseq_hi.
3518
        {
3478
//     */
3519
          // Wait so that the clock can catch up and the time adjustment won't overflow.
3479
//    private static void updateClockSequence()
3520
          try
3480
//    {
3521
          {
3481
//      // clockseq_hi
3522
            Thread.sleep(sleepTime);
3482
//      uuid[8] = (byte)(((clockSequence >> 8) & 0x3F) | 0x80);
3523
          }
3483
//      // clockseq_low
3524
          catch (InterruptedException exception)
3484
//      uuid[9] = (byte)(clockSequence & 0xFF);
3525
          {
3485
//    }
3526
          }
3486
3527
3487
//    /**
3528
          timeAdjustment = 0;
3488
//     * Updates the UUID with the current time, compensating for the fact
3529
          currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3489
//     * that the clock resolution may be less than 100 ns. The byte array
3530
3490
//     * will have its first eight bytes populated with the time in the
3531
          while (lastTime == currentTime)
3491
//     * correct sequence of bytes, as per the specification.
3532
          {
3492
//     */
3533
            try
3493
//    private static void updateCurrentTime()
3534
            {
3494
//    {
3535
              ++sleepTime;
3495
//      // Get the current time in milliseconds since the epoch
3536
              Thread.sleep(1);
3496
//      // and adjust it to match the epoch required by the specification.
3537
            }
3497
//      //
3538
            catch (InterruptedException exception)
3498
//      long currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3539
            {
3499
//
3540
            }
3500
//      if (lastTime > currentTime)
3541
            currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3501
//      {
3542
          }
3502
//        // The system clock has been rewound so the clock sequence must be incremented
3543
        }
3503
//        // to ensure that a duplicate UUID is not generated.
3544
      }
3504
//        //
3545
      else
3505
//        ++clockSequence;
3546
      {
3506
//
3547
        timeAdjustment = 0;
3507
//        if (16384 == clockSequence)
3548
      }
3508
//        {
3549
3509
//          clockSequence = 0;
3550
      lastTime = currentTime;
3510
//        }
3551
3511
//
3552
      // Since the granularity of time in Java is only milliseconds, 
3512
//        updateClockSequence();
3553
      // add an adjustment so that the time is represented in 100s of nanoseconds.
3513
//      }
3554
      // The version number (1) is multiplexed into the most significant hex digit.
3514
//      else if (lastTime == currentTime)
3555
      //
3515
//      {
3556
      currentTime *= 10000;
3516
//        // The system time hasn't changed so add some increment of 100s of nanoseconds to guarantee uniqueness.
3557
      currentTime += timeAdjustment;
3517
//        //
3558
      currentTime |= 0x1000000000000000L;
3518
//        ++timeAdjustment;
3559
3519
//
3560
      // Place the time into the byte array in network byte order.
3520
//        if (timeAdjustment > 9999)
3561
      //
3521
//        {
3562
      for (int i = 0; i < 4; ++i)
3522
//          // Wait so that the clock can catch up and the time adjustment won't overflow.
3563
      {
3523
//          try
3564
        // time_low
3524
//          {
3565
        //
3525
//            Thread.sleep(sleepTime);
3566
        uuid[i] = (byte)((currentTime >> 8 * (3 - i)) & 0xFFL);
3526
//          }
3567
      }
3527
//          catch (InterruptedException exception)
3568
3528
//          {
3569
      for (int i = 0; i < 2; ++i)
3529
//          }
3570
      {
3530
//
3571
        // time_mid
3531
//          timeAdjustment = 0;
3572
        //
3532
//          currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3573
        uuid[i + 4] = (byte)((currentTime >> 8 * (1 - i) + 32) & 0xFFL);
3533
//
3574
      }
3534
//          while (lastTime == currentTime)
3575
3535
//          {
3576
      for (int i = 0; i < 2; ++i)
3536
//            try
3577
      {
3537
//            {
3578
        // time_hi
3538
//              ++sleepTime;
3579
        //
3539
//              Thread.sleep(1);
3580
        uuid[i + 6] = (byte)((currentTime >> 8 * (1 - i) + 48) & 0xFFL);
3540
//            }
3581
      }
3541
//            catch (InterruptedException exception)
3582
    }
3542
//            {
3583
  }
3543
//            }
3544
//            currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
3545
//          }
3546
//        }
3547
//      }
3548
//      else
3549
//      {
3550
//        timeAdjustment = 0;
3551
//      }
3552
//
3553
//      lastTime = currentTime;
3554
//
3555
//      // Since the granularity of time in Java is only milliseconds,
3556
//      // add an adjustment so that the time is represented in 100s of nanoseconds.
3557
//      // The version number (1) is multiplexed into the most significant hex digit.
3558
//      //
3559
//      currentTime *= 10000;
3560
//      currentTime += timeAdjustment;
3561
//      currentTime |= 0x1000000000000000L;
3562
//
3563
//      // Place the time into the byte array in network byte order.
3564
//      //
3565
//      for (int i = 0; i < 4; ++i)
3566
//      {
3567
//        // time_low
3568
//        //
3569
//        uuid[i] = (byte)((currentTime >> 8 * (3 - i)) & 0xFFL);
3570
//      }
3571
//
3572
//      for (int i = 0; i < 2; ++i)
3573
//      {
3574
//        // time_mid
3575
//        //
3576
//        uuid[i + 4] = (byte)((currentTime >> 8 * (1 - i) + 32) & 0xFFL);
3577
//      }
3578
//
3579
//      for (int i = 0; i < 2; ++i)
3580
//      {
3581
//        // time_hi
3582
//        //
3583
//        uuid[i + 6] = (byte)((currentTime >> 8 * (1 - i) + 48) & 0xFFL);
3584
//      }
3585
//    }
3586
//  }
3584
3587
3585
  /**
3588
  /**
3586
   * Marks the package to indicate that it and everything it contains or that its contents depend on can no longer be changed.
3589
   * Marks the package to indicate that it and everything it contains or that its contents depend on can no longer be changed.
(-)src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java (-4 / +14 lines)
Lines 21-27 Link Here
21
import java.util.Collection;
21
import java.util.Collection;
22
import java.util.Collections;
22
import java.util.Collections;
23
import java.util.HashMap;
23
import java.util.HashMap;
24
import java.util.Hashtable;
24
//XXX GWT CHANGE No Hashtable available
25
import java.util.List;
25
import java.util.List;
26
import java.util.Map;
26
import java.util.Map;
27
import java.util.StringTokenizer;
27
import java.util.StringTokenizer;
Lines 72-78 Link Here
72
72
73
  public BasicExtendedMetaData(String annotationURI, EPackage.Registry registry, Map annotationMap)
73
  public BasicExtendedMetaData(String annotationURI, EPackage.Registry registry, Map annotationMap)
74
  {
74
  {
75
    this.annotationURI = annotationURI.intern();
75
//XXX GWT CHANGE no String.intern()
76
    this.annotationURI = annotationURI;
76
    this.registry = registry;
77
    this.registry = registry;
77
    this.demandRegistry = new org.eclipse.emf.ecore.impl.EPackageRegistryImpl();
78
    this.demandRegistry = new org.eclipse.emf.ecore.impl.EPackageRegistryImpl();
78
    this.annotationMap = annotationMap;
79
    this.annotationMap = annotationMap;
Lines 1902-1908 Link Here
1902
    {
1903
    {
1903
      prefix.append('_');
1904
      prefix.append('_');
1904
    }
1905
    }
1905
    return prefix.reverse().toString();
1906
//XXX No reverse available for StringBuffer
1907
    char[] ar = prefix.toString().toCharArray();
1908
    char[] nar = new char[ar.length];
1909
1910
    for( int i = 0; i < ar.length; i++ ) {
1911
    	nar[i] = ar[ar.length - 1 - i];
1912
    }
1913
1914
    return new String(nar);
1906
  }
1915
  }
1907
1916
1908
  public EClassifier demandType(String namespace, String name)
1917
  public EClassifier demandType(String namespace, String name)
Lines 2776-2782 Link Here
2776
    {
2785
    {
2777
      if (validatorMap == null)
2786
      if (validatorMap == null)
2778
      {
2787
      {
2779
        validatorMap = new Hashtable();
2788
//XXX GWT CHANGE No Hashtable
2789
        validatorMap = new HashMap();
2780
      }
2790
      }
2781
      return validatorMap;
2791
      return validatorMap;
2782
    }
2792
    }
(-)src/org/eclipse/emf/ecore/util/BasicInternalEList.java (-3 / +3 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.util;
17
package org.eclipse.emf.ecore.util;
18
18
19
19
//XXX GWT CHANGE No Reflection
20
import java.lang.reflect.Array;
21
import java.util.Collection;
20
import java.util.Collection;
22
import java.util.Iterator;
21
import java.util.Iterator;
23
import java.util.List;
22
import java.util.List;
Lines 57-63 Link Here
57
56
58
  protected Object [] newData(int capacity)
57
  protected Object [] newData(int capacity)
59
  {
58
  {
60
    return (Object [])Array.newInstance(dataClass, capacity);
59
//FIXME GWT CHANGE No Reflection
60
    return (Object [])new Object[capacity];
61
  }
61
  }
62
62
63
  public NotificationChain basicRemove(Object object, NotificationChain notifications)
63
  public NotificationChain basicRemove(Object object, NotificationChain notifications)
(-)src/org/eclipse/emf/ecore/util/EcoreEMap.java (-3 / +4 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package  org.eclipse.emf.ecore.util;
17
package  org.eclipse.emf.ecore.util;
18
18
19
19
//XXX GWT CHANGE No Reflection
20
import java.lang.reflect.Array;
20
//import java.lang.reflect.Array;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.List;
22
import java.util.List;
23
import java.util.ListIterator;
23
import java.util.ListIterator;
Lines 142-148 Link Here
142
      {
142
      {
143
        public Object [] newData(int listCapacity)
143
        public Object [] newData(int listCapacity)
144
        {
144
        {
145
          return (Object [])Array.newInstance(entryClass, listCapacity);
145
//FIXME GWT CHANGE No Reflection
146
          return (Object [])new Object[listCapacity];
146
        }
147
        }
147
      };
148
      };
148
  }
149
  }
(-)src/org/eclipse/emf/ecore/util/FeatureMapUtil.java (-29 / +32 lines)
Lines 23-34 Link Here
23
import java.util.Collection;
23
import java.util.Collection;
24
import java.util.Collections;
24
import java.util.Collections;
25
import java.util.ConcurrentModificationException;
25
import java.util.ConcurrentModificationException;
26
import java.util.HashMap;
26
import java.util.Iterator;
27
import java.util.Iterator;
27
import java.util.List;
28
import java.util.List;
28
import java.util.ListIterator;
29
import java.util.ListIterator;
29
import java.util.Map;
30
import java.util.Map;
30
import java.util.NoSuchElementException;
31
import java.util.NoSuchElementException;
31
import java.util.WeakHashMap;
32
//XXX GWT CHANGE No WeakHashMap
32
33
33
import org.eclipse.emf.common.notify.Notification;
34
import org.eclipse.emf.common.notify.Notification;
34
import org.eclipse.emf.common.notify.NotificationChain;
35
import org.eclipse.emf.common.notify.NotificationChain;
Lines 185-193 Link Here
185
      if (value != null && !eStructuralFeature.getEType().isInstance(value))
186
      if (value != null && !eStructuralFeature.getEType().isInstance(value))
186
      {
187
      {
187
        String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName();
188
        String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName();
188
        throw 
189
        throw
189
          new ClassCastException
190
          new ClassCastException
190
            ("The feature '" + eStructuralFeature.getName()  + "'s type '" + 
191
            ("The feature '" + eStructuralFeature.getName()  + "'s type '" +
191
                eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'");
192
                eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'");
192
      }
193
      }
193
    }
194
    }
Lines 215-221 Link Here
215
      else
216
      else
216
      {
217
      {
217
        FeatureMap.Entry entry = (FeatureMap.Entry)that;
218
        FeatureMap.Entry entry = (FeatureMap.Entry)that;
218
        return 
219
        return
219
          entry.getEStructuralFeature() == eStructuralFeature &&
220
          entry.getEStructuralFeature() == eStructuralFeature &&
220
          (value == null ? entry.getValue() == null : value.equals(entry.getValue()));
221
          (value == null ? entry.getValue() == null : value.equals(entry.getValue()));
221
      }
222
      }
Lines 230-239 Link Here
230
    {
231
    {
231
      String prefix = eStructuralFeature.getEContainingClass().getEPackage().getNsPrefix();
232
      String prefix = eStructuralFeature.getEContainingClass().getEPackage().getNsPrefix();
232
      eStructuralFeature.getName();
233
      eStructuralFeature.getName();
233
      return 
234
      return
234
         (prefix != null && prefix.length() != 0 ? 
235
         (prefix != null && prefix.length() != 0 ?
235
            prefix + ":" + eStructuralFeature.getName() : 
236
            prefix + ":" + eStructuralFeature.getName() :
236
            eStructuralFeature.getName()) + 
237
            eStructuralFeature.getName()) +
237
           "=" + value;
238
           "=" + value;
238
/*
239
/*
239
      StringBuffer result = new StringBuffer(super.toString());
240
      StringBuffer result = new StringBuffer(super.toString());
Lines 517-522 Link Here
517
518
518
  public static class FeatureEList extends AbstractList implements InternalEList.Unsettable, EStructuralFeature.Setting
519
  public static class FeatureEList extends AbstractList implements InternalEList.Unsettable, EStructuralFeature.Setting
519
  {
520
  {
521
//XXX GWT CHANGE No modCount available
522
//	  protected int modCount = 0;
520
    public static class Basic extends FeatureEList
523
    public static class Basic extends FeatureEList
521
    {
524
    {
522
      public Basic(EStructuralFeature feature, FeatureMap.Internal featureMap)
525
      public Basic(EStructuralFeature feature, FeatureMap.Internal featureMap)
Lines 670-682 Link Here
670
    {
673
    {
671
      featureMap.addUnique(getEStructuralFeature(), index, object);
674
      featureMap.addUnique(getEStructuralFeature(), index, object);
672
    }
675
    }
673
    
676
674
    public boolean addAllUnique(Collection collection)
677
    public boolean addAllUnique(Collection collection)
675
    {
678
    {
676
      modCount = -1;
679
      modCount = -1;
677
      return featureMap.addAllUnique(collection);
680
      return featureMap.addAllUnique(collection);
678
    }
681
    }
679
    
682
680
    public void addUnique(Entry.Internal entry)
683
    public void addUnique(Entry.Internal entry)
681
    {
684
    {
682
      modCount = -1;
685
      modCount = -1;
Lines 823-839 Link Here
823
  public static class FeatureFeatureMap extends FeatureEList implements FeatureMap.Internal, FeatureMap.Internal.Wrapper
826
  public static class FeatureFeatureMap extends FeatureEList implements FeatureMap.Internal, FeatureMap.Internal.Wrapper
824
  {
827
  {
825
    protected FeatureMap.Internal.Wrapper wrapper = this;
828
    protected FeatureMap.Internal.Wrapper wrapper = this;
826
    
829
827
    public FeatureFeatureMap(EStructuralFeature feature, FeatureMap.Internal featureMap)
830
    public FeatureFeatureMap(EStructuralFeature feature, FeatureMap.Internal featureMap)
828
    {
831
    {
829
      super(feature, featureMap);
832
      super(feature, featureMap);
830
    }
833
    }
831
    
834
832
    public FeatureMap.ValueListIterator valueListIterator()
835
    public FeatureMap.ValueListIterator valueListIterator()
833
    {
836
    {
834
      return featureMap.valueListIterator();
837
      return featureMap.valueListIterator();
835
    }
838
    }
836
    
839
837
    public FeatureMap.ValueListIterator valueListIterator(int index)
840
    public FeatureMap.ValueListIterator valueListIterator(int index)
838
    {
841
    {
839
      return featureMap.valueListIterator(index);
842
      return featureMap.valueListIterator(index);
Lines 1111-1117 Link Here
1111
    {
1114
    {
1112
      featureMap.unset(feature);
1115
      featureMap.unset(feature);
1113
    }
1116
    }
1114
    
1117
1115
    public Wrapper getWrapper()
1118
    public Wrapper getWrapper()
1116
    {
1119
    {
1117
      return wrapper;
1120
      return wrapper;
Lines 1193-1206 Link Here
1193
    {
1196
    {
1194
      super(owner, eventType, feature, oldObject, newObject, index, wasSet);
1197
      super(owner, eventType, feature, oldObject, newObject, index, wasSet);
1195
    }
1198
    }
1196
    
1199
1197
    public int getFeatureID(Class expectedClass)
1200
    public int getFeatureID(Class expectedClass)
1198
    {
1201
    {
1199
      if (featureID == NO_FEATURE_ID && feature != null)
1202
      if (featureID == NO_FEATURE_ID && feature != null)
1200
      {
1203
      {
1201
        Class containerClass = feature.getContainerClass();
1204
        Class containerClass = feature.getContainerClass();
1202
        featureID = containerClass == null ? 
1205
        featureID = containerClass == null ?
1203
          notifier.eClass().getFeatureID(feature) : 
1206
          notifier.eClass().getFeatureID(feature) :
1204
          notifier.eDerivedStructuralFeatureID(feature.getFeatureID(), containerClass);
1207
          notifier.eDerivedStructuralFeatureID(feature.getFeatureID(), containerClass);
1205
      }
1208
      }
1206
      return notifier.eBaseStructuralFeatureID(featureID, expectedClass);
1209
      return notifier.eBaseStructuralFeatureID(featureID, expectedClass);
Lines 1348-1355 Link Here
1348
    protected List wildcards;
1351
    protected List wildcards;
1349
    protected String name;
1352
    protected String name;
1350
    protected boolean isElement;
1353
    protected boolean isElement;
1351
    
1354
//XXX GWT CHANGE No WeakHashMap
1352
    protected class Cache extends WeakHashMap
1355
    protected class Cache extends HashMap
1353
    {
1356
    {
1354
      public Boolean get(EStructuralFeature eStructuralFeature)
1357
      public Boolean get(EStructuralFeature eStructuralFeature)
1355
      {
1358
      {
Lines 1417-1424 Link Here
1417
        for (int i = 0, size = containingClass.getFeatureCount(); i < size; ++i)
1420
        for (int i = 0, size = containingClass.getFeatureCount(); i < size; ++i)
1418
        {
1421
        {
1419
          EStructuralFeature feature = containingClass.getEStructuralFeature(i);
1422
          EStructuralFeature feature = containingClass.getEStructuralFeature(i);
1420
          for (EStructuralFeature group = ExtendedMetaData.INSTANCE.getGroup(feature); 
1423
          for (EStructuralFeature group = ExtendedMetaData.INSTANCE.getGroup(feature);
1421
               group != null; 
1424
               group != null;
1422
               group = ExtendedMetaData.INSTANCE.getGroup(group))
1425
               group = ExtendedMetaData.INSTANCE.getGroup(group))
1423
          {
1426
          {
1424
            if (group == eStructuralFeature)
1427
            if (group == eStructuralFeature)
Lines 1428-1434 Link Here
1428
          }
1431
          }
1429
        }
1432
        }
1430
      }
1433
      }
1431
      else 
1434
      else
1432
      {
1435
      {
1433
        wildcards = null;
1436
        wildcards = null;
1434
        isElement = true;
1437
        isElement = true;
Lines 1465-1473 Link Here
1465
      if (wildcards == ANY_WILDCARD)
1468
      if (wildcards == ANY_WILDCARD)
1466
      {
1469
      {
1467
        int featureKind = ExtendedMetaData.INSTANCE.getFeatureKind(feature);
1470
        int featureKind = ExtendedMetaData.INSTANCE.getFeatureKind(feature);
1468
        return 
1471
        return
1469
          isElement ? 
1472
          isElement ?
1470
            featureKind == ExtendedMetaData.ELEMENT_FEATURE && 
1473
            featureKind == ExtendedMetaData.ELEMENT_FEATURE &&
1471
              feature != XMLTypeFeatures.TEXT && feature != XMLTypeFeatures.CDATA && feature != XMLTypeFeatures.COMMENT :
1474
              feature != XMLTypeFeatures.TEXT && feature != XMLTypeFeatures.CDATA && feature != XMLTypeFeatures.COMMENT :
1472
            featureKind == ExtendedMetaData.ATTRIBUTE_FEATURE;
1475
            featureKind == ExtendedMetaData.ATTRIBUTE_FEATURE;
1473
      }
1476
      }
Lines 1493-1499 Link Here
1493
    }
1496
    }
1494
  }
1497
  }
1495
1498
1496
  protected static Validator NULL_VALIDATOR = 
1499
  protected static Validator NULL_VALIDATOR =
1497
    new Validator()
1500
    new Validator()
1498
    {
1501
    {
1499
      public boolean isValid(EStructuralFeature eStructuralFeature)
1502
      public boolean isValid(EStructuralFeature eStructuralFeature)
Lines 1516-1522 Link Here
1516
    }
1519
    }
1517
    else
1520
    else
1518
    {
1521
    {
1519
      BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder holder = 
1522
      BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder holder =
1520
        (BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder)eStructuralFeature;
1523
        (BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder)eStructuralFeature;
1521
      BasicExtendedMetaData.EStructuralFeatureExtendedMetaData extendedMetaData = holder.getExtendedMetaData();
1524
      BasicExtendedMetaData.EStructuralFeatureExtendedMetaData extendedMetaData = holder.getExtendedMetaData();
1522
      if (extendedMetaData == null)
1525
      if (extendedMetaData == null)
Lines 1560-1567 Link Here
1560
        else
1563
        else
1561
        {
1564
        {
1562
          int affiliationUpperBound = affiliation.getUpperBound();
1565
          int affiliationUpperBound = affiliation.getUpperBound();
1563
          return 
1566
          return
1564
            (affiliationUpperBound > 1 || affiliationUpperBound == ETypedElement.UNBOUNDED_MULTIPLICITY) && 
1567
            (affiliationUpperBound > 1 || affiliationUpperBound == ETypedElement.UNBOUNDED_MULTIPLICITY) &&
1565
              ExtendedMetaData.INSTANCE.getFeatureKind(affiliation) != ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE;
1568
              ExtendedMetaData.INSTANCE.getFeatureKind(affiliation) != ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE;
1566
        }
1569
        }
1567
      }
1570
      }
(-)src/org/eclipse/emf/ecore/util/ECrossReferenceAdapter.java (-24 / +28 lines)
Lines 235-263 Link Here
235
    {
235
    {
236
      // This should be the same as the logic in ResourceImpl.getEObject(String).
236
      // This should be the same as the logic in ResourceImpl.getEObject(String).
237
      //
237
      //
238
      String fragment = uri.fragment();
238
    	throw new UnsupportedOperationException();
239
      if (fragment != null)
239
//FIXME GWT CHANGE
240
      {
240
//      String fragment = uri.fragment();
241
        int length = fragment.length();
241
//      if (fragment != null)
242
        if (length > 0 && fragment.charAt(0) != '/' && fragment.charAt(length - 1) == '?')
242
//      {
243
        {
243
//        int length = fragment.length();
244
          int index = fragment.lastIndexOf('?', length - 2);
244
//        if (length > 0 && fragment.charAt(0) != '/' && fragment.charAt(length - 1) == '?')
245
          if (index > 0)
245
//        {
246
          {
246
//          int index = fragment.lastIndexOf('?', length - 2);
247
            uri = uri.trimFragment().appendFragment(fragment.substring(0, index));
247
//          if (index > 0)
248
          }
248
//          {
249
        }
249
//            uri = uri.trimFragment().appendFragment(fragment.substring(0, index));
250
      }
250
//          }
251
      Resource resourceContext = objectContext.eResource();
251
//        }
252
      if (resourceContext != null)
252
//      }
253
      {
253
//      Resource resourceContext = objectContext.eResource();
254
        ResourceSet resourceSetContext = resourceContext.getResourceSet();
254
//      if (resourceContext != null)
255
        if (resourceSetContext != null)
255
//      {
256
        {
256
//        ResourceSet resourceSetContext = resourceContext.getResourceSet();
257
          return resourceSetContext.getURIConverter().normalize(uri);
257
//        if (resourceSetContext != null)
258
        }
258
//        {
259
      }
259
//          return resourceSetContext.getURIConverter().normalize(uri);
260
      return uri;
260
//        }
261
//      }
262
//      return uri;
261
    }
263
    }
262
    
264
    
263
    protected boolean resolve()
265
    protected boolean resolve()
Lines 357-363 Link Here
357
          ResourceSet resourceSet = resource.getResourceSet();
359
          ResourceSet resourceSet = resource.getResourceSet();
358
          if (resourceSet != null)
360
          if (resourceSet != null)
359
          {
361
          {
360
            uri = resourceSet.getURIConverter().normalize(uri);
362
        	  throw new UnsupportedOperationException();
363
//FIXME GWT CHANGE
364
//            uri = resourceSet.getURIConverter().normalize(uri);
361
          }
365
          }
362
          uri = uri.appendFragment(resource.getURIFragment(eObject));
366
          uri = uri.appendFragment(resource.getURIFragment(eObject));
363
        }
367
        }
(-)src/org/eclipse/emf/ecore/util/EcoreEList.java (-4 / +7 lines)
Lines 16-23 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.util;
17
package org.eclipse.emf.ecore.util;
18
18
19
19
//XXX GWT CHANGE No Reflection
20
import java.lang.reflect.Array;
20
//import java.lang.reflect.Array;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.List;
22
import java.util.List;
23
import java.util.ListIterator;
23
import java.util.ListIterator;
Lines 51-57 Link Here
51
51
52
  protected Object [] newData(int capacity)
52
  protected Object [] newData(int capacity)
53
  {
53
  {
54
    return (Object [])Array.newInstance(dataClass, capacity);
54
//FIXME GWT CHANGE No Reflection
55
    return (Object [])new Object[capacity];
55
  }
56
  }
56
57
57
  protected Object validate(int index, Object object)
58
  protected Object validate(int index, Object object)
Lines 66-72 Link Here
66
67
67
  protected boolean isInstance(Object object)
68
  protected boolean isInstance(Object object)
68
  {
69
  {
69
    return dataClass.isInstance(object);
70
	  return true;
71
//FIXME GWT CHANGE No Reflection
72
//    return dataClass.isInstance(object);
70
  }
73
  }
71
74
72
  public Object getNotifier()
75
  public Object getNotifier()
(-)src/org/eclipse/emf/ecore/util/EObjectValidator.java (-19 / +20 lines)
Lines 25-31 Link Here
25
import java.util.ListIterator;
25
import java.util.ListIterator;
26
import java.util.Map;
26
import java.util.Map;
27
27
28
import java.math.BigDecimal;
28
//GWT CHANGE No Big-Values
29
//import java.math.BigDecimal;
29
30
30
import org.eclipse.emf.common.util.BasicDiagnostic;
31
import org.eclipse.emf.common.util.BasicDiagnostic;
31
import org.eclipse.emf.common.util.Diagnostic;
32
import org.eclipse.emf.common.util.Diagnostic;
Lines 800-823 Link Here
800
          result = false;
801
          result = false;
801
        }
802
        }
802
      }
803
      }
803
804
//FIXME NO Big-Values
804
      if (effectiveTotalDigits != -1)
805
//      if (effectiveTotalDigits != -1)
805
      {
806
//      {
806
        if (value instanceof BigDecimal && ((BigDecimal)value).unscaledValue().abs().toString().length() > effectiveTotalDigits)
807
//        if (value instanceof BigDecimal && ((BigDecimal)value).unscaledValue().abs().toString().length() > effectiveTotalDigits)
807
        {
808
//        {
808
          if (diagnostics != null) reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context);
809
//          if (diagnostics != null) reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context);
809
          result = false;
810
//          result = false;
810
        }
811
//        }
811
      }
812
//      }
812
813
//
813
      if (effectiveFractionDigits != -1)
814
//      if (effectiveFractionDigits != -1)
814
      {
815
//      {
815
        if (value instanceof BigDecimal && ((BigDecimal)value).scale() > effectiveFractionDigits)
816
//        if (value instanceof BigDecimal && ((BigDecimal)value).scale() > effectiveFractionDigits)
816
        {
817
//        {
817
          if (diagnostics != null) reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context);
818
//          if (diagnostics != null) reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context);
818
          result = false;
819
//          result = false;
819
        }
820
//        }
820
      }
821
//      }
821
822
822
      if (itemType != null)
823
      if (itemType != null)
823
      {
824
      {
(-)src/org/eclipse/emf/ecore/plugin/GeneratedPackageRegistryReader.java (-98 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: GeneratedPackageRegistryReader.java,v 1.7 2006/05/25 19:17:08 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import java.util.Map;
21
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.Platform;
24
25
import org.eclipse.emf.common.util.URI;
26
import org.eclipse.emf.ecore.EPackage;
27
28
/**
29
 * A plugin extension reader that populates the
30
 * {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry.
31
 * Clients are not expected to use this class directly.
32
 */
33
class GeneratedPackageRegistryReader extends RegistryReader
34
{
35
  static final String TAG_PACKAGE = "package";
36
  static final String ATT_URI = "uri";
37
  static final String ATT_CLASS = "class";
38
  static final String ATT_GEN_MODEL = "genModel";
39
  
40
  protected Map ePackageNsURIToGenModelLocationMap;
41
  
42
  public GeneratedPackageRegistryReader()
43
  {
44
    super
45
      (Platform.getExtensionRegistry(),
46
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
47
       EcorePlugin.GENERATED_PACKAGE_PPID);
48
  }
49
  
50
  public GeneratedPackageRegistryReader(Map ePackageNsURIToGenModelLocationMap)
51
  {
52
    this();
53
    this.ePackageNsURIToGenModelLocationMap = ePackageNsURIToGenModelLocationMap;
54
  }
55
56
  protected boolean readElement(IConfigurationElement element)
57
  {
58
    if (element.getName().equals(TAG_PACKAGE))
59
    {
60
      String packageURI = element.getAttribute(ATT_URI);
61
      if (packageURI == null)
62
      {
63
        logMissingAttribute(element, ATT_URI);
64
      }
65
      else if (element.getAttribute(ATT_CLASS) == null)
66
      {
67
        logMissingAttribute(element, ATT_CLASS);
68
      }
69
      else
70
      {
71
        Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor(element, ATT_CLASS));
72
        if (previous instanceof PluginClassDescriptor)
73
        {
74
          PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
75
          EcorePlugin.INSTANCE.log
76
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
77
        }
78
        
79
        if (ePackageNsURIToGenModelLocationMap != null)
80
        {
81
          String genModel = element.getAttribute(ATT_GEN_MODEL);
82
          if (genModel != null)
83
          {
84
            URI genModelURI = URI.createURI(genModel);
85
            if (genModelURI.isRelative())
86
            {
87
              genModelURI = URI.createURI("platform:/plugin/" + element.getDeclaringExtension().getContributor().getName() + "/" + genModel);
88
            }
89
            ePackageNsURIToGenModelLocationMap.put(packageURI, genModelURI);
90
          }
91
        }
92
        return true;
93
      }
94
    }
95
96
    return false;
97
  }
98
}
(-)src/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java (-73 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ExtensionParserRegistryReader.java,v 1.5 2006/05/25 19:17:08 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.Platform;
22
23
import org.eclipse.emf.ecore.resource.Resource;
24
25
26
/**
27
 * A plugin extension reader that populates the 
28
 * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory's 
29
 * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap() extension} map.
30
 * Clients are not expected to use this class directly.
31
 */
32
class ExtensionParserRegistryReader extends RegistryReader
33
{
34
  static final String TAG_PARSER = "parser";
35
  static final String ATT_TYPE = "type";
36
  static final String ATT_CLASS = "class";
37
38
  public ExtensionParserRegistryReader()
39
  {
40
    super
41
      (Platform.getExtensionRegistry(),
42
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
43
       EcorePlugin.EXTENSION_PARSER_PPID);
44
  }
45
46
  protected boolean readElement(IConfigurationElement element)
47
  {
48
    if (element.getName().equals(TAG_PARSER))
49
    {
50
      String type = element.getAttribute(ATT_TYPE);
51
      if (type == null)
52
      {
53
        logMissingAttribute(element, ATT_TYPE);
54
      }
55
      else if (element.getAttribute(ATT_CLASS) == null)
56
      {
57
        logMissingAttribute(element, ATT_CLASS);
58
      }
59
      else
60
      {
61
        Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
62
        if (previous instanceof ResourceFactoryDescriptor)
63
        {
64
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
65
          EcorePlugin.INSTANCE.log
66
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
67
        }
68
        return true;
69
      }
70
    }
71
    return false;
72
  }
73
}
(-)src/org/eclipse/emf/ecore/plugin/EcorePlugin.java (-603 / +17 lines)
Lines 1-614 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: EcorePlugin.java,v 1.14.2.1 2007/05/10 17:29:50 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
1
package org.eclipse.emf.ecore.plugin;
18
2
19
import java.io.File;
20
import java.io.IOException;
21
import java.io.InputStream;
22
import java.util.Collection;
23
import java.util.HashMap;
24
import java.util.HashSet;
25
import java.util.Iterator;
26
import java.util.Map;
27
28
import javax.xml.parsers.SAXParser;
29
import javax.xml.parsers.SAXParserFactory;
30
31
import org.osgi.framework.BundleContext;
32
import org.xml.sax.Attributes;
33
import org.xml.sax.InputSource;
34
import org.xml.sax.SAXException;
35
import org.xml.sax.helpers.DefaultHandler;
36
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.resources.IProject;
39
import org.eclipse.core.resources.IWorkspaceRoot;
40
import org.eclipse.core.resources.ResourcesPlugin;
41
import org.eclipse.core.runtime.CoreException;
42
import org.eclipse.core.runtime.IConfigurationElement;
43
import org.eclipse.core.runtime.Platform;
44
45
import org.eclipse.emf.common.EMFPlugin;
46
import org.eclipse.emf.common.util.ResourceLocator;
3
import org.eclipse.emf.common.util.ResourceLocator;
47
import org.eclipse.emf.common.util.URI;
48
import org.eclipse.emf.common.util.WrappedException;
49
import org.eclipse.emf.ecore.EPackage;
4
import org.eclipse.emf.ecore.EPackage;
50
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
51
import org.eclipse.emf.ecore.xml.type.internal.RegEx;
52
53
54
/**
55
 * A collection of platform-neutral static utilities
56
 * as well as Eclipse support utilities.
57
 */
58
public class EcorePlugin  extends EMFPlugin
59
{
60
  /**
61
   * The singleton instance of the plugin.
62
   */
63
  public static final EcorePlugin INSTANCE = new EcorePlugin();
64
65
  /**
66
   * Creates the singleton instance.
67
   */
68
  private EcorePlugin()
69
  {
70
    super(new ResourceLocator[] {});
71
  }
72
73
  /*
74
   * Javadoc copied from base class.
75
   */
76
  public ResourceLocator getPluginResourceLocator()
77
  {
78
    return plugin;
79
  }
80
81
  /**
82
   * Returns the platform resource map.
83
   * <p>
84
   * This map is from {@link String} to {@link URI}.
85
   * It is the logical equivalent of the map implied by an {@link IWorkspaceRoot}:
86
   * I.e., each entry in the map corresponds to
87
   * an {@link org.eclipse.core.resources.IProject} 
88
   * that has a {@link org.eclipse.core.resources.IResource#getName name} 
89
   * and a location {@link org.eclipse.core.resources.IResource#getLocation location};
90
   * the name is the key 
91
   * and the location, interpretted as a {@link URI#createFileURI file URI}, is the value.
92
   * This map is used to {@link #resolvePlatformResourcePath resolve} a platform resource path,
93
   * and thereby supports relocatable projects in a manner that is transparently the same as an Eclipse workspace.
94
   * </p>
95
   * @return the platform resource map.
96
   * @see #resolvePlatformResourcePath
97
   */
98
  public static Map getPlatformResourceMap()
99
  {
100
    if (platformResourceMap == null)
101
    {
102
      platformResourceMap = new HashMap();
103
    }
104
    return platformResourceMap;
105
  }
106
107
  /**
108
   * Resolves a platform resource path of the form <code>"/project/path"</code> 
109
   * against the platform resource map.
110
   * <p>
111
   * The first segment of the path, i.e., the <em>project name</em>,
112
   * is used to get a URI from the {@link #getPlatformResourceMap() map}.
113
   * If a URI results, the remaining segments are {@link URI#resolve resolved} against it
114
   * and that is the result.
115
   * Otherwise, the result is <code>null</code>.
116
   * For example, given this mapping
117
   *<pre>
118
   *  EcoreUtil.getPlatformResourceMap().put
119
   *    ("project", URI.createURI("file:///C:/location/"));
120
   *</pre>
121
   * the following transformation would result:
122
   *<pre>
123
   *  /project/directory/file
124
   *    ->
125
   *  file:///C:/location/directory/file
126
   *</pre>
127
   * </p>
128
   * @return the resolved URI or <code>null</code>.
129
   */
130
  public static URI resolvePlatformResourcePath(String platformResourcePath)
131
  {
132
    if (platformResourceMap != null)
133
    {
134
      int index = platformResourcePath.indexOf("/", 1);
135
      String rootContainerName = platformResourcePath.substring(1, index);
136
      String relativeName = platformResourcePath.substring(index + 1);
137
      URI rootContainerLocation = (URI)getPlatformResourceMap().get(rootContainerName);
138
      if (rootContainerLocation != null)
139
      {
140
        return URI.createURI(relativeName).resolve(rootContainerLocation);
141
      }
142
    }
143
    return null;
144
  }
145
146
  /**
147
   * Handles recognized platform resource arguments and returns the stripped result.
148
   * <p>
149
   * Recognized arguments are of this form:
150
   *<pre>
151
   *  -platformResource ( &lt;project-name> &lt;file-or-URI> )+
152
   *</pre>
153
   * E.g., This these arguments
154
   *<pre>
155
   *  -platformResource project file:///C:/location/
156
   *</pre>
157
   * will produce this effect:
158
   *<pre>
159
   *  EcoreUtil.getPlatformResourceMap().put
160
   *    ("project", URI.createURI("file:///C:/location/"));
161
   *</pre>
162
   * This mechanism supports relocatable projects outside of Eclipse.
163
   * </p>
164
   * @param arguments an array of "command line" options.
165
   * @return the arguments stripped of those recognized as platform resource options.
166
   */
167
  public static String [] handlePlatformResourceOptions(String [] arguments)
168
  {
169
    getPlatformResourceMap();
170
171
    for (int i = 0; i < arguments.length; ++i)
172
    {
173
      if (arguments[i].equalsIgnoreCase("-platformResource"))
174
      {
175
        int start = i;
176
        while (++i < arguments.length && !arguments[i].startsWith("-"))
177
        {
178
          String rootContainerName = arguments[i];
179
          if (++i < arguments.length)
180
          {
181
            String rootContainerLocation = arguments[i];
182
183
            // This let's us test whether the string exists as a file.
184
            // If not, we try as a URI.
185
            //
186
            URI uri;
187
            File file = new File(rootContainerLocation);
188
            if (file.isDirectory() || !file.exists() && file.getParent() != null && file.getParentFile().isDirectory())
189
            {
190
              try
191
              {
192
                file = file.getCanonicalFile();
193
              }
194
              catch (IOException exception)
195
              {
196
                throw new WrappedException(exception);
197
              }
198
              uri = URI.createFileURI(file.toString() + "/");
199
            }
200
            else
201
            {
202
              uri = URI.createURI(rootContainerLocation);
203
            }
204
205
            platformResourceMap.put(rootContainerName, uri);
206
          }
207
        }
208
209
        String [] remainingArguments = new String [arguments.length - (i - start)];
210
        System.arraycopy(arguments, 0, remainingArguments, 0, start);
211
        System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i);
212
        return remainingArguments;
213
      }
214
    }
215
216
    return arguments;
217
  }
218
  
219
  /**
220
   * Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String) 
221
   * to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}).
222
   * @return a map from package namespace to GenModel location.
223
   */
224
  public static Map getEPackageNsURIToGenModelLocationMap()
225
  {
226
    if (ePackageNsURIToGenModelLocationMap == null)
227
    {
228
      ePackageNsURIToGenModelLocationMap = new HashMap();
229
    }
230
    return ePackageNsURIToGenModelLocationMap;
231
  }
232
233
  /**
234
   * Computes a map from <code>platform:/resource/&lt;plugin-location>/</code> {@link URI} to 
235
   * <code>platform:/plugin/&lt;plugin-id>/</code> URI
236
   * for each URI in the collection of the form <code>platform:/plugin/&lt;plugin-id>/...</code>.
237
   * This allows each plugin to be {@link org.eclipse.emf.ecore.resource.URIConverter#getURIMap() treated} 
238
   * as if it were a project in the workspace.
239
   * If the workspace already contains a project for the plugin location, no mapping is produced.
240
   * @return a map from workspace URIs to plugin URIs.
241
   * @param uris a collections of {@link URI}s.
242
   * @return a map from platform resource URI to platform plugin URI.
243
   */
244
  public static Map computePlatformResourceToPlatformPluginMap(Collection uris)
245
  {
246
    Map result = new HashMap();
247
    IWorkspaceRoot root = getWorkspaceRoot();
248
    if (root != null)
249
    {
250
      for (Iterator i = uris.iterator(); i.hasNext(); )
251
      {
252
        URI uri = (URI)i.next();
253
        if ("platform".equals(uri.scheme()) && uri.segmentCount() > 1 && "plugin".equals(uri.segment(0)))
254
        {
255
          String pluginID = uri.segment(1);
256
          if (!root.getProject(pluginID).isOpen())
257
          {
258
            result.put(URI.createPlatformResourceURI(pluginID + "/"), URI.createURI("platform:/plugin/" + pluginID + "/"));
259
          }
260
        }
261
      }
262
    }
263
    return result;
264
  }
265
  
266
  private static RegEx.RegularExpression bundleSymbolNamePattern;
267
  private static byte [] NO_BYTES = new byte [0];
268
  
269
  /**
270
   * Computes a map from <code>platform:/plugin/&lt;plugin-id>/</code> {@link URI} to 
271
   * <code>platform:/resource/&lt;plugin-location>/</code> URI
272
   * for each plugin project in the workspace.
273
   * This allows each plugin from the runtime to be {@link org.eclipse.emf.ecore.resource.URIConverter#getURIMap() redirected} 
274
   * to its active version in the workspace.
275
   * @return a map from plugin URIs to resource URIs.
276
   * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
277
   * @see URI
278
   */
279
  public static Map computePlatformPluginToPlatformResourceMap()
280
  {
281
    Map result = new HashMap();
282
    IWorkspaceRoot root = getWorkspaceRoot();
283
    if (root != null)
284
    { 
285
      IProject [] projects = root.getProjects();
286
      if (projects != null)
287
      {
288
        String pluginID = null;
289
        
290
        class Handler extends DefaultHandler
291
        {
292
          public String pluginID;
293
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
294
          {
295
            if ("".equals(uri) && "plugin".equals(localName))
296
            {
297
              pluginID = attributes.getValue("id");
298
            }
299
            throw new SAXException("Done");
300
          }
301
        };
302
        Handler handler = new Handler();
303
        
304
        SAXParserFactory parserFactory= SAXParserFactory.newInstance();
305
        parserFactory.setNamespaceAware(true);
306
        SAXParser parser = null;
307
        
308
        try
309
        {
310
          parser = parserFactory.newSAXParser();
311
        }
312
        catch (Exception exception)
313
        {
314
          INSTANCE.log(exception);
315
        }
316
        
317
        if (bundleSymbolNamePattern == null)
318
        {
319
          bundleSymbolNamePattern = new RegEx.RegularExpression("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", "m");
320
        }
321
        
322
        byte [] bytes = NO_BYTES;
323
        
324
        for (int i = 0, size = projects.length; i < size; ++i)
325
        {
326
          IProject project = projects[i];
327
          if (project.isOpen())
328
          {
329
            pluginID = null;
330
            IFile manifest = project.getFile("META-INF/MANIFEST.MF");
331
            if (manifest.exists())
332
            {
333
              try
334
              {
335
                InputStream inputStream = manifest.getContents(); 
336
                int available = inputStream.available();
337
                if (bytes.length < available)
338
                {
339
                  bytes = new byte [available];
340
                }
341
                inputStream.read(bytes);
342
                String contents = new String(bytes, "UTF-8");
343
                RegEx.Match match = new RegEx.Match();
344
                if (bundleSymbolNamePattern.matches(contents, match)) 
345
                {
346
                  pluginID = match.getCapturedText(1);
347
                }
348
              }
349
              catch (Exception exception)
350
              {
351
                EcorePlugin.INSTANCE.log(exception);
352
              }
353
            }
354
            else if (parser != null)
355
            {
356
              final IFile plugin = project.getFile("plugin.xml");
357
              if (plugin.exists())
358
              {
359
                try
360
                {
361
                  parser.parse(new InputSource(plugin.getContents()), handler);
362
                }
363
                catch (Exception exception)
364
                {
365
                  if (handler.pluginID != null)
366
                  {
367
                    pluginID = handler.pluginID;
368
                  }
369
                  else
370
                  {
371
                    INSTANCE.log(exception);
372
                  }
373
                }
374
              }
375
            }
376
            
377
            if (pluginID != null)
378
            {
379
              URI platformPluginURI = URI.createURI("platform:/plugin/" + pluginID + "/");
380
              URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/");
381
              result.put(platformPluginURI, platformResourceURI);
382
            }
383
          }
384
        }
385
      }
386
    }
387
    
388
    return result;
389
  }
390
  
391
  /**
392
   * Computes a map so that plugins in the workspace will override those in the environment
393
   * and so that plugins with Ecore and GenModels will look like projects in the workspace.
394
   * It's implemented like this:
395
   *<pre>
396
   *  Map result = new HashMap();
397
   *  result.putAll(computePlatformPluginToPlatformResourceMap());
398
   *  result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values())));
399
   *  return result;
400
   *</pre>
401
   * @return computes a map so that plugins in the workspace will override those in the environment
402
   * and so that plugins with Ecore and GenModels will look like projects in the workspace.
403
   * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
404
   * @see URI
405
   * @see #computePlatformPluginToPlatformResourceMap()
406
   * @see #computePlatformResourceToPlatformPluginMap(Collection)
407
   */
408
  public static Map computePlatformURIMap()
409
  {
410
    Map result = new HashMap();
411
    result.putAll(computePlatformPluginToPlatformResourceMap());
412
    result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values())));
413
    return result;
414
  }
415
  
416
  /**
417
   * The platform resource map.
418
   * @see #getPlatformResourceMap
419
   */
420
  private static Map platformResourceMap;
421
  
422
  /**
423
   * The map fro
424
   * @see #getPlatformResourceMap
425
   */
426
  private static Map ePackageNsURIToGenModelLocationMap;
427
428
  /** 
429
   * A plugin implementation that handles Ecore plugin registration.
430
   * @see #startup
431
   */
432
  static public class Implementation extends EclipsePlugin
433
  {
434
    /**
435
     * Creates the singleton instance.
436
     */
437
    public Implementation()
438
    {
439
      super();
440
      plugin = this;
441
    }
442
  
443
    /**
444
     * Starts up this plugin by reading some extensions and populating the relevant registries.
445
     * <p>
446
     * The {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry
447
     * is populated by plugin registration of the form:
448
     *<pre>
449
     *  &lt;extension point="org.eclipse.emf.ecore.generated_package" >
450
     *      &lt;package uri="http://www.example.org/abc/Abc.ecore" class="org.example.abc.AbcPackage"/>
451
     *  &lt;extension>
452
     *</pre>
453
     * </p>
454
     * The URI is arbitrary but an absolute URI is recommended.
455
     * Provision for access to the serialized model via <code>"http:"</code> is encouraged.
456
     * <p>
457
     * The {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory registry's 
458
     * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap() extension} map
459
     * is populated by plugin registration of the form:
460
     *<pre>
461
     *  &lt;extension point="org.eclipse.emf.ecore.extension_parser">
462
     *      &lt;parser type="abc" class="org.example.abc.util.AbcResourceFactoryImpl"/>
463
     *  &lt;extension>
464
     *</pre>
465
     * </p>
466
     * <p>
467
     * The {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory registry's
468
     * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getProtocolToFactoryMap() protocol} map
469
     * is populated by plugin registration of the form:
470
     *<pre>
471
     *  &lt;extension point="org.eclipse.emf.ecore.protocol_parser" >
472
     *      &lt;parser protocolName="abc" class="org.example.abc.util.AbcResourceFactoryImpl"/>
473
     *  &lt;extension>
474
     *</pre>
475
     * </p>
476
     * <p>
477
     * The {@link org.eclipse.emf.ecore.resource.URIConverter#URI_MAP global} URI map
478
     * is populated by plugin registration of the form:
479
     *<pre>
480
     *  &lt;extension point="org.eclipse.emf.ecore.uri_mapping" >
481
     *      &lt;mapping source="//special/" target="special/"/>
482
     *  &lt;extension>
483
     *</pre>
484
     * If the target is relative, it is resolved against the plugin's installed location,
485
     * resulting in a URI of the form:
486
     *<pre>
487
     *  platform:/plugin/plugin-name_1.2.3/...
488
     *</pre>
489
     * The above registration would map
490
     *<pre>
491
     *  //special/a/b.c
492
     *</pre>
493
     * to
494
     *<pre>
495
     *  platform:/plugin/plugin-name_1.2.3/special/a/b.c
496
     *</pre>
497
     * </p>
498
     * @throws Exception if there is a show stopping problem.
499
     */
500
    public void start(BundleContext context) throws Exception
501
    {
502
      super.start(context);
503
504
      if (System.getProperty("org.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin") == null &&
505
            Platform.getBundle("org.eclipse.core.resources") != null)
506
      {
507
        workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
508
      }
509
510
      new RegistryReader
511
        (Platform.getExtensionRegistry(),
512
         EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
513
         PACKAGE_REGISTRY_IMPLEMENTATION)
514
      {
515
        IConfigurationElement previous;
516
517
        protected boolean readElement(IConfigurationElement element)
518
        {
519
          if (element.getName().equals("registry"))
520
          {
521
            String implementationClass = element.getAttribute("class");
522
            if (implementationClass == null)
523
            {
524
              logMissingAttribute(element, "class");
525
            }
526
            else
527
            {
528
              if (defaultRegistryImplementation != null)
529
              {
530
                if (previous != null)
531
                {
532
                  log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package registry implementation");
533
                }
534
                if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator)
535
                {
536
                  return false;
537
                }
538
              }
539
              try
540
              {
541
                defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class");
542
                previous = element;
543
              }
544
              catch (CoreException exception)
545
              {
546
                log(exception);
547
              }
548
              return true;
549
            }
550
          }
551
          return false;
552
        }
553
        
554
      }.readRegistry();
555
556
      new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap()).readRegistry();
557
      new FactoryOverrideRegistryReader().readRegistry();
558
      new ExtensionParserRegistryReader().readRegistry();
559
      new ProtocolParserRegistryReader().readRegistry();
560
      new URIMappingRegistryReader().readRegistry();
561
    }
562
  }
563
5
564
  /**
6
public class EcorePlugin implements ResourceLocator {
565
   * The default registry implementation singleton.
566
   */
567
  private static EPackage.Registry defaultRegistryImplementation; 
568
7
569
  /**
8
	public static final EcorePlugin INSTANCE = new EcorePlugin();
570
   * Returns the default registry implementation singleton.
571
   * @return the default registry implementation singleton.
572
   */
573
  public static EPackage.Registry getDefaultRegistryImplementation()
574
  {
575
    return defaultRegistryImplementation;
576
  }
577
9
578
  /**
10
	public void log(Exception exception) {
579
   * Returns the Eclipse plugin singleton.
11
		exception.printStackTrace();
580
   * @return the plugin singleton.
12
		System.err.println(exception.toString());
581
   */
13
	}
582
  public static Implementation getPlugin()
583
  {
584
    return plugin;
585
  }
586
14
587
  /**
15
	public String getString(String key) {
588
   * The plugin singleton
16
		return key;
589
   */
17
	}
590
  private static Implementation plugin;
591
18
592
  /**
19
	public String getString(String string, Object[] objects) {
593
   * The workspace root.
20
		return string;
594
   * @see #getWorkspaceRoot
21
	}
595
   */
596
  private static IWorkspaceRoot workspaceRoot;
597
22
598
  /**
23
	public static EPackage.Registry getDefaultRegistryImplementation() {
599
   * Returns the workspace root, or <code>null</code>, if the runtime environment is stand-alone.
24
		// TODO Auto-generated method stub
600
   * @return the workspace root, or <code>null</code>.
25
		return null;
601
   */
26
	}
602
  public static IWorkspaceRoot getWorkspaceRoot()
603
  {
604
    return workspaceRoot;
605
  }
606
27
607
  static final String GENERATED_PACKAGE_PPID = "generated_package";
28
}
608
  static final String FACTORY_OVERRIDE_PPID = "factory_override";
609
  static final String EXTENSION_PARSER_PPID = "extension_parser";
610
  static final String PROTOCOL_PARSER_PPID = "protocol_parser";
611
  static final String SCHEME_PARSER_PPID = "scheme_parser";
612
  static final String URI_MAPPING_PPID = "uri_mapping";
613
  static final String PACKAGE_REGISTRY_IMPLEMENTATION = "package_registry_implementation";
614
}
(-)src/org/eclipse/emf/ecore/plugin/FactoryOverrideRegistryReader.java (-77 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: FactoryOverrideRegistryReader.java,v 1.3 2006/05/25 19:17:08 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.Platform;
22
23
import org.eclipse.emf.ecore.EPackage;
24
25
26
/**
27
 * A plugin extension reader that populates the
28
 * {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry.
29
 * Clients are not expected to use this class directly.
30
 */
31
class FactoryOverrideRegistryReader extends RegistryReader
32
{
33
  static final String TAG_FACTORY = "factory";
34
  static final String ATT_URI = "uri";
35
  static final String ATT_CLASS = "class";
36
  
37
  public FactoryOverrideRegistryReader()
38
  {
39
    super
40
      (Platform.getExtensionRegistry(),
41
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
42
       EcorePlugin.FACTORY_OVERRIDE_PPID);
43
  }
44
45
  protected boolean readElement(IConfigurationElement element)
46
  {
47
    if (element.getName().equals(TAG_FACTORY))
48
    {
49
      String packageURI = element.getAttribute(ATT_URI);
50
      if (packageURI == null)
51
      {
52
        logMissingAttribute(element, ATT_URI);
53
      }
54
      else if (element.getAttribute(ATT_CLASS) == null)
55
      {
56
        logMissingAttribute(element, ATT_CLASS);
57
      }
58
      else
59
      {
60
        Object ePackageDescriptor = EPackage.Registry.INSTANCE.get(packageURI);
61
        if (ePackageDescriptor instanceof EPackage.Descriptor)
62
        {
63
          EPackage.Registry.INSTANCE.put(packageURI, new EFactoryDescriptor(element, ATT_CLASS, (EPackage.Descriptor)ePackageDescriptor));
64
          if (ePackageDescriptor instanceof EFactoryDescriptor)
65
          {
66
            EFactoryDescriptor descriptor = (EFactoryDescriptor)ePackageDescriptor;
67
            EcorePlugin.INSTANCE.log
68
              ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a factory override for '" + packageURI + "'");
69
          }
70
        }
71
        return true;
72
      }
73
    }
74
75
    return false;
76
  }
77
}
(-)src/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java (-74 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ProtocolParserRegistryReader.java,v 1.5 2006/05/25 19:17:08 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.Platform;
22
23
import org.eclipse.emf.ecore.resource.Resource;
24
25
26
/**
27
 * A plugin extension reader that populates the
28
 * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory's
29
 * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getProtocolToFactoryMap() protocol} map.
30
 * Clients are not expected to use this class directly.
31
 */
32
class ProtocolParserRegistryReader extends RegistryReader
33
{
34
  static final String TAG_PARSER = "parser";
35
  static final String ATT_PROTOCOLNAME = "protocolName";
36
  static final String ATT_CLASS = "class";
37
38
  public ProtocolParserRegistryReader()
39
  {
40
    super
41
      (Platform.getExtensionRegistry(),
42
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
43
       EcorePlugin.PROTOCOL_PARSER_PPID);
44
  }
45
46
  protected boolean readElement(IConfigurationElement element)
47
  {
48
    if (element.getName().equals(TAG_PARSER))
49
    {
50
      String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
51
      if (protocolName == null)
52
      {
53
        logMissingAttribute(element, ATT_PROTOCOLNAME);
54
      }
55
      else if (element.getAttribute(ATT_CLASS) == null)
56
      {
57
        logMissingAttribute(element, ATT_CLASS);
58
      }
59
      else
60
      {
61
        Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
62
        if (previous instanceof ResourceFactoryDescriptor)
63
        {
64
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
65
          EcorePlugin.INSTANCE.log
66
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
67
        }
68
        return true;
69
      }
70
    }
71
72
    return false;
73
  }
74
}
(-)src/org/eclipse/emf/ecore/plugin/RegistryReader.java (-229 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: RegistryReader.java,v 1.6 2006/02/22 22:28:56 marcelop Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import java.lang.reflect.Field;
21
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IConfigurationElement;
24
import org.eclipse.core.runtime.IExtension;
25
import org.eclipse.core.runtime.IExtensionPoint;
26
import org.eclipse.core.runtime.IExtensionRegistry;
27
import org.eclipse.core.runtime.Platform;
28
29
import org.eclipse.emf.common.util.WrappedException;
30
import org.eclipse.emf.ecore.EFactory;
31
import org.eclipse.emf.ecore.EPackage;
32
import org.eclipse.emf.ecore.resource.Resource;
33
34
35
public abstract class RegistryReader
36
{
37
  protected static final String TAG_DESCRIPTION = "description";
38
39
  protected IExtensionRegistry pluginRegistry;
40
  String pluginID;
41
  String extensionPointID;
42
43
  public RegistryReader(IExtensionRegistry pluginRegistry, String pluginID, String extensionPointID)
44
  {
45
    super();
46
    this.pluginRegistry = pluginRegistry;
47
    this.pluginID = pluginID;
48
    this.extensionPointID = extensionPointID;
49
  }
50
51
  /**
52
   * Implement this method to read element attributes. 
53
   * If this element has subelements, the reader will recursively cycle through them 
54
   * and will call this method, so don't do it here.
55
   */
56
  protected abstract boolean readElement(IConfigurationElement element);
57
58
  /**
59
   * Reads from the plugin registry and parses it.
60
   */
61
  public void readRegistry()
62
  {
63
    IExtensionPoint point = pluginRegistry.getExtensionPoint(pluginID, extensionPointID);
64
    if (point != null)
65
    {
66
      IConfigurationElement[] elements = point.getConfigurationElements();
67
      for (int i = 0; i < elements.length; i++)
68
      {
69
        internalReadElement(elements[i]);
70
      }
71
    }
72
  }
73
74
  private void internalReadElement(IConfigurationElement element)
75
  {
76
    boolean recognized = this.readElement(element);
77
    if (recognized)
78
    {
79
      IConfigurationElement[] children = element.getChildren();
80
      for (int i = 0; i < children.length; ++i)
81
      {
82
        internalReadElement(children[i]);
83
      }
84
    }
85
    else
86
    {
87
      logError(element, "Error processing extension: " + element);
88
    }
89
  }
90
91
  /**
92
   * Logs the error in the desktop log using the provided
93
   * text and the information in the configuration element.
94
   */
95
  protected void logError(IConfigurationElement element, String text)
96
  {
97
    IExtension extension = element.getDeclaringExtension();
98
    System.err.println("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier());
99
    System.err.println(text);
100
  }
101
102
  /**
103
   * Logs a very common registry error when a required attribute is missing.
104
   */
105
  protected void logMissingAttribute(IConfigurationElement element, String attributeName)
106
  {
107
    logError(element, "The required attribute '" + attributeName + "' not defined");
108
  }
109
110
  public static class PluginClassDescriptor 
111
  {
112
    protected IConfigurationElement element;
113
    protected String attributeName;
114
115
    public PluginClassDescriptor(IConfigurationElement element, String attributeName)
116
    {
117
      this.element = element;
118
      this.attributeName = attributeName;
119
    }
120
121
    public Object createInstance()
122
    {
123
      try
124
      {
125
        return element.createExecutableExtension(attributeName);
126
      }
127
      catch (CoreException e)
128
      {
129
        throw new WrappedException(e);
130
      }
131
    }
132
  }
133
134
  static class ResourceFactoryDescriptor extends PluginClassDescriptor implements Resource.Factory.Descriptor
135
  {
136
    protected Resource.Factory factoryInstance;
137
138
    public ResourceFactoryDescriptor(IConfigurationElement e, String attrName)
139
    {
140
      super(e, attrName);
141
    }
142
143
    public Resource.Factory createFactory()
144
    {
145
      if (factoryInstance == null)
146
      {
147
        factoryInstance = (Resource.Factory)createInstance();
148
      }
149
      return factoryInstance;
150
    }
151
  }
152
153
  static class EPackageDescriptor extends PluginClassDescriptor implements EPackage.Descriptor
154
  {
155
    public EPackageDescriptor(IConfigurationElement element, String attributeName)
156
    {
157
      super(element, attributeName);
158
    }
159
160
    public EPackage getEPackage()
161
    {
162
      // First try to see if this class has an eInstance 
163
      //
164
      try
165
      {
166
        Class javaClass = Platform.getBundle(element.getDeclaringExtension().getContributor().getName()).loadClass(element.getAttribute(attributeName));
167
        Field field = javaClass.getField("eINSTANCE");
168
        Object result = field.get(null);
169
        return (EPackage)result;
170
      }
171
      catch (ClassNotFoundException e)
172
      {
173
        throw new WrappedException(e);
174
      }
175
      catch (IllegalAccessException e)
176
      {
177
        throw new WrappedException(e);
178
      }
179
      catch (NoSuchFieldException e)
180
      {
181
        throw new WrappedException(e);
182
      }
183
    }
184
    
185
    public EFactory getEFactory()
186
    {
187
      return null;
188
    }
189
  }
190
  
191
  static class EFactoryDescriptor extends PluginClassDescriptor implements EPackage.Descriptor
192
  {
193
    protected EPackage.Descriptor overridenDescriptor;
194
    
195
    public EFactoryDescriptor(IConfigurationElement element, String attributeName, EPackage.Descriptor overridenDescriptor)
196
    {
197
      super(element, attributeName);
198
      this.overridenDescriptor = overridenDescriptor;
199
    }
200
201
    public EPackage getEPackage()
202
    {
203
      return overridenDescriptor.getEPackage();
204
    }
205
    
206
    public EFactory getEFactory()
207
    {
208
      // First try to see if this class has an eInstance 
209
      //
210
      try
211
      {
212
        Class javaClass = Platform.getBundle(element.getDeclaringExtension().getContributor().getName()).loadClass(element.getAttribute(attributeName));
213
        return (EFactory)javaClass.newInstance();
214
      }
215
      catch (ClassNotFoundException e)
216
      {
217
        throw new WrappedException(e);
218
      }
219
      catch (IllegalAccessException e)
220
      {
221
        throw new WrappedException(e);
222
      }
223
      catch (InstantiationException e)
224
      {
225
        throw new WrappedException(e);
226
      }
227
    }
228
  }
229
}
(-)src/org/eclipse/emf/ecore/plugin/URIMappingRegistryReader.java (-91 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: URIMappingRegistryReader.java,v 1.6 2006/05/25 19:17:08 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
20
import java.util.HashMap;
21
import java.util.Map;
22
23
import org.eclipse.core.runtime.IConfigurationElement;
24
import org.eclipse.core.runtime.Platform;
25
26
import org.eclipse.emf.common.util.URI;
27
import org.eclipse.emf.ecore.resource.URIConverter;
28
29
30
/**
31
 * A plugin extension reader that populates the
32
 * {@link org.eclipse.emf.ecore.resource.URIConverter#URI_MAP global} mapping registry.
33
 * Clients are not expected to use this class directly.
34
 */
35
class URIMappingRegistryReader extends RegistryReader 
36
{
37
  static final String TAG_MAPPING  = "mapping";
38
  static final String ATT_SOURCE   = "source";
39
  static final String ATT_TARGET   = "target";
40
   
41
  protected Map map = new HashMap();
42
43
  public URIMappingRegistryReader() 
44
  {
45
    super
46
      (Platform.getExtensionRegistry(),
47
       EcorePlugin.getPlugin().getBundle().getSymbolicName(),
48
       EcorePlugin.URI_MAPPING_PPID);
49
  }
50
51
  protected boolean readElement(IConfigurationElement element) 
52
  {
53
    if (element.getName().equals(TAG_MAPPING))
54
    {
55
      String sourceURIValue = element.getAttribute(ATT_SOURCE);
56
      if (sourceURIValue == null)
57
      {
58
        logMissingAttribute(element, ATT_SOURCE);
59
      }
60
      else
61
      {
62
        String targetURIValue = element.getAttribute(ATT_TARGET);
63
        if (targetURIValue == null)
64
        {
65
          logMissingAttribute(element, ATT_TARGET);
66
        }
67
        else
68
        {
69
          URI sourceURI = URI.createURI(sourceURIValue);
70
          URI targetURI = URI.createURI(targetURIValue);
71
          if (targetURI.isRelative() && targetURI.hasRelativePath())
72
          {
73
            targetURI = 
74
              targetURI.resolve
75
                (URI.createURI
76
                  (Platform.getBundle(element.getDeclaringExtension().getContributor().getName()).getEntry("/").toString()));
77
          }
78
          URIConverter.URI_MAP.put(sourceURI, targetURI);
79
          IConfigurationElement previous = (IConfigurationElement)map.put(sourceURI, element);
80
          if (previous != null)
81
          {
82
            EcorePlugin.INSTANCE.log
83
              ("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a URI mapping for '" + sourceURI + "'");
84
          }
85
          return true;
86
        }
87
      }
88
    }
89
    return false;
90
  }
91
}
(-)src/org/eclipse/emf/ecore/xml/type/util/XMLTypeUtil.java (-255 / +11 lines)
Lines 1-261 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypeUtil.java,v 1.8 2006/02/10 20:51:22 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.util;
1
package org.eclipse.emf.ecore.xml.type.util;
18
2
3
import org.eclipse.emf.ecore.EValidator.PatternMatcher;
19
4
20
import org.eclipse.emf.ecore.EValidator;
5
public class XMLTypeUtil {
21
import org.eclipse.emf.ecore.xml.type.internal.DataValue;
22
import org.eclipse.emf.ecore.xml.type.internal.QName;
23
import org.eclipse.emf.ecore.xml.type.internal.RegEx;
24
import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar;
25
import org.eclipse.emf.ecore.xml.type.internal.XMLDuration;
26
6
7
	public static String normalize(String value, boolean b) {
8
		// TODO Auto-generated method stub
9
		return null;
10
	}
11
12
	public static PatternMatcher createPatternMatcher(String next) {
13
		// TODO Auto-generated method stub
14
		return null;
15
	}
27
16
28
/**
29
 * This class contains convenient static methods for working with XML-related information.
30
 */
31
public final class XMLTypeUtil
32
{
33
  public static final int EQUALS = 0;
34
  public static final int LESS_THAN = -1;
35
  public static final int GREATER_THAN = 1;
36
  public static final int INDETERMINATE = 2;
37
38
  public static int compareCalendar(Object calendar1, Object calendar2)
39
  {
40
    return XMLCalendar.compare((XMLCalendar)calendar1, (XMLCalendar)calendar2);
41
  }
42
43
  public static int compareDuration(Object duration1, Object duration2)
44
  {
45
    return XMLDuration.compare((XMLDuration)duration1, (XMLDuration)duration2);
46
  }
47
48
  public static boolean isSpace(char value)
49
  {
50
    return DataValue.XMLChar.isSpace(value);
51
  }
52
53
  // TODO
54
  // This is faster than many charAt() calls.
55
  //
56
  private static class CharArrayThreadLocal extends ThreadLocal
57
  {
58
    private Thread cachedThread;
59
    private char [] cachedResult;
60
61
    public final char [] get(int capacity)
62
    {
63
      Thread currentThread = Thread.currentThread();
64
      char [] result = cachedResult;
65
      if (cachedThread != currentThread)
66
      {
67
        cachedThread = currentThread;
68
        result = (char [])get();
69
      }
70
      if (result.length < capacity)
71
      {
72
        result = new char [capacity];
73
        set(result);
74
      }
75
      return cachedResult = result;
76
    }
77
78
    protected Object initialValue()
79
    {
80
      return new char [20];
81
    }
82
  }
83
84
  private static final CharArrayThreadLocal VALUE = new CharArrayThreadLocal();
85
86
  public static String normalize(String value, boolean collapse) 
87
  {
88
    if (value == null)
89
    {
90
      return null;
91
    }
92
93
    int length = value.length();
94
    if (length == 0)
95
    {
96
      return "";
97
    }
98
99
    char [] valueArray = VALUE.get(length);
100
    value.getChars(0, length, valueArray, 0);
101
    StringBuffer buffer = null;
102
    boolean skipSpace = collapse;
103
    for (int i = 0, offset = 0; i < length; i++) 
104
    {
105
      char c = valueArray[i];
106
      if (isSpace(c)) 
107
      {
108
        if (skipSpace)
109
        {
110
          if (buffer == null)
111
          {
112
            buffer = new StringBuffer(value);
113
          }
114
          buffer.deleteCharAt(i - offset++);
115
        }
116
        else 
117
        {
118
          skipSpace = collapse;
119
          if (c != ' ')
120
          {
121
            if (buffer == null)
122
            {
123
              buffer = new StringBuffer(value);
124
            }
125
            buffer.setCharAt(i - offset, ' ');
126
          }
127
        }
128
      }
129
      else 
130
      {
131
        skipSpace = false;
132
      }
133
    }
134
135
    if (skipSpace) 
136
    {
137
      if (buffer == null)
138
      {
139
        return value.substring(0, length - 1);
140
      }
141
      else 
142
      {
143
        length = buffer.length();
144
        if (length > 0)
145
        {
146
          return buffer.substring(0, length - 1);
147
        }
148
        else
149
        {
150
          return "";
151
        }
152
      }
153
    }
154
    else
155
    {
156
      if (buffer == null)
157
      {
158
        return value;
159
      }
160
      else
161
      {
162
        return buffer.toString();
163
      }
164
    }
165
  }
166
167
  public static EValidator.PatternMatcher createPatternMatcher(String pattern)
168
  {
169
    return new PatternMatcherImpl(pattern);
170
  }
171
  
172
  
173
  /**
174
   * Creates a new QName object with the specified values
175
   * @param namespaceUri namespace uri value or null
176
   * @param localPart localPart (not null)
177
   * @param prefix prefix value or null
178
   * @return The newly created QName object
179
   */
180
  public static Object createQName(String namespaceUri, String localPart, String prefix)
181
  {
182
    return new QName(namespaceUri, localPart, prefix);
183
  }
184
  
185
  /**
186
   * Sets the QName object values to the specified onces
187
   * @param namespaceUri namespace uri value or null
188
   * @param localPart localPart (not null)
189
   * @param prefix prefix value or null
190
   */
191
  public static void setQNameValues(Object qname, String namespaceUri, String localPart, String prefix)
192
  {
193
      QName qn = (QName)qname;
194
      qn.setLocalPart(localPart);
195
      qn.setNamespaceURI(namespaceUri);
196
      qn.setPrefix(prefix);
197
  }
198
  
199
  /**
200
   * Returns the namespaceURI of a QName.
201
   */
202
  public static String getQNameNamespaceURI(Object qname)
203
  {
204
    return ((QName)qname).getNamespaceURI();
205
  }
206
  /**
207
   * Returns the localPart of a QName.
208
   */
209
  public static String getQNameLocalPart(Object qname)
210
  {
211
    return ((QName)qname).getLocalPart();
212
  }
213
  
214
  /**
215
   * Returns the prefix of a QName.
216
   */
217
  public static String getQNamePrefix(Object qname)
218
  {
219
    return ((QName)qname).getPrefix();
220
  }
221
222
  private static class PatternMatcherImpl implements EValidator.PatternMatcher
223
  {
224
    protected RegEx.RegularExpression regularExpression;
225
226
    public PatternMatcherImpl(String pattern)
227
    {
228
      regularExpression =  new RegEx.RegularExpression(pattern, "X");
229
    }
230
231
    public boolean matches(String value)
232
    {
233
      return regularExpression.matches(value);
234
    }
235
236
    public String toString()
237
    {
238
      return regularExpression.getPattern();
239
    }
240
  }
241
242
/*
243
  public static void main(String args[])
244
  {
245
    System.err.println("###YES");
246
    String x1 = normalize("  x  ", true);
247
    String x2 = normalize("  x  ", false);
248
    String x3 = normalize("  x  x  ", true);
249
    String x4 = normalize("  x  x  ", false);
250
    String x5 = normalize("  x  x ", true);
251
    String x6 = normalize("  x  x ", false);
252
    String x7 = normalize("  x  x", true);
253
    String x8 = normalize("  x  x", false);
254
    String x9 = normalize("  x \n x", true);
255
    String x10 = normalize("  x \n x", false);
256
    System.err.println(XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.eINSTANCE.getInt(), " 1 "));
257
    System.err.println(XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.eINSTANCE.getInt(), "  1 \n "));
258
    System.err.println("###YES");
259
  }
260
*/
261
}
17
}
(-)src/org/eclipse/emf/ecore/xml/type/util/XMLTypeValidator.java (-1372 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypeValidator.java,v 1.9 2005/11/23 18:10:02 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.util;
18
19
import java.math.BigDecimal;
20
import java.math.BigInteger;
21
22
import java.util.Iterator;
23
import java.util.List;
24
import java.util.Map;
25
26
import org.eclipse.emf.common.util.DiagnosticChain;
27
28
import org.eclipse.emf.ecore.EPackage;
29
30
import org.eclipse.emf.ecore.util.EObjectValidator;
31
32
import org.eclipse.emf.ecore.xml.type.*;
33
34
/**
35
 * <!-- begin-user-doc -->
36
 * The <b>Validator</b> for the model.
37
 * <!-- end-user-doc -->
38
 * @see org.eclipse.emf.ecore.xml.type.XMLTypePackage
39
 * @generated
40
 */
41
public class XMLTypeValidator extends EObjectValidator
42
{
43
  /**
44
   * The cached model package
45
   * <!-- begin-user-doc -->
46
   * <!-- end-user-doc -->
47
   * @generated
48
   */
49
  public static final XMLTypeValidator INSTANCE = new XMLTypeValidator();
50
51
  /**
52
   * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
53
   * <!-- begin-user-doc -->
54
   * <!-- end-user-doc -->
55
   * @see org.eclipse.emf.common.util.Diagnostic#getSource()
56
   * @see org.eclipse.emf.common.util.Diagnostic#getCode()
57
   * @generated
58
   */
59
  public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecore.xml.type";
60
61
  /**
62
   * A constant with a fixed name that can be used as the base value for additional hand written constants.
63
   * <!-- begin-user-doc -->
64
   * <!-- end-user-doc -->
65
   * @generated
66
   */
67
  private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;
68
69
  /**
70
   * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class.
71
   * <!-- begin-user-doc -->
72
   * <!-- end-user-doc -->
73
   * @generated
74
   */
75
  protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;
76
77
  /**
78
   * Creates an instance of the switch.
79
   * <!-- begin-user-doc -->
80
   * <!-- end-user-doc -->
81
   * @generated
82
   */
83
  public XMLTypeValidator()
84
  {
85
    super();
86
  }
87
88
  /**
89
   * Returns the package of this validator switch.
90
   * <!-- begin-user-doc -->
91
   * <!-- end-user-doc -->
92
   * @generated
93
   */
94
  protected EPackage getEPackage()
95
  {
96
    return XMLTypePackage.eINSTANCE;
97
  }
98
99
  /**
100
   * Calls <code>validateXXX</code> for the corresonding classifier of the model.
101
   * <!-- begin-user-doc -->
102
   * <!-- end-user-doc -->
103
   * @generated
104
   */
105
  protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map context)
106
  {
107
    switch (classifierID)
108
    {
109
      case XMLTypePackage.ANY_TYPE:
110
        return validateAnyType((AnyType)value, diagnostics, context);
111
      case XMLTypePackage.SIMPLE_ANY_TYPE:
112
        return validateSimpleAnyType((SimpleAnyType)value, diagnostics, context);
113
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT:
114
        return validateXMLTypeDocumentRoot((XMLTypeDocumentRoot)value, diagnostics, context);
115
      case XMLTypePackage.ANY_SIMPLE_TYPE:
116
        return validateAnySimpleType(value, diagnostics, context);
117
      case XMLTypePackage.ANY_URI:
118
        return validateAnyURI((String)value, diagnostics, context);
119
      case XMLTypePackage.BASE64_BINARY:
120
        return validateBase64Binary((byte[])value, diagnostics, context);
121
      case XMLTypePackage.BOOLEAN:
122
        return validateBoolean(((Boolean)value).booleanValue(), diagnostics, context);
123
      case XMLTypePackage.BOOLEAN_OBJECT:
124
        return validateBooleanObject((Boolean)value, diagnostics, context);
125
      case XMLTypePackage.BYTE:
126
        return validateByte(((Byte)value).byteValue(), diagnostics, context);
127
      case XMLTypePackage.BYTE_OBJECT:
128
        return validateByteObject((Byte)value, diagnostics, context);
129
      case XMLTypePackage.DATE:
130
        return validateDate(value, diagnostics, context);
131
      case XMLTypePackage.DATE_TIME:
132
        return validateDateTime(value, diagnostics, context);
133
      case XMLTypePackage.DECIMAL:
134
        return validateDecimal((BigDecimal)value, diagnostics, context);
135
      case XMLTypePackage.DOUBLE:
136
        return validateDouble(((Double)value).doubleValue(), diagnostics, context);
137
      case XMLTypePackage.DOUBLE_OBJECT:
138
        return validateDoubleObject((Double)value, diagnostics, context);
139
      case XMLTypePackage.DURATION:
140
        return validateDuration(value, diagnostics, context);
141
      case XMLTypePackage.ENTITIES:
142
        return validateENTITIES((List)value, diagnostics, context);
143
      case XMLTypePackage.ENTITIES_BASE:
144
        return validateENTITIESBase((List)value, diagnostics, context);
145
      case XMLTypePackage.ENTITY:
146
        return validateENTITY((String)value, diagnostics, context);
147
      case XMLTypePackage.FLOAT:
148
        return validateFloat(((Float)value).floatValue(), diagnostics, context);
149
      case XMLTypePackage.FLOAT_OBJECT:
150
        return validateFloatObject((Float)value, diagnostics, context);
151
      case XMLTypePackage.GDAY:
152
        return validateGDay(value, diagnostics, context);
153
      case XMLTypePackage.GMONTH:
154
        return validateGMonth(value, diagnostics, context);
155
      case XMLTypePackage.GMONTH_DAY:
156
        return validateGMonthDay(value, diagnostics, context);
157
      case XMLTypePackage.GYEAR:
158
        return validateGYear(value, diagnostics, context);
159
      case XMLTypePackage.GYEAR_MONTH:
160
        return validateGYearMonth(value, diagnostics, context);
161
      case XMLTypePackage.HEX_BINARY:
162
        return validateHexBinary((byte[])value, diagnostics, context);
163
      case XMLTypePackage.ID:
164
        return validateID((String)value, diagnostics, context);
165
      case XMLTypePackage.IDREF:
166
        return validateIDREF((String)value, diagnostics, context);
167
      case XMLTypePackage.IDREFS:
168
        return validateIDREFS((List)value, diagnostics, context);
169
      case XMLTypePackage.IDREFS_BASE:
170
        return validateIDREFSBase((List)value, diagnostics, context);
171
      case XMLTypePackage.INT:
172
        return validateInt(((Integer)value).intValue(), diagnostics, context);
173
      case XMLTypePackage.INTEGER:
174
        return validateInteger((BigInteger)value, diagnostics, context);
175
      case XMLTypePackage.INT_OBJECT:
176
        return validateIntObject((Integer)value, diagnostics, context);
177
      case XMLTypePackage.LANGUAGE:
178
        return validateLanguage((String)value, diagnostics, context);
179
      case XMLTypePackage.LONG:
180
        return validateLong(((Long)value).longValue(), diagnostics, context);
181
      case XMLTypePackage.LONG_OBJECT:
182
        return validateLongObject((Long)value, diagnostics, context);
183
      case XMLTypePackage.NAME:
184
        return validateName((String)value, diagnostics, context);
185
      case XMLTypePackage.NC_NAME:
186
        return validateNCName((String)value, diagnostics, context);
187
      case XMLTypePackage.NEGATIVE_INTEGER:
188
        return validateNegativeInteger((BigInteger)value, diagnostics, context);
189
      case XMLTypePackage.NMTOKEN:
190
        return validateNMTOKEN((String)value, diagnostics, context);
191
      case XMLTypePackage.NMTOKENS:
192
        return validateNMTOKENS((List)value, diagnostics, context);
193
      case XMLTypePackage.NMTOKENS_BASE:
194
        return validateNMTOKENSBase((List)value, diagnostics, context);
195
      case XMLTypePackage.NON_NEGATIVE_INTEGER:
196
        return validateNonNegativeInteger((BigInteger)value, diagnostics, context);
197
      case XMLTypePackage.NON_POSITIVE_INTEGER:
198
        return validateNonPositiveInteger((BigInteger)value, diagnostics, context);
199
      case XMLTypePackage.NORMALIZED_STRING:
200
        return validateNormalizedString((String)value, diagnostics, context);
201
      case XMLTypePackage.NOTATION:
202
        return validateNOTATION(value, diagnostics, context);
203
      case XMLTypePackage.POSITIVE_INTEGER:
204
        return validatePositiveInteger((BigInteger)value, diagnostics, context);
205
      case XMLTypePackage.QNAME:
206
        return validateQName(value, diagnostics, context);
207
      case XMLTypePackage.SHORT:
208
        return validateShort(((Short)value).shortValue(), diagnostics, context);
209
      case XMLTypePackage.SHORT_OBJECT:
210
        return validateShortObject((Short)value, diagnostics, context);
211
      case XMLTypePackage.STRING:
212
        return validateString((String)value, diagnostics, context);
213
      case XMLTypePackage.TIME:
214
        return validateTime(value, diagnostics, context);
215
      case XMLTypePackage.TOKEN:
216
        return validateToken((String)value, diagnostics, context);
217
      case XMLTypePackage.UNSIGNED_BYTE:
218
        return validateUnsignedByte(((Short)value).shortValue(), diagnostics, context);
219
      case XMLTypePackage.UNSIGNED_BYTE_OBJECT:
220
        return validateUnsignedByteObject((Short)value, diagnostics, context);
221
      case XMLTypePackage.UNSIGNED_INT:
222
        return validateUnsignedInt(((Long)value).longValue(), diagnostics, context);
223
      case XMLTypePackage.UNSIGNED_INT_OBJECT:
224
        return validateUnsignedIntObject((Long)value, diagnostics, context);
225
      case XMLTypePackage.UNSIGNED_LONG:
226
        return validateUnsignedLong((BigInteger)value, diagnostics, context);
227
      case XMLTypePackage.UNSIGNED_SHORT:
228
        return validateUnsignedShort(((Integer)value).intValue(), diagnostics, context);
229
      case XMLTypePackage.UNSIGNED_SHORT_OBJECT:
230
        return validateUnsignedShortObject((Integer)value, diagnostics, context);
231
      default: 
232
        return true;
233
    }
234
  }
235
236
  /**
237
   * <!-- begin-user-doc -->
238
   * <!-- end-user-doc -->
239
   * @generated
240
   */
241
  public boolean validateAnyType(AnyType anyType, DiagnosticChain diagnostics, Map context)
242
  {
243
    return validate_EveryDefaultConstraint(anyType, diagnostics, context);
244
  }
245
246
  /**
247
   * <!-- begin-user-doc -->
248
   * <!-- end-user-doc -->
249
   * @generated
250
   */
251
  public boolean validateSimpleAnyType(SimpleAnyType simpleAnyType, DiagnosticChain diagnostics, Map context)
252
  {
253
    return validate_EveryDefaultConstraint(simpleAnyType, diagnostics, context);
254
  }
255
256
  /**
257
   * <!-- begin-user-doc -->
258
   * <!-- end-user-doc -->
259
   * @generated
260
   */
261
  public boolean validateXMLTypeDocumentRoot(XMLTypeDocumentRoot xmlTypeDocumentRoot, DiagnosticChain diagnostics, Map context)
262
  {
263
    return validate_EveryDefaultConstraint(xmlTypeDocumentRoot, diagnostics, context);
264
  }
265
266
  /**
267
   * <!-- begin-user-doc -->
268
   * <!-- end-user-doc -->
269
   * @generated
270
   */
271
  public boolean validateAnySimpleType(Object anySimpleType, DiagnosticChain diagnostics, Map context)
272
  {
273
    return true;
274
  }
275
276
  /**
277
   * <!-- begin-user-doc -->
278
   * <!-- end-user-doc -->
279
   * @generated
280
   */
281
  public boolean validateAnyURI(String anyURI, DiagnosticChain diagnostics, Map context)
282
  {
283
    return true;
284
  }
285
286
  /**
287
   * <!-- begin-user-doc -->
288
   * <!-- end-user-doc -->
289
   * @generated
290
   */
291
  public boolean validateBase64Binary(byte[] base64Binary, DiagnosticChain diagnostics, Map context)
292
  {
293
    return true;
294
  }
295
296
  /**
297
   * <!-- begin-user-doc -->
298
   * <!-- end-user-doc -->
299
   * @generated
300
   */
301
  public boolean validateBoolean(boolean boolean_, DiagnosticChain diagnostics, Map context)
302
  {
303
    return true;
304
  }
305
306
  /**
307
   * <!-- begin-user-doc -->
308
   * <!-- end-user-doc -->
309
   * @generated
310
   */
311
  public boolean validateBooleanObject(Boolean booleanObject, DiagnosticChain diagnostics, Map context)
312
  {
313
    return true;
314
  }
315
316
  /**
317
   * <!-- begin-user-doc -->
318
   * <!-- end-user-doc -->
319
   * @generated
320
   */
321
  public boolean validateByte(byte byte_, DiagnosticChain diagnostics, Map context)
322
  {
323
    return true;
324
  }
325
326
  /**
327
   * <!-- begin-user-doc -->
328
   * <!-- end-user-doc -->
329
   * @generated
330
   */
331
  public boolean validateByteObject(Byte byteObject, DiagnosticChain diagnostics, Map context)
332
  {
333
    return true;
334
  }
335
336
  /**
337
   * <!-- begin-user-doc -->
338
   * <!-- end-user-doc -->
339
   * @generated
340
   */
341
  public boolean validateDate(Object date, DiagnosticChain diagnostics, Map context)
342
  {
343
    return true;
344
  }
345
346
  /**
347
   * <!-- begin-user-doc -->
348
   * <!-- end-user-doc -->
349
   * @generated
350
   */
351
  public boolean validateDateTime(Object dateTime, DiagnosticChain diagnostics, Map context)
352
  {
353
    return true;
354
  }
355
356
  /**
357
   * <!-- begin-user-doc -->
358
   * <!-- end-user-doc -->
359
   * @generated
360
   */
361
  public boolean validateDecimal(BigDecimal decimal, DiagnosticChain diagnostics, Map context)
362
  {
363
    return true;
364
  }
365
366
  /**
367
   * <!-- begin-user-doc -->
368
   * <!-- end-user-doc -->
369
   * @generated
370
   */
371
  public boolean validateDouble(double double_, DiagnosticChain diagnostics, Map context)
372
  {
373
    return true;
374
  }
375
376
  /**
377
   * <!-- begin-user-doc -->
378
   * <!-- end-user-doc -->
379
   * @generated
380
   */
381
  public boolean validateDoubleObject(Double doubleObject, DiagnosticChain diagnostics, Map context)
382
  {
383
    return true;
384
  }
385
386
  /**
387
   * <!-- begin-user-doc -->
388
   * <!-- end-user-doc -->
389
   * @generated
390
   */
391
  public boolean validateDuration(Object duration, DiagnosticChain diagnostics, Map context)
392
  {
393
    return true;
394
  }
395
396
  /**
397
   * <!-- begin-user-doc -->
398
   * <!-- end-user-doc -->
399
   * @generated
400
   */
401
  public boolean validateENTITIES(List entities, DiagnosticChain diagnostics, Map context)
402
  {
403
    boolean result = validateENTITIESBase_ItemType(entities, diagnostics, context);
404
    if (result || diagnostics != null) result &= validateENTITIES_MinLength(entities, diagnostics, context);
405
    return result;
406
  }
407
408
  /**
409
   * Validates the MinLength constraint of '<em>ENTITIES</em>'.
410
   * <!-- begin-user-doc -->
411
   * <!-- end-user-doc -->
412
   * @generated
413
   */
414
  public boolean validateENTITIES_MinLength(List entities, DiagnosticChain diagnostics, Map context)
415
  {
416
    int length = entities.size();  
417
    boolean result = length >= 1;
418
    if (!result && diagnostics != null) 
419
      reportMinLengthViolation(XMLTypePackage.Literals.ENTITIES, entities, length, 1, diagnostics, context);
420
    return result;
421
  }
422
423
  /**
424
   * <!-- begin-user-doc -->
425
   * <!-- end-user-doc -->
426
   * @generated
427
   */
428
  public boolean validateENTITIESBase(List entitiesBase, DiagnosticChain diagnostics, Map context)
429
  {
430
    boolean result = validateENTITIESBase_ItemType(entitiesBase, diagnostics, context);
431
    return result;
432
  }
433
434
  /**
435
   * Validates the ItemType constraint of '<em>ENTITIES Base</em>'.
436
   * <!-- begin-user-doc -->
437
   * <!-- end-user-doc -->
438
   * @generated
439
   */
440
  public boolean validateENTITIESBase_ItemType(List entitiesBase, DiagnosticChain diagnostics, Map context)
441
  {
442
    boolean result = true;
443
    for (Iterator i = entitiesBase.iterator(); i.hasNext() && (result || diagnostics != null); )
444
    {
445
      Object item = i.next();
446
      if (XMLTypePackage.Literals.ENTITY.isInstance(item))
447
      {
448
        result &= validateENTITY((String)item, diagnostics, context);
449
      }
450
      else
451
      {
452
        result = false;
453
        reportDataValueTypeViolation(XMLTypePackage.Literals.ENTITY, item, diagnostics, context);
454
      }
455
    }
456
    return result;
457
  }
458
459
  /**
460
   * <!-- begin-user-doc -->
461
   * <!-- end-user-doc -->
462
   * @generated
463
   */
464
  public boolean validateENTITY(String entity, DiagnosticChain diagnostics, Map context)
465
  {
466
    boolean result = validateNCName_Pattern(entity, diagnostics, context);
467
    return result;
468
  }
469
470
  /**
471
   * <!-- begin-user-doc -->
472
   * <!-- end-user-doc -->
473
   * @generated
474
   */
475
  public boolean validateFloat(float float_, DiagnosticChain diagnostics, Map context)
476
  {
477
    return true;
478
  }
479
480
  /**
481
   * <!-- begin-user-doc -->
482
   * <!-- end-user-doc -->
483
   * @generated
484
   */
485
  public boolean validateFloatObject(Float floatObject, DiagnosticChain diagnostics, Map context)
486
  {
487
    return true;
488
  }
489
490
  /**
491
   * <!-- begin-user-doc -->
492
   * <!-- end-user-doc -->
493
   * @generated
494
   */
495
  public boolean validateGDay(Object gDay, DiagnosticChain diagnostics, Map context)
496
  {
497
    return true;
498
  }
499
500
  /**
501
   * <!-- begin-user-doc -->
502
   * <!-- end-user-doc -->
503
   * @generated
504
   */
505
  public boolean validateGMonth(Object gMonth, DiagnosticChain diagnostics, Map context)
506
  {
507
    return true;
508
  }
509
510
  /**
511
   * <!-- begin-user-doc -->
512
   * <!-- end-user-doc -->
513
   * @generated
514
   */
515
  public boolean validateGMonthDay(Object gMonthDay, DiagnosticChain diagnostics, Map context)
516
  {
517
    return true;
518
  }
519
520
  /**
521
   * <!-- begin-user-doc -->
522
   * <!-- end-user-doc -->
523
   * @generated
524
   */
525
  public boolean validateGYear(Object gYear, DiagnosticChain diagnostics, Map context)
526
  {
527
    return true;
528
  }
529
530
  /**
531
   * <!-- begin-user-doc -->
532
   * <!-- end-user-doc -->
533
   * @generated
534
   */
535
  public boolean validateGYearMonth(Object gYearMonth, DiagnosticChain diagnostics, Map context)
536
  {
537
    return true;
538
  }
539
540
  /**
541
   * <!-- begin-user-doc -->
542
   * <!-- end-user-doc -->
543
   * @generated
544
   */
545
  public boolean validateHexBinary(byte[] hexBinary, DiagnosticChain diagnostics, Map context)
546
  {
547
    return true;
548
  }
549
550
  /**
551
   * <!-- begin-user-doc -->
552
   * <!-- end-user-doc -->
553
   * @generated
554
   */
555
  public boolean validateID(String id, DiagnosticChain diagnostics, Map context)
556
  {
557
    boolean result = validateNCName_Pattern(id, diagnostics, context);
558
    return result;
559
  }
560
561
  /**
562
   * <!-- begin-user-doc -->
563
   * <!-- end-user-doc -->
564
   * @generated
565
   */
566
  public boolean validateIDREF(String idref, DiagnosticChain diagnostics, Map context)
567
  {
568
    boolean result = validateNCName_Pattern(idref, diagnostics, context);
569
    return result;
570
  }
571
572
  /**
573
   * <!-- begin-user-doc -->
574
   * <!-- end-user-doc -->
575
   * @generated
576
   */
577
  public boolean validateIDREFS(List idrefs, DiagnosticChain diagnostics, Map context)
578
  {
579
    boolean result = validateIDREFSBase_ItemType(idrefs, diagnostics, context);
580
    if (result || diagnostics != null) result &= validateIDREFS_MinLength(idrefs, diagnostics, context);
581
    return result;
582
  }
583
584
  /**
585
   * Validates the MinLength constraint of '<em>IDREFS</em>'.
586
   * <!-- begin-user-doc -->
587
   * <!-- end-user-doc -->
588
   * @generated
589
   */
590
  public boolean validateIDREFS_MinLength(List idrefs, DiagnosticChain diagnostics, Map context)
591
  {
592
    int length = idrefs.size();  
593
    boolean result = length >= 1;
594
    if (!result && diagnostics != null) 
595
      reportMinLengthViolation(XMLTypePackage.Literals.IDREFS, idrefs, length, 1, diagnostics, context);
596
    return result;
597
  }
598
599
  /**
600
   * <!-- begin-user-doc -->
601
   * <!-- end-user-doc -->
602
   * @generated
603
   */
604
  public boolean validateIDREFSBase(List idrefsBase, DiagnosticChain diagnostics, Map context)
605
  {
606
    boolean result = validateIDREFSBase_ItemType(idrefsBase, diagnostics, context);
607
    return result;
608
  }
609
610
  /**
611
   * Validates the ItemType constraint of '<em>IDREFS Base</em>'.
612
   * <!-- begin-user-doc -->
613
   * <!-- end-user-doc -->
614
   * @generated
615
   */
616
  public boolean validateIDREFSBase_ItemType(List idrefsBase, DiagnosticChain diagnostics, Map context)
617
  {
618
    boolean result = true;
619
    for (Iterator i = idrefsBase.iterator(); i.hasNext() && (result || diagnostics != null); )
620
    {
621
      Object item = i.next();
622
      if (XMLTypePackage.Literals.IDREF.isInstance(item))
623
      {
624
        result &= validateIDREF((String)item, diagnostics, context);
625
      }
626
      else
627
      {
628
        result = false;
629
        reportDataValueTypeViolation(XMLTypePackage.Literals.IDREF, item, diagnostics, context);
630
      }
631
    }
632
    return result;
633
  }
634
635
  /**
636
   * <!-- begin-user-doc -->
637
   * <!-- end-user-doc -->
638
   * @generated
639
   */
640
  public boolean validateInt(int int_, DiagnosticChain diagnostics, Map context)
641
  {
642
    return true;
643
  }
644
645
  /**
646
   * <!-- begin-user-doc -->
647
   * <!-- end-user-doc -->
648
   * @generated
649
   */
650
  public boolean validateInteger(BigInteger integer, DiagnosticChain diagnostics, Map context)
651
  {
652
    return true;
653
  }
654
655
  /**
656
   * <!-- begin-user-doc -->
657
   * <!-- end-user-doc -->
658
   * @generated
659
   */
660
  public boolean validateIntObject(Integer intObject, DiagnosticChain diagnostics, Map context)
661
  {
662
    return true;
663
  }
664
665
  /**
666
   * <!-- begin-user-doc -->
667
   * <!-- end-user-doc -->
668
   * @generated
669
   */
670
  public boolean validateLanguage(String language, DiagnosticChain diagnostics, Map context)
671
  {
672
    boolean result = validateLanguage_Pattern(language, diagnostics, context);
673
    return result;
674
  }
675
676
  /**
677
   * <!-- begin-user-doc -->
678
   * <!-- end-user-doc -->
679
   * @generated
680
   * @see #validateLanguage_Pattern
681
   */
682
  public static final  PatternMatcher [][] LANGUAGE__PATTERN__VALUES =
683
    new PatternMatcher [][] 
684
    {
685
      new PatternMatcher [] 
686
      {
687
        XMLTypeUtil.createPatternMatcher("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*")
688
      }
689
    };
690
691
  /**
692
   * Validates the Pattern constraint of '<em>Language</em>'.
693
   * <!-- begin-user-doc -->
694
   * <!-- end-user-doc -->
695
   * @generated
696
   */
697
  public boolean validateLanguage_Pattern(String language, DiagnosticChain diagnostics, Map context)
698
  {
699
    return validatePattern(XMLTypePackage.Literals.LANGUAGE, language, LANGUAGE__PATTERN__VALUES, diagnostics, context);
700
  }
701
702
  /**
703
   * <!-- begin-user-doc -->
704
   * <!-- end-user-doc -->
705
   * @generated
706
   */
707
  public boolean validateLong(long long_, DiagnosticChain diagnostics, Map context)
708
  {
709
    return true;
710
  }
711
712
  /**
713
   * <!-- begin-user-doc -->
714
   * <!-- end-user-doc -->
715
   * @generated
716
   */
717
  public boolean validateLongObject(Long longObject, DiagnosticChain diagnostics, Map context)
718
  {
719
    return true;
720
  }
721
722
  /**
723
   * <!-- begin-user-doc -->
724
   * <!-- end-user-doc -->
725
   * @generated
726
   */
727
  public boolean validateName(String name, DiagnosticChain diagnostics, Map context)
728
  {
729
    boolean result = validateName_Pattern(name, diagnostics, context);
730
    return result;
731
  }
732
733
  /**
734
   * <!-- begin-user-doc -->
735
   * <!-- end-user-doc -->
736
   * @generated
737
   * @see #validateName_Pattern
738
   */
739
  public static final  PatternMatcher [][] NAME__PATTERN__VALUES =
740
    new PatternMatcher [][] 
741
    {
742
      new PatternMatcher [] 
743
      {
744
        XMLTypeUtil.createPatternMatcher("\\i\\c*")
745
      }
746
    };
747
748
  /**
749
   * Validates the Pattern constraint of '<em>Name</em>'.
750
   * <!-- begin-user-doc -->
751
   * <!-- end-user-doc -->
752
   * @generated
753
   */
754
  public boolean validateName_Pattern(String name, DiagnosticChain diagnostics, Map context)
755
  {
756
    return validatePattern(XMLTypePackage.Literals.NAME, name, NAME__PATTERN__VALUES, diagnostics, context);
757
  }
758
759
  /**
760
   * <!-- begin-user-doc -->
761
   * <!-- end-user-doc -->
762
   * @generated
763
   */
764
  public boolean validateNCName(String ncName, DiagnosticChain diagnostics, Map context)
765
  {
766
    boolean result = validateNCName_Pattern(ncName, diagnostics, context);
767
    return result;
768
  }
769
770
  /**
771
   * <!-- begin-user-doc -->
772
   * <!-- end-user-doc -->
773
   * @generated
774
   * @see #validateNCName_Pattern
775
   */
776
  public static final  PatternMatcher [][] NC_NAME__PATTERN__VALUES =
777
    new PatternMatcher [][] 
778
    {
779
      new PatternMatcher [] 
780
      {
781
        XMLTypeUtil.createPatternMatcher("[\\i-[:]][\\c-[:]]*")
782
      },
783
      new PatternMatcher [] 
784
      {
785
        XMLTypeUtil.createPatternMatcher("\\i\\c*")
786
      }
787
    };
788
789
  /**
790
   * Validates the Pattern constraint of '<em>NC Name</em>'.
791
   * <!-- begin-user-doc -->
792
   * <!-- end-user-doc -->
793
   * @generated
794
   */
795
  public boolean validateNCName_Pattern(String ncName, DiagnosticChain diagnostics, Map context)
796
  {
797
    return validatePattern(XMLTypePackage.Literals.NC_NAME, ncName, NC_NAME__PATTERN__VALUES, diagnostics, context);
798
  }
799
800
  /**
801
   * <!-- begin-user-doc -->
802
   * <!-- end-user-doc -->
803
   * @generated
804
   */
805
  public boolean validateNegativeInteger(BigInteger negativeInteger, DiagnosticChain diagnostics, Map context)
806
  {
807
    boolean result = validateNegativeInteger_Max(negativeInteger, diagnostics, context);
808
    return result;
809
  }
810
811
  /**
812
   * <!-- begin-user-doc -->
813
   * <!-- end-user-doc -->
814
   * @generated
815
   * @see #validateNegativeInteger_Max
816
   */
817
  public static final BigInteger NEGATIVE_INTEGER__MAX__VALUE = new BigInteger("-1");
818
819
  /**
820
   * Validates the Max constraint of '<em>Negative Integer</em>'.
821
   * <!-- begin-user-doc -->
822
   * <!-- end-user-doc -->
823
   * @generated
824
   */
825
  public boolean validateNegativeInteger_Max(BigInteger negativeInteger, DiagnosticChain diagnostics, Map context)
826
  {
827
    boolean result = negativeInteger.compareTo(NEGATIVE_INTEGER__MAX__VALUE) <= 0;
828
    if (!result && diagnostics != null) 
829
      reportMaxViolation(XMLTypePackage.Literals.NEGATIVE_INTEGER, negativeInteger, NEGATIVE_INTEGER__MAX__VALUE, true, diagnostics, context);
830
    return result; 
831
  }
832
833
  /**
834
   * <!-- begin-user-doc -->
835
   * <!-- end-user-doc -->
836
   * @generated
837
   */
838
  public boolean validateNMTOKEN(String nmtoken, DiagnosticChain diagnostics, Map context)
839
  {
840
    boolean result = validateNMTOKEN_Pattern(nmtoken, diagnostics, context);
841
    return result;
842
  }
843
844
  /**
845
   * <!-- begin-user-doc -->
846
   * <!-- end-user-doc -->
847
   * @generated
848
   * @see #validateNMTOKEN_Pattern
849
   */
850
  public static final  PatternMatcher [][] NMTOKEN__PATTERN__VALUES =
851
    new PatternMatcher [][] 
852
    {
853
      new PatternMatcher [] 
854
      {
855
        XMLTypeUtil.createPatternMatcher("\\c+")
856
      }
857
    };
858
859
  /**
860
   * Validates the Pattern constraint of '<em>NMTOKEN</em>'.
861
   * <!-- begin-user-doc -->
862
   * <!-- end-user-doc -->
863
   * @generated
864
   */
865
  public boolean validateNMTOKEN_Pattern(String nmtoken, DiagnosticChain diagnostics, Map context)
866
  {
867
    return validatePattern(XMLTypePackage.Literals.NMTOKEN, nmtoken, NMTOKEN__PATTERN__VALUES, diagnostics, context);
868
  }
869
870
  /**
871
   * <!-- begin-user-doc -->
872
   * <!-- end-user-doc -->
873
   * @generated
874
   */
875
  public boolean validateNMTOKENS(List nmtokens, DiagnosticChain diagnostics, Map context)
876
  {
877
    boolean result = validateNMTOKENSBase_ItemType(nmtokens, diagnostics, context);
878
    if (result || diagnostics != null) result &= validateNMTOKENS_MinLength(nmtokens, diagnostics, context);
879
    return result;
880
  }
881
882
  /**
883
   * Validates the MinLength constraint of '<em>NMTOKENS</em>'.
884
   * <!-- begin-user-doc -->
885
   * <!-- end-user-doc -->
886
   * @generated
887
   */
888
  public boolean validateNMTOKENS_MinLength(List nmtokens, DiagnosticChain diagnostics, Map context)
889
  {
890
    int length = nmtokens.size();  
891
    boolean result = length >= 1;
892
    if (!result && diagnostics != null) 
893
      reportMinLengthViolation(XMLTypePackage.Literals.NMTOKENS, nmtokens, length, 1, diagnostics, context);
894
    return result;
895
  }
896
897
  /**
898
   * <!-- begin-user-doc -->
899
   * <!-- end-user-doc -->
900
   * @generated
901
   */
902
  public boolean validateNMTOKENSBase(List nmtokensBase, DiagnosticChain diagnostics, Map context)
903
  {
904
    boolean result = validateNMTOKENSBase_ItemType(nmtokensBase, diagnostics, context);
905
    return result;
906
  }
907
908
  /**
909
   * Validates the ItemType constraint of '<em>NMTOKENS Base</em>'.
910
   * <!-- begin-user-doc -->
911
   * <!-- end-user-doc -->
912
   * @generated
913
   */
914
  public boolean validateNMTOKENSBase_ItemType(List nmtokensBase, DiagnosticChain diagnostics, Map context)
915
  {
916
    boolean result = true;
917
    for (Iterator i = nmtokensBase.iterator(); i.hasNext() && (result || diagnostics != null); )
918
    {
919
      Object item = i.next();
920
      if (XMLTypePackage.Literals.NMTOKEN.isInstance(item))
921
      {
922
        result &= validateNMTOKEN((String)item, diagnostics, context);
923
      }
924
      else
925
      {
926
        result = false;
927
        reportDataValueTypeViolation(XMLTypePackage.Literals.NMTOKEN, item, diagnostics, context);
928
      }
929
    }
930
    return result;
931
  }
932
933
  /**
934
   * <!-- begin-user-doc -->
935
   * <!-- end-user-doc -->
936
   * @generated
937
   */
938
  public boolean validateNonNegativeInteger(BigInteger nonNegativeInteger, DiagnosticChain diagnostics, Map context)
939
  {
940
    boolean result = validateNonNegativeInteger_Min(nonNegativeInteger, diagnostics, context);
941
    return result;
942
  }
943
944
  /**
945
   * <!-- begin-user-doc -->
946
   * <!-- end-user-doc -->
947
   * @generated
948
   * @see #validateNonNegativeInteger_Min
949
   */
950
  public static final BigInteger NON_NEGATIVE_INTEGER__MIN__VALUE = new BigInteger("0");
951
952
  /**
953
   * Validates the Min constraint of '<em>Non Negative Integer</em>'.
954
   * <!-- begin-user-doc -->
955
   * <!-- end-user-doc -->
956
   * @generated
957
   */
958
  public boolean validateNonNegativeInteger_Min(BigInteger nonNegativeInteger, DiagnosticChain diagnostics, Map context)
959
  {
960
    boolean result = nonNegativeInteger.compareTo(NON_NEGATIVE_INTEGER__MIN__VALUE) >= 0;
961
    if (!result && diagnostics != null) 
962
      reportMinViolation(XMLTypePackage.Literals.NON_NEGATIVE_INTEGER, nonNegativeInteger, NON_NEGATIVE_INTEGER__MIN__VALUE, true, diagnostics, context);
963
    return result; 
964
  }
965
966
  /**
967
   * <!-- begin-user-doc -->
968
   * <!-- end-user-doc -->
969
   * @generated
970
   */
971
  public boolean validateNonPositiveInteger(BigInteger nonPositiveInteger, DiagnosticChain diagnostics, Map context)
972
  {
973
    boolean result = validateNonPositiveInteger_Max(nonPositiveInteger, diagnostics, context);
974
    return result;
975
  }
976
977
  /**
978
   * <!-- begin-user-doc -->
979
   * <!-- end-user-doc -->
980
   * @generated
981
   * @see #validateNonPositiveInteger_Max
982
   */
983
  public static final BigInteger NON_POSITIVE_INTEGER__MAX__VALUE = new BigInteger("0");
984
985
  /**
986
   * Validates the Max constraint of '<em>Non Positive Integer</em>'.
987
   * <!-- begin-user-doc -->
988
   * <!-- end-user-doc -->
989
   * @generated
990
   */
991
  public boolean validateNonPositiveInteger_Max(BigInteger nonPositiveInteger, DiagnosticChain diagnostics, Map context)
992
  {
993
    boolean result = nonPositiveInteger.compareTo(NON_POSITIVE_INTEGER__MAX__VALUE) <= 0;
994
    if (!result && diagnostics != null) 
995
      reportMaxViolation(XMLTypePackage.Literals.NON_POSITIVE_INTEGER, nonPositiveInteger, NON_POSITIVE_INTEGER__MAX__VALUE, true, diagnostics, context);
996
    return result; 
997
  }
998
999
  /**
1000
   * <!-- begin-user-doc -->
1001
   * <!-- end-user-doc -->
1002
   * @generated
1003
   */
1004
  public boolean validateNormalizedString(String normalizedString, DiagnosticChain diagnostics, Map context)
1005
  {
1006
    return true;
1007
  }
1008
1009
  /**
1010
   * <!-- begin-user-doc -->
1011
   * <!-- end-user-doc -->
1012
   * @generated
1013
   */
1014
  public boolean validateNOTATION(Object notation, DiagnosticChain diagnostics, Map context)
1015
  {
1016
    return true;
1017
  }
1018
1019
  /**
1020
   * <!-- begin-user-doc -->
1021
   * <!-- end-user-doc -->
1022
   * @generated
1023
   */
1024
  public boolean validatePositiveInteger(BigInteger positiveInteger, DiagnosticChain diagnostics, Map context)
1025
  {
1026
    boolean result = validatePositiveInteger_Min(positiveInteger, diagnostics, context);
1027
    return result;
1028
  }
1029
1030
  /**
1031
   * <!-- begin-user-doc -->
1032
   * <!-- end-user-doc -->
1033
   * @generated
1034
   * @see #validatePositiveInteger_Min
1035
   */
1036
  public static final BigInteger POSITIVE_INTEGER__MIN__VALUE = new BigInteger("1");
1037
1038
  /**
1039
   * Validates the Min constraint of '<em>Positive Integer</em>'.
1040
   * <!-- begin-user-doc -->
1041
   * <!-- end-user-doc -->
1042
   * @generated
1043
   */
1044
  public boolean validatePositiveInteger_Min(BigInteger positiveInteger, DiagnosticChain diagnostics, Map context)
1045
  {
1046
    boolean result = positiveInteger.compareTo(POSITIVE_INTEGER__MIN__VALUE) >= 0;
1047
    if (!result && diagnostics != null) 
1048
      reportMinViolation(XMLTypePackage.Literals.POSITIVE_INTEGER, positiveInteger, POSITIVE_INTEGER__MIN__VALUE, true, diagnostics, context);
1049
    return result; 
1050
  }
1051
1052
  /**
1053
   * <!-- begin-user-doc -->
1054
   * <!-- end-user-doc -->
1055
   * @generated
1056
   */
1057
  public boolean validateQName(Object qName, DiagnosticChain diagnostics, Map context)
1058
  {
1059
    return true;
1060
  }
1061
1062
  /**
1063
   * <!-- begin-user-doc -->
1064
   * <!-- end-user-doc -->
1065
   * @generated
1066
   */
1067
  public boolean validateShort(short short_, DiagnosticChain diagnostics, Map context)
1068
  {
1069
    return true;
1070
  }
1071
1072
  /**
1073
   * <!-- begin-user-doc -->
1074
   * <!-- end-user-doc -->
1075
   * @generated
1076
   */
1077
  public boolean validateShortObject(Short shortObject, DiagnosticChain diagnostics, Map context)
1078
  {
1079
    return true;
1080
  }
1081
1082
  /**
1083
   * <!-- begin-user-doc -->
1084
   * <!-- end-user-doc -->
1085
   * @generated
1086
   */
1087
  public boolean validateString(String string, DiagnosticChain diagnostics, Map context)
1088
  {
1089
    return true;
1090
  }
1091
1092
  /**
1093
   * <!-- begin-user-doc -->
1094
   * <!-- end-user-doc -->
1095
   * @generated
1096
   */
1097
  public boolean validateTime(Object time, DiagnosticChain diagnostics, Map context)
1098
  {
1099
    return true;
1100
  }
1101
1102
  /**
1103
   * <!-- begin-user-doc -->
1104
   * <!-- end-user-doc -->
1105
   * @generated
1106
   */
1107
  public boolean validateToken(String token, DiagnosticChain diagnostics, Map context)
1108
  {
1109
    return true;
1110
  }
1111
1112
  /**
1113
   * <!-- begin-user-doc -->
1114
   * <!-- end-user-doc -->
1115
   * @generated
1116
   */
1117
  public boolean validateUnsignedByte(short unsignedByte, DiagnosticChain diagnostics, Map context)
1118
  {
1119
    boolean result = validateUnsignedByte_Min(unsignedByte, diagnostics, context);
1120
    if (result || diagnostics != null) result &= validateUnsignedByte_Max(unsignedByte, diagnostics, context);
1121
    return result;
1122
  }
1123
1124
  /**
1125
   * <!-- begin-user-doc -->
1126
   * <!-- end-user-doc -->
1127
   * @generated
1128
   * @see #validateUnsignedByte_Min
1129
   */
1130
  public static final short UNSIGNED_BYTE__MIN__VALUE = 0;
1131
1132
  /**
1133
   * Validates the Min constraint of '<em>Unsigned Byte</em>'.
1134
   * <!-- begin-user-doc -->
1135
   * <!-- end-user-doc -->
1136
   * @generated
1137
   */
1138
  public boolean validateUnsignedByte_Min(short unsignedByte, DiagnosticChain diagnostics, Map context)
1139
  {
1140
    boolean result = unsignedByte >= UNSIGNED_BYTE__MIN__VALUE;
1141
    if (!result && diagnostics != null) 
1142
      reportMinViolation(XMLTypePackage.Literals.UNSIGNED_BYTE, new Short(unsignedByte), new Short(UNSIGNED_BYTE__MIN__VALUE), true, diagnostics, context);
1143
    return result;
1144
  }
1145
1146
  /**
1147
   * <!-- begin-user-doc -->
1148
   * <!-- end-user-doc -->
1149
   * @generated
1150
   * @see #validateUnsignedByte_Max
1151
   */
1152
  public static final short UNSIGNED_BYTE__MAX__VALUE = 255;
1153
1154
  /**
1155
   * Validates the Max constraint of '<em>Unsigned Byte</em>'.
1156
   * <!-- begin-user-doc -->
1157
   * <!-- end-user-doc -->
1158
   * @generated
1159
   */
1160
  public boolean validateUnsignedByte_Max(short unsignedByte, DiagnosticChain diagnostics, Map context)
1161
  {
1162
    boolean result = unsignedByte <= UNSIGNED_BYTE__MAX__VALUE;
1163
    if (!result && diagnostics != null) 
1164
      reportMaxViolation(XMLTypePackage.Literals.UNSIGNED_BYTE, new Short(unsignedByte), new Short(UNSIGNED_BYTE__MAX__VALUE), true, diagnostics, context);
1165
    return result; 
1166
  }
1167
1168
  /**
1169
   * <!-- begin-user-doc -->
1170
   * <!-- end-user-doc -->
1171
   * @generated
1172
   */
1173
  public boolean validateUnsignedByteObject(Short unsignedByteObject, DiagnosticChain diagnostics, Map context)
1174
  {
1175
    boolean result = validateUnsignedByte_Min(unsignedByteObject.shortValue(), diagnostics, context);
1176
    if (result || diagnostics != null) result &= validateUnsignedByte_Max(unsignedByteObject.shortValue(), diagnostics, context);
1177
    return result;
1178
  }
1179
1180
  /**
1181
   * <!-- begin-user-doc -->
1182
   * <!-- end-user-doc -->
1183
   * @generated
1184
   */
1185
  public boolean validateUnsignedInt(long unsignedInt, DiagnosticChain diagnostics, Map context)
1186
  {
1187
    boolean result = validateUnsignedInt_Min(unsignedInt, diagnostics, context);
1188
    if (result || diagnostics != null) result &= validateUnsignedInt_Max(unsignedInt, diagnostics, context);
1189
    return result;
1190
  }
1191
1192
  /**
1193
   * <!-- begin-user-doc -->
1194
   * <!-- end-user-doc -->
1195
   * @generated
1196
   * @see #validateUnsignedInt_Min
1197
   */
1198
  public static final long UNSIGNED_INT__MIN__VALUE = 0L;
1199
1200
  /**
1201
   * Validates the Min constraint of '<em>Unsigned Int</em>'.
1202
   * <!-- begin-user-doc -->
1203
   * <!-- end-user-doc -->
1204
   * @generated
1205
   */
1206
  public boolean validateUnsignedInt_Min(long unsignedInt, DiagnosticChain diagnostics, Map context)
1207
  {
1208
    boolean result = unsignedInt >= UNSIGNED_INT__MIN__VALUE;
1209
    if (!result && diagnostics != null) 
1210
      reportMinViolation(XMLTypePackage.Literals.UNSIGNED_INT, new Long(unsignedInt), new Long(UNSIGNED_INT__MIN__VALUE), true, diagnostics, context);
1211
    return result;
1212
  }
1213
1214
  /**
1215
   * <!-- begin-user-doc -->
1216
   * <!-- end-user-doc -->
1217
   * @generated
1218
   * @see #validateUnsignedInt_Max
1219
   */
1220
  public static final long UNSIGNED_INT__MAX__VALUE = 4294967295L;
1221
1222
  /**
1223
   * Validates the Max constraint of '<em>Unsigned Int</em>'.
1224
   * <!-- begin-user-doc -->
1225
   * <!-- end-user-doc -->
1226
   * @generated
1227
   */
1228
  public boolean validateUnsignedInt_Max(long unsignedInt, DiagnosticChain diagnostics, Map context)
1229
  {
1230
    boolean result = unsignedInt <= UNSIGNED_INT__MAX__VALUE;
1231
    if (!result && diagnostics != null) 
1232
      reportMaxViolation(XMLTypePackage.Literals.UNSIGNED_INT, new Long(unsignedInt), new Long(UNSIGNED_INT__MAX__VALUE), true, diagnostics, context);
1233
    return result; 
1234
  }
1235
1236
  /**
1237
   * <!-- begin-user-doc -->
1238
   * <!-- end-user-doc -->
1239
   * @generated
1240
   */
1241
  public boolean validateUnsignedIntObject(Long unsignedIntObject, DiagnosticChain diagnostics, Map context)
1242
  {
1243
    boolean result = validateUnsignedInt_Min(unsignedIntObject.longValue(), diagnostics, context);
1244
    if (result || diagnostics != null) result &= validateUnsignedInt_Max(unsignedIntObject.longValue(), diagnostics, context);
1245
    return result;
1246
  }
1247
1248
  /**
1249
   * <!-- begin-user-doc -->
1250
   * <!-- end-user-doc -->
1251
   * @generated
1252
   */
1253
  public boolean validateUnsignedLong(BigInteger unsignedLong, DiagnosticChain diagnostics, Map context)
1254
  {
1255
    boolean result = validateUnsignedLong_Min(unsignedLong, diagnostics, context);
1256
    if (result || diagnostics != null) result &= validateUnsignedLong_Max(unsignedLong, diagnostics, context);
1257
    return result;
1258
  }
1259
1260
  /**
1261
   * <!-- begin-user-doc -->
1262
   * <!-- end-user-doc -->
1263
   * @generated
1264
   * @see #validateUnsignedLong_Min
1265
   */
1266
  public static final BigInteger UNSIGNED_LONG__MIN__VALUE = new BigInteger("0");
1267
1268
  /**
1269
   * Validates the Min constraint of '<em>Unsigned Long</em>'.
1270
   * <!-- begin-user-doc -->
1271
   * <!-- end-user-doc -->
1272
   * @generated
1273
   */
1274
  public boolean validateUnsignedLong_Min(BigInteger unsignedLong, DiagnosticChain diagnostics, Map context)
1275
  {
1276
    boolean result = unsignedLong.compareTo(UNSIGNED_LONG__MIN__VALUE) >= 0;
1277
    if (!result && diagnostics != null) 
1278
      reportMinViolation(XMLTypePackage.Literals.UNSIGNED_LONG, unsignedLong, UNSIGNED_LONG__MIN__VALUE, true, diagnostics, context);
1279
    return result; 
1280
  }
1281
1282
  /**
1283
   * <!-- begin-user-doc -->
1284
   * <!-- end-user-doc -->
1285
   * @generated
1286
   * @see #validateUnsignedLong_Max
1287
   */
1288
  public static final BigInteger UNSIGNED_LONG__MAX__VALUE = new BigInteger("18446744073709551615");
1289
1290
  /**
1291
   * Validates the Max constraint of '<em>Unsigned Long</em>'.
1292
   * <!-- begin-user-doc -->
1293
   * <!-- end-user-doc -->
1294
   * @generated
1295
   */
1296
  public boolean validateUnsignedLong_Max(BigInteger unsignedLong, DiagnosticChain diagnostics, Map context)
1297
  {
1298
    boolean result = unsignedLong.compareTo(UNSIGNED_LONG__MAX__VALUE) <= 0;
1299
    if (!result && diagnostics != null) 
1300
      reportMaxViolation(XMLTypePackage.Literals.UNSIGNED_LONG, unsignedLong, UNSIGNED_LONG__MAX__VALUE, true, diagnostics, context);
1301
    return result; 
1302
  }
1303
1304
  /**
1305
   * <!-- begin-user-doc -->
1306
   * <!-- end-user-doc -->
1307
   * @generated
1308
   */
1309
  public boolean validateUnsignedShort(int unsignedShort, DiagnosticChain diagnostics, Map context)
1310
  {
1311
    boolean result = validateUnsignedShort_Min(unsignedShort, diagnostics, context);
1312
    if (result || diagnostics != null) result &= validateUnsignedShort_Max(unsignedShort, diagnostics, context);
1313
    return result;
1314
  }
1315
1316
  /**
1317
   * <!-- begin-user-doc -->
1318
   * <!-- end-user-doc -->
1319
   * @generated
1320
   * @see #validateUnsignedShort_Min
1321
   */
1322
  public static final int UNSIGNED_SHORT__MIN__VALUE = 0;
1323
1324
  /**
1325
   * Validates the Min constraint of '<em>Unsigned Short</em>'.
1326
   * <!-- begin-user-doc -->
1327
   * <!-- end-user-doc -->
1328
   * @generated
1329
   */
1330
  public boolean validateUnsignedShort_Min(int unsignedShort, DiagnosticChain diagnostics, Map context)
1331
  {
1332
    boolean result = unsignedShort >= UNSIGNED_SHORT__MIN__VALUE;
1333
    if (!result && diagnostics != null) 
1334
      reportMinViolation(XMLTypePackage.Literals.UNSIGNED_SHORT, new Integer(unsignedShort), new Integer(UNSIGNED_SHORT__MIN__VALUE), true, diagnostics, context);
1335
    return result;
1336
  }
1337
1338
  /**
1339
   * <!-- begin-user-doc -->
1340
   * <!-- end-user-doc -->
1341
   * @generated
1342
   * @see #validateUnsignedShort_Max
1343
   */
1344
  public static final int UNSIGNED_SHORT__MAX__VALUE = 65535;
1345
1346
  /**
1347
   * Validates the Max constraint of '<em>Unsigned Short</em>'.
1348
   * <!-- begin-user-doc -->
1349
   * <!-- end-user-doc -->
1350
   * @generated
1351
   */
1352
  public boolean validateUnsignedShort_Max(int unsignedShort, DiagnosticChain diagnostics, Map context)
1353
  {
1354
    boolean result = unsignedShort <= UNSIGNED_SHORT__MAX__VALUE;
1355
    if (!result && diagnostics != null) 
1356
      reportMaxViolation(XMLTypePackage.Literals.UNSIGNED_SHORT, new Integer(unsignedShort), new Integer(UNSIGNED_SHORT__MAX__VALUE), true, diagnostics, context);
1357
    return result; 
1358
  }
1359
1360
  /**
1361
   * <!-- begin-user-doc -->
1362
   * <!-- end-user-doc -->
1363
   * @generated
1364
   */
1365
  public boolean validateUnsignedShortObject(Integer unsignedShortObject, DiagnosticChain diagnostics, Map context)
1366
  {
1367
    boolean result = validateUnsignedShort_Min(unsignedShortObject.intValue(), diagnostics, context);
1368
    if (result || diagnostics != null) result &= validateUnsignedShort_Max(unsignedShortObject.intValue(), diagnostics, context);
1369
    return result;
1370
  }
1371
1372
} //XMLTypeValidator
(-)src/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.java (-2455 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypeResourceImpl.java,v 1.2 2006/05/03 19:30:32 davidms Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.util;
18
19
import java.math.BigDecimal;
20
import java.math.BigInteger;
21
22
23
import java.util.List;
24
import org.eclipse.emf.common.util.URI;
25
26
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
27
28
import org.eclipse.emf.ecore.xml.type.AnyType;
29
import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
30
import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
31
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
32
// import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
33
34
import org.xml.sax.Attributes;
35
import org.xml.sax.SAXException;
36
import org.xml.sax.SAXParseException;
37
import org.xml.sax.helpers.DefaultHandler;
38
39
40
/**
41
 * <!-- begin-user-doc -->
42
 * The <b>Resource </b> associated with the package.
43
 * <!-- end-user-doc -->
44
 * @see org.eclipse.emf.ecore.xml.type.util.XMLTypeResourceFactoryImpl
45
 * @generated
46
 */
47
public class XMLTypeResourceImpl extends ResourceImpl
48
{
49
  /**
50
   * Creates an instance of the resource.
51
   * <!-- begin-user-doc -->
52
   * <!-- end-user-doc -->
53
   * @param uri the URI of the new resource.
54
   * @generated
55
   */
56
  public XMLTypeResourceImpl(URI uri)
57
  {
58
    super(uri);
59
  }
60
61
  /**
62
   * <!-- begin-user-doc -->
63
   * <!-- end-user-doc -->
64
   * @generated
65
   */
66
  public final static class FrameFactory {
67
    /**
68
     * <!-- begin-user-doc -->
69
     * <!-- end-user-doc -->
70
     * @generated
71
     */
72
    public static final FrameFactory INSTANCE = new FrameFactory();
73
  
74
    /**
75
     * <!-- begin-user-doc -->
76
     * <!-- end-user-doc -->
77
     * @generated
78
     */
79
    protected AnyTypeStackFrame anyType;
80
81
    /**
82
     * <!-- begin-user-doc -->
83
     * <!-- end-user-doc -->
84
     * @generated
85
     */
86
    protected SimpleAnyTypeStackFrame simpleAnyType;
87
88
    /**
89
     * <!-- begin-user-doc -->
90
     * <!-- end-user-doc -->
91
     * @generated
92
     */
93
    protected XMLTypeDocumentRootStackFrame xmlTypeDocumentRoot;
94
95
    /**
96
     * <!-- begin-user-doc -->
97
     * <!-- end-user-doc -->
98
     * @generated
99
     */
100
    protected XMLTypeResourceImpl.DataFrame anySimpleType;
101
102
    /**
103
     * <!-- begin-user-doc -->
104
     * <!-- end-user-doc -->
105
     * @generated
106
     */
107
    protected XMLTypeResourceImpl.DataFrame anyURI;
108
109
    /**
110
     * <!-- begin-user-doc -->
111
     * <!-- end-user-doc -->
112
     * @generated
113
     */
114
    protected XMLTypeResourceImpl.DataFrame base64Binary;
115
116
    /**
117
     * <!-- begin-user-doc -->
118
     * <!-- end-user-doc -->
119
     * @generated
120
     */
121
    protected XMLTypeResourceImpl.DataFrame boolean_;
122
123
    /**
124
     * <!-- begin-user-doc -->
125
     * <!-- end-user-doc -->
126
     * @generated
127
     */
128
    protected XMLTypeResourceImpl.DataFrame booleanObject;
129
130
    /**
131
     * <!-- begin-user-doc -->
132
     * <!-- end-user-doc -->
133
     * @generated
134
     */
135
    protected XMLTypeResourceImpl.DataFrame byte_;
136
137
    /**
138
     * <!-- begin-user-doc -->
139
     * <!-- end-user-doc -->
140
     * @generated
141
     */
142
    protected XMLTypeResourceImpl.DataFrame byteObject;
143
144
    /**
145
     * <!-- begin-user-doc -->
146
     * <!-- end-user-doc -->
147
     * @generated
148
     */
149
    protected XMLTypeResourceImpl.DataFrame date;
150
151
    /**
152
     * <!-- begin-user-doc -->
153
     * <!-- end-user-doc -->
154
     * @generated
155
     */
156
    protected XMLTypeResourceImpl.DataFrame dateTime;
157
158
    /**
159
     * <!-- begin-user-doc -->
160
     * <!-- end-user-doc -->
161
     * @generated
162
     */
163
    protected XMLTypeResourceImpl.DataFrame decimal;
164
165
    /**
166
     * <!-- begin-user-doc -->
167
     * <!-- end-user-doc -->
168
     * @generated
169
     */
170
    protected XMLTypeResourceImpl.DataFrame double_;
171
172
    /**
173
     * <!-- begin-user-doc -->
174
     * <!-- end-user-doc -->
175
     * @generated
176
     */
177
    protected XMLTypeResourceImpl.DataFrame doubleObject;
178
179
    /**
180
     * <!-- begin-user-doc -->
181
     * <!-- end-user-doc -->
182
     * @generated
183
     */
184
    protected XMLTypeResourceImpl.DataFrame duration;
185
186
    /**
187
     * <!-- begin-user-doc -->
188
     * <!-- end-user-doc -->
189
     * @generated
190
     */
191
    protected XMLTypeResourceImpl.DataFrame entities;
192
193
    /**
194
     * <!-- begin-user-doc -->
195
     * <!-- end-user-doc -->
196
     * @generated
197
     */
198
    protected XMLTypeResourceImpl.DataFrame entitiesBase;
199
200
    /**
201
     * <!-- begin-user-doc -->
202
     * <!-- end-user-doc -->
203
     * @generated
204
     */
205
    protected XMLTypeResourceImpl.DataFrame entity;
206
207
    /**
208
     * <!-- begin-user-doc -->
209
     * <!-- end-user-doc -->
210
     * @generated
211
     */
212
    protected XMLTypeResourceImpl.DataFrame float_;
213
214
    /**
215
     * <!-- begin-user-doc -->
216
     * <!-- end-user-doc -->
217
     * @generated
218
     */
219
    protected XMLTypeResourceImpl.DataFrame floatObject;
220
221
    /**
222
     * <!-- begin-user-doc -->
223
     * <!-- end-user-doc -->
224
     * @generated
225
     */
226
    protected XMLTypeResourceImpl.DataFrame gDay;
227
228
    /**
229
     * <!-- begin-user-doc -->
230
     * <!-- end-user-doc -->
231
     * @generated
232
     */
233
    protected XMLTypeResourceImpl.DataFrame gMonth;
234
235
    /**
236
     * <!-- begin-user-doc -->
237
     * <!-- end-user-doc -->
238
     * @generated
239
     */
240
    protected XMLTypeResourceImpl.DataFrame gMonthDay;
241
242
    /**
243
     * <!-- begin-user-doc -->
244
     * <!-- end-user-doc -->
245
     * @generated
246
     */
247
    protected XMLTypeResourceImpl.DataFrame gYear;
248
249
    /**
250
     * <!-- begin-user-doc -->
251
     * <!-- end-user-doc -->
252
     * @generated
253
     */
254
    protected XMLTypeResourceImpl.DataFrame gYearMonth;
255
256
    /**
257
     * <!-- begin-user-doc -->
258
     * <!-- end-user-doc -->
259
     * @generated
260
     */
261
    protected XMLTypeResourceImpl.DataFrame hexBinary;
262
263
    /**
264
     * <!-- begin-user-doc -->
265
     * <!-- end-user-doc -->
266
     * @generated
267
     */
268
    protected XMLTypeResourceImpl.DataFrame id;
269
270
    /**
271
     * <!-- begin-user-doc -->
272
     * <!-- end-user-doc -->
273
     * @generated
274
     */
275
    protected XMLTypeResourceImpl.DataFrame idref;
276
277
    /**
278
     * <!-- begin-user-doc -->
279
     * <!-- end-user-doc -->
280
     * @generated
281
     */
282
    protected XMLTypeResourceImpl.DataFrame idrefs;
283
284
    /**
285
     * <!-- begin-user-doc -->
286
     * <!-- end-user-doc -->
287
     * @generated
288
     */
289
    protected XMLTypeResourceImpl.DataFrame idrefsBase;
290
291
    /**
292
     * <!-- begin-user-doc -->
293
     * <!-- end-user-doc -->
294
     * @generated
295
     */
296
    protected XMLTypeResourceImpl.DataFrame int_;
297
298
    /**
299
     * <!-- begin-user-doc -->
300
     * <!-- end-user-doc -->
301
     * @generated
302
     */
303
    protected XMLTypeResourceImpl.DataFrame integer;
304
305
    /**
306
     * <!-- begin-user-doc -->
307
     * <!-- end-user-doc -->
308
     * @generated
309
     */
310
    protected XMLTypeResourceImpl.DataFrame intObject;
311
312
    /**
313
     * <!-- begin-user-doc -->
314
     * <!-- end-user-doc -->
315
     * @generated
316
     */
317
    protected XMLTypeResourceImpl.DataFrame language;
318
319
    /**
320
     * <!-- begin-user-doc -->
321
     * <!-- end-user-doc -->
322
     * @generated
323
     */
324
    protected XMLTypeResourceImpl.DataFrame long_;
325
326
    /**
327
     * <!-- begin-user-doc -->
328
     * <!-- end-user-doc -->
329
     * @generated
330
     */
331
    protected XMLTypeResourceImpl.DataFrame longObject;
332
333
    /**
334
     * <!-- begin-user-doc -->
335
     * <!-- end-user-doc -->
336
     * @generated
337
     */
338
    protected XMLTypeResourceImpl.DataFrame name;
339
340
    /**
341
     * <!-- begin-user-doc -->
342
     * <!-- end-user-doc -->
343
     * @generated
344
     */
345
    protected XMLTypeResourceImpl.DataFrame ncName;
346
347
    /**
348
     * <!-- begin-user-doc -->
349
     * <!-- end-user-doc -->
350
     * @generated
351
     */
352
    protected XMLTypeResourceImpl.DataFrame negativeInteger;
353
354
    /**
355
     * <!-- begin-user-doc -->
356
     * <!-- end-user-doc -->
357
     * @generated
358
     */
359
    protected XMLTypeResourceImpl.DataFrame nmtoken;
360
361
    /**
362
     * <!-- begin-user-doc -->
363
     * <!-- end-user-doc -->
364
     * @generated
365
     */
366
    protected XMLTypeResourceImpl.DataFrame nmtokens;
367
368
    /**
369
     * <!-- begin-user-doc -->
370
     * <!-- end-user-doc -->
371
     * @generated
372
     */
373
    protected XMLTypeResourceImpl.DataFrame nmtokensBase;
374
375
    /**
376
     * <!-- begin-user-doc -->
377
     * <!-- end-user-doc -->
378
     * @generated
379
     */
380
    protected XMLTypeResourceImpl.DataFrame nonNegativeInteger;
381
382
    /**
383
     * <!-- begin-user-doc -->
384
     * <!-- end-user-doc -->
385
     * @generated
386
     */
387
    protected XMLTypeResourceImpl.DataFrame nonPositiveInteger;
388
389
    /**
390
     * <!-- begin-user-doc -->
391
     * <!-- end-user-doc -->
392
     * @generated
393
     */
394
    protected XMLTypeResourceImpl.DataFrame normalizedString;
395
396
    /**
397
     * <!-- begin-user-doc -->
398
     * <!-- end-user-doc -->
399
     * @generated
400
     */
401
    protected XMLTypeResourceImpl.DataFrame notation;
402
403
    /**
404
     * <!-- begin-user-doc -->
405
     * <!-- end-user-doc -->
406
     * @generated
407
     */
408
    protected XMLTypeResourceImpl.DataFrame positiveInteger;
409
410
    /**
411
     * <!-- begin-user-doc -->
412
     * <!-- end-user-doc -->
413
     * @generated
414
     */
415
    protected XMLTypeResourceImpl.DataFrame qName;
416
417
    /**
418
     * <!-- begin-user-doc -->
419
     * <!-- end-user-doc -->
420
     * @generated
421
     */
422
    protected XMLTypeResourceImpl.DataFrame short_;
423
424
    /**
425
     * <!-- begin-user-doc -->
426
     * <!-- end-user-doc -->
427
     * @generated
428
     */
429
    protected XMLTypeResourceImpl.DataFrame shortObject;
430
431
    /**
432
     * <!-- begin-user-doc -->
433
     * <!-- end-user-doc -->
434
     * @generated
435
     */
436
    protected XMLTypeResourceImpl.DataFrame string;
437
438
    /**
439
     * <!-- begin-user-doc -->
440
     * <!-- end-user-doc -->
441
     * @generated
442
     */
443
    protected XMLTypeResourceImpl.DataFrame time;
444
445
    /**
446
     * <!-- begin-user-doc -->
447
     * <!-- end-user-doc -->
448
     * @generated
449
     */
450
    protected XMLTypeResourceImpl.DataFrame token;
451
452
    /**
453
     * <!-- begin-user-doc -->
454
     * <!-- end-user-doc -->
455
     * @generated
456
     */
457
    protected XMLTypeResourceImpl.DataFrame unsignedByte;
458
459
    /**
460
     * <!-- begin-user-doc -->
461
     * <!-- end-user-doc -->
462
     * @generated
463
     */
464
    protected XMLTypeResourceImpl.DataFrame unsignedByteObject;
465
466
    /**
467
     * <!-- begin-user-doc -->
468
     * <!-- end-user-doc -->
469
     * @generated
470
     */
471
    protected XMLTypeResourceImpl.DataFrame unsignedInt;
472
473
    /**
474
     * <!-- begin-user-doc -->
475
     * <!-- end-user-doc -->
476
     * @generated
477
     */
478
    protected XMLTypeResourceImpl.DataFrame unsignedIntObject;
479
480
    /**
481
     * <!-- begin-user-doc -->
482
     * <!-- end-user-doc -->
483
     * @generated
484
     */
485
    protected XMLTypeResourceImpl.DataFrame unsignedLong;
486
487
    /**
488
     * <!-- begin-user-doc -->
489
     * <!-- end-user-doc -->
490
     * @generated
491
     */
492
    protected XMLTypeResourceImpl.DataFrame unsignedShort;
493
494
    /**
495
     * <!-- begin-user-doc -->
496
     * <!-- end-user-doc -->
497
     * @generated
498
     */
499
    protected XMLTypeResourceImpl.DataFrame unsignedShortObject;
500
501
    /**
502
     * <!-- begin-user-doc -->
503
     * <!-- end-user-doc -->
504
     * @generated
505
     */
506
    public AnyTypeStackFrame pushAnyType(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
507
    {
508
       AnyTypeStackFrame resultAnyType = anyType == null ? new AnyTypeStackFrame() : anyType;
509
       anyType = null;
510
       resultAnyType.pushOnto(previous);
511
       resultAnyType.handleAttributes(attributes);
512
       return resultAnyType;
513
    }
514
515
    /**
516
     * <!-- begin-user-doc -->
517
     * <!-- end-user-doc -->
518
     * @generated
519
     */
520
    public AnyType popAnyType(AnyTypeStackFrame anyType)
521
    {
522
      AnyType resultAnyTypeValue = anyType.popAnyType();
523
      this.anyType = anyType;
524
      return resultAnyTypeValue;
525
    }
526
527
    /**
528
     * <!-- begin-user-doc -->
529
     * <!-- end-user-doc -->
530
     * @generated
531
     */
532
    public static class AnyTypeStackFrame extends XMLTypeResourceImpl.StackFrame
533
    {
534
      /**
535
       * <!-- begin-user-doc -->
536
       * <!-- end-user-doc -->
537
       * @generated
538
       */
539
      protected AnyType theAnyType;
540
    
541
      /**
542
       * <!-- begin-user-doc -->
543
       * <!-- end-user-doc -->
544
       * @generated
545
       */
546
      public void handleAttributes(Attributes attributes)
547
      {
548
      }
549
    
550
      /**
551
       * <!-- begin-user-doc -->
552
       * <!-- end-user-doc -->
553
       * @generated
554
       */
555
      public XMLTypeResourceImpl.StackFrame startElement(String namespace, String localName, String qName, Attributes attributes) throws SAXException
556
      {
557
        return super.startElement(namespace, localName, qName, attributes);
558
      }
559
560
      /**
561
       * <!-- begin-user-doc -->
562
       * <!-- end-user-doc -->
563
       * @generated
564
       */
565
      public void endElement(XMLTypeResourceImpl.StackFrame child) throws SAXException
566
      {
567
        super.endElement(child);
568
      }
569
570
      /**
571
       * <!-- begin-user-doc -->
572
       * <!-- end-user-doc -->
573
       * @generated
574
       */
575
      public void create()
576
      {
577
        theAnyType = XMLTypeFactory.eINSTANCE.createAnyType();
578
      }
579
    
580
      /**
581
       * <!-- begin-user-doc -->
582
       * <!-- end-user-doc -->
583
       * @generated
584
       */
585
      protected AnyType popAnyType()
586
      {
587
        pop();
588
        AnyType resultAnyTypeValue = theAnyType;
589
        theAnyType = null;
590
        return resultAnyTypeValue;
591
      }
592
    
593
    }
594
595
    /**
596
     * <!-- begin-user-doc -->
597
     * <!-- end-user-doc -->
598
     * @generated
599
     */
600
    public SimpleAnyTypeStackFrame pushSimpleAnyType(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
601
    {
602
       SimpleAnyTypeStackFrame resultSimpleAnyType = simpleAnyType == null ? new SimpleAnyTypeStackFrame() : simpleAnyType;
603
       simpleAnyType = null;
604
       resultSimpleAnyType.pushOnto(previous);
605
       resultSimpleAnyType.handleAttributes(attributes);
606
       return resultSimpleAnyType;
607
    }
608
609
    /**
610
     * <!-- begin-user-doc -->
611
     * <!-- end-user-doc -->
612
     * @generated
613
     */
614
    public SimpleAnyType popSimpleAnyType(SimpleAnyTypeStackFrame simpleAnyType)
615
    {
616
      SimpleAnyType resultSimpleAnyTypeValue = simpleAnyType.popSimpleAnyType();
617
      this.simpleAnyType = simpleAnyType;
618
      return resultSimpleAnyTypeValue;
619
    }
620
621
    /**
622
     * <!-- begin-user-doc -->
623
     * <!-- end-user-doc -->
624
     * @generated
625
     */
626
    public static class SimpleAnyTypeStackFrame extends XMLTypeResourceImpl.StackFrame
627
    {
628
      /**
629
       * <!-- begin-user-doc -->
630
       * <!-- end-user-doc -->
631
       * @generated
632
       */
633
      protected SimpleAnyType theSimpleAnyType;
634
    
635
      /**
636
       * <!-- begin-user-doc -->
637
       * <!-- end-user-doc -->
638
       * @generated
639
       */
640
      public void handleAttributes(Attributes attributes)
641
      {
642
      }
643
    
644
      /**
645
       * <!-- begin-user-doc -->
646
       * <!-- end-user-doc -->
647
       * @generated
648
       */
649
      public XMLTypeResourceImpl.StackFrame startElement(String namespace, String localName, String qName, Attributes attributes) throws SAXException
650
      {
651
        return super.startElement(namespace, localName, qName, attributes);
652
      }
653
654
      /**
655
       * <!-- begin-user-doc -->
656
       * <!-- end-user-doc -->
657
       * @generated
658
       */
659
      public void endElement(XMLTypeResourceImpl.StackFrame child) throws SAXException
660
      {
661
        super.endElement(child);
662
      }
663
664
      /**
665
       * <!-- begin-user-doc -->
666
       * <!-- end-user-doc -->
667
       * @generated
668
       */
669
      public void create()
670
      {
671
        theSimpleAnyType = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
672
      }
673
    
674
      /**
675
       * <!-- begin-user-doc -->
676
       * <!-- end-user-doc -->
677
       * @generated
678
       */
679
      protected SimpleAnyType popSimpleAnyType()
680
      {
681
        pop();
682
        SimpleAnyType resultSimpleAnyTypeValue = theSimpleAnyType;
683
        theSimpleAnyType = null;
684
        return resultSimpleAnyTypeValue;
685
      }
686
    
687
    }
688
689
    /**
690
     * <!-- begin-user-doc -->
691
     * <!-- end-user-doc -->
692
     * @generated
693
     */
694
    public XMLTypeDocumentRootStackFrame pushXMLTypeDocumentRoot(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
695
    {
696
       XMLTypeDocumentRootStackFrame resultXMLTypeDocumentRoot = xmlTypeDocumentRoot == null ? new XMLTypeDocumentRootStackFrame() : xmlTypeDocumentRoot;
697
       xmlTypeDocumentRoot = null;
698
       resultXMLTypeDocumentRoot.pushOnto(previous);
699
       resultXMLTypeDocumentRoot.handleAttributes(attributes);
700
       return resultXMLTypeDocumentRoot;
701
    }
702
703
    /**
704
     * <!-- begin-user-doc -->
705
     * <!-- end-user-doc -->
706
     * @generated
707
     */
708
    public XMLTypeDocumentRoot popXMLTypeDocumentRoot(XMLTypeDocumentRootStackFrame xmlTypeDocumentRoot)
709
    {
710
      XMLTypeDocumentRoot resultXMLTypeDocumentRootValue = xmlTypeDocumentRoot.popXMLTypeDocumentRoot();
711
      this.xmlTypeDocumentRoot = xmlTypeDocumentRoot;
712
      return resultXMLTypeDocumentRootValue;
713
    }
714
715
    /**
716
     * <!-- begin-user-doc -->
717
     * <!-- end-user-doc -->
718
     * @generated
719
     */
720
    public static class XMLTypeDocumentRootStackFrame extends XMLTypeResourceImpl.StackFrame
721
    {
722
      /**
723
       * <!-- begin-user-doc -->
724
       * <!-- end-user-doc -->
725
       * @generated
726
       */
727
      protected XMLTypeDocumentRoot theXMLTypeDocumentRoot;
728
    
729
      /**
730
       * <!-- begin-user-doc -->
731
       * <!-- end-user-doc -->
732
       * @generated
733
       */
734
      protected XMLTypeResourceImpl.DataFrame cDATA;
735
    
736
      /**
737
       * <!-- begin-user-doc -->
738
       * <!-- end-user-doc -->
739
       * @generated
740
       */
741
      protected XMLTypeResourceImpl.DataFrame comment;
742
    
743
      /**
744
       * <!-- begin-user-doc -->
745
       * <!-- end-user-doc -->
746
       * @generated
747
       */
748
      protected XMLTypeResourceImpl.DataFrame text;
749
    
750
      /**
751
       * <!-- begin-user-doc -->
752
       * <!-- end-user-doc -->
753
       * @generated
754
       */
755
      public void handleAttributes(Attributes attributes)
756
      {
757
      }
758
    
759
      /**
760
       * <!-- begin-user-doc -->
761
       * <!-- end-user-doc -->
762
       * @generated
763
       */
764
      public XMLTypeResourceImpl.StackFrame startElement(String namespace, String localName, String qName, Attributes attributes) throws SAXException
765
      {
766
        if ("cDATA".equals(localName) && "http://www.eclipse.org/emf/2003/XMLType".equals(namespace))
767
        {
768
          return cDATA = XMLTypeResourceImpl.FrameFactory.INSTANCE.pushString(this, attributes);
769
        }
770
        else if ("comment".equals(localName) && "http://www.eclipse.org/emf/2003/XMLType".equals(namespace))
771
        {
772
          return comment = XMLTypeResourceImpl.FrameFactory.INSTANCE.pushString(this, attributes);
773
        }
774
        else if ("text".equals(localName) && "http://www.eclipse.org/emf/2003/XMLType".equals(namespace))
775
        {
776
          return text = XMLTypeResourceImpl.FrameFactory.INSTANCE.pushString(this, attributes);
777
        }
778
        else
779
        {
780
          return super.startElement(namespace, localName, qName, attributes);
781
        }
782
      }
783
784
      /**
785
       * <!-- begin-user-doc -->
786
       * <!-- end-user-doc -->
787
       * @generated
788
       */
789
      public void endElement(XMLTypeResourceImpl.StackFrame child) throws SAXException
790
      {
791
        if (child == cDATA)
792
        {
793
          theXMLTypeDocumentRoot.setCDATA(XMLTypeResourceImpl.FrameFactory.INSTANCE.popString(cDATA));
794
          cDATA = null;
795
        }
796
        else if (child == comment)
797
        {
798
          theXMLTypeDocumentRoot.setComment(XMLTypeResourceImpl.FrameFactory.INSTANCE.popString(comment));
799
          comment = null;
800
        }
801
        else if (child == text)
802
        {
803
          theXMLTypeDocumentRoot.setText(XMLTypeResourceImpl.FrameFactory.INSTANCE.popString(text));
804
          text = null;
805
        }
806
        else
807
        {
808
          super.endElement(child);
809
        }
810
      }
811
812
      /**
813
       * <!-- begin-user-doc -->
814
       * <!-- end-user-doc -->
815
       * @generated
816
       */
817
      public void create()
818
      {
819
        theXMLTypeDocumentRoot = XMLTypeFactory.eINSTANCE.createXMLTypeDocumentRoot();
820
      }
821
    
822
      /**
823
       * <!-- begin-user-doc -->
824
       * <!-- end-user-doc -->
825
       * @generated
826
       */
827
      protected XMLTypeDocumentRoot popXMLTypeDocumentRoot()
828
      {
829
        pop();
830
        XMLTypeDocumentRoot resultXMLTypeDocumentRootValue = theXMLTypeDocumentRoot;
831
        theXMLTypeDocumentRoot = null;
832
        return resultXMLTypeDocumentRootValue;
833
      }
834
    
835
    }
836
837
    /**
838
     * <!-- begin-user-doc -->
839
     * <!-- end-user-doc -->
840
     * @generated
841
     */
842
    public XMLTypeResourceImpl.DataFrame pushAnySimpleType(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
843
    {
844
       XMLTypeResourceImpl.DataFrame resultAnySimpleType = anySimpleType == null ? new XMLTypeResourceImpl.DataFrame() : anySimpleType;
845
       anySimpleType = null;
846
       resultAnySimpleType.pushOnto(previous);
847
       resultAnySimpleType.handleAttributes(attributes);
848
       return resultAnySimpleType;
849
    }
850
851
    /**
852
     * <!-- begin-user-doc -->
853
     * <!-- end-user-doc -->
854
     * @generated
855
     */
856
    public Object popAnySimpleType(XMLTypeResourceImpl.DataFrame anySimpleType)
857
    {
858
      Object resultAnySimpleTypeValue = XMLTypeFactory.eINSTANCE.createAnySimpleType(anySimpleType.popValue());
859
      this.anySimpleType = anySimpleType;
860
      return resultAnySimpleTypeValue;
861
    }
862
863
    /**
864
     * <!-- begin-user-doc -->
865
     * <!-- end-user-doc -->
866
     * @generated
867
     */
868
    public XMLTypeResourceImpl.DataFrame pushAnyURI(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
869
    {
870
       XMLTypeResourceImpl.DataFrame resultAnyURI = anyURI == null ? new XMLTypeResourceImpl.DataFrame() : anyURI;
871
       anyURI = null;
872
       resultAnyURI.pushOnto(previous);
873
       resultAnyURI.handleAttributes(attributes);
874
       return resultAnyURI;
875
    }
876
877
    /**
878
     * <!-- begin-user-doc -->
879
     * <!-- end-user-doc -->
880
     * @generated
881
     */
882
    public String popAnyURI(XMLTypeResourceImpl.DataFrame anyURI)
883
    {
884
      String resultAnyURIValue = XMLTypeFactory.eINSTANCE.createAnyURI(anyURI.popValue());
885
      this.anyURI = anyURI;
886
      return resultAnyURIValue;
887
    }
888
889
    /**
890
     * <!-- begin-user-doc -->
891
     * <!-- end-user-doc -->
892
     * @generated
893
     */
894
    public XMLTypeResourceImpl.DataFrame pushBase64Binary(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
895
    {
896
       XMLTypeResourceImpl.DataFrame resultBase64Binary = base64Binary == null ? new XMLTypeResourceImpl.DataFrame() : base64Binary;
897
       base64Binary = null;
898
       resultBase64Binary.pushOnto(previous);
899
       resultBase64Binary.handleAttributes(attributes);
900
       return resultBase64Binary;
901
    }
902
903
    /**
904
     * <!-- begin-user-doc -->
905
     * <!-- end-user-doc -->
906
     * @generated
907
     */
908
    public byte[] popBase64Binary(XMLTypeResourceImpl.DataFrame base64Binary)
909
    {
910
      byte[] resultBase64BinaryValue = XMLTypeFactory.eINSTANCE.createBase64Binary(base64Binary.popValue());
911
      this.base64Binary = base64Binary;
912
      return resultBase64BinaryValue;
913
    }
914
915
    /**
916
     * <!-- begin-user-doc -->
917
     * <!-- end-user-doc -->
918
     * @generated
919
     */
920
    public XMLTypeResourceImpl.DataFrame pushBoolean(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
921
    {
922
       XMLTypeResourceImpl.DataFrame resultBoolean = boolean_ == null ? new XMLTypeResourceImpl.DataFrame() : boolean_;
923
       boolean_ = null;
924
       resultBoolean.pushOnto(previous);
925
       resultBoolean.handleAttributes(attributes);
926
       return resultBoolean;
927
    }
928
929
    /**
930
     * <!-- begin-user-doc -->
931
     * <!-- end-user-doc -->
932
     * @generated
933
     */
934
    public boolean popBoolean(XMLTypeResourceImpl.DataFrame boolean_)
935
    {
936
      boolean resultBooleanValue = XMLTypeFactory.eINSTANCE.createBoolean(boolean_.popValue());
937
      this.boolean_ = boolean_;
938
      return resultBooleanValue;
939
    }
940
941
    /**
942
     * <!-- begin-user-doc -->
943
     * <!-- end-user-doc -->
944
     * @generated
945
     */
946
    public XMLTypeResourceImpl.DataFrame pushBooleanObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
947
    {
948
       XMLTypeResourceImpl.DataFrame resultBooleanObject = booleanObject == null ? new XMLTypeResourceImpl.DataFrame() : booleanObject;
949
       booleanObject = null;
950
       resultBooleanObject.pushOnto(previous);
951
       resultBooleanObject.handleAttributes(attributes);
952
       return resultBooleanObject;
953
    }
954
955
    /**
956
     * <!-- begin-user-doc -->
957
     * <!-- end-user-doc -->
958
     * @generated
959
     */
960
    public Boolean popBooleanObject(XMLTypeResourceImpl.DataFrame booleanObject)
961
    {
962
      Boolean resultBooleanObjectValue = XMLTypeFactory.eINSTANCE.createBooleanObject(booleanObject.popValue());
963
      this.booleanObject = booleanObject;
964
      return resultBooleanObjectValue;
965
    }
966
967
    /**
968
     * <!-- begin-user-doc -->
969
     * <!-- end-user-doc -->
970
     * @generated
971
     */
972
    public XMLTypeResourceImpl.DataFrame pushByte(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
973
    {
974
       XMLTypeResourceImpl.DataFrame resultByte = byte_ == null ? new XMLTypeResourceImpl.DataFrame() : byte_;
975
       byte_ = null;
976
       resultByte.pushOnto(previous);
977
       resultByte.handleAttributes(attributes);
978
       return resultByte;
979
    }
980
981
    /**
982
     * <!-- begin-user-doc -->
983
     * <!-- end-user-doc -->
984
     * @generated
985
     */
986
    public byte popByte(XMLTypeResourceImpl.DataFrame byte_)
987
    {
988
      byte resultByteValue = XMLTypeFactory.eINSTANCE.createByte(byte_.popValue());
989
      this.byte_ = byte_;
990
      return resultByteValue;
991
    }
992
993
    /**
994
     * <!-- begin-user-doc -->
995
     * <!-- end-user-doc -->
996
     * @generated
997
     */
998
    public XMLTypeResourceImpl.DataFrame pushByteObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
999
    {
1000
       XMLTypeResourceImpl.DataFrame resultByteObject = byteObject == null ? new XMLTypeResourceImpl.DataFrame() : byteObject;
1001
       byteObject = null;
1002
       resultByteObject.pushOnto(previous);
1003
       resultByteObject.handleAttributes(attributes);
1004
       return resultByteObject;
1005
    }
1006
1007
    /**
1008
     * <!-- begin-user-doc -->
1009
     * <!-- end-user-doc -->
1010
     * @generated
1011
     */
1012
    public Byte popByteObject(XMLTypeResourceImpl.DataFrame byteObject)
1013
    {
1014
      Byte resultByteObjectValue = XMLTypeFactory.eINSTANCE.createByteObject(byteObject.popValue());
1015
      this.byteObject = byteObject;
1016
      return resultByteObjectValue;
1017
    }
1018
1019
    /**
1020
     * <!-- begin-user-doc -->
1021
     * <!-- end-user-doc -->
1022
     * @generated
1023
     */
1024
    public XMLTypeResourceImpl.DataFrame pushDate(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1025
    {
1026
       XMLTypeResourceImpl.DataFrame resultDate = date == null ? new XMLTypeResourceImpl.DataFrame() : date;
1027
       date = null;
1028
       resultDate.pushOnto(previous);
1029
       resultDate.handleAttributes(attributes);
1030
       return resultDate;
1031
    }
1032
1033
    /**
1034
     * <!-- begin-user-doc -->
1035
     * <!-- end-user-doc -->
1036
     * @generated
1037
     */
1038
    public Object popDate(XMLTypeResourceImpl.DataFrame date)
1039
    {
1040
      Object resultDateValue = XMLTypeFactory.eINSTANCE.createDate(date.popValue());
1041
      this.date = date;
1042
      return resultDateValue;
1043
    }
1044
1045
    /**
1046
     * <!-- begin-user-doc -->
1047
     * <!-- end-user-doc -->
1048
     * @generated
1049
     */
1050
    public XMLTypeResourceImpl.DataFrame pushDateTime(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1051
    {
1052
       XMLTypeResourceImpl.DataFrame resultDateTime = dateTime == null ? new XMLTypeResourceImpl.DataFrame() : dateTime;
1053
       dateTime = null;
1054
       resultDateTime.pushOnto(previous);
1055
       resultDateTime.handleAttributes(attributes);
1056
       return resultDateTime;
1057
    }
1058
1059
    /**
1060
     * <!-- begin-user-doc -->
1061
     * <!-- end-user-doc -->
1062
     * @generated
1063
     */
1064
    public Object popDateTime(XMLTypeResourceImpl.DataFrame dateTime)
1065
    {
1066
      Object resultDateTimeValue = XMLTypeFactory.eINSTANCE.createDateTime(dateTime.popValue());
1067
      this.dateTime = dateTime;
1068
      return resultDateTimeValue;
1069
    }
1070
1071
    /**
1072
     * <!-- begin-user-doc -->
1073
     * <!-- end-user-doc -->
1074
     * @generated
1075
     */
1076
    public XMLTypeResourceImpl.DataFrame pushDecimal(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1077
    {
1078
       XMLTypeResourceImpl.DataFrame resultDecimal = decimal == null ? new XMLTypeResourceImpl.DataFrame() : decimal;
1079
       decimal = null;
1080
       resultDecimal.pushOnto(previous);
1081
       resultDecimal.handleAttributes(attributes);
1082
       return resultDecimal;
1083
    }
1084
1085
    /**
1086
     * <!-- begin-user-doc -->
1087
     * <!-- end-user-doc -->
1088
     * @generated
1089
     */
1090
    public BigDecimal popDecimal(XMLTypeResourceImpl.DataFrame decimal)
1091
    {
1092
      BigDecimal resultDecimalValue = XMLTypeFactory.eINSTANCE.createDecimal(decimal.popValue());
1093
      this.decimal = decimal;
1094
      return resultDecimalValue;
1095
    }
1096
1097
    /**
1098
     * <!-- begin-user-doc -->
1099
     * <!-- end-user-doc -->
1100
     * @generated
1101
     */
1102
    public XMLTypeResourceImpl.DataFrame pushDouble(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1103
    {
1104
       XMLTypeResourceImpl.DataFrame resultDouble = double_ == null ? new XMLTypeResourceImpl.DataFrame() : double_;
1105
       double_ = null;
1106
       resultDouble.pushOnto(previous);
1107
       resultDouble.handleAttributes(attributes);
1108
       return resultDouble;
1109
    }
1110
1111
    /**
1112
     * <!-- begin-user-doc -->
1113
     * <!-- end-user-doc -->
1114
     * @generated
1115
     */
1116
    public double popDouble(XMLTypeResourceImpl.DataFrame double_)
1117
    {
1118
      double resultDoubleValue = XMLTypeFactory.eINSTANCE.createDouble(double_.popValue());
1119
      this.double_ = double_;
1120
      return resultDoubleValue;
1121
    }
1122
1123
    /**
1124
     * <!-- begin-user-doc -->
1125
     * <!-- end-user-doc -->
1126
     * @generated
1127
     */
1128
    public XMLTypeResourceImpl.DataFrame pushDoubleObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1129
    {
1130
       XMLTypeResourceImpl.DataFrame resultDoubleObject = doubleObject == null ? new XMLTypeResourceImpl.DataFrame() : doubleObject;
1131
       doubleObject = null;
1132
       resultDoubleObject.pushOnto(previous);
1133
       resultDoubleObject.handleAttributes(attributes);
1134
       return resultDoubleObject;
1135
    }
1136
1137
    /**
1138
     * <!-- begin-user-doc -->
1139
     * <!-- end-user-doc -->
1140
     * @generated
1141
     */
1142
    public Double popDoubleObject(XMLTypeResourceImpl.DataFrame doubleObject)
1143
    {
1144
      Double resultDoubleObjectValue = XMLTypeFactory.eINSTANCE.createDoubleObject(doubleObject.popValue());
1145
      this.doubleObject = doubleObject;
1146
      return resultDoubleObjectValue;
1147
    }
1148
1149
    /**
1150
     * <!-- begin-user-doc -->
1151
     * <!-- end-user-doc -->
1152
     * @generated
1153
     */
1154
    public XMLTypeResourceImpl.DataFrame pushDuration(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1155
    {
1156
       XMLTypeResourceImpl.DataFrame resultDuration = duration == null ? new XMLTypeResourceImpl.DataFrame() : duration;
1157
       duration = null;
1158
       resultDuration.pushOnto(previous);
1159
       resultDuration.handleAttributes(attributes);
1160
       return resultDuration;
1161
    }
1162
1163
    /**
1164
     * <!-- begin-user-doc -->
1165
     * <!-- end-user-doc -->
1166
     * @generated
1167
     */
1168
    public Object popDuration(XMLTypeResourceImpl.DataFrame duration)
1169
    {
1170
      Object resultDurationValue = XMLTypeFactory.eINSTANCE.createDuration(duration.popValue());
1171
      this.duration = duration;
1172
      return resultDurationValue;
1173
    }
1174
1175
    /**
1176
     * <!-- begin-user-doc -->
1177
     * <!-- end-user-doc -->
1178
     * @generated
1179
     */
1180
    public XMLTypeResourceImpl.DataFrame pushENTITIES(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1181
    {
1182
       XMLTypeResourceImpl.DataFrame resultENTITIES = entities == null ? new XMLTypeResourceImpl.DataFrame() : entities;
1183
       entities = null;
1184
       resultENTITIES.pushOnto(previous);
1185
       resultENTITIES.handleAttributes(attributes);
1186
       return resultENTITIES;
1187
    }
1188
1189
    /**
1190
     * <!-- begin-user-doc -->
1191
     * <!-- end-user-doc -->
1192
     * @generated
1193
     */
1194
    public List popENTITIES(XMLTypeResourceImpl.DataFrame entities)
1195
    {
1196
      List resultENTITIESValue = XMLTypeFactory.eINSTANCE.createENTITIES(entities.popValue());
1197
      this.entities = entities;
1198
      return resultENTITIESValue;
1199
    }
1200
1201
    /**
1202
     * <!-- begin-user-doc -->
1203
     * <!-- end-user-doc -->
1204
     * @generated
1205
     */
1206
    public XMLTypeResourceImpl.DataFrame pushENTITIESBase(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1207
    {
1208
       XMLTypeResourceImpl.DataFrame resultENTITIESBase = entitiesBase == null ? new XMLTypeResourceImpl.DataFrame() : entitiesBase;
1209
       entitiesBase = null;
1210
       resultENTITIESBase.pushOnto(previous);
1211
       resultENTITIESBase.handleAttributes(attributes);
1212
       return resultENTITIESBase;
1213
    }
1214
1215
    /**
1216
     * <!-- begin-user-doc -->
1217
     * <!-- end-user-doc -->
1218
     * @generated
1219
     */
1220
    public List popENTITIESBase(XMLTypeResourceImpl.DataFrame entitiesBase)
1221
    {
1222
      List resultENTITIESBaseValue = XMLTypeFactory.eINSTANCE.createENTITIESBase(entitiesBase.popValue());
1223
      this.entitiesBase = entitiesBase;
1224
      return resultENTITIESBaseValue;
1225
    }
1226
1227
    /**
1228
     * <!-- begin-user-doc -->
1229
     * <!-- end-user-doc -->
1230
     * @generated
1231
     */
1232
    public XMLTypeResourceImpl.DataFrame pushENTITY(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1233
    {
1234
       XMLTypeResourceImpl.DataFrame resultENTITY = entity == null ? new XMLTypeResourceImpl.DataFrame() : entity;
1235
       entity = null;
1236
       resultENTITY.pushOnto(previous);
1237
       resultENTITY.handleAttributes(attributes);
1238
       return resultENTITY;
1239
    }
1240
1241
    /**
1242
     * <!-- begin-user-doc -->
1243
     * <!-- end-user-doc -->
1244
     * @generated
1245
     */
1246
    public String popENTITY(XMLTypeResourceImpl.DataFrame entity)
1247
    {
1248
      String resultENTITYValue = XMLTypeFactory.eINSTANCE.createENTITY(entity.popValue());
1249
      this.entity = entity;
1250
      return resultENTITYValue;
1251
    }
1252
1253
    /**
1254
     * <!-- begin-user-doc -->
1255
     * <!-- end-user-doc -->
1256
     * @generated
1257
     */
1258
    public XMLTypeResourceImpl.DataFrame pushFloat(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1259
    {
1260
       XMLTypeResourceImpl.DataFrame resultFloat = float_ == null ? new XMLTypeResourceImpl.DataFrame() : float_;
1261
       float_ = null;
1262
       resultFloat.pushOnto(previous);
1263
       resultFloat.handleAttributes(attributes);
1264
       return resultFloat;
1265
    }
1266
1267
    /**
1268
     * <!-- begin-user-doc -->
1269
     * <!-- end-user-doc -->
1270
     * @generated
1271
     */
1272
    public float popFloat(XMLTypeResourceImpl.DataFrame float_)
1273
    {
1274
      float resultFloatValue = XMLTypeFactory.eINSTANCE.createFloat(float_.popValue());
1275
      this.float_ = float_;
1276
      return resultFloatValue;
1277
    }
1278
1279
    /**
1280
     * <!-- begin-user-doc -->
1281
     * <!-- end-user-doc -->
1282
     * @generated
1283
     */
1284
    public XMLTypeResourceImpl.DataFrame pushFloatObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1285
    {
1286
       XMLTypeResourceImpl.DataFrame resultFloatObject = floatObject == null ? new XMLTypeResourceImpl.DataFrame() : floatObject;
1287
       floatObject = null;
1288
       resultFloatObject.pushOnto(previous);
1289
       resultFloatObject.handleAttributes(attributes);
1290
       return resultFloatObject;
1291
    }
1292
1293
    /**
1294
     * <!-- begin-user-doc -->
1295
     * <!-- end-user-doc -->
1296
     * @generated
1297
     */
1298
    public Float popFloatObject(XMLTypeResourceImpl.DataFrame floatObject)
1299
    {
1300
      Float resultFloatObjectValue = XMLTypeFactory.eINSTANCE.createFloatObject(floatObject.popValue());
1301
      this.floatObject = floatObject;
1302
      return resultFloatObjectValue;
1303
    }
1304
1305
    /**
1306
     * <!-- begin-user-doc -->
1307
     * <!-- end-user-doc -->
1308
     * @generated
1309
     */
1310
    public XMLTypeResourceImpl.DataFrame pushGDay(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1311
    {
1312
       XMLTypeResourceImpl.DataFrame resultGDay = gDay == null ? new XMLTypeResourceImpl.DataFrame() : gDay;
1313
       gDay = null;
1314
       resultGDay.pushOnto(previous);
1315
       resultGDay.handleAttributes(attributes);
1316
       return resultGDay;
1317
    }
1318
1319
    /**
1320
     * <!-- begin-user-doc -->
1321
     * <!-- end-user-doc -->
1322
     * @generated
1323
     */
1324
    public Object popGDay(XMLTypeResourceImpl.DataFrame gDay)
1325
    {
1326
      Object resultGDayValue = XMLTypeFactory.eINSTANCE.createGDay(gDay.popValue());
1327
      this.gDay = gDay;
1328
      return resultGDayValue;
1329
    }
1330
1331
    /**
1332
     * <!-- begin-user-doc -->
1333
     * <!-- end-user-doc -->
1334
     * @generated
1335
     */
1336
    public XMLTypeResourceImpl.DataFrame pushGMonth(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1337
    {
1338
       XMLTypeResourceImpl.DataFrame resultGMonth = gMonth == null ? new XMLTypeResourceImpl.DataFrame() : gMonth;
1339
       gMonth = null;
1340
       resultGMonth.pushOnto(previous);
1341
       resultGMonth.handleAttributes(attributes);
1342
       return resultGMonth;
1343
    }
1344
1345
    /**
1346
     * <!-- begin-user-doc -->
1347
     * <!-- end-user-doc -->
1348
     * @generated
1349
     */
1350
    public Object popGMonth(XMLTypeResourceImpl.DataFrame gMonth)
1351
    {
1352
      Object resultGMonthValue = XMLTypeFactory.eINSTANCE.createGMonth(gMonth.popValue());
1353
      this.gMonth = gMonth;
1354
      return resultGMonthValue;
1355
    }
1356
1357
    /**
1358
     * <!-- begin-user-doc -->
1359
     * <!-- end-user-doc -->
1360
     * @generated
1361
     */
1362
    public XMLTypeResourceImpl.DataFrame pushGMonthDay(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1363
    {
1364
       XMLTypeResourceImpl.DataFrame resultGMonthDay = gMonthDay == null ? new XMLTypeResourceImpl.DataFrame() : gMonthDay;
1365
       gMonthDay = null;
1366
       resultGMonthDay.pushOnto(previous);
1367
       resultGMonthDay.handleAttributes(attributes);
1368
       return resultGMonthDay;
1369
    }
1370
1371
    /**
1372
     * <!-- begin-user-doc -->
1373
     * <!-- end-user-doc -->
1374
     * @generated
1375
     */
1376
    public Object popGMonthDay(XMLTypeResourceImpl.DataFrame gMonthDay)
1377
    {
1378
      Object resultGMonthDayValue = XMLTypeFactory.eINSTANCE.createGMonthDay(gMonthDay.popValue());
1379
      this.gMonthDay = gMonthDay;
1380
      return resultGMonthDayValue;
1381
    }
1382
1383
    /**
1384
     * <!-- begin-user-doc -->
1385
     * <!-- end-user-doc -->
1386
     * @generated
1387
     */
1388
    public XMLTypeResourceImpl.DataFrame pushGYear(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1389
    {
1390
       XMLTypeResourceImpl.DataFrame resultGYear = gYear == null ? new XMLTypeResourceImpl.DataFrame() : gYear;
1391
       gYear = null;
1392
       resultGYear.pushOnto(previous);
1393
       resultGYear.handleAttributes(attributes);
1394
       return resultGYear;
1395
    }
1396
1397
    /**
1398
     * <!-- begin-user-doc -->
1399
     * <!-- end-user-doc -->
1400
     * @generated
1401
     */
1402
    public Object popGYear(XMLTypeResourceImpl.DataFrame gYear)
1403
    {
1404
      Object resultGYearValue = XMLTypeFactory.eINSTANCE.createGYear(gYear.popValue());
1405
      this.gYear = gYear;
1406
      return resultGYearValue;
1407
    }
1408
1409
    /**
1410
     * <!-- begin-user-doc -->
1411
     * <!-- end-user-doc -->
1412
     * @generated
1413
     */
1414
    public XMLTypeResourceImpl.DataFrame pushGYearMonth(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1415
    {
1416
       XMLTypeResourceImpl.DataFrame resultGYearMonth = gYearMonth == null ? new XMLTypeResourceImpl.DataFrame() : gYearMonth;
1417
       gYearMonth = null;
1418
       resultGYearMonth.pushOnto(previous);
1419
       resultGYearMonth.handleAttributes(attributes);
1420
       return resultGYearMonth;
1421
    }
1422
1423
    /**
1424
     * <!-- begin-user-doc -->
1425
     * <!-- end-user-doc -->
1426
     * @generated
1427
     */
1428
    public Object popGYearMonth(XMLTypeResourceImpl.DataFrame gYearMonth)
1429
    {
1430
      Object resultGYearMonthValue = XMLTypeFactory.eINSTANCE.createGYearMonth(gYearMonth.popValue());
1431
      this.gYearMonth = gYearMonth;
1432
      return resultGYearMonthValue;
1433
    }
1434
1435
    /**
1436
     * <!-- begin-user-doc -->
1437
     * <!-- end-user-doc -->
1438
     * @generated
1439
     */
1440
    public XMLTypeResourceImpl.DataFrame pushHexBinary(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1441
    {
1442
       XMLTypeResourceImpl.DataFrame resultHexBinary = hexBinary == null ? new XMLTypeResourceImpl.DataFrame() : hexBinary;
1443
       hexBinary = null;
1444
       resultHexBinary.pushOnto(previous);
1445
       resultHexBinary.handleAttributes(attributes);
1446
       return resultHexBinary;
1447
    }
1448
1449
    /**
1450
     * <!-- begin-user-doc -->
1451
     * <!-- end-user-doc -->
1452
     * @generated
1453
     */
1454
    public byte[] popHexBinary(XMLTypeResourceImpl.DataFrame hexBinary)
1455
    {
1456
      byte[] resultHexBinaryValue = XMLTypeFactory.eINSTANCE.createHexBinary(hexBinary.popValue());
1457
      this.hexBinary = hexBinary;
1458
      return resultHexBinaryValue;
1459
    }
1460
1461
    /**
1462
     * <!-- begin-user-doc -->
1463
     * <!-- end-user-doc -->
1464
     * @generated
1465
     */
1466
    public XMLTypeResourceImpl.DataFrame pushID(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1467
    {
1468
       XMLTypeResourceImpl.DataFrame resultID = id == null ? new XMLTypeResourceImpl.DataFrame() : id;
1469
       id = null;
1470
       resultID.pushOnto(previous);
1471
       resultID.handleAttributes(attributes);
1472
       return resultID;
1473
    }
1474
1475
    /**
1476
     * <!-- begin-user-doc -->
1477
     * <!-- end-user-doc -->
1478
     * @generated
1479
     */
1480
    public String popID(XMLTypeResourceImpl.DataFrame id)
1481
    {
1482
      String resultIDValue = XMLTypeFactory.eINSTANCE.createID(id.popValue());
1483
      this.id = id;
1484
      return resultIDValue;
1485
    }
1486
1487
    /**
1488
     * <!-- begin-user-doc -->
1489
     * <!-- end-user-doc -->
1490
     * @generated
1491
     */
1492
    public XMLTypeResourceImpl.DataFrame pushIDREF(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1493
    {
1494
       XMLTypeResourceImpl.DataFrame resultIDREF = idref == null ? new XMLTypeResourceImpl.DataFrame() : idref;
1495
       idref = null;
1496
       resultIDREF.pushOnto(previous);
1497
       resultIDREF.handleAttributes(attributes);
1498
       return resultIDREF;
1499
    }
1500
1501
    /**
1502
     * <!-- begin-user-doc -->
1503
     * <!-- end-user-doc -->
1504
     * @generated
1505
     */
1506
    public String popIDREF(XMLTypeResourceImpl.DataFrame idref)
1507
    {
1508
      String resultIDREFValue = XMLTypeFactory.eINSTANCE.createIDREF(idref.popValue());
1509
      this.idref = idref;
1510
      return resultIDREFValue;
1511
    }
1512
1513
    /**
1514
     * <!-- begin-user-doc -->
1515
     * <!-- end-user-doc -->
1516
     * @generated
1517
     */
1518
    public XMLTypeResourceImpl.DataFrame pushIDREFS(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1519
    {
1520
       XMLTypeResourceImpl.DataFrame resultIDREFS = idrefs == null ? new XMLTypeResourceImpl.DataFrame() : idrefs;
1521
       idrefs = null;
1522
       resultIDREFS.pushOnto(previous);
1523
       resultIDREFS.handleAttributes(attributes);
1524
       return resultIDREFS;
1525
    }
1526
1527
    /**
1528
     * <!-- begin-user-doc -->
1529
     * <!-- end-user-doc -->
1530
     * @generated
1531
     */
1532
    public List popIDREFS(XMLTypeResourceImpl.DataFrame idrefs)
1533
    {
1534
      List resultIDREFSValue = XMLTypeFactory.eINSTANCE.createIDREFS(idrefs.popValue());
1535
      this.idrefs = idrefs;
1536
      return resultIDREFSValue;
1537
    }
1538
1539
    /**
1540
     * <!-- begin-user-doc -->
1541
     * <!-- end-user-doc -->
1542
     * @generated
1543
     */
1544
    public XMLTypeResourceImpl.DataFrame pushIDREFSBase(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1545
    {
1546
       XMLTypeResourceImpl.DataFrame resultIDREFSBase = idrefsBase == null ? new XMLTypeResourceImpl.DataFrame() : idrefsBase;
1547
       idrefsBase = null;
1548
       resultIDREFSBase.pushOnto(previous);
1549
       resultIDREFSBase.handleAttributes(attributes);
1550
       return resultIDREFSBase;
1551
    }
1552
1553
    /**
1554
     * <!-- begin-user-doc -->
1555
     * <!-- end-user-doc -->
1556
     * @generated
1557
     */
1558
    public List popIDREFSBase(XMLTypeResourceImpl.DataFrame idrefsBase)
1559
    {
1560
      List resultIDREFSBaseValue = XMLTypeFactory.eINSTANCE.createIDREFSBase(idrefsBase.popValue());
1561
      this.idrefsBase = idrefsBase;
1562
      return resultIDREFSBaseValue;
1563
    }
1564
1565
    /**
1566
     * <!-- begin-user-doc -->
1567
     * <!-- end-user-doc -->
1568
     * @generated
1569
     */
1570
    public XMLTypeResourceImpl.DataFrame pushInt(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1571
    {
1572
       XMLTypeResourceImpl.DataFrame resultInt = int_ == null ? new XMLTypeResourceImpl.DataFrame() : int_;
1573
       int_ = null;
1574
       resultInt.pushOnto(previous);
1575
       resultInt.handleAttributes(attributes);
1576
       return resultInt;
1577
    }
1578
1579
    /**
1580
     * <!-- begin-user-doc -->
1581
     * <!-- end-user-doc -->
1582
     * @generated
1583
     */
1584
    public int popInt(XMLTypeResourceImpl.DataFrame int_)
1585
    {
1586
      int resultIntValue = XMLTypeFactory.eINSTANCE.createInt(int_.popValue());
1587
      this.int_ = int_;
1588
      return resultIntValue;
1589
    }
1590
1591
    /**
1592
     * <!-- begin-user-doc -->
1593
     * <!-- end-user-doc -->
1594
     * @generated
1595
     */
1596
    public XMLTypeResourceImpl.DataFrame pushInteger(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1597
    {
1598
       XMLTypeResourceImpl.DataFrame resultInteger = integer == null ? new XMLTypeResourceImpl.DataFrame() : integer;
1599
       integer = null;
1600
       resultInteger.pushOnto(previous);
1601
       resultInteger.handleAttributes(attributes);
1602
       return resultInteger;
1603
    }
1604
1605
    /**
1606
     * <!-- begin-user-doc -->
1607
     * <!-- end-user-doc -->
1608
     * @generated
1609
     */
1610
    public BigInteger popInteger(XMLTypeResourceImpl.DataFrame integer)
1611
    {
1612
      BigInteger resultIntegerValue = XMLTypeFactory.eINSTANCE.createInteger(integer.popValue());
1613
      this.integer = integer;
1614
      return resultIntegerValue;
1615
    }
1616
1617
    /**
1618
     * <!-- begin-user-doc -->
1619
     * <!-- end-user-doc -->
1620
     * @generated
1621
     */
1622
    public XMLTypeResourceImpl.DataFrame pushIntObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1623
    {
1624
       XMLTypeResourceImpl.DataFrame resultIntObject = intObject == null ? new XMLTypeResourceImpl.DataFrame() : intObject;
1625
       intObject = null;
1626
       resultIntObject.pushOnto(previous);
1627
       resultIntObject.handleAttributes(attributes);
1628
       return resultIntObject;
1629
    }
1630
1631
    /**
1632
     * <!-- begin-user-doc -->
1633
     * <!-- end-user-doc -->
1634
     * @generated
1635
     */
1636
    public Integer popIntObject(XMLTypeResourceImpl.DataFrame intObject)
1637
    {
1638
      Integer resultIntObjectValue = XMLTypeFactory.eINSTANCE.createIntObject(intObject.popValue());
1639
      this.intObject = intObject;
1640
      return resultIntObjectValue;
1641
    }
1642
1643
    /**
1644
     * <!-- begin-user-doc -->
1645
     * <!-- end-user-doc -->
1646
     * @generated
1647
     */
1648
    public XMLTypeResourceImpl.DataFrame pushLanguage(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1649
    {
1650
       XMLTypeResourceImpl.DataFrame resultLanguage = language == null ? new XMLTypeResourceImpl.DataFrame() : language;
1651
       language = null;
1652
       resultLanguage.pushOnto(previous);
1653
       resultLanguage.handleAttributes(attributes);
1654
       return resultLanguage;
1655
    }
1656
1657
    /**
1658
     * <!-- begin-user-doc -->
1659
     * <!-- end-user-doc -->
1660
     * @generated
1661
     */
1662
    public String popLanguage(XMLTypeResourceImpl.DataFrame language)
1663
    {
1664
      String resultLanguageValue = XMLTypeFactory.eINSTANCE.createLanguage(language.popValue());
1665
      this.language = language;
1666
      return resultLanguageValue;
1667
    }
1668
1669
    /**
1670
     * <!-- begin-user-doc -->
1671
     * <!-- end-user-doc -->
1672
     * @generated
1673
     */
1674
    public XMLTypeResourceImpl.DataFrame pushLong(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1675
    {
1676
       XMLTypeResourceImpl.DataFrame resultLong = long_ == null ? new XMLTypeResourceImpl.DataFrame() : long_;
1677
       long_ = null;
1678
       resultLong.pushOnto(previous);
1679
       resultLong.handleAttributes(attributes);
1680
       return resultLong;
1681
    }
1682
1683
    /**
1684
     * <!-- begin-user-doc -->
1685
     * <!-- end-user-doc -->
1686
     * @generated
1687
     */
1688
    public long popLong(XMLTypeResourceImpl.DataFrame long_)
1689
    {
1690
      long resultLongValue = XMLTypeFactory.eINSTANCE.createLong(long_.popValue());
1691
      this.long_ = long_;
1692
      return resultLongValue;
1693
    }
1694
1695
    /**
1696
     * <!-- begin-user-doc -->
1697
     * <!-- end-user-doc -->
1698
     * @generated
1699
     */
1700
    public XMLTypeResourceImpl.DataFrame pushLongObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1701
    {
1702
       XMLTypeResourceImpl.DataFrame resultLongObject = longObject == null ? new XMLTypeResourceImpl.DataFrame() : longObject;
1703
       longObject = null;
1704
       resultLongObject.pushOnto(previous);
1705
       resultLongObject.handleAttributes(attributes);
1706
       return resultLongObject;
1707
    }
1708
1709
    /**
1710
     * <!-- begin-user-doc -->
1711
     * <!-- end-user-doc -->
1712
     * @generated
1713
     */
1714
    public Long popLongObject(XMLTypeResourceImpl.DataFrame longObject)
1715
    {
1716
      Long resultLongObjectValue = XMLTypeFactory.eINSTANCE.createLongObject(longObject.popValue());
1717
      this.longObject = longObject;
1718
      return resultLongObjectValue;
1719
    }
1720
1721
    /**
1722
     * <!-- begin-user-doc -->
1723
     * <!-- end-user-doc -->
1724
     * @generated
1725
     */
1726
    public XMLTypeResourceImpl.DataFrame pushName(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1727
    {
1728
       XMLTypeResourceImpl.DataFrame resultName = name == null ? new XMLTypeResourceImpl.DataFrame() : name;
1729
       name = null;
1730
       resultName.pushOnto(previous);
1731
       resultName.handleAttributes(attributes);
1732
       return resultName;
1733
    }
1734
1735
    /**
1736
     * <!-- begin-user-doc -->
1737
     * <!-- end-user-doc -->
1738
     * @generated
1739
     */
1740
    public String popName(XMLTypeResourceImpl.DataFrame name)
1741
    {
1742
      String resultNameValue = XMLTypeFactory.eINSTANCE.createName(name.popValue());
1743
      this.name = name;
1744
      return resultNameValue;
1745
    }
1746
1747
    /**
1748
     * <!-- begin-user-doc -->
1749
     * <!-- end-user-doc -->
1750
     * @generated
1751
     */
1752
    public XMLTypeResourceImpl.DataFrame pushNCName(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1753
    {
1754
       XMLTypeResourceImpl.DataFrame resultNCName = ncName == null ? new XMLTypeResourceImpl.DataFrame() : ncName;
1755
       ncName = null;
1756
       resultNCName.pushOnto(previous);
1757
       resultNCName.handleAttributes(attributes);
1758
       return resultNCName;
1759
    }
1760
1761
    /**
1762
     * <!-- begin-user-doc -->
1763
     * <!-- end-user-doc -->
1764
     * @generated
1765
     */
1766
    public String popNCName(XMLTypeResourceImpl.DataFrame ncName)
1767
    {
1768
      String resultNCNameValue = XMLTypeFactory.eINSTANCE.createNCName(ncName.popValue());
1769
      this.ncName = ncName;
1770
      return resultNCNameValue;
1771
    }
1772
1773
    /**
1774
     * <!-- begin-user-doc -->
1775
     * <!-- end-user-doc -->
1776
     * @generated
1777
     */
1778
    public XMLTypeResourceImpl.DataFrame pushNegativeInteger(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1779
    {
1780
       XMLTypeResourceImpl.DataFrame resultNegativeInteger = negativeInteger == null ? new XMLTypeResourceImpl.DataFrame() : negativeInteger;
1781
       negativeInteger = null;
1782
       resultNegativeInteger.pushOnto(previous);
1783
       resultNegativeInteger.handleAttributes(attributes);
1784
       return resultNegativeInteger;
1785
    }
1786
1787
    /**
1788
     * <!-- begin-user-doc -->
1789
     * <!-- end-user-doc -->
1790
     * @generated
1791
     */
1792
    public BigInteger popNegativeInteger(XMLTypeResourceImpl.DataFrame negativeInteger)
1793
    {
1794
      BigInteger resultNegativeIntegerValue = XMLTypeFactory.eINSTANCE.createNegativeInteger(negativeInteger.popValue());
1795
      this.negativeInteger = negativeInteger;
1796
      return resultNegativeIntegerValue;
1797
    }
1798
1799
    /**
1800
     * <!-- begin-user-doc -->
1801
     * <!-- end-user-doc -->
1802
     * @generated
1803
     */
1804
    public XMLTypeResourceImpl.DataFrame pushNMTOKEN(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1805
    {
1806
       XMLTypeResourceImpl.DataFrame resultNMTOKEN = nmtoken == null ? new XMLTypeResourceImpl.DataFrame() : nmtoken;
1807
       nmtoken = null;
1808
       resultNMTOKEN.pushOnto(previous);
1809
       resultNMTOKEN.handleAttributes(attributes);
1810
       return resultNMTOKEN;
1811
    }
1812
1813
    /**
1814
     * <!-- begin-user-doc -->
1815
     * <!-- end-user-doc -->
1816
     * @generated
1817
     */
1818
    public String popNMTOKEN(XMLTypeResourceImpl.DataFrame nmtoken)
1819
    {
1820
      String resultNMTOKENValue = XMLTypeFactory.eINSTANCE.createNMTOKEN(nmtoken.popValue());
1821
      this.nmtoken = nmtoken;
1822
      return resultNMTOKENValue;
1823
    }
1824
1825
    /**
1826
     * <!-- begin-user-doc -->
1827
     * <!-- end-user-doc -->
1828
     * @generated
1829
     */
1830
    public XMLTypeResourceImpl.DataFrame pushNMTOKENS(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1831
    {
1832
       XMLTypeResourceImpl.DataFrame resultNMTOKENS = nmtokens == null ? new XMLTypeResourceImpl.DataFrame() : nmtokens;
1833
       nmtokens = null;
1834
       resultNMTOKENS.pushOnto(previous);
1835
       resultNMTOKENS.handleAttributes(attributes);
1836
       return resultNMTOKENS;
1837
    }
1838
1839
    /**
1840
     * <!-- begin-user-doc -->
1841
     * <!-- end-user-doc -->
1842
     * @generated
1843
     */
1844
    public List popNMTOKENS(XMLTypeResourceImpl.DataFrame nmtokens)
1845
    {
1846
      List resultNMTOKENSValue = XMLTypeFactory.eINSTANCE.createNMTOKENS(nmtokens.popValue());
1847
      this.nmtokens = nmtokens;
1848
      return resultNMTOKENSValue;
1849
    }
1850
1851
    /**
1852
     * <!-- begin-user-doc -->
1853
     * <!-- end-user-doc -->
1854
     * @generated
1855
     */
1856
    public XMLTypeResourceImpl.DataFrame pushNMTOKENSBase(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1857
    {
1858
       XMLTypeResourceImpl.DataFrame resultNMTOKENSBase = nmtokensBase == null ? new XMLTypeResourceImpl.DataFrame() : nmtokensBase;
1859
       nmtokensBase = null;
1860
       resultNMTOKENSBase.pushOnto(previous);
1861
       resultNMTOKENSBase.handleAttributes(attributes);
1862
       return resultNMTOKENSBase;
1863
    }
1864
1865
    /**
1866
     * <!-- begin-user-doc -->
1867
     * <!-- end-user-doc -->
1868
     * @generated
1869
     */
1870
    public List popNMTOKENSBase(XMLTypeResourceImpl.DataFrame nmtokensBase)
1871
    {
1872
      List resultNMTOKENSBaseValue = XMLTypeFactory.eINSTANCE.createNMTOKENSBase(nmtokensBase.popValue());
1873
      this.nmtokensBase = nmtokensBase;
1874
      return resultNMTOKENSBaseValue;
1875
    }
1876
1877
    /**
1878
     * <!-- begin-user-doc -->
1879
     * <!-- end-user-doc -->
1880
     * @generated
1881
     */
1882
    public XMLTypeResourceImpl.DataFrame pushNonNegativeInteger(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1883
    {
1884
       XMLTypeResourceImpl.DataFrame resultNonNegativeInteger = nonNegativeInteger == null ? new XMLTypeResourceImpl.DataFrame() : nonNegativeInteger;
1885
       nonNegativeInteger = null;
1886
       resultNonNegativeInteger.pushOnto(previous);
1887
       resultNonNegativeInteger.handleAttributes(attributes);
1888
       return resultNonNegativeInteger;
1889
    }
1890
1891
    /**
1892
     * <!-- begin-user-doc -->
1893
     * <!-- end-user-doc -->
1894
     * @generated
1895
     */
1896
    public BigInteger popNonNegativeInteger(XMLTypeResourceImpl.DataFrame nonNegativeInteger)
1897
    {
1898
      BigInteger resultNonNegativeIntegerValue = XMLTypeFactory.eINSTANCE.createNonNegativeInteger(nonNegativeInteger.popValue());
1899
      this.nonNegativeInteger = nonNegativeInteger;
1900
      return resultNonNegativeIntegerValue;
1901
    }
1902
1903
    /**
1904
     * <!-- begin-user-doc -->
1905
     * <!-- end-user-doc -->
1906
     * @generated
1907
     */
1908
    public XMLTypeResourceImpl.DataFrame pushNonPositiveInteger(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1909
    {
1910
       XMLTypeResourceImpl.DataFrame resultNonPositiveInteger = nonPositiveInteger == null ? new XMLTypeResourceImpl.DataFrame() : nonPositiveInteger;
1911
       nonPositiveInteger = null;
1912
       resultNonPositiveInteger.pushOnto(previous);
1913
       resultNonPositiveInteger.handleAttributes(attributes);
1914
       return resultNonPositiveInteger;
1915
    }
1916
1917
    /**
1918
     * <!-- begin-user-doc -->
1919
     * <!-- end-user-doc -->
1920
     * @generated
1921
     */
1922
    public BigInteger popNonPositiveInteger(XMLTypeResourceImpl.DataFrame nonPositiveInteger)
1923
    {
1924
      BigInteger resultNonPositiveIntegerValue = XMLTypeFactory.eINSTANCE.createNonPositiveInteger(nonPositiveInteger.popValue());
1925
      this.nonPositiveInteger = nonPositiveInteger;
1926
      return resultNonPositiveIntegerValue;
1927
    }
1928
1929
    /**
1930
     * <!-- begin-user-doc -->
1931
     * <!-- end-user-doc -->
1932
     * @generated
1933
     */
1934
    public XMLTypeResourceImpl.DataFrame pushNormalizedString(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1935
    {
1936
       XMLTypeResourceImpl.DataFrame resultNormalizedString = normalizedString == null ? new XMLTypeResourceImpl.DataFrame() : normalizedString;
1937
       normalizedString = null;
1938
       resultNormalizedString.pushOnto(previous);
1939
       resultNormalizedString.handleAttributes(attributes);
1940
       return resultNormalizedString;
1941
    }
1942
1943
    /**
1944
     * <!-- begin-user-doc -->
1945
     * <!-- end-user-doc -->
1946
     * @generated
1947
     */
1948
    public String popNormalizedString(XMLTypeResourceImpl.DataFrame normalizedString)
1949
    {
1950
      String resultNormalizedStringValue = XMLTypeFactory.eINSTANCE.createNormalizedString(normalizedString.popValue());
1951
      this.normalizedString = normalizedString;
1952
      return resultNormalizedStringValue;
1953
    }
1954
1955
    /**
1956
     * <!-- begin-user-doc -->
1957
     * <!-- end-user-doc -->
1958
     * @generated
1959
     */
1960
    public XMLTypeResourceImpl.DataFrame pushNOTATION(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1961
    {
1962
       XMLTypeResourceImpl.DataFrame resultNOTATION = notation == null ? new XMLTypeResourceImpl.DataFrame() : notation;
1963
       notation = null;
1964
       resultNOTATION.pushOnto(previous);
1965
       resultNOTATION.handleAttributes(attributes);
1966
       return resultNOTATION;
1967
    }
1968
1969
    /**
1970
     * <!-- begin-user-doc -->
1971
     * <!-- end-user-doc -->
1972
     * @generated
1973
     */
1974
    public Object popNOTATION(XMLTypeResourceImpl.DataFrame notation)
1975
    {
1976
      Object resultNOTATIONValue = XMLTypeFactory.eINSTANCE.createNOTATION(notation.popValue());
1977
      this.notation = notation;
1978
      return resultNOTATIONValue;
1979
    }
1980
1981
    /**
1982
     * <!-- begin-user-doc -->
1983
     * <!-- end-user-doc -->
1984
     * @generated
1985
     */
1986
    public XMLTypeResourceImpl.DataFrame pushPositiveInteger(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
1987
    {
1988
       XMLTypeResourceImpl.DataFrame resultPositiveInteger = positiveInteger == null ? new XMLTypeResourceImpl.DataFrame() : positiveInteger;
1989
       positiveInteger = null;
1990
       resultPositiveInteger.pushOnto(previous);
1991
       resultPositiveInteger.handleAttributes(attributes);
1992
       return resultPositiveInteger;
1993
    }
1994
1995
    /**
1996
     * <!-- begin-user-doc -->
1997
     * <!-- end-user-doc -->
1998
     * @generated
1999
     */
2000
    public BigInteger popPositiveInteger(XMLTypeResourceImpl.DataFrame positiveInteger)
2001
    {
2002
      BigInteger resultPositiveIntegerValue = XMLTypeFactory.eINSTANCE.createPositiveInteger(positiveInteger.popValue());
2003
      this.positiveInteger = positiveInteger;
2004
      return resultPositiveIntegerValue;
2005
    }
2006
2007
    /**
2008
     * <!-- begin-user-doc -->
2009
     * <!-- end-user-doc -->
2010
     * @generated
2011
     */
2012
    public XMLTypeResourceImpl.DataFrame pushQName(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2013
    {
2014
       XMLTypeResourceImpl.DataFrame resultQName = qName == null ? new XMLTypeResourceImpl.DataFrame() : qName;
2015
       qName = null;
2016
       resultQName.pushOnto(previous);
2017
       resultQName.handleAttributes(attributes);
2018
       return resultQName;
2019
    }
2020
2021
    /**
2022
     * <!-- begin-user-doc -->
2023
     * <!-- end-user-doc -->
2024
     * @generated
2025
     */
2026
    public Object popQName(XMLTypeResourceImpl.DataFrame qName)
2027
    {
2028
      Object resultQNameValue = XMLTypeFactory.eINSTANCE.createQName(qName.popValue());
2029
      this.qName = qName;
2030
      return resultQNameValue;
2031
    }
2032
2033
    /**
2034
     * <!-- begin-user-doc -->
2035
     * <!-- end-user-doc -->
2036
     * @generated
2037
     */
2038
    public XMLTypeResourceImpl.DataFrame pushShort(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2039
    {
2040
       XMLTypeResourceImpl.DataFrame resultShort = short_ == null ? new XMLTypeResourceImpl.DataFrame() : short_;
2041
       short_ = null;
2042
       resultShort.pushOnto(previous);
2043
       resultShort.handleAttributes(attributes);
2044
       return resultShort;
2045
    }
2046
2047
    /**
2048
     * <!-- begin-user-doc -->
2049
     * <!-- end-user-doc -->
2050
     * @generated
2051
     */
2052
    public short popShort(XMLTypeResourceImpl.DataFrame short_)
2053
    {
2054
      short resultShortValue = XMLTypeFactory.eINSTANCE.createShort(short_.popValue());
2055
      this.short_ = short_;
2056
      return resultShortValue;
2057
    }
2058
2059
    /**
2060
     * <!-- begin-user-doc -->
2061
     * <!-- end-user-doc -->
2062
     * @generated
2063
     */
2064
    public XMLTypeResourceImpl.DataFrame pushShortObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2065
    {
2066
       XMLTypeResourceImpl.DataFrame resultShortObject = shortObject == null ? new XMLTypeResourceImpl.DataFrame() : shortObject;
2067
       shortObject = null;
2068
       resultShortObject.pushOnto(previous);
2069
       resultShortObject.handleAttributes(attributes);
2070
       return resultShortObject;
2071
    }
2072
2073
    /**
2074
     * <!-- begin-user-doc -->
2075
     * <!-- end-user-doc -->
2076
     * @generated
2077
     */
2078
    public Short popShortObject(XMLTypeResourceImpl.DataFrame shortObject)
2079
    {
2080
      Short resultShortObjectValue = XMLTypeFactory.eINSTANCE.createShortObject(shortObject.popValue());
2081
      this.shortObject = shortObject;
2082
      return resultShortObjectValue;
2083
    }
2084
2085
    /**
2086
     * <!-- begin-user-doc -->
2087
     * <!-- end-user-doc -->
2088
     * @generated
2089
     */
2090
    public XMLTypeResourceImpl.DataFrame pushString(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2091
    {
2092
       XMLTypeResourceImpl.DataFrame resultString = string == null ? new XMLTypeResourceImpl.DataFrame() : string;
2093
       string = null;
2094
       resultString.pushOnto(previous);
2095
       resultString.handleAttributes(attributes);
2096
       return resultString;
2097
    }
2098
2099
    /**
2100
     * <!-- begin-user-doc -->
2101
     * <!-- end-user-doc -->
2102
     * @generated NOT
2103
     */
2104
    public String popString(XMLTypeResourceImpl.DataFrame string)
2105
    {
2106
      String resultStringValue = string.popValue();
2107
      this.string = string;
2108
      return resultStringValue;
2109
    }
2110
2111
    /**
2112
     * <!-- begin-user-doc -->
2113
     * <!-- end-user-doc -->
2114
     * @generated
2115
     */
2116
    public XMLTypeResourceImpl.DataFrame pushTime(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2117
    {
2118
       XMLTypeResourceImpl.DataFrame resultTime = time == null ? new XMLTypeResourceImpl.DataFrame() : time;
2119
       time = null;
2120
       resultTime.pushOnto(previous);
2121
       resultTime.handleAttributes(attributes);
2122
       return resultTime;
2123
    }
2124
2125
    /**
2126
     * <!-- begin-user-doc -->
2127
     * <!-- end-user-doc -->
2128
     * @generated
2129
     */
2130
    public Object popTime(XMLTypeResourceImpl.DataFrame time)
2131
    {
2132
      Object resultTimeValue = XMLTypeFactory.eINSTANCE.createTime(time.popValue());
2133
      this.time = time;
2134
      return resultTimeValue;
2135
    }
2136
2137
    /**
2138
     * <!-- begin-user-doc -->
2139
     * <!-- end-user-doc -->
2140
     * @generated
2141
     */
2142
    public XMLTypeResourceImpl.DataFrame pushToken(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2143
    {
2144
       XMLTypeResourceImpl.DataFrame resultToken = token == null ? new XMLTypeResourceImpl.DataFrame() : token;
2145
       token = null;
2146
       resultToken.pushOnto(previous);
2147
       resultToken.handleAttributes(attributes);
2148
       return resultToken;
2149
    }
2150
2151
    /**
2152
     * <!-- begin-user-doc -->
2153
     * <!-- end-user-doc -->
2154
     * @generated
2155
     */
2156
    public String popToken(XMLTypeResourceImpl.DataFrame token)
2157
    {
2158
      String resultTokenValue = XMLTypeFactory.eINSTANCE.createToken(token.popValue());
2159
      this.token = token;
2160
      return resultTokenValue;
2161
    }
2162
2163
    /**
2164
     * <!-- begin-user-doc -->
2165
     * <!-- end-user-doc -->
2166
     * @generated
2167
     */
2168
    public XMLTypeResourceImpl.DataFrame pushUnsignedByte(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2169
    {
2170
       XMLTypeResourceImpl.DataFrame resultUnsignedByte = unsignedByte == null ? new XMLTypeResourceImpl.DataFrame() : unsignedByte;
2171
       unsignedByte = null;
2172
       resultUnsignedByte.pushOnto(previous);
2173
       resultUnsignedByte.handleAttributes(attributes);
2174
       return resultUnsignedByte;
2175
    }
2176
2177
    /**
2178
     * <!-- begin-user-doc -->
2179
     * <!-- end-user-doc -->
2180
     * @generated
2181
     */
2182
    public short popUnsignedByte(XMLTypeResourceImpl.DataFrame unsignedByte)
2183
    {
2184
      short resultUnsignedByteValue = XMLTypeFactory.eINSTANCE.createUnsignedByte(unsignedByte.popValue());
2185
      this.unsignedByte = unsignedByte;
2186
      return resultUnsignedByteValue;
2187
    }
2188
2189
    /**
2190
     * <!-- begin-user-doc -->
2191
     * <!-- end-user-doc -->
2192
     * @generated
2193
     */
2194
    public XMLTypeResourceImpl.DataFrame pushUnsignedByteObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2195
    {
2196
       XMLTypeResourceImpl.DataFrame resultUnsignedByteObject = unsignedByteObject == null ? new XMLTypeResourceImpl.DataFrame() : unsignedByteObject;
2197
       unsignedByteObject = null;
2198
       resultUnsignedByteObject.pushOnto(previous);
2199
       resultUnsignedByteObject.handleAttributes(attributes);
2200
       return resultUnsignedByteObject;
2201
    }
2202
2203
    /**
2204
     * <!-- begin-user-doc -->
2205
     * <!-- end-user-doc -->
2206
     * @generated
2207
     */
2208
    public Short popUnsignedByteObject(XMLTypeResourceImpl.DataFrame unsignedByteObject)
2209
    {
2210
      Short resultUnsignedByteObjectValue = XMLTypeFactory.eINSTANCE.createUnsignedByteObject(unsignedByteObject.popValue());
2211
      this.unsignedByteObject = unsignedByteObject;
2212
      return resultUnsignedByteObjectValue;
2213
    }
2214
2215
    /**
2216
     * <!-- begin-user-doc -->
2217
     * <!-- end-user-doc -->
2218
     * @generated
2219
     */
2220
    public XMLTypeResourceImpl.DataFrame pushUnsignedInt(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2221
    {
2222
       XMLTypeResourceImpl.DataFrame resultUnsignedInt = unsignedInt == null ? new XMLTypeResourceImpl.DataFrame() : unsignedInt;
2223
       unsignedInt = null;
2224
       resultUnsignedInt.pushOnto(previous);
2225
       resultUnsignedInt.handleAttributes(attributes);
2226
       return resultUnsignedInt;
2227
    }
2228
2229
    /**
2230
     * <!-- begin-user-doc -->
2231
     * <!-- end-user-doc -->
2232
     * @generated
2233
     */
2234
    public long popUnsignedInt(XMLTypeResourceImpl.DataFrame unsignedInt)
2235
    {
2236
      long resultUnsignedIntValue = XMLTypeFactory.eINSTANCE.createUnsignedInt(unsignedInt.popValue());
2237
      this.unsignedInt = unsignedInt;
2238
      return resultUnsignedIntValue;
2239
    }
2240
2241
    /**
2242
     * <!-- begin-user-doc -->
2243
     * <!-- end-user-doc -->
2244
     * @generated
2245
     */
2246
    public XMLTypeResourceImpl.DataFrame pushUnsignedIntObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2247
    {
2248
       XMLTypeResourceImpl.DataFrame resultUnsignedIntObject = unsignedIntObject == null ? new XMLTypeResourceImpl.DataFrame() : unsignedIntObject;
2249
       unsignedIntObject = null;
2250
       resultUnsignedIntObject.pushOnto(previous);
2251
       resultUnsignedIntObject.handleAttributes(attributes);
2252
       return resultUnsignedIntObject;
2253
    }
2254
2255
    /**
2256
     * <!-- begin-user-doc -->
2257
     * <!-- end-user-doc -->
2258
     * @generated
2259
     */
2260
    public Long popUnsignedIntObject(XMLTypeResourceImpl.DataFrame unsignedIntObject)
2261
    {
2262
      Long resultUnsignedIntObjectValue = XMLTypeFactory.eINSTANCE.createUnsignedIntObject(unsignedIntObject.popValue());
2263
      this.unsignedIntObject = unsignedIntObject;
2264
      return resultUnsignedIntObjectValue;
2265
    }
2266
2267
    /**
2268
     * <!-- begin-user-doc -->
2269
     * <!-- end-user-doc -->
2270
     * @generated
2271
     */
2272
    public XMLTypeResourceImpl.DataFrame pushUnsignedLong(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2273
    {
2274
       XMLTypeResourceImpl.DataFrame resultUnsignedLong = unsignedLong == null ? new XMLTypeResourceImpl.DataFrame() : unsignedLong;
2275
       unsignedLong = null;
2276
       resultUnsignedLong.pushOnto(previous);
2277
       resultUnsignedLong.handleAttributes(attributes);
2278
       return resultUnsignedLong;
2279
    }
2280
2281
    /**
2282
     * <!-- begin-user-doc -->
2283
     * <!-- end-user-doc -->
2284
     * @generated
2285
     */
2286
    public BigInteger popUnsignedLong(XMLTypeResourceImpl.DataFrame unsignedLong)
2287
    {
2288
      BigInteger resultUnsignedLongValue = XMLTypeFactory.eINSTANCE.createUnsignedLong(unsignedLong.popValue());
2289
      this.unsignedLong = unsignedLong;
2290
      return resultUnsignedLongValue;
2291
    }
2292
2293
    /**
2294
     * <!-- begin-user-doc -->
2295
     * <!-- end-user-doc -->
2296
     * @generated
2297
     */
2298
    public XMLTypeResourceImpl.DataFrame pushUnsignedShort(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2299
    {
2300
       XMLTypeResourceImpl.DataFrame resultUnsignedShort = unsignedShort == null ? new XMLTypeResourceImpl.DataFrame() : unsignedShort;
2301
       unsignedShort = null;
2302
       resultUnsignedShort.pushOnto(previous);
2303
       resultUnsignedShort.handleAttributes(attributes);
2304
       return resultUnsignedShort;
2305
    }
2306
2307
    /**
2308
     * <!-- begin-user-doc -->
2309
     * <!-- end-user-doc -->
2310
     * @generated
2311
     */
2312
    public int popUnsignedShort(XMLTypeResourceImpl.DataFrame unsignedShort)
2313
    {
2314
      int resultUnsignedShortValue = XMLTypeFactory.eINSTANCE.createUnsignedShort(unsignedShort.popValue());
2315
      this.unsignedShort = unsignedShort;
2316
      return resultUnsignedShortValue;
2317
    }
2318
2319
    /**
2320
     * <!-- begin-user-doc -->
2321
     * <!-- end-user-doc -->
2322
     * @generated
2323
     */
2324
    public XMLTypeResourceImpl.DataFrame pushUnsignedShortObject(XMLTypeResourceImpl.StackFrame previous, Attributes attributes)
2325
    {
2326
       XMLTypeResourceImpl.DataFrame resultUnsignedShortObject = unsignedShortObject == null ? new XMLTypeResourceImpl.DataFrame() : unsignedShortObject;
2327
       unsignedShortObject = null;
2328
       resultUnsignedShortObject.pushOnto(previous);
2329
       resultUnsignedShortObject.handleAttributes(attributes);
2330
       return resultUnsignedShortObject;
2331
    }
2332
2333
    /**
2334
     * <!-- begin-user-doc -->
2335
     * <!-- end-user-doc -->
2336
     * @generated
2337
     */
2338
    public Integer popUnsignedShortObject(XMLTypeResourceImpl.DataFrame unsignedShortObject)
2339
    {
2340
      Integer resultUnsignedShortObjectValue = XMLTypeFactory.eINSTANCE.createUnsignedShortObject(unsignedShortObject.popValue());
2341
      this.unsignedShortObject = unsignedShortObject;
2342
      return resultUnsignedShortObjectValue;
2343
    }
2344
2345
  }
2346
2347
  public static abstract class StackFrame
2348
  {
2349
    private StackFrame previous;
2350
    
2351
    final public void pushOnto(StackFrame previous)
2352
    {
2353
      this.previous = previous;
2354
      create();
2355
    }
2356
    
2357
    final public void pop()
2358
    {
2359
      this.previous = null;
2360
    }
2361
    
2362
    public void handleAttributes(Attributes attributes)
2363
    {
2364
    }
2365
    
2366
    public StackFrame startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
2367
    {
2368
      throw new SAXException("Unexpected start element");
2369
    }
2370
    
2371
    public void endElement(StackFrame child) throws SAXException
2372
    {
2373
      throw new SAXException("Unexpected end element");
2374
    }
2375
    
2376
    final public StackFrame endElement() throws SAXException
2377
    {
2378
      StackFrame result = previous;
2379
      previous.endElement(this);
2380
      return result;
2381
    }
2382
    
2383
    public void characters(char[] text, int start, int length) throws SAXException
2384
    {
2385
    }
2386
    
2387
    public void create()
2388
    {
2389
    }
2390
  }
2391
2392
  public static class DataFrame extends StackFrame
2393
  {
2394
    protected StringBuffer stringBuffer;
2395
    
2396
    public void characters(char[] text, int start, int length) throws SAXException
2397
    {
2398
      if (stringBuffer == null)
2399
      {
2400
        stringBuffer = new StringBuffer();
2401
      }
2402
      stringBuffer.append(text, start, length);
2403
    }
2404
    
2405
    public String popValue()
2406
    {
2407
      if (stringBuffer == null)
2408
      {
2409
        pop();
2410
        return null;
2411
      }
2412
      else
2413
      {
2414
        String result = stringBuffer.toString();
2415
        stringBuffer.setLength(0);
2416
        pop();
2417
        return result;
2418
      }
2419
    }
2420
  }
2421
  
2422
  public static class Handler extends DefaultHandler
2423
  {
2424
    protected StackFrame stackFrame = null;
2425
    
2426
    public Handler(StackFrame stackFrame)
2427
    {
2428
      this.stackFrame = stackFrame;
2429
    }
2430
    
2431
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
2432
    {
2433
      stackFrame = stackFrame.startElement(uri, localName, qName, attributes);
2434
    }
2435
    
2436
    public void endElement(String uri, String localName, String qName) throws SAXException
2437
    {
2438
      stackFrame = stackFrame.endElement();
2439
    }
2440
    
2441
    public void characters(char[] text, int start, int length) throws SAXException
2442
    {
2443
      stackFrame.characters(text, start, length);
2444
    }
2445
2446
    public void error(SAXParseException exception) throws SAXException
2447
    {
2448
    }
2449
2450
    public void fatalError(SAXParseException exception) throws SAXException
2451
    {
2452
    }
2453
  }
2454
 
2455
} //XMLTypeResourceImpl
(-)META-INF/MANIFEST.MF (-3 lines)
Lines 13-21 Link Here
13
 org.eclipse.emf.ecore.resource,
13
 org.eclipse.emf.ecore.resource,
14
 org.eclipse.emf.ecore.resource.impl,
14
 org.eclipse.emf.ecore.resource.impl,
15
 org.eclipse.emf.ecore.util,
15
 org.eclipse.emf.ecore.util,
16
 org.eclipse.emf.ecore.xml.namespace,
17
 org.eclipse.emf.ecore.xml.namespace.impl,
18
 org.eclipse.emf.ecore.xml.namespace.util,
19
 org.eclipse.emf.ecore.xml.type,
16
 org.eclipse.emf.ecore.xml.type,
20
 org.eclipse.emf.ecore.xml.type.impl,
17
 org.eclipse.emf.ecore.xml.type.impl,
21
 org.eclipse.emf.ecore.xml.type.internal,
18
 org.eclipse.emf.ecore.xml.type.internal,
(-)src/org/eclipse/emf/ecore/resource/URIConverter.java (-429 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2002-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: URIConverter.java,v 1.5.2.1 2007/05/10 17:29:50 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.resource;
18
19
20
import java.io.ByteArrayInputStream;
21
import java.io.ByteArrayOutputStream;
22
import java.io.IOException;
23
import java.io.InputStream;
24
import java.io.InputStreamReader;
25
import java.io.OutputStream;
26
import java.io.OutputStreamWriter;
27
import java.io.Reader;
28
import java.io.StringReader;
29
import java.io.Writer;
30
import java.util.Map;
31
32
import org.eclipse.emf.common.util.URI;
33
import org.eclipse.emf.ecore.xml.type.internal.RegEx;
34
35
36
/**
37
 * A converter to normalize a URI or to produce an input or output stream for a URI.
38
 * <p>
39
 * A resource set provides {@link ResourceSet#getURIConverter one} of these
40
 * for use by it's {@link ResourceSet#getResources resources}
41
 * when they are {@link Resource#save(java.util.Map) serialized} and {@link Resource#load(java.util.Map) deserialized}.
42
 * A resource set also uses this directly when it {@link ResourceSet#getResource looks up} a resource:
43
 * a resource is considered a match if {@link Resource#getURI it's URI}, 
44
 * and the URI being looked up, 
45
 * {@link #normalize normalize} to {@link URI#equals(Object) equal} URIs.
46
 * </p>
47
 */
48
public interface URIConverter
49
{
50
  /**
51
   * Returns the normalized form of the URI.
52
   * <p>
53
   * This may, in theory, do absolutly anything.
54
   * Default behaviour includes 
55
   * applying URI {@link URIConverter#getURIMap mapping},
56
   * assuming <code>"file:"</code> protocol 
57
   * for a {@link URI#isRelative relative} URI with a {@link URI#hasRelativePath relative path}:
58
   *<pre>
59
   *  ./WhateverDirectory/Whatever.file 
60
   *    -> 
61
   *  file:./WhateverDirectory/Whatever.file
62
   *</pre>
63
   * and assuming <code>"platform:/resource"</code> protocol 
64
   * for a relative URI with an {@link URI#hasAbsolutePath absolute path}:
65
   *<pre>
66
   *  /WhateverRelocatableProject/Whatever.file 
67
   *    -> 
68
   *  platform:/resource/WhateverRelocatableProject/Whatever.file
69
   *</pre>
70
   * </p>
71
   * <p>
72
   * It is important to emphasize that normalization can result it loss of information.
73
   * The normalized URI should generally be used only for comparison and for access to input or output streams.
74
   * </p>
75
   * @param uri the URI to normalize.
76
   * @return the normalized form.
77
   * @see org.eclipse.emf.ecore.plugin.EcorePlugin#getPlatformResourceMap
78
   */
79
  URI normalize(URI uri);
80
81
  /**
82
   * Returns the map used for remapping a logical URI to a physical URI when {@link #normalize normalizing}.
83
   * <p>
84
   * An implementation will typically also delegate to the {@link URIConverter#URI_MAP global} map,
85
   * so registrations made in this map are <em>local</em> to this URI converter,
86
   * i.e., they augment or override those of the global map.
87
   * </p>
88
   * <p>
89
   * The map generally specifies instance to instance mapping,
90
   * except for the case that both the key URI and the value URI end with "/", 
91
   * which specifies a folder to folder mapping.
92
   * A folder mapping will remap any URI that has the key as its {@link URI#replacePrefix prefix}, 
93
   * e.g., if the map contains:
94
   *<pre>
95
   *  http://www.example.com/ -> platform:/resource/example/
96
   *</pre>
97
   * then the URI
98
   *<pre>
99
   *  http://www.example.com/a/b/c.d
100
   *</pre>
101
   * will map to 
102
   *<pre>
103
   *  platform:/resource/example/a/b/c.d
104
   *</pre>
105
   * A matching instance mapping is considered first.
106
   * If there isn't one, the folder mappings are considered starting with the {@link URI#segmentCount() longest} prefix. 
107
   * </p>
108
   * @see #normalize(URI)
109
   * @see #URI_MAP
110
   * @return the map used for remapping a logical URI to a physical URI.
111
   */
112
  Map getURIMap();
113
114
  /**
115
   * The global static URI map.
116
   * Registrations made in this instance will (typically) be available
117
   * for {@link URIConverter#normalize use} by any URI converter.
118
   * It is populated by URI mappings registered via
119
   * {@link org.eclipse.emf.ecore.plugin.EcorePlugin.Implementation#startup plugin registration}.
120
   * @see #normalize(URI)
121
   */
122
  Map URI_MAP = org.eclipse.emf.ecore.resource.impl.URIMappingRegistryImpl.INSTANCE.map();
123
124
  /**
125
   * Creates an input stream for the URI and returns it.
126
   * <p>
127
   * It {@link #normalize normalizes} the URI and uses that as the basis for further processing.
128
   * Special requirements, such as an Eclipse file refresh, 
129
   * are handled by the {@link org.eclipse.emf.ecore.resource.impl.URIConverterImpl default implementation}.
130
   * </p>
131
   * @return an open input stream.
132
   * @exception IOException if there is a problem obtaining an open input stream.
133
   */
134
  InputStream createInputStream(URI uri) throws IOException;
135
136
  /**
137
   * An interface that is optionally implemented by the input streams returned from 
138
   * {@link URIConverter#createInputStream(URI)}.
139
   * @see ReadableInputStream
140
   */
141
  interface Readable
142
  {
143
    /**
144
     * Returns a reader that provides access to the same underlying data as the input stream itself.
145
     * @return a reader that provides access to the same underlying data as the input stream itself.
146
     */
147
    Reader asReader();
148
    
149
    /**
150
     * Returns the encoding used to convert the reader's characters to bytes.
151
     * @return the encoding used to convert the reader's characters to bytes.
152
     */
153
    String getEncoding();
154
  }
155
156
  /**
157
   * A wrapper around a reader that implements an input stream but can be unwrapped to access the reader directly.
158
   */
159
  public class ReadableInputStream extends InputStream implements Readable
160
  {
161
    private static final RegEx.RegularExpression XML_HEADER = new RegEx.RegularExpression("<\\?xml\\s+(?:version\\s*=\\s*\"[^\"]*\"\\s+)encoding\\s*=\\s*\"\\s*([^\\s\"]*)\"\\s*\\?>");
162
    
163
    public static String getEncoding(String xmlString)
164
    {
165
      RegEx.Match match = new RegEx.Match(); 
166
      return
167
        XML_HEADER.matches(xmlString, match) ?
168
          match.getCapturedText(1) :
169
          null;
170
    }
171
    
172
    protected String encoding;
173
    protected Reader reader;
174
    protected Buffer buffer;
175
    
176
    public ReadableInputStream(Reader reader, String encoding)
177
    {
178
      super();
179
      this.reader = reader;
180
      this.encoding = encoding;
181
    }
182
    
183
    public ReadableInputStream(String string, String encoding)
184
    {
185
      this(new StringReader(string), encoding);
186
    }
187
    
188
    public ReadableInputStream(String xmlString)
189
    {
190
      this(new StringReader(xmlString), getEncoding(xmlString));
191
    }
192
    
193
    public int read() throws IOException
194
    {
195
      if (buffer == null)
196
      {
197
        buffer = new Buffer(100);
198
      }
199
      
200
      return buffer.read();
201
    }
202
203
    public Reader asReader()
204
    {
205
      return reader;
206
    }
207
    
208
    public String getEncoding()
209
    {
210
      return encoding; 
211
    }
212
213
    public void close() throws IOException
214
    {
215
      super.close();
216
      reader.close();
217
    }
218
219
    public void reset() throws IOException
220
    {
221
      super.reset();
222
      reader.reset();
223
    }
224
    
225
    protected class Buffer extends ByteArrayOutputStream
226
    {
227
      protected int index;
228
      protected char [] characters;
229
      protected OutputStreamWriter writer;
230
      
231
      public Buffer(int size) throws IOException
232
      {
233
        super(size);
234
        characters = new char [size];
235
        writer = new OutputStreamWriter(this, encoding);
236
      }
237
      
238
      public int read() throws IOException
239
      {
240
        if (index < count)
241
        {
242
          return buf[index++];
243
        }
244
        else
245
        {
246
          index = 0;
247
          reset();
248
          
249
          int readCount = reader.read(characters);
250
          if (readCount < 0)
251
          {
252
            return -1;
253
          }
254
          else
255
          {
256
            writer.write(characters, 0, readCount);
257
            writer.flush();
258
            return buf[index++];
259
          }
260
        }
261
      }
262
    }
263
  }
264
  
265
  /**
266
   * Creates an output stream for the URI and returns it.
267
   * <p>
268
   * It {@link #normalize normalizes} the URI and uses that as the basis for further processing.
269
   * Special requirements, such as an Eclipse file refresh and automatic subdirectory creation, 
270
   * are handled by the {@link org.eclipse.emf.ecore.resource.impl.URIConverterImpl default implementation}.
271
   * </p>
272
   * @return an open output stream.
273
   * @exception IOException if there is a problem obtaining an open output stream.
274
   */
275
  OutputStream createOutputStream(URI uri) throws IOException;
276
  
277
  /**
278
   * An interface that is optionally implemented by the output streams returned from 
279
   * {@link URIConverter#createOutputStream(URI)}.
280
   * @see WriteableOutputStream
281
   */
282
  interface Writeable
283
  {
284
    /**
285
     * Returns a writer that provides access to the same underlying data as the input stream itself.
286
     * @return a writer that provides access to the same underlying data as the input stream itself.
287
     */
288
    Writer asWriter();
289
    
290
    /**
291
     * Returns the encoding used to convert the writer's bytes to characters.
292
     * @return the encoding used to convert the writer's bytes to characters.
293
     */
294
    String getEncoding();
295
  }
296
297
  /**
298
   * A wrapper around a writer that implements an output stream but can be unwrapped to access the writer directly.
299
   */
300
  public static class WriteableOutputStream extends OutputStream implements Writeable
301
  {
302
    protected String encoding;
303
    protected Writer writer;
304
    protected Buffer buffer;
305
306
    public WriteableOutputStream(Writer writer, String encoding)
307
    {
308
      super();
309
      this.writer = writer;
310
      this.encoding = encoding;
311
    }
312
    
313
    public void write(int b) throws IOException
314
    {
315
      if (buffer == null)
316
      {
317
        buffer = new Buffer(100);
318
      }
319
      
320
      buffer.write(b);
321
    }
322
323
    public Writer asWriter()
324
    {
325
      return writer;
326
    }
327
328
    public String getEncoding()
329
    {
330
      return encoding;
331
    }
332
    
333
    public void close() throws IOException
334
    {
335
      super.close();
336
      writer.close();
337
    }
338
    
339
    public void flush() throws IOException
340
    {
341
      super.flush();
342
      buffer.flush();
343
      writer.flush();
344
    }
345
346
    protected class Buffer extends ByteArrayInputStream
347
    {
348
      protected int index;
349
      protected char [] characters;
350
      protected InputStreamReader reader;
351
      
352
      public Buffer(int size) throws IOException
353
      {
354
        super(new byte [size], 0, 0);
355
        characters = new char [size];
356
        reader = new InputStreamReader(this, encoding);
357
      }
358
      
359
      public void write(int b) throws IOException
360
      {
361
        if (count < buf.length)
362
        {
363
          buf[count++] = (byte)b;
364
        }
365
        else
366
        {
367
          int readCount = reader.read(characters);
368
          if (readCount > 0)
369
          {
370
            writer.write(characters, 0, readCount);
371
          }
372
          count = 0;
373
          index = 0;
374
          pos = 0;
375
          write(b);
376
        }
377
      }
378
      
379
      public void flush() throws IOException
380
      {
381
        int readCount = reader.read(characters);
382
        if (readCount > 0)
383
        {
384
          writer.write(characters, 0, readCount);
385
        }
386
        count = 0;
387
        index = 0;
388
        pos = 0;
389
      }
390
    }
391
  }
392
393
  /**
394
   * An interface to be implemented by encryption service providers.
395
   * @since 2.2.0
396
   */
397
  interface Cipher
398
  {
399
    /**
400
     * Encrypts the specified output stream.
401
     * @param outputStream
402
     * @return an encrypted output stream
403
     */
404
    OutputStream encrypt(OutputStream outputStream) throws Exception;
405
  
406
    /**
407
     * This method is invoked after the encrypted output stream is used
408
     * allowing the Cipher implementation to do any maintenance work required,
409
     * such as flushing an internal cache.
410
     * @param The encrypted outputStream returned by {@link #encrypt(OutputStream)}.
411
     */
412
    void finish(OutputStream outputStream) throws Exception;
413
  
414
    /**
415
     * Decrypts the specified input stream.
416
     * @param inputStream
417
     * @return a decrypted input stream
418
     */
419
    InputStream decrypt(InputStream inputStream) throws Exception;
420
    
421
    /**
422
     * This method is invoked after the decrypted input stream is used
423
     * allowing the Cipher implementation to do any maintenance work required,
424
     * such as flushing internal cache.
425
     * @param The inputStream returned by {@link #decrypt(InputStream)}.
426
     */
427
    void finish(InputStream inputStream) throws Exception;
428
  }
429
}
(-)src/org/eclipse/emf/ecore/resource/Resource.java (-104 / +104 lines)
Lines 17-25 Link Here
17
package org.eclipse.emf.ecore.resource;
17
package org.eclipse.emf.ecore.resource;
18
18
19
19
20
import java.io.IOException;
20
//import java.io.IOException;
21
import java.io.InputStream;
21
//import java.io.InputStream;
22
import java.io.OutputStream;
22
//import java.io.OutputStream;
23
import java.util.Map;
23
import java.util.Map;
24
24
25
import org.eclipse.emf.common.notify.NotificationChain;
25
import org.eclipse.emf.common.notify.NotificationChain;
Lines 115-131 Link Here
115
   * The {@link #getWarnings} feature {@link org.eclipse.emf.common.notify.Notification#getFeatureID ID}.
115
   * The {@link #getWarnings} feature {@link org.eclipse.emf.common.notify.Notification#getFeatureID ID}.
116
   */
116
   */
117
  int RESOURCE__WARNINGS = 7;
117
  int RESOURCE__WARNINGS = 7;
118
  
118
119
  /**
119
  /**
120
   * Specify a {@link URIConverter.Cipher} to encrypt and decrypt the resource content.
120
   * Specify a {@link URIConverter.Cipher} to encrypt and decrypt the resource content.
121
   */  
121
   */
122
  String OPTION_CIPHER = "CIPHER"; 
122
  String OPTION_CIPHER = "CIPHER";
123
123
124
  /**
124
  /**
125
   * Specify whether the content of the resource should be zipped during save and unzip
125
   * Specify whether the content of the resource should be zipped during save and unzip
126
   * during load.  The default value is <tt>Boolean.FALSE</tt>
126
   * during load.  The default value is <tt>Boolean.FALSE</tt>
127
   */  
127
   */
128
  String OPTION_ZIP = "ZIP"; 
128
  String OPTION_ZIP = "ZIP";
129
129
130
  /**
130
  /**
131
   * Returns the containing resource set.
131
   * Returns the containing resource set.
Lines 220-296 Link Here
220
   */
220
   */
221
  EObject getEObject(String uriFragment);
221
  EObject getEObject(String uriFragment);
222
222
223
  /**
223
//  /**
224
   * Saves the resource using the specified options.
224
//   * Saves the resource using the specified options.
225
   * <p>
225
//   * <p>
226
   * Options are handled generically as feature-to-setting entries;
226
//   * Options are handled generically as feature-to-setting entries;
227
   * the resource will ignore options it doesn't recognize.
227
//   * the resource will ignore options it doesn't recognize.
228
   * The options could even include things like an Eclipse progress monitor...
228
//   * The options could even include things like an Eclipse progress monitor...
229
   * </p>
229
//   * </p>
230
   * <p>
230
//   * <p>
231
   * An implementation typically uses the {@link ResourceSet#getURIConverter URI converter}
231
//   * An implementation typically uses the {@link ResourceSet#getURIConverter URI converter}
232
   * of the {@link #getResourceSet containing} resource set
232
//   * of the {@link #getResourceSet containing} resource set
233
   * to {@link URIConverter#createOutputStream create} an output stream,
233
//   * to {@link URIConverter#createOutputStream create} an output stream,
234
   * and then delegates to {@link #save(OutputStream, Map) save(OutputStream, Map)}.
234
//   * and then delegates to {@link #save(OutputStream, Map) save(OutputStream, Map)}.
235
   * </p>
235
//   * </p>
236
   * @param options the save options.
236
//   * @param options the save options.
237
   * @see #save(OutputStream, Map)
237
//   * @see #save(OutputStream, Map)
238
   */
238
//   */
239
  void save(Map options) throws IOException;
239
//  void save(Map options) throws IOException;
240
240
241
  /**
241
//  /**
242
   * Loads the resource using the specified options.
242
//   * Loads the resource using the specified options.
243
   * <p>
243
//   * <p>
244
   * Options are handled generically as feature-to-setting entries;
244
//   * Options are handled generically as feature-to-setting entries;
245
   * the resource will ignore options it doesn't recognize.
245
//   * the resource will ignore options it doesn't recognize.
246
   * The options could even include things like an Eclipse progress monitor...
246
//   * The options could even include things like an Eclipse progress monitor...
247
   * </p>
247
//   * </p>
248
   * <p>
248
//   * <p>
249
   * An implementation typically uses the {@link ResourceSet#getURIConverter URI converter}
249
//   * An implementation typically uses the {@link ResourceSet#getURIConverter URI converter}
250
   * of the {@link #getResourceSet containing} resource set
250
//   * of the {@link #getResourceSet containing} resource set
251
   * to {@link URIConverter#createInputStream create} an input stream,
251
//   * to {@link URIConverter#createInputStream create} an input stream,
252
   * and then delegates to {@link #load(InputStream, Map) load(InputStream, Map)}.
252
//   * and then delegates to {@link #load(InputStream, Map) load(InputStream, Map)}.
253
   * </p>
253
//   * </p>
254
   * <p>
254
//   * <p>
255
   * When the load completes, the {@link #getErrors errors} and {@link #getWarnings warnings} can be consulted.
255
//   * When the load completes, the {@link #getErrors errors} and {@link #getWarnings warnings} can be consulted.
256
   * An implementation will typically deserialize as much of a document as possible
256
//   * An implementation will typically deserialize as much of a document as possible
257
   * while producing diagnostics for any problems that are encountered.
257
//   * while producing diagnostics for any problems that are encountered.
258
   * </p>
258
//   * </p>
259
   * @param options the load options.
259
//   * @param options the load options.
260
   * @see #load(InputStream, Map)
260
//   * @see #load(InputStream, Map)
261
   */
261
//   */
262
  void load(Map options) throws IOException;
262
//  void load(Map options) throws IOException;
263
263
264
  /**
264
//  /**
265
   * Saves the resource to the output stream using the specified options.
265
//   * Saves the resource to the output stream using the specified options.
266
   * <p>
266
//   * <p>
267
   * Usually, {@link #save(Map) save(Map)} is called directly and it calls this.
267
//   * Usually, {@link #save(Map) save(Map)} is called directly and it calls this.
268
   * </p>
268
//   * </p>
269
   * @param outputStream the stream
269
//   * @param outputStream the stream
270
   * @param options the save options.
270
//   * @param options the save options.
271
   * @see #save(Map)
271
//   * @see #save(Map)
272
   * @see #load(InputStream, Map)
272
//   * @see #load(InputStream, Map)
273
   */
273
//   */
274
  void save(OutputStream outputStream, Map options) throws IOException;
274
//  void save(OutputStream outputStream, Map options) throws IOException;
275
275
//
276
  /**
276
//  /**
277
   * Loads the resource from the input stream using the specified options.
277
//   * Loads the resource from the input stream using the specified options.
278
   * <p>
278
//   * <p>
279
   * Usually, {@link #load(Map) load(Map)} is called directly and it calls this.
279
//   * Usually, {@link #load(Map) load(Map)} is called directly and it calls this.
280
   * </p>
280
//   * </p>
281
   * @param inputStream the stream
281
//   * @param inputStream the stream
282
   * @param options the load options.
282
//   * @param options the load options.
283
   * @see #load(Map)
283
//   * @see #load(Map)
284
   * @see #save(OutputStream, Map)
284
//   * @see #save(OutputStream, Map)
285
   */
285
//   */
286
  void load(InputStream inputStream, Map options) throws IOException;
286
//  void load(InputStream inputStream, Map options) throws IOException;
287
287
288
  /**
288
  /**
289
   * Returns whether modification tracking is enabled.
289
   * Returns whether modification tracking is enabled.
290
   * <p>
290
   * <p>
291
   * If modification tracking is enabled,
291
   * If modification tracking is enabled,
292
   * each object of the resource must be adapted in order to listen for changes.
292
   * each object of the resource must be adapted in order to listen for changes.
293
   * This will make the processing of {@link Resource.Internal#attached attached} 
293
   * This will make the processing of {@link Resource.Internal#attached attached}
294
   * and {@link Resource.Internal#detached detached } significantly more expensive.
294
   * and {@link Resource.Internal#detached detached } significantly more expensive.
295
   * as well as all model editing, in general.
295
   * as well as all model editing, in general.
296
   * </p>
296
   * </p>
Lines 513-519 Link Here
513
       * {@link org.eclipse.emf.ecore.resource.Resource.Factory}
513
       * {@link org.eclipse.emf.ecore.resource.Resource.Factory}
514
       * or {@link org.eclipse.emf.ecore.resource.Resource.Factory.Descriptor}.
514
       * or {@link org.eclipse.emf.ecore.resource.Resource.Factory.Descriptor}.
515
       * <p>
515
       * <p>
516
       * The {@link #DEFAULT_EXTENSION default} file extension <code>"*"</code> 
516
       * The {@link #DEFAULT_EXTENSION default} file extension <code>"*"</code>
517
       * can be registered as a default that matches any file extension.
517
       * can be registered as a default that matches any file extension.
518
       * This is typically reserved for a default factory that supports XMI serialization;
518
       * This is typically reserved for a default factory that supports XMI serialization;
519
       * clients are strongly discouraged from using this feature in the global registry,
519
       * clients are strongly discouraged from using this feature in the global registry,
Lines 536-571 Link Here
536
    }
536
    }
537
  }
537
  }
538
538
539
  /**
539
//  /**
540
   * An IO exception that wraps another exception.
540
//   * An IO exception that wraps another exception.
541
   * <p>
541
//   * <p>
542
   * Since save and load throw an IO Exception,
542
//   * Since save and load throw an IO Exception,
543
   * it may be convenient for an implementation to wrap another exception
543
//   * it may be convenient for an implementation to wrap another exception
544
   * in order to throw it as an IO exception.
544
//   * in order to throw it as an IO exception.
545
   * </p>
545
//   * </p>
546
   */
546
//   */
547
  class IOWrappedException extends IOException
547
//  class IOWrappedException extends IOException
548
  {
548
//  {
549
    /**
549
//    /**
550
     * Creates an instance which wraps the given exception.
550
//     * Creates an instance which wraps the given exception.
551
     * @param exception the exception to wrap.
551
//     * @param exception the exception to wrap.
552
     */
552
//     */
553
    public IOWrappedException(Exception exception)
553
//    public IOWrappedException(Exception exception)
554
    {
554
//    {
555
      super(exception.getLocalizedMessage());
555
//      super(exception.getLocalizedMessage());
556
      initCause(exception);
556
//      initCause(exception);
557
    }
557
//    }
558
558
//
559
    /**
559
//    /**
560
     * Returns the wrapped exception.
560
//     * Returns the wrapped exception.
561
     * @return the wrapped exception.
561
//     * @return the wrapped exception.
562
     * @deprecated in 2.2.  Use {@link #getCause()} instead.  
562
//     * @deprecated in 2.2.  Use {@link #getCause()} instead.
563
     */
563
//     */
564
    public Exception getWrappedException()
564
//    public Exception getWrappedException()
565
    {
565
//    {
566
      return (Exception)getCause();
566
//      return (Exception)getCause();
567
    }
567
//    }
568
  }
568
//  }
569
569
570
  /**
570
  /**
571
   * An internal interface implemented by all resources.
571
   * An internal interface implemented by all resources.
(-)src/org/eclipse/emf/ecore/resource/ResourceSet.java (-34 / +34 lines)
Lines 33-51 Link Here
33
 * A resource set manages a collection of related {@link #getResources resources}
33
 * A resource set manages a collection of related {@link #getResources resources}
34
 * and produces notification for changes to that collection.
34
 * and produces notification for changes to that collection.
35
 * It provides a {@link #getAllContents tree} of contents.
35
 * It provides a {@link #getAllContents tree} of contents.
36
 * A collection of {@link #getAdapterFactories adapter factories} 
36
 * A collection of {@link #getAdapterFactories adapter factories}
37
 * supports {@link org.eclipse.emf.ecore.util.EcoreUtil#getRegisteredAdapter adapter lookup} via registered adapter factory.
37
 * supports {@link org.eclipse.emf.ecore.util.EcoreUtil#getRegisteredAdapter adapter lookup} via registered adapter factory.
38
 * </p>
38
 * </p>
39
 * <p>
39
 * <p>
40
 * A resource can be {@link #createResource created} 
40
 * A resource can be {@link #createResource created}
41
 * or {@link #getResource(URI, boolean) demand loaded}
41
 * or {@link #getResource(URI, boolean) demand loaded}
42
 * into the collection.
42
 * into the collection.
43
 * The {@link #getResourceFactoryRegistry registry} of resource factories can be configured
43
 * The {@link #getResourceFactoryRegistry registry} of resource factories can be configured
44
 * to create resources of the appropriate type.
44
 * to create resources of the appropriate type.
45
 * A proxy can be {@link #getEObject resolved} by the resource set, 
45
 * A proxy can be {@link #getEObject resolved} by the resource set,
46
 * and may cause the demand load of a resource.
46
 * and may cause the demand load of a resource.
47
 * Default {@link #getLoadOptions load options} are used during demand load.
47
 * Default {@link #getLoadOptions load options} are used during demand load.
48
 * A {@link #getURIConverter URI converter} can be configured to 
48
 * A {@link #getURIConverter URI converter} can be configured to
49
 * normalize URIs for comparison and to monitor access to the backing store.
49
 * normalize URIs for comparison and to monitor access to the backing store.
50
 * </p>
50
 * </p>
51
 * @see Resource
51
 * @see Resource
Lines 63-69 Link Here
63
  /**
63
  /**
64
   * Returns the direct {@link Resource}s being managed.
64
   * Returns the direct {@link Resource}s being managed.
65
   * <p>
65
   * <p>
66
   * A resource added to this list 
66
   * A resource added to this list
67
   * will be {@link Resource#getResourceSet contained} by this resource set.
67
   * will be {@link Resource#getResourceSet contained} by this resource set.
68
   * If it was previously contained by a resource set, it will have been removed.
68
   * If it was previously contained by a resource set, it will have been removed.
69
   * </p>
69
   * </p>
Lines 73-80 Link Here
73
  EList getResources();
73
  EList getResources();
74
74
75
  /**
75
  /**
76
   * Returns a tree iterator that iterates over all the {@link #getResources direct resources} 
76
   * Returns a tree iterator that iterates over all the {@link #getResources direct resources}
77
   * and over the content {@link Resource#getAllContents tree} of each. 
77
   * and over the content {@link Resource#getAllContents tree} of each.
78
   * @return a tree iterator that iterates over all contents.
78
   * @return a tree iterator that iterates over all contents.
79
   * @see EObject#eAllContents
79
   * @see EObject#eAllContents
80
   * @see Resource#getAllContents
80
   * @see Resource#getAllContents
Lines 85-97 Link Here
85
  /**
85
  /**
86
   * Returns the list of registered {@link org.eclipse.emf.common.notify.AdapterFactory} instances.
86
   * Returns the list of registered {@link org.eclipse.emf.common.notify.AdapterFactory} instances.
87
   * <p>
87
   * <p>
88
   * One style of adapter {@link org.eclipse.emf.ecore.util.EcoreUtil#getRegisteredAdapter lookup} supported by EMF 
88
   * One style of adapter {@link org.eclipse.emf.ecore.util.EcoreUtil#getRegisteredAdapter lookup} supported by EMF
89
   * is via registered adapter factories.
89
   * is via registered adapter factories.
90
   * Since these factories are accessible to any fully contained object via
90
   * Since these factories are accessible to any fully contained object via
91
   *<pre>
91
   *<pre>
92
   *  eObject.eResource().getResourceSet().getAdapterFactories()
92
   *  eObject.eResource().getResourceSet().getAdapterFactories()
93
   *</pre>
93
   *</pre>
94
   * they can be used to create adapters on demand, 
94
   * they can be used to create adapters on demand,
95
   * without going to the factory first.
95
   * without going to the factory first.
96
   * </p>
96
   * </p>
97
   * @return the list of adapter factories.
97
   * @return the list of adapter factories.
Lines 117-123 Link Here
117
   * Returns the object resolved by the URI.
117
   * Returns the object resolved by the URI.
118
   * <p>
118
   * <p>
119
   * Every object {@link EObject#eResource contained} by a resource (or that is a {@link EObject#eIsProxy proxy})
119
   * Every object {@link EObject#eResource contained} by a resource (or that is a {@link EObject#eIsProxy proxy})
120
   * has a {@link org.eclipse.emf.ecore.util.EcoreUtil#getURI corresponding URI} 
120
   * has a {@link org.eclipse.emf.ecore.util.EcoreUtil#getURI corresponding URI}
121
   * that resolves to the object.
121
   * that resolves to the object.
122
   * So for any object contained by a resource, the following is <code>true</code>.
122
   * So for any object contained by a resource, the following is <code>true</code>.
123
   *<pre>
123
   *<pre>
Lines 144-171 Link Here
144
  /**
144
  /**
145
   * Returns the resource resolved by the URI.
145
   * Returns the resource resolved by the URI.
146
   * <p>
146
   * <p>
147
   * A resource set is expected to implement the following strategy 
147
   * A resource set is expected to implement the following strategy
148
   * in order to resolve the given URI to a resource.
148
   * in order to resolve the given URI to a resource.
149
   * First it uses it's {@link #getURIConverter URI converter} to {@link URIConverter#normalize normalize} the URI 
149
   * First it uses it's {@link #getURIConverter URI converter} to {@link URIConverter#normalize normalize} the URI
150
   * and then to compare it with the normalized URI of each resource;
150
   * and then to compare it with the normalized URI of each resource;
151
   * if it finds a match, 
151
   * if it finds a match,
152
   * that resource becomes the result.
152
   * that resource becomes the result.
153
   * Failing that,
153
   * Failing that,
154
   * it {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#delegatedGetResource delegates} 
154
   * it {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#delegatedGetResource delegates}
155
   * to allow the URI to be resolved elsewhere.
155
   * to allow the URI to be resolved elsewhere.
156
   * For example, 
156
   * For example,
157
   * the {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE package registry}
157
   * the {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE package registry}
158
   * is used to {@link org.eclipse.emf.ecore.EPackage.Registry#getEPackage resolve} 
158
   * is used to {@link org.eclipse.emf.ecore.EPackage.Registry#getEPackage resolve}
159
   * the {@link org.eclipse.emf.ecore.EPackage namespace URI} of a package
159
   * the {@link org.eclipse.emf.ecore.EPackage namespace URI} of a package
160
   * to the static instance of that package.
160
   * to the static instance of that package.
161
   * So the important point is that an arbitrary implementation may resolve the URI to any resource,
161
   * So the important point is that an arbitrary implementation may resolve the URI to any resource,
162
   * not necessarily to one contained by this particular resource set.
162
   * not necessarily to one contained by this particular resource set.
163
   * If the delegation step fails to provide a result,
163
   * If the delegation step fails to provide a result,
164
   * and if <code>loadOnDemand</code> is <code>true</code>,
164
   * and if <code>loadOnDemand</code> is <code>true</code>,
165
   * a resource is {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandCreateResource created} 
165
   * a resource is {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandCreateResource created}
166
   * and that resource becomes the result.
166
   * and that resource becomes the result.
167
   * If <code>loadOnDemand</code> is <code>true</code>
167
   * If <code>loadOnDemand</code> is <code>true</code>
168
   * and the result resource is not {@link Resource#isLoaded loaded}, 
168
   * and the result resource is not {@link Resource#isLoaded loaded},
169
   * it will be {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandLoad loaded} before it is returned.
169
   * it will be {@link org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandLoad loaded} before it is returned.
170
   * </p>
170
   * </p>
171
   * @param uri the URI to resolve.
171
   * @param uri the URI to resolve.
Lines 179-185 Link Here
179
  /**
179
  /**
180
   * Creates a new resource, of the appropriate type, and returns it.
180
   * Creates a new resource, of the appropriate type, and returns it.
181
   * <p>
181
   * <p>
182
   * It delegates to the resource factory {@link #getResourceFactoryRegistry registry} 
182
   * It delegates to the resource factory {@link #getResourceFactoryRegistry registry}
183
   * to determine the {@link Resource.Factory.Registry#getFactory correct} factory,
183
   * to determine the {@link Resource.Factory.Registry#getFactory correct} factory,
184
   * and then it uses that factory to {@link Resource.Factory#createResource create} the resource
184
   * and then it uses that factory to {@link Resource.Factory#createResource create} the resource
185
   * and add it to the {@link #getResources contents}.
185
   * and add it to the {@link #getResources contents}.
Lines 211-231 Link Here
211
   */
211
   */
212
  void setResourceFactoryRegistry(Resource.Factory.Registry resourceFactoryRegistry);
212
  void setResourceFactoryRegistry(Resource.Factory.Registry resourceFactoryRegistry);
213
213
214
  /**
214
//  /**
215
   * Returns the converter used to normalize URIs and to open streams.
215
//   * Returns the converter used to normalize URIs and to open streams.
216
   * @return the URI converter.
216
//   * @return the URI converter.
217
   * @see URIConverter
217
//   * @see URIConverter
218
   * @see URI
218
//   * @see URI
219
   */
219
//   */
220
  URIConverter getURIConverter();
220
//  URIConverter getURIConverter();
221
221
222
  /**
222
//  /**
223
   * Sets the converter used to normalize URIs and to open streams.
223
//   * Sets the converter used to normalize URIs and to open streams.
224
   * @param converter the new converter.
224
//   * @param converter the new converter.
225
   * @see URIConverter
225
//   * @see URIConverter
226
   * @see URI
226
//   * @see URI
227
   */
227
//   */
228
  void setURIConverter(URIConverter converter);
228
//  void setURIConverter(URIConverter converter);
229
229
230
  /**
230
  /**
231
   * Returns the registry used for looking up a package based namespace.
231
   * Returns the registry used for looking up a package based namespace.
(-)src/org/eclipse/emf/ecore/xml/namespace/impl/XMLNamespacePackageImpl.java (-499 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespacePackageImpl.java,v 1.11 2005/12/02 18:07:47 davidms Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace.impl;
18
19
20
import org.eclipse.emf.ecore.EAttribute;
21
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EDataType;
23
import org.eclipse.emf.ecore.EEnum;
24
import org.eclipse.emf.ecore.EPackage;
25
import org.eclipse.emf.ecore.EReference;
26
import org.eclipse.emf.ecore.EValidator;
27
import org.eclipse.emf.ecore.impl.EPackageImpl;
28
import org.eclipse.emf.ecore.xml.namespace.SpaceType;
29
import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot;
30
import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory;
31
import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage;
32
import org.eclipse.emf.ecore.xml.namespace.util.XMLNamespaceValidator;
33
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
34
35
36
/**
37
 * <!-- begin-user-doc -->
38
 * An implementation of the model <b>Package</b>.
39
 * <!-- end-user-doc -->
40
 * @generated
41
 */
42
public class XMLNamespacePackageImpl extends EPackageImpl implements XMLNamespacePackage
43
{
44
  /**
45
   * <!-- begin-user-doc -->
46
   * <!-- end-user-doc -->
47
   * @generated
48
   */
49
  private EClass xmlNamespaceDocumentRootEClass = null;
50
51
  /**
52
   * <!-- begin-user-doc -->
53
   * <!-- end-user-doc -->
54
   * @generated
55
   */
56
  private EEnum spaceTypeEEnum = null;
57
58
  /**
59
   * <!-- begin-user-doc -->
60
   * <!-- end-user-doc -->
61
   * @generated
62
   */
63
  private EDataType langTypeEDataType = null;
64
65
  /**
66
   * <!-- begin-user-doc -->
67
   * <!-- end-user-doc -->
68
   * @generated
69
   */
70
  private EDataType langTypeNullEDataType = null;
71
72
  /**
73
   * <!-- begin-user-doc -->
74
   * <!-- end-user-doc -->
75
   * @generated
76
   */
77
  private EDataType spaceTypeObjectEDataType = null;
78
79
  /**
80
   * Creates an instance of the model <b>Package</b>, registered with
81
   * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
82
   * package URI value.
83
   * <p>Note: the correct way to create the package is via the static
84
   * factory method {@link #init init()}, which also performs
85
   * initialization of the package, or returns the registered package,
86
   * if one already exists.
87
   * <!-- begin-user-doc -->
88
   * <!-- end-user-doc -->
89
   * @see org.eclipse.emf.ecore.EPackage.Registry
90
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#eNS_URI
91
   * @see #init()
92
   * @generated
93
   */
94
  private XMLNamespacePackageImpl()
95
  {
96
    super(eNS_URI, XMLNamespaceFactory.eINSTANCE);
97
  }
98
99
  /**
100
   * <!-- begin-user-doc -->
101
   * <!-- end-user-doc -->
102
   * @generated
103
   */
104
  private static boolean isInited = false;
105
106
  /**
107
   * Creates, registers, and initializes the <b>Package</b> for this
108
   * model, and for any others upon which it depends.  Simple
109
   * dependencies are satisfied by calling this method on all
110
   * dependent packages before doing anything else.  This method drives
111
   * initialization for interdependent packages directly, in parallel
112
   * with this package, itself.
113
   * <p>Of this package and its interdependencies, all packages which
114
   * have not yet been registered by their URI values are first created
115
   * and registered.  The packages are then initialized in two steps:
116
   * meta-model objects for all of the packages are created before any
117
   * are initialized, since one package's meta-model objects may refer to
118
   * those of another.
119
   * <p>Invocation of this method will not affect any packages that have
120
   * already been initialized.
121
   * <!-- begin-user-doc -->
122
   * <!-- end-user-doc -->
123
   * @see #eNS_URI
124
   * @see #createPackageContents()
125
   * @see #initializePackageContents()
126
   * @generated
127
   */
128
  public static XMLNamespacePackage init()
129
  {
130
    if (isInited) return (XMLNamespacePackage)EPackage.Registry.INSTANCE.getEPackage(XMLNamespacePackage.eNS_URI);
131
132
    // Obtain or create and register package
133
    XMLNamespacePackageImpl theXMLNamespacePackage = (XMLNamespacePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof XMLNamespacePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new XMLNamespacePackageImpl());
134
135
    isInited = true;
136
137
    // Initialize simple dependencies
138
    XMLTypePackage.eINSTANCE.eClass();
139
140
    // Create package meta-data objects
141
    theXMLNamespacePackage.createPackageContents();
142
143
    // Initialize created meta-data
144
    theXMLNamespacePackage.initializePackageContents();
145
146
    // Register package validator
147
    EValidator.Registry.INSTANCE.put
148
      (theXMLNamespacePackage, 
149
       new EValidator.Descriptor()
150
       {
151
         public EValidator getEValidator()
152
         {
153
           return XMLNamespaceValidator.INSTANCE;
154
         }
155
       });
156
157
    // Mark meta-data to indicate it can't be changed
158
    theXMLNamespacePackage.freeze();
159
160
    return theXMLNamespacePackage;
161
  }
162
163
  /**
164
   * <!-- begin-user-doc -->
165
   * <!-- end-user-doc -->
166
   * @generated
167
   */
168
  public EClass getXMLNamespaceDocumentRoot()
169
  {
170
    return xmlNamespaceDocumentRootEClass;
171
  }
172
173
  /**
174
   * <!-- begin-user-doc -->
175
   * <!-- end-user-doc -->
176
   * @generated
177
   */
178
  public EAttribute getXMLNamespaceDocumentRoot_Mixed()
179
  {
180
    return (EAttribute)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(0);
181
  }
182
183
  /**
184
   * <!-- begin-user-doc -->
185
   * <!-- end-user-doc -->
186
   * @generated
187
   */
188
  public EReference getXMLNamespaceDocumentRoot_XMLNSPrefixMap()
189
  {
190
    return (EReference)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(1);
191
  }
192
193
  /**
194
   * <!-- begin-user-doc -->
195
   * <!-- end-user-doc -->
196
   * @generated
197
   */
198
  public EReference getXMLNamespaceDocumentRoot_XSISchemaLocation()
199
  {
200
    return (EReference)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(2);
201
  }
202
203
  /**
204
   * <!-- begin-user-doc -->
205
   * <!-- end-user-doc -->
206
   * @generated
207
   */
208
  public EAttribute getXMLNamespaceDocumentRoot_Base()
209
  {
210
    return (EAttribute)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(3);
211
  }
212
213
  /**
214
   * <!-- begin-user-doc -->
215
   * <!-- end-user-doc -->
216
   * @generated
217
   */
218
  public EAttribute getXMLNamespaceDocumentRoot_Id()
219
  {
220
    return (EAttribute)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(4);
221
  }
222
223
  /**
224
   * <!-- begin-user-doc -->
225
   * <!-- end-user-doc -->
226
   * @generated
227
   */
228
  public EAttribute getXMLNamespaceDocumentRoot_Lang()
229
  {
230
    return (EAttribute)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(5);
231
  }
232
233
  /**
234
   * <!-- begin-user-doc -->
235
   * <!-- end-user-doc -->
236
   * @generated
237
   */
238
  public EAttribute getXMLNamespaceDocumentRoot_Space()
239
  {
240
    return (EAttribute)xmlNamespaceDocumentRootEClass.getEStructuralFeatures().get(6);
241
  }
242
243
  /**
244
   * <!-- begin-user-doc -->
245
   * <!-- end-user-doc -->
246
   * @generated
247
   */
248
  public EEnum getSpaceType()
249
  {
250
    return spaceTypeEEnum;
251
  }
252
253
  /**
254
   * <!-- begin-user-doc -->
255
   * <!-- end-user-doc -->
256
   * @generated
257
   */
258
  public EDataType getLangType()
259
  {
260
    return langTypeEDataType;
261
  }
262
263
  /**
264
   * <!-- begin-user-doc -->
265
   * <!-- end-user-doc -->
266
   * @generated
267
   */
268
  public EDataType getLangTypeNull()
269
  {
270
    return langTypeNullEDataType;
271
  }
272
273
  /**
274
   * <!-- begin-user-doc -->
275
   * <!-- end-user-doc -->
276
   * @generated
277
   */
278
  public EDataType getSpaceTypeObject()
279
  {
280
    return spaceTypeObjectEDataType;
281
  }
282
283
  /**
284
   * <!-- begin-user-doc -->
285
   * <!-- end-user-doc -->
286
   * @generated
287
   */
288
  public XMLNamespaceFactory getXMLNamespaceFactory()
289
  {
290
    return (XMLNamespaceFactory)getEFactoryInstance();
291
  }
292
293
  /**
294
   * <!-- begin-user-doc -->
295
   * <!-- end-user-doc -->
296
   * @generated
297
   */
298
  private boolean isCreated = false;
299
300
  /**
301
   * Creates the meta-model objects for the package.  This method is
302
   * guarded to have no affect on any invocation but its first.
303
   * <!-- begin-user-doc -->
304
   * <!-- end-user-doc -->
305
   * @generated
306
   */
307
  public void createPackageContents()
308
  {
309
    if (isCreated) return;
310
    isCreated = true;
311
312
    // Create classes and their features
313
    xmlNamespaceDocumentRootEClass = createEClass(XML_NAMESPACE_DOCUMENT_ROOT);
314
    createEAttribute(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__MIXED);
315
    createEReference(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
316
    createEReference(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
317
    createEAttribute(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__BASE);
318
    createEAttribute(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__ID);
319
    createEAttribute(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__LANG);
320
    createEAttribute(xmlNamespaceDocumentRootEClass, XML_NAMESPACE_DOCUMENT_ROOT__SPACE);
321
322
    // Create enums
323
    spaceTypeEEnum = createEEnum(SPACE_TYPE);
324
325
    // Create data types
326
    langTypeEDataType = createEDataType(LANG_TYPE);
327
    langTypeNullEDataType = createEDataType(LANG_TYPE_NULL);
328
    spaceTypeObjectEDataType = createEDataType(SPACE_TYPE_OBJECT);
329
  }
330
331
  /**
332
   * <!-- begin-user-doc -->
333
   * <!-- end-user-doc -->
334
   * @generated
335
   */
336
  private boolean isInitialized = false;
337
338
  /**
339
   * Complete the initialization of the package and its meta-model.  This
340
   * method is guarded to have no affect on any invocation but its first.
341
   * <!-- begin-user-doc -->
342
   * <!-- end-user-doc -->
343
   * @generated
344
   */
345
  public void initializePackageContents()
346
  {
347
    if (isInitialized) return;
348
    isInitialized = true;
349
350
    // Initialize package
351
    setName(eNAME);
352
    setNsPrefix(eNS_PREFIX);
353
    setNsURI(eNS_URI);
354
355
    // Obtain other dependent packages
356
    XMLTypePackage theXMLTypePackage = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI);
357
358
    // Add supertypes to classes
359
360
    // Initialize classes and features; add operations and parameters
361
    initEClass(xmlNamespaceDocumentRootEClass, XMLNamespaceDocumentRoot.class, "XMLNamespaceDocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
362
    initEAttribute(getXMLNamespaceDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
363
    initEReference(getXMLNamespaceDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
364
    initEReference(getXMLNamespaceDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
365
    initEAttribute(getXMLNamespaceDocumentRoot_Base(), theXMLTypePackage.getAnyURI(), "base", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
366
    initEAttribute(getXMLNamespaceDocumentRoot_Id(), theXMLTypePackage.getID(), "id", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
367
    initEAttribute(getXMLNamespaceDocumentRoot_Lang(), this.getLangType(), "lang", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
368
    initEAttribute(getXMLNamespaceDocumentRoot_Space(), this.getSpaceType(), "space", "preserve", 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
369
370
    // Initialize enums and add enum literals
371
    initEEnum(spaceTypeEEnum, SpaceType.class, "SpaceType");
372
    addEEnumLiteral(spaceTypeEEnum, SpaceType.DEFAULT_LITERAL);
373
    addEEnumLiteral(spaceTypeEEnum, SpaceType.PRESERVE_LITERAL);
374
375
    // Initialize data types
376
    initEDataType(langTypeEDataType, String.class, "LangType", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
377
    initEDataType(langTypeNullEDataType, String.class, "LangTypeNull", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
378
    initEDataType(spaceTypeObjectEDataType, SpaceType.class, "SpaceTypeObject", IS_SERIALIZABLE, IS_GENERATED_INSTANCE_CLASS);
379
380
    // Create resource
381
    createResource(eNS_URI);
382
383
    // Create annotations
384
    // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
385
    createExtendedMetaDataAnnotations();
386
  }
387
388
  /**
389
   * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
390
   * <!-- begin-user-doc -->
391
   * <!-- end-user-doc -->
392
   * @generated
393
   */
394
  protected void createExtendedMetaDataAnnotations()
395
  {
396
    String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";		
397
    addAnnotation
398
      (langTypeEDataType, 
399
       source, 
400
       new String[] 
401
       {
402
       "name", "lang_._1_._type",
403
       "memberTypes", "http://www.eclipse.org/emf/2003/XMLType#language lang_._1_._type_._member_._1"
404
       });		
405
    addAnnotation
406
      (langTypeNullEDataType, 
407
       source, 
408
       new String[] 
409
       {
410
       "name", "lang_._1_._type_._member_._1",
411
       "baseType", "http://www.eclipse.org/emf/2003/XMLType#string",
412
       "enumeration", ""
413
       });		
414
    addAnnotation
415
      (spaceTypeEEnum, 
416
       source, 
417
       new String[] 
418
       {
419
       "name", "space_._type"
420
       });		
421
    addAnnotation
422
      (spaceTypeObjectEDataType, 
423
       source, 
424
       new String[] 
425
       {
426
       "name", "space_._type:Object",
427
       "baseType", "space_._type"
428
       });		
429
    addAnnotation
430
      (xmlNamespaceDocumentRootEClass, 
431
       source, 
432
       new String[] 
433
       {
434
       "name", "",
435
       "kind", "mixed"
436
       });		
437
    addAnnotation
438
      (getXMLNamespaceDocumentRoot_Mixed(), 
439
       source, 
440
       new String[] 
441
       {
442
       "kind", "elementWildcard",
443
       "name", ":mixed"
444
       });		
445
    addAnnotation
446
      (getXMLNamespaceDocumentRoot_XMLNSPrefixMap(), 
447
       source, 
448
       new String[] 
449
       {
450
       "kind", "attribute",
451
       "name", "xmlns:prefix"
452
       });		
453
    addAnnotation
454
      (getXMLNamespaceDocumentRoot_XSISchemaLocation(), 
455
       source, 
456
       new String[] 
457
       {
458
       "kind", "attribute",
459
       "name", "xsi:schemaLocation"
460
       });		
461
    addAnnotation
462
      (getXMLNamespaceDocumentRoot_Base(), 
463
       source, 
464
       new String[] 
465
       {
466
       "kind", "attribute",
467
       "name", "base",
468
       "namespace", "##targetNamespace"
469
       });		
470
    addAnnotation
471
      (getXMLNamespaceDocumentRoot_Id(), 
472
       source, 
473
       new String[] 
474
       {
475
       "kind", "attribute",
476
       "name", "id",
477
       "namespace", "##targetNamespace"
478
       });		
479
    addAnnotation
480
      (getXMLNamespaceDocumentRoot_Lang(), 
481
       source, 
482
       new String[] 
483
       {
484
       "kind", "attribute",
485
       "name", "lang",
486
       "namespace", "##targetNamespace"
487
       });		
488
    addAnnotation
489
      (getXMLNamespaceDocumentRoot_Space(), 
490
       source, 
491
       new String[] 
492
       {
493
       "kind", "attribute",
494
       "name", "space",
495
       "namespace", "##targetNamespace"
496
       });
497
  }
498
499
} //XMLNamespacePackageImpl
(-)src/org/eclipse/emf/ecore/xml/namespace/impl/XMLNamespaceFactoryImpl.java (-301 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespaceFactoryImpl.java,v 1.9 2005/11/23 18:10:02 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace.impl;
18
19
20
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.EDataType;
22
import org.eclipse.emf.ecore.EObject;
23
import org.eclipse.emf.ecore.EPackage;
24
25
import org.eclipse.emf.ecore.impl.EFactoryImpl;
26
import org.eclipse.emf.ecore.plugin.EcorePlugin;
27
28
import org.eclipse.emf.ecore.util.Diagnostician;
29
import org.eclipse.emf.ecore.xml.namespace.*;
30
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
31
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
32
33
34
/**
35
 * <!-- begin-user-doc -->
36
 * An implementation of the model <b>Factory</b>.
37
 * <!-- end-user-doc -->
38
 * @generated
39
 */
40
public class XMLNamespaceFactoryImpl extends EFactoryImpl implements XMLNamespaceFactory
41
{
42
  /**
43
   * Creates the default factory implementation.
44
   * <!-- begin-user-doc -->
45
   * <!-- end-user-doc -->
46
   * @generated
47
   */
48
  public static XMLNamespaceFactory init()
49
  {
50
    try
51
    {
52
      XMLNamespaceFactory theXMLNamespaceFactory = (XMLNamespaceFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.w3.org/XML/1998/namespace"); 
53
      if (theXMLNamespaceFactory != null)
54
      {
55
        return theXMLNamespaceFactory;
56
      }
57
    }
58
    catch (Exception exception)
59
    {
60
      EcorePlugin.INSTANCE.log(exception);
61
    }
62
    return new XMLNamespaceFactoryImpl();
63
  }
64
65
  /**
66
   * Creates an instance of the factory.
67
   * <!-- begin-user-doc -->
68
   * <!-- end-user-doc -->
69
   * @generated
70
   */
71
  public XMLNamespaceFactoryImpl()
72
  {
73
    super();
74
  }
75
76
  /**
77
   * <!-- begin-user-doc -->
78
   * <!-- end-user-doc -->
79
   * @generated
80
   */
81
  public EObject create(EClass eClass)
82
  {
83
    switch (eClass.getClassifierID())
84
    {
85
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT: return createXMLNamespaceDocumentRoot();
86
      default:
87
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
88
    }
89
  }
90
91
  /**
92
   * <!-- begin-user-doc -->
93
   * <!-- end-user-doc -->
94
   * @generated
95
   */
96
  public Object createFromString(EDataType eDataType, String initialValue)
97
  {
98
    switch (eDataType.getClassifierID())
99
    {
100
      case XMLNamespacePackage.SPACE_TYPE:
101
        return createSpaceTypeFromString(eDataType, initialValue);
102
      case XMLNamespacePackage.LANG_TYPE:
103
        return createLangTypeFromString(eDataType, initialValue);
104
      case XMLNamespacePackage.LANG_TYPE_NULL:
105
        return createLangTypeNullFromString(eDataType, initialValue);
106
      case XMLNamespacePackage.SPACE_TYPE_OBJECT:
107
        return createSpaceTypeObjectFromString(eDataType, initialValue);
108
      default:
109
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
110
    }
111
  }
112
113
  /**
114
   * <!-- begin-user-doc -->
115
   * <!-- end-user-doc -->
116
   * @generated
117
   */
118
  public String convertToString(EDataType eDataType, Object instanceValue)
119
  {
120
    switch (eDataType.getClassifierID())
121
    {
122
      case XMLNamespacePackage.SPACE_TYPE:
123
        return convertSpaceTypeToString(eDataType, instanceValue);
124
      case XMLNamespacePackage.LANG_TYPE:
125
        return convertLangTypeToString(eDataType, instanceValue);
126
      case XMLNamespacePackage.LANG_TYPE_NULL:
127
        return convertLangTypeNullToString(eDataType, instanceValue);
128
      case XMLNamespacePackage.SPACE_TYPE_OBJECT:
129
        return convertSpaceTypeObjectToString(eDataType, instanceValue);
130
      default:
131
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
132
    }
133
  }
134
135
  /**
136
   * <!-- begin-user-doc -->
137
   * <!-- end-user-doc -->
138
   * @generated
139
   */
140
  public XMLNamespaceDocumentRoot createXMLNamespaceDocumentRoot()
141
  {
142
    XMLNamespaceDocumentRootImpl xmlNamespaceDocumentRoot = new XMLNamespaceDocumentRootImpl();
143
    return xmlNamespaceDocumentRoot;
144
  }
145
146
  /**
147
   * <!-- begin-user-doc -->
148
   * <!-- end-user-doc -->
149
   * @generated
150
   */
151
  public SpaceType createSpaceTypeFromString(EDataType eDataType, String initialValue)
152
  {
153
    SpaceType result = SpaceType.get(initialValue);
154
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
155
    return result;
156
  }
157
158
  /**
159
   * <!-- begin-user-doc -->
160
   * <!-- end-user-doc -->
161
   * @generated
162
   */
163
  public String convertSpaceTypeToString(EDataType eDataType, Object instanceValue)
164
  {
165
    return instanceValue == null ? null : instanceValue.toString();
166
  }
167
168
  /**
169
   * <!-- begin-user-doc -->
170
   * <!-- end-user-doc -->
171
   * @generated
172
   */
173
  public String createLangTypeFromString(EDataType eDataType, String initialValue)
174
  {
175
    if (initialValue == null) return null;
176
    String result = null;
177
    RuntimeException exception = null;
178
    try
179
    {
180
      result = (String)XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.Literals.LANGUAGE, initialValue);
181
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null))
182
      {
183
        return result;
184
      }
185
    }
186
    catch (RuntimeException e)
187
    {
188
      exception = e;
189
    }
190
    try
191
    {
192
      result = (String)createLangTypeNullFromString(XMLNamespacePackage.Literals.LANG_TYPE_NULL, initialValue);
193
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null))
194
      {
195
        return result;
196
      }
197
    }
198
    catch (RuntimeException e)
199
    {
200
      exception = e;
201
    }
202
    if (result != null || exception == null) return result;
203
    
204
    throw exception;
205
  }
206
207
  /**
208
   * <!-- begin-user-doc -->
209
   * <!-- end-user-doc -->
210
   * @generated
211
   */
212
  public String convertLangTypeToString(EDataType eDataType, Object instanceValue)
213
  {
214
    if (instanceValue == null) return null;
215
    if (XMLTypePackage.Literals.LANGUAGE.isInstance(instanceValue))
216
    {
217
      try
218
      {
219
        String value = XMLTypeFactory.eINSTANCE.convertToString(XMLTypePackage.Literals.LANGUAGE, instanceValue);
220
        if (value != null) return value;
221
      }
222
      catch (Exception e)
223
      {
224
      }
225
    }
226
    if (XMLNamespacePackage.Literals.LANG_TYPE_NULL.isInstance(instanceValue))
227
    {
228
      try
229
      {
230
        String value = convertLangTypeNullToString(XMLNamespacePackage.Literals.LANG_TYPE_NULL, instanceValue);
231
        if (value != null) return value;
232
      }
233
      catch (Exception e)
234
      {
235
      }
236
    }
237
    throw new IllegalArgumentException("Invalid value: '"+instanceValue+"' for datatype :"+eDataType.getName());
238
  }
239
240
  /**
241
   * <!-- begin-user-doc -->
242
   * <!-- end-user-doc -->
243
   * @generated
244
   */
245
  public String createLangTypeNullFromString(EDataType eDataType, String initialValue)
246
  {
247
    return (String)XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.Literals.STRING, initialValue);
248
  }
249
250
  /**
251
   * <!-- begin-user-doc -->
252
   * <!-- end-user-doc -->
253
   * @generated
254
   */
255
  public String convertLangTypeNullToString(EDataType eDataType, Object instanceValue)
256
  {
257
    return XMLTypeFactory.eINSTANCE.convertToString(XMLTypePackage.Literals.STRING, instanceValue);
258
  }
259
260
  /**
261
   * <!-- begin-user-doc -->
262
   * <!-- end-user-doc -->
263
   * @generated
264
   */
265
  public SpaceType createSpaceTypeObjectFromString(EDataType eDataType, String initialValue)
266
  {
267
    return (SpaceType)createSpaceTypeFromString(XMLNamespacePackage.Literals.SPACE_TYPE, initialValue);
268
  }
269
270
  /**
271
   * <!-- begin-user-doc -->
272
   * <!-- end-user-doc -->
273
   * @generated
274
   */
275
  public String convertSpaceTypeObjectToString(EDataType eDataType, Object instanceValue)
276
  {
277
    return convertSpaceTypeToString(XMLNamespacePackage.Literals.SPACE_TYPE, instanceValue);
278
  }
279
280
  /**
281
   * <!-- begin-user-doc -->
282
   * <!-- end-user-doc -->
283
   * @generated
284
   */
285
  public XMLNamespacePackage getXMLNamespacePackage()
286
  {
287
    return (XMLNamespacePackage)getEPackage();
288
  }
289
290
  /**
291
   * <!-- begin-user-doc -->
292
   * <!-- end-user-doc -->
293
   * @deprecated
294
   * @generated
295
   */
296
  public static XMLNamespacePackage getPackage()
297
  {
298
    return XMLNamespacePackage.eINSTANCE;
299
  }
300
301
} //XMLNamespaceFactoryImpl
(-)src/org/eclipse/emf/ecore/xml/namespace/impl/XMLNamespaceDocumentRootImpl.java (-528 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespaceDocumentRootImpl.java,v 1.9 2005/11/25 17:49:48 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace.impl;
18
19
20
import org.eclipse.emf.common.notify.Notification;
21
import org.eclipse.emf.common.notify.NotificationChain;
22
import org.eclipse.emf.common.util.EMap;
23
import org.eclipse.emf.ecore.EClass;
24
import org.eclipse.emf.ecore.EStructuralFeature;
25
import org.eclipse.emf.ecore.EcorePackage;
26
import org.eclipse.emf.ecore.InternalEObject;
27
import org.eclipse.emf.ecore.impl.ENotificationImpl;
28
import org.eclipse.emf.ecore.impl.EObjectImpl;
29
import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
30
import org.eclipse.emf.ecore.util.BasicFeatureMap;
31
import org.eclipse.emf.ecore.util.EcoreEMap;
32
import org.eclipse.emf.ecore.util.FeatureMap;
33
import org.eclipse.emf.ecore.util.InternalEList;
34
import org.eclipse.emf.ecore.xml.namespace.SpaceType;
35
import org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot;
36
import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage;
37
38
39
/**
40
 * <!-- begin-user-doc -->
41
 * An implementation of the model object '<em><b>Document Root</b></em>'.
42
 * <!-- end-user-doc -->
43
 * <p>
44
 * The following features are implemented:
45
 * <ul>
46
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getMixed <em>Mixed</em>}</li>
47
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}</li>
48
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getXSISchemaLocation <em>XSI Schema Location</em>}</li>
49
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getBase <em>Base</em>}</li>
50
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getId <em>Id</em>}</li>
51
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getLang <em>Lang</em>}</li>
52
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl#getSpace <em>Space</em>}</li>
53
 * </ul>
54
 * </p>
55
 *
56
 * @generated
57
 */
58
public class XMLNamespaceDocumentRootImpl extends EObjectImpl implements XMLNamespaceDocumentRoot
59
{
60
  /**
61
   * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
62
   * <!-- begin-user-doc -->
63
   * <!-- end-user-doc -->
64
   * @see #getMixed()
65
   * @generated
66
   * @ordered
67
   */
68
  protected FeatureMap mixed = null;
69
70
  /**
71
   * The cached value of the '{@link #getXMLNSPrefixMap() <em>XMLNS Prefix Map</em>}' map.
72
   * <!-- begin-user-doc -->
73
   * <!-- end-user-doc -->
74
   * @see #getXMLNSPrefixMap()
75
   * @generated
76
   * @ordered
77
   */
78
  protected EMap xMLNSPrefixMap = null;
79
80
  /**
81
   * The cached value of the '{@link #getXSISchemaLocation() <em>XSI Schema Location</em>}' map.
82
   * <!-- begin-user-doc -->
83
   * <!-- end-user-doc -->
84
   * @see #getXSISchemaLocation()
85
   * @generated
86
   * @ordered
87
   */
88
  protected EMap xSISchemaLocation = null;
89
90
  /**
91
   * The default value of the '{@link #getBase() <em>Base</em>}' attribute.
92
   * <!-- begin-user-doc -->
93
   * <!-- end-user-doc -->
94
   * @see #getBase()
95
   * @generated
96
   * @ordered
97
   */
98
  protected static final String BASE_EDEFAULT = null;
99
100
  /**
101
   * The cached value of the '{@link #getBase() <em>Base</em>}' attribute.
102
   * <!-- begin-user-doc -->
103
   * <!-- end-user-doc -->
104
   * @see #getBase()
105
   * @generated
106
   * @ordered
107
   */
108
  protected String base = BASE_EDEFAULT;
109
110
  /**
111
   * The default value of the '{@link #getId() <em>Id</em>}' attribute.
112
   * <!-- begin-user-doc -->
113
   * <!-- end-user-doc -->
114
   * @see #getId()
115
   * @generated
116
   * @ordered
117
   */
118
  protected static final String ID_EDEFAULT = null;
119
120
  /**
121
   * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
122
   * <!-- begin-user-doc -->
123
   * <!-- end-user-doc -->
124
   * @see #getId()
125
   * @generated
126
   * @ordered
127
   */
128
  protected String id = ID_EDEFAULT;
129
130
  /**
131
   * The default value of the '{@link #getLang() <em>Lang</em>}' attribute.
132
   * <!-- begin-user-doc -->
133
   * <!-- end-user-doc -->
134
   * @see #getLang()
135
   * @generated
136
   * @ordered
137
   */
138
  protected static final String LANG_EDEFAULT = null;
139
140
  /**
141
   * The cached value of the '{@link #getLang() <em>Lang</em>}' attribute.
142
   * <!-- begin-user-doc -->
143
   * <!-- end-user-doc -->
144
   * @see #getLang()
145
   * @generated
146
   * @ordered
147
   */
148
  protected String lang = LANG_EDEFAULT;
149
150
  /**
151
   * The default value of the '{@link #getSpace() <em>Space</em>}' attribute.
152
   * <!-- begin-user-doc -->
153
   * <!-- end-user-doc -->
154
   * @see #getSpace()
155
   * @generated
156
   * @ordered
157
   */
158
  protected static final SpaceType SPACE_EDEFAULT = SpaceType.PRESERVE_LITERAL;
159
160
  /**
161
   * The cached value of the '{@link #getSpace() <em>Space</em>}' attribute.
162
   * <!-- begin-user-doc -->
163
   * <!-- end-user-doc -->
164
   * @see #getSpace()
165
   * @generated
166
   * @ordered
167
   */
168
  protected SpaceType space = SPACE_EDEFAULT;
169
170
  /**
171
   * This is true if the Space attribute has been set.
172
   * <!-- begin-user-doc -->
173
   * <!-- end-user-doc -->
174
   * @generated
175
   * @ordered
176
   */
177
  protected boolean spaceESet = false;
178
179
  /**
180
   * <!-- begin-user-doc -->
181
   * <!-- end-user-doc -->
182
   * @generated
183
   */
184
  protected XMLNamespaceDocumentRootImpl()
185
  {
186
    super();
187
  }
188
189
  /**
190
   * <!-- begin-user-doc -->
191
   * <!-- end-user-doc -->
192
   * @generated
193
   */
194
  protected EClass eStaticClass()
195
  {
196
    return XMLNamespacePackage.Literals.XML_NAMESPACE_DOCUMENT_ROOT;
197
  }
198
199
  /**
200
   * <!-- begin-user-doc -->
201
   * <!-- end-user-doc -->
202
   * @generated
203
   */
204
  public FeatureMap getMixed()
205
  {
206
    if (mixed == null)
207
    {
208
      mixed = new BasicFeatureMap(this, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED);
209
    }
210
    return mixed;
211
  }
212
213
  /**
214
   * <!-- begin-user-doc -->
215
   * <!-- end-user-doc -->
216
   * @generated
217
   */
218
  public EMap getXMLNSPrefixMap()
219
  {
220
    if (xMLNSPrefixMap == null)
221
    {
222
      xMLNSPrefixMap = new EcoreEMap(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
223
    }
224
    return xMLNSPrefixMap;
225
  }
226
227
  /**
228
   * <!-- begin-user-doc -->
229
   * <!-- end-user-doc -->
230
   * @generated
231
   */
232
  public EMap getXSISchemaLocation()
233
  {
234
    if (xSISchemaLocation == null)
235
    {
236
      xSISchemaLocation = new EcoreEMap(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
237
    }
238
    return xSISchemaLocation;
239
  }
240
241
  /**
242
   * <!-- begin-user-doc -->
243
   * <!-- end-user-doc -->
244
   * @generated
245
   */
246
  public String getBase()
247
  {
248
    return base;
249
  }
250
251
  /**
252
   * <!-- begin-user-doc -->
253
   * <!-- end-user-doc -->
254
   * @generated
255
   */
256
  public void setBase(String newBase)
257
  {
258
    String oldBase = base;
259
    base = newBase;
260
    if (eNotificationRequired())
261
      eNotify(new ENotificationImpl(this, Notification.SET, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__BASE, oldBase, base));
262
  }
263
264
  /**
265
   * <!-- begin-user-doc -->
266
   * <!-- end-user-doc -->
267
   * @generated
268
   */
269
  public String getId()
270
  {
271
    return id;
272
  }
273
274
  /**
275
   * <!-- begin-user-doc -->
276
   * <!-- end-user-doc -->
277
   * @generated
278
   */
279
  public void setId(String newId)
280
  {
281
    String oldId = id;
282
    id = newId;
283
    if (eNotificationRequired())
284
      eNotify(new ENotificationImpl(this, Notification.SET, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__ID, oldId, id));
285
  }
286
287
  /**
288
   * <!-- begin-user-doc -->
289
   * <!-- end-user-doc -->
290
   * @generated
291
   */
292
  public String getLang()
293
  {
294
    return lang;
295
  }
296
297
  /**
298
   * <!-- begin-user-doc -->
299
   * <!-- end-user-doc -->
300
   * @generated
301
   */
302
  public void setLang(String newLang)
303
  {
304
    String oldLang = lang;
305
    lang = newLang;
306
    if (eNotificationRequired())
307
      eNotify(new ENotificationImpl(this, Notification.SET, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__LANG, oldLang, lang));
308
  }
309
310
  /**
311
   * <!-- begin-user-doc -->
312
   * <!-- end-user-doc -->
313
   * @generated
314
   */
315
  public SpaceType getSpace()
316
  {
317
    return space;
318
  }
319
320
  /**
321
   * <!-- begin-user-doc -->
322
   * <!-- end-user-doc -->
323
   * @generated
324
   */
325
  public void setSpace(SpaceType newSpace)
326
  {
327
    SpaceType oldSpace = space;
328
    space = newSpace == null ? SPACE_EDEFAULT : newSpace;
329
    boolean oldSpaceESet = spaceESet;
330
    spaceESet = true;
331
    if (eNotificationRequired())
332
      eNotify(new ENotificationImpl(this, Notification.SET, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE, oldSpace, space, !oldSpaceESet));
333
  }
334
335
  /**
336
   * <!-- begin-user-doc -->
337
   * <!-- end-user-doc -->
338
   * @generated
339
   */
340
  public void unsetSpace()
341
  {
342
    SpaceType oldSpace = space;
343
    boolean oldSpaceESet = spaceESet;
344
    space = SPACE_EDEFAULT;
345
    spaceESet = false;
346
    if (eNotificationRequired())
347
      eNotify(new ENotificationImpl(this, Notification.UNSET, XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE, oldSpace, SPACE_EDEFAULT, oldSpaceESet));
348
  }
349
350
  /**
351
   * <!-- begin-user-doc -->
352
   * <!-- end-user-doc -->
353
   * @generated
354
   */
355
  public boolean isSetSpace()
356
  {
357
    return spaceESet;
358
  }
359
360
  /**
361
   * <!-- begin-user-doc -->
362
   * <!-- end-user-doc -->
363
   * @generated
364
   */
365
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
366
  {
367
    switch (featureID)
368
    {
369
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED:
370
        return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs);
371
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
372
        return ((InternalEList)getXMLNSPrefixMap()).basicRemove(otherEnd, msgs);
373
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
374
        return ((InternalEList)getXSISchemaLocation()).basicRemove(otherEnd, msgs);
375
    }
376
    return eDynamicInverseRemove(otherEnd, featureID, msgs);
377
  }
378
379
  /**
380
   * <!-- begin-user-doc -->
381
   * <!-- end-user-doc -->
382
   * @generated
383
   */
384
  public Object eGet(int featureID, boolean resolve, boolean coreType)
385
  {
386
    switch (featureID)
387
    {
388
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED:
389
        if (coreType) return getMixed();
390
        return ((FeatureMap.Internal)getMixed()).getWrapper();
391
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
392
        if (coreType) return getXMLNSPrefixMap();
393
        else return getXMLNSPrefixMap().map();
394
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
395
        if (coreType) return getXSISchemaLocation();
396
        else return getXSISchemaLocation().map();
397
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__BASE:
398
        return getBase();
399
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__ID:
400
        return getId();
401
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__LANG:
402
        return getLang();
403
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE:
404
        return getSpace();
405
    }
406
    return eDynamicGet(featureID, resolve, coreType);
407
  }
408
409
  /**
410
   * <!-- begin-user-doc -->
411
   * <!-- end-user-doc -->
412
   * @generated
413
   */
414
  public void eSet(int featureID, Object newValue)
415
  {
416
    switch (featureID)
417
    {
418
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED:
419
        ((FeatureMap.Internal)getMixed()).set(newValue);
420
        return;
421
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
422
        ((EStructuralFeature.Setting)getXMLNSPrefixMap()).set(newValue);
423
        return;
424
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
425
        ((EStructuralFeature.Setting)getXSISchemaLocation()).set(newValue);
426
        return;
427
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__BASE:
428
        setBase((String)newValue);
429
        return;
430
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__ID:
431
        setId((String)newValue);
432
        return;
433
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__LANG:
434
        setLang((String)newValue);
435
        return;
436
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE:
437
        setSpace((SpaceType)newValue);
438
        return;
439
    }
440
    eDynamicSet(featureID, newValue);
441
  }
442
443
  /**
444
   * <!-- begin-user-doc -->
445
   * <!-- end-user-doc -->
446
   * @generated
447
   */
448
  public void eUnset(int featureID)
449
  {
450
    switch (featureID)
451
    {
452
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED:
453
        getMixed().clear();
454
        return;
455
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
456
        getXMLNSPrefixMap().clear();
457
        return;
458
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
459
        getXSISchemaLocation().clear();
460
        return;
461
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__BASE:
462
        setBase(BASE_EDEFAULT);
463
        return;
464
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__ID:
465
        setId(ID_EDEFAULT);
466
        return;
467
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__LANG:
468
        setLang(LANG_EDEFAULT);
469
        return;
470
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE:
471
        unsetSpace();
472
        return;
473
    }
474
    eDynamicUnset(featureID);
475
  }
476
477
  /**
478
   * <!-- begin-user-doc -->
479
   * <!-- end-user-doc -->
480
   * @generated
481
   */
482
  public boolean eIsSet(int featureID)
483
  {
484
    switch (featureID)
485
    {
486
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__MIXED:
487
        return mixed != null && !mixed.isEmpty();
488
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
489
        return xMLNSPrefixMap != null && !xMLNSPrefixMap.isEmpty();
490
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
491
        return xSISchemaLocation != null && !xSISchemaLocation.isEmpty();
492
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__BASE:
493
        return BASE_EDEFAULT == null ? base != null : !BASE_EDEFAULT.equals(base);
494
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__ID:
495
        return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
496
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__LANG:
497
        return LANG_EDEFAULT == null ? lang != null : !LANG_EDEFAULT.equals(lang);
498
      case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT__SPACE:
499
        return isSetSpace();
500
    }
501
    return eDynamicIsSet(featureID);
502
  }
503
504
  /**
505
   * <!-- begin-user-doc -->
506
   * <!-- end-user-doc -->
507
   * @generated
508
   */
509
  public String toString()
510
  {
511
    if (eIsProxy()) return super.toString();
512
513
    StringBuffer result = new StringBuffer(super.toString());
514
    result.append(" (mixed: ");
515
    result.append(mixed);
516
    result.append(", base: ");
517
    result.append(base);
518
    result.append(", id: ");
519
    result.append(id);
520
    result.append(", lang: ");
521
    result.append(lang);
522
    result.append(", space: ");
523
    if (spaceESet) result.append(space); else result.append("<unset>");
524
    result.append(')');
525
    return result.toString();
526
  }
527
528
} //XMLNamespaceDocumentRootImpl
(-)src/org/eclipse/emf/ecore/xml/type/impl/XMLTypeFactoryImpl.java (-2894 / +674 lines)
Lines 1-2906 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2006 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypeFactoryImpl.java,v 1.23 2006/03/20 20:11:47 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.impl;
1
package org.eclipse.emf.ecore.xml.type.impl;
18
2
19
import java.math.BigDecimal;
3
//import java.math.BigDecimal;
20
import java.math.BigInteger;
4
//import java.math.BigInteger;
21
import java.text.DateFormat;
22
import java.text.FieldPosition;
23
import java.text.ParseException;
24
import java.text.SimpleDateFormat;
25
import java.util.ArrayList;
26
import java.util.Date;
27
import java.util.Iterator;
28
import java.util.List;
5
import java.util.List;
29
import java.util.StringTokenizer;
30
6
7
import org.eclipse.emf.common.notify.Notification;
8
import org.eclipse.emf.common.util.EList;
9
import org.eclipse.emf.common.util.TreeIterator;
10
import org.eclipse.emf.ecore.EAnnotation;
31
import org.eclipse.emf.ecore.EClass;
11
import org.eclipse.emf.ecore.EClass;
32
import org.eclipse.emf.ecore.EDataType;
12
import org.eclipse.emf.ecore.EDataType;
33
import org.eclipse.emf.ecore.EObject;
13
import org.eclipse.emf.ecore.EObject;
34
import org.eclipse.emf.ecore.EPackage;
14
import org.eclipse.emf.ecore.EPackage;
15
import org.eclipse.emf.ecore.EReference;
16
import org.eclipse.emf.ecore.EStructuralFeature;
17
import org.eclipse.emf.ecore.resource.Resource;
18
import org.eclipse.emf.ecore.xml.type.AnyType;
19
import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
20
import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
21
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
22
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
23
24
public class XMLTypeFactoryImpl implements XMLTypeFactory {
25
26
	public static XMLTypeFactory init() {
27
		// TODO Auto-generated method stub
28
		return null;
29
	}
30
31
	public String convertAnySimpleType(Object instanceValue) {
32
		// TODO Auto-generated method stub
33
		return null;
34
	}
35
36
	public String convertAnyURI(String instanceValue) {
37
		// TODO Auto-generated method stub
38
		return null;
39
	}
40
41
	public String convertBase64Binary(byte[] instanceValue) {
42
		// TODO Auto-generated method stub
43
		return null;
44
	}
45
46
	public String convertBoolean(boolean instanceValue) {
47
		// TODO Auto-generated method stub
48
		return null;
49
	}
50
51
	public String convertBooleanObject(Boolean instanceValue) {
52
		// TODO Auto-generated method stub
53
		return null;
54
	}
55
56
	public String convertByte(byte instanceValue) {
57
		// TODO Auto-generated method stub
58
		return null;
59
	}
60
61
	public String convertByteObject(Byte instanceValue) {
62
		// TODO Auto-generated method stub
63
		return null;
64
	}
65
66
	public String convertDate(Object instanceValue) {
67
		// TODO Auto-generated method stub
68
		return null;
69
	}
70
71
	public String convertDateTime(Object instanceValue) {
72
		// TODO Auto-generated method stub
73
		return null;
74
	}
75
76
	public String convertDouble(double instanceValue) {
77
		// TODO Auto-generated method stub
78
		return null;
79
	}
80
81
	public String convertDoubleObject(Double instanceValue) {
82
		// TODO Auto-generated method stub
83
		return null;
84
	}
85
86
	public String convertDuration(Object instanceValue) {
87
		// TODO Auto-generated method stub
88
		return null;
89
	}
90
91
	public String convertENTITIES(List instanceValue) {
92
		// TODO Auto-generated method stub
93
		return null;
94
	}
95
96
	public String convertENTITIESBase(List instanceValue) {
97
		// TODO Auto-generated method stub
98
		return null;
99
	}
100
101
	public String convertENTITY(String instanceValue) {
102
		// TODO Auto-generated method stub
103
		return null;
104
	}
105
106
	public String convertFloat(float instanceValue) {
107
		// TODO Auto-generated method stub
108
		return null;
109
	}
110
111
	public String convertFloatObject(Float instanceValue) {
112
		// TODO Auto-generated method stub
113
		return null;
114
	}
115
116
	public String convertGDay(Object instanceValue) {
117
		// TODO Auto-generated method stub
118
		return null;
119
	}
120
121
	public String convertGMonth(Object instanceValue) {
122
		// TODO Auto-generated method stub
123
		return null;
124
	}
125
126
	public String convertGMonthDay(Object instanceValue) {
127
		// TODO Auto-generated method stub
128
		return null;
129
	}
130
131
	public String convertGYear(Object instanceValue) {
132
		// TODO Auto-generated method stub
133
		return null;
134
	}
135
136
	public String convertGYearMonth(Object instanceValue) {
137
		// TODO Auto-generated method stub
138
		return null;
139
	}
140
141
	public String convertHexBinary(byte[] instanceValue) {
142
		// TODO Auto-generated method stub
143
		return null;
144
	}
145
146
	public String convertID(String instanceValue) {
147
		// TODO Auto-generated method stub
148
		return null;
149
	}
150
151
	public String convertIDREF(String instanceValue) {
152
		// TODO Auto-generated method stub
153
		return null;
154
	}
155
156
	public String convertIDREFS(List instanceValue) {
157
		// TODO Auto-generated method stub
158
		return null;
159
	}
160
161
	public String convertIDREFSBase(List instanceValue) {
162
		// TODO Auto-generated method stub
163
		return null;
164
	}
165
166
	public String convertInt(int instanceValue) {
167
		// TODO Auto-generated method stub
168
		return null;
169
	}
170
171
	public String convertIntObject(Integer instanceValue) {
172
		// TODO Auto-generated method stub
173
		return null;
174
	}
175
176
	public String convertLanguage(String instanceValue) {
177
		// TODO Auto-generated method stub
178
		return null;
179
	}
180
181
	public String convertLong(long instanceValue) {
182
		// TODO Auto-generated method stub
183
		return null;
184
	}
185
186
	public String convertLongObject(Long instanceValue) {
187
		// TODO Auto-generated method stub
188
		return null;
189
	}
190
191
	public String convertNCName(String instanceValue) {
192
		// TODO Auto-generated method stub
193
		return null;
194
	}
195
196
	public String convertNMTOKEN(String instanceValue) {
197
		// TODO Auto-generated method stub
198
		return null;
199
	}
200
201
	public String convertNMTOKENS(List instanceValue) {
202
		// TODO Auto-generated method stub
203
		return null;
204
	}
205
206
	public String convertNMTOKENSBase(List instanceValue) {
207
		// TODO Auto-generated method stub
208
		return null;
209
	}
210
211
	public String convertNOTATION(Object instanceValue) {
212
		// TODO Auto-generated method stub
213
		return null;
214
	}
215
216
	public String convertName(String instanceValue) {
217
		// TODO Auto-generated method stub
218
		return null;
219
	}
220
221
	public String convertNormalizedString(String instanceValue) {
222
		// TODO Auto-generated method stub
223
		return null;
224
	}
225
226
	public String convertQName(Object instanceValue) {
227
		// TODO Auto-generated method stub
228
		return null;
229
	}
230
231
	public String convertShort(short instanceValue) {
232
		// TODO Auto-generated method stub
233
		return null;
234
	}
235
236
	public String convertShortObject(Short instanceValue) {
237
		// TODO Auto-generated method stub
238
		return null;
239
	}
240
241
	public String convertString(String instanceValue) {
242
		// TODO Auto-generated method stub
243
		return null;
244
	}
245
246
	public String convertTime(Object instanceValue) {
247
		// TODO Auto-generated method stub
248
		return null;
249
	}
250
251
	public String convertToken(String instanceValue) {
252
		// TODO Auto-generated method stub
253
		return null;
254
	}
255
256
	public String convertUnsignedByte(short instanceValue) {
257
		// TODO Auto-generated method stub
258
		return null;
259
	}
260
261
	public String convertUnsignedByteObject(Short instanceValue) {
262
		// TODO Auto-generated method stub
263
		return null;
264
	}
265
266
	public String convertUnsignedInt(long instanceValue) {
267
		// TODO Auto-generated method stub
268
		return null;
269
	}
270
271
	public String convertUnsignedIntObject(Long instanceValue) {
272
		// TODO Auto-generated method stub
273
		return null;
274
	}
275
276
	public String convertUnsignedShort(int instanceValue) {
277
		// TODO Auto-generated method stub
278
		return null;
279
	}
280
281
	public String convertUnsignedShortObject(Integer instanceValue) {
282
		// TODO Auto-generated method stub
283
		return null;
284
	}
285
286
	public Object createAnySimpleType(String literal) {
287
		// TODO Auto-generated method stub
288
		return null;
289
	}
290
291
	public AnyType createAnyType() {
292
		// TODO Auto-generated method stub
293
		return null;
294
	}
295
296
	public String createAnyURI(String literal) {
297
		// TODO Auto-generated method stub
298
		return null;
299
	}
300
301
	public byte[] createBase64Binary(String literal) {
302
		// TODO Auto-generated method stub
303
		return null;
304
	}
305
306
	public boolean createBoolean(String literal) {
307
		// TODO Auto-generated method stub
308
		return false;
309
	}
310
311
	public Boolean createBooleanObject(String literal) {
312
		// TODO Auto-generated method stub
313
		return null;
314
	}
315
316
	public byte createByte(String literal) {
317
		// TODO Auto-generated method stub
318
		return 0;
319
	}
320
321
	public Byte createByteObject(String literal) {
322
		// TODO Auto-generated method stub
323
		return null;
324
	}
325
326
	public Object createDate(String literal) {
327
		// TODO Auto-generated method stub
328
		return null;
329
	}
330
331
	public Object createDateTime(String literal) {
332
		// TODO Auto-generated method stub
333
		return null;
334
	}
335
336
	public double createDouble(String literal) {
337
		// TODO Auto-generated method stub
338
		return 0;
339
	}
340
341
	public Double createDoubleObject(String literal) {
342
		// TODO Auto-generated method stub
343
		return null;
344
	}
345
346
	public Object createDuration(String literal) {
347
		// TODO Auto-generated method stub
348
		return null;
349
	}
350
351
	public List createENTITIES(String literal) {
352
		// TODO Auto-generated method stub
353
		return null;
354
	}
355
356
	public List createENTITIESBase(String literal) {
357
		// TODO Auto-generated method stub
358
		return null;
359
	}
360
361
	public String createENTITY(String literal) {
362
		// TODO Auto-generated method stub
363
		return null;
364
	}
365
366
	public float createFloat(String literal) {
367
		// TODO Auto-generated method stub
368
		return 0;
369
	}
370
371
	public Float createFloatObject(String literal) {
372
		// TODO Auto-generated method stub
373
		return null;
374
	}
375
376
	public Object createGDay(String literal) {
377
		// TODO Auto-generated method stub
378
		return null;
379
	}
380
381
	public Object createGMonth(String literal) {
382
		// TODO Auto-generated method stub
383
		return null;
384
	}
385
386
	public Object createGMonthDay(String literal) {
387
		// TODO Auto-generated method stub
388
		return null;
389
	}
390
391
	public Object createGYear(String literal) {
392
		// TODO Auto-generated method stub
393
		return null;
394
	}
395
396
	public Object createGYearMonth(String literal) {
397
		// TODO Auto-generated method stub
398
		return null;
399
	}
400
401
	public byte[] createHexBinary(String literal) {
402
		// TODO Auto-generated method stub
403
		return null;
404
	}
405
406
	public String createID(String literal) {
407
		// TODO Auto-generated method stub
408
		return null;
409
	}
410
411
	public String createIDREF(String literal) {
412
		// TODO Auto-generated method stub
413
		return null;
414
	}
415
416
	public List createIDREFS(String literal) {
417
		// TODO Auto-generated method stub
418
		return null;
419
	}
420
421
	public List createIDREFSBase(String literal) {
422
		// TODO Auto-generated method stub
423
		return null;
424
	}
425
426
	public int createInt(String literal) {
427
		// TODO Auto-generated method stub
428
		return 0;
429
	}
430
431
	public Integer createIntObject(String literal) {
432
		// TODO Auto-generated method stub
433
		return null;
434
	}
435
436
	public String createLanguage(String literal) {
437
		// TODO Auto-generated method stub
438
		return null;
439
	}
440
441
	public long createLong(String literal) {
442
		// TODO Auto-generated method stub
443
		return 0;
444
	}
445
446
	public Long createLongObject(String literal) {
447
		// TODO Auto-generated method stub
448
		return null;
449
	}
450
451
	public String createNCName(String literal) {
452
		// TODO Auto-generated method stub
453
		return null;
454
	}
455
456
	public String createNMTOKEN(String literal) {
457
		// TODO Auto-generated method stub
458
		return null;
459
	}
460
461
	public List createNMTOKENS(String literal) {
462
		// TODO Auto-generated method stub
463
		return null;
464
	}
465
466
	public List createNMTOKENSBase(String literal) {
467
		// TODO Auto-generated method stub
468
		return null;
469
	}
470
471
	public Object createNOTATION(String literal) {
472
		// TODO Auto-generated method stub
473
		return null;
474
	}
475
476
	public String createName(String literal) {
477
		// TODO Auto-generated method stub
478
		return null;
479
	}
480
481
	public String createNormalizedString(String literal) {
482
		// TODO Auto-generated method stub
483
		return null;
484
	}
485
486
	public Object createQName(String literal) {
487
		// TODO Auto-generated method stub
488
		return null;
489
	}
490
491
	public short createShort(String literal) {
492
		// TODO Auto-generated method stub
493
		return 0;
494
	}
495
496
	public Short createShortObject(String literal) {
497
		// TODO Auto-generated method stub
498
		return null;
499
	}
500
501
	public SimpleAnyType createSimpleAnyType() {
502
		// TODO Auto-generated method stub
503
		return null;
504
	}
505
506
	public String createString(String literal) {
507
		// TODO Auto-generated method stub
508
		return null;
509
	}
510
511
	public Object createTime(String literal) {
512
		// TODO Auto-generated method stub
513
		return null;
514
	}
515
516
	public String createToken(String literal) {
517
		// TODO Auto-generated method stub
518
		return null;
519
	}
520
521
	public short createUnsignedByte(String literal) {
522
		// TODO Auto-generated method stub
523
		return 0;
524
	}
525
526
	public Short createUnsignedByteObject(String literal) {
527
		// TODO Auto-generated method stub
528
		return null;
529
	}
530
531
	public long createUnsignedInt(String literal) {
532
		// TODO Auto-generated method stub
533
		return 0;
534
	}
535
536
	public Long createUnsignedIntObject(String literal) {
537
		// TODO Auto-generated method stub
538
		return null;
539
	}
540
541
	public int createUnsignedShort(String literal) {
542
		// TODO Auto-generated method stub
543
		return 0;
544
	}
545
546
	public Integer createUnsignedShortObject(String literal) {
547
		// TODO Auto-generated method stub
548
		return null;
549
	}
550
551
	public XMLTypeDocumentRoot createXMLTypeDocumentRoot() {
552
		// TODO Auto-generated method stub
553
		return null;
554
	}
555
556
	public XMLTypePackage getXMLTypePackage() {
557
		// TODO Auto-generated method stub
558
		return null;
559
	}
560
561
	public String convertToString(EDataType dataType, Object instanceValue) {
562
		// TODO Auto-generated method stub
563
		return null;
564
	}
565
566
	public EObject create(EClass class1) {
567
		// TODO Auto-generated method stub
568
		return null;
569
	}
570
571
	public Object createFromString(EDataType dataType, String literalValue) {
572
		// TODO Auto-generated method stub
573
		return null;
574
	}
575
576
	public EPackage getEPackage() {
577
		// TODO Auto-generated method stub
578
		return null;
579
	}
580
581
	public void setEPackage(EPackage value) {
582
		// TODO Auto-generated method stub
583
584
	}
585
586
	public EAnnotation getEAnnotation(String source) {
587
		// TODO Auto-generated method stub
588
		return null;
589
	}
590
591
	public EList getEAnnotations() {
592
		// TODO Auto-generated method stub
593
		return null;
594
	}
595
596
	public TreeIterator eAllContents() {
597
		// TODO Auto-generated method stub
598
		return null;
599
	}
600
601
	public EClass eClass() {
602
		// TODO Auto-generated method stub
603
		return null;
604
	}
605
606
	public EObject eContainer() {
607
		// TODO Auto-generated method stub
608
		return null;
609
	}
610
611
	public EStructuralFeature eContainingFeature() {
612
		// TODO Auto-generated method stub
613
		return null;
614
	}
615
616
	public EReference eContainmentFeature() {
617
		// TODO Auto-generated method stub
618
		return null;
619
	}
620
621
	public EList eContents() {
622
		// TODO Auto-generated method stub
623
		return null;
624
	}
625
626
	public EList eCrossReferences() {
627
		// TODO Auto-generated method stub
628
		return null;
629
	}
630
631
	public Object eGet(EStructuralFeature feature) {
632
		// TODO Auto-generated method stub
633
		return null;
634
	}
635
636
	public Object eGet(EStructuralFeature feature, boolean resolve) {
637
		// TODO Auto-generated method stub
638
		return null;
639
	}
640
641
	public boolean eIsProxy() {
642
		// TODO Auto-generated method stub
643
		return false;
644
	}
645
646
	public boolean eIsSet(EStructuralFeature feature) {
647
		// TODO Auto-generated method stub
648
		return false;
649
	}
650
651
	public Resource eResource() {
652
		// TODO Auto-generated method stub
653
		return null;
654
	}
655
656
	public void eSet(EStructuralFeature feature, Object newValue) {
657
		// TODO Auto-generated method stub
658
659
	}
660
661
	public void eUnset(EStructuralFeature feature) {
662
		// TODO Auto-generated method stub
663
664
	}
665
666
	public EList eAdapters() {
667
		// TODO Auto-generated method stub
668
		return null;
669
	}
670
671
	public boolean eDeliver() {
672
		// TODO Auto-generated method stub
673
		return false;
674
	}
675
676
	public void eNotify(Notification notification) {
677
		// TODO Auto-generated method stub
35
678
36
import org.eclipse.emf.ecore.impl.EFactoryImpl;
679
	}
37
import org.eclipse.emf.ecore.plugin.EcorePlugin;
38
680
39
import org.eclipse.emf.ecore.xml.type.*;
681
	public void eSetDeliver(boolean deliver) {
40
import org.eclipse.emf.ecore.xml.type.internal.QName;
682
		// TODO Auto-generated method stub
41
import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar;
42
import org.eclipse.emf.ecore.xml.type.internal.XMLDuration;
43
import org.eclipse.emf.ecore.xml.type.internal.DataValue.Base64;
44
import org.eclipse.emf.ecore.xml.type.internal.DataValue.HexBin;
45
46
/**
47
 * <!-- begin-user-doc -->
48
 * An implementation of the model <b>Factory</b>.
49
 * <!-- end-user-doc -->
50
 * @generated
51
 */
52
public class XMLTypeFactoryImpl extends EFactoryImpl implements XMLTypeFactory
53
{
54
  /**
55
   * <!-- begin-user-doc -->
56
   * <!-- end-user-doc -->
57
   * @generated NOT
58
   */
59
  public Object createAnySimpleType(String literal)
60
  {
61
    return literal;
62
  }
63
64
  /**
65
   * <!-- begin-user-doc -->
66
   * <!-- end-user-doc -->
67
   * @generated NOT
68
   */
69
  public String convertAnySimpleType(Object instanceValue)
70
  {
71
    return instanceValue == null ? null : instanceValue.toString();
72
  }
73
74
  /**
75
   * <!-- begin-user-doc -->
76
   * <!-- end-user-doc -->
77
   * @generated NOT 
78
   */
79
  public String createAnyURI(String literal)
80
  {
81
    // Per Schema 1.0 it is not clear if the result returned should be a valid URI. 
82
    // For the future if we plant to surport IRIs then it is better not to massage
83
    // the initialValue. 
84
    // We should thought consider where would be the best way to validate anyURI values -- EL
85
    
86
    /*initialValue = collapseWhiteSpace(initialValue);
87
    if (initialValue != null)
88
    {
89
      //encode special characters using XLink 5.4 algorithm
90
      initialValue = URI.encode(initialValue);
91
      // Support for relative URLs
92
      // According to Java 1.1: URLs may also be specified with a
93
      // String and the URL object that it is related to.
94
      try 
95
      {
96
        new URI(URI.BASE_URI, initialValue);
97
      }
98
      catch (URI.MalformedURIException e)
99
      {
100
        throw new InvalidDatatypeValueException("Invalid anyURI value: '"+initialValue+"' :"+e.toString());
101
      }
102
    }*/
103
    return literal;
104
  }
105
106
  /**
107
   * <!-- begin-user-doc -->
108
   * <!-- end-user-doc -->
109
   * @generated NOT
110
   */
111
  public String convertAnyURI(String instanceValue)
112
  {
113
    return instanceValue;
114
  }
115
116
  /**
117
   * <!-- begin-user-doc -->
118
   * <!-- end-user-doc -->
119
   * @generated NOT
120
   */
121
  public byte[] createBase64Binary(String literal)
122
  {
123
    if (literal == null) return null;
124
    byte[] value = Base64.decode(collapseWhiteSpace(literal));
125
    if (value == null)
126
    {
127
      throw new InvalidDatatypeValueException("Invalid base64Binary value: '" + literal + "'");
128
    }
129
    return value;
130
  }
131
132
  /**
133
   * <!-- begin-user-doc -->
134
   * <!-- end-user-doc -->
135
   * @generated NOT
136
   */
137
  public String convertBase64Binary(byte[] instanceValue)
138
  {
139
    return instanceValue == null ? null : Base64.encode(instanceValue);
140
  }
141
142
  /**
143
   * <!-- begin-user-doc -->
144
   * <!-- end-user-doc -->
145
   * @generated NOT
146
   */
147
  public boolean createBoolean(String initialValue)
148
  {
149
    return initialValue == null ? false : primitiveBooleanValueOf(initialValue);	
150
  }
151
152
  /**
153
   * <!-- begin-user-doc -->
154
   * <!-- end-user-doc -->
155
   * @generated NOT
156
   */
157
  public String convertBoolean(boolean instanceValue)
158
  {
159
    return instanceValue ? "true" : "false";
160
  }	
161
    
162
  /**
163
   * <!-- begin-user-doc -->
164
   * <!-- end-user-doc -->
165
   * @generated NOT
166
   */
167
  public Boolean createBooleanObject(String literal)
168
  {
169
    return literal == null ? null : booleanValueOf(literal);
170
  }
171
172
  /**
173
   * <!-- begin-user-doc -->
174
   * <!-- end-user-doc -->
175
   * @generated NOT
176
   */
177
  public String convertBooleanObject(Boolean instanceValue)
178
  {
179
    return instanceValue == null ? null : convertBoolean(instanceValue.booleanValue());
180
  }
181
182
  /**
183
   * <!-- begin-user-doc -->
184
   * <!-- end-user-doc -->
185
   * @generated NOT
186
   */
187
  public byte createByte(String literal)
188
  {
189
    return literal == null ? 0 : Byte.parseByte(collapseWhiteSpace(literal));
190
  }
191
  
192
  /**
193
   * <!-- begin-user-doc -->
194
   * <!-- end-user-doc -->
195
   * @generated NOT
196
   */
197
  public String convertByte(byte instanceValue)
198
  {
199
    return Byte.toString(instanceValue);
200
  }
201
    
202
  /**
203
   * <!-- begin-user-doc -->
204
   * <!-- end-user-doc -->
205
   * @generated NOT
206
   */
207
  public Byte createByteObject(String literal)
208
  {
209
    return literal == null ? null : Byte.valueOf(collapseWhiteSpace(literal));
210
  }
211
212
  /**
213
   * <!-- begin-user-doc -->
214
   * <!-- end-user-doc -->
215
   * @generated NOT
216
   */
217
  public String convertByteObject(Byte instanceValue)
218
  {
219
    return instanceValue == null ? null : instanceValue.toString();
220
  }
221
222
  /**
223
   * <!-- begin-user-doc -->
224
   * <!-- end-user-doc -->
225
   * @generated NOT
226
   */
227
  public Object createDate(String literal)
228
  {
229
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.DATE);
230
  }
231
232
  /**
233
   * <!-- begin-user-doc -->
234
   * <!-- end-user-doc -->
235
   * @generated NOT
236
   */
237
  public String convertDate(Object instanceValue)
238
  {
239
    if (instanceValue == null)
240
    {
241
      return null;
242
    }
243
    if (instanceValue instanceof Date)
244
    {
245
      // Bug 124306: we should rely on XMLCalendar to normalize Dave value, to ensure that all Date value
246
      // fields are taken into account.
247
      return new XMLCalendar((Date)instanceValue, XMLCalendar.DATE).toString();
248
    }
249
    return instanceValue.toString();
250
  }
251
252
  /**
253
   * <!-- begin-user-doc -->
254
   * <!-- end-user-doc -->
255
   * @generated NOT
256
   */
257
  public Object createDateTime(String literal)
258
  {
259
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.DATETIME);
260
  }
261
262
  /**
263
   * <!-- begin-user-doc -->
264
   * <!-- end-user-doc -->
265
   * @generated NOT
266
   */
267
  public String convertDateTime(Object instanceValue)
268
  {
269
    if (instanceValue == null)
270
    {
271
      return null;
272
    }
273
    if (instanceValue instanceof Date)
274
    {
275
      return EDATE_FORMATS[0].format((Date)instanceValue);
276
    }
277
    return instanceValue.toString();
278
  }
279
280
  /**
281
   * <!-- begin-user-doc -->
282
   * <!-- end-user-doc -->
283
   * @generated NOT
284
   */
285
  public BigDecimal createDecimal(String literal)
286
  {
287
    return literal == null ? null : new BigDecimal(collapseWhiteSpace(literal));
288
  }
289
290
  /**
291
   * <!-- begin-user-doc -->
292
   * <!-- end-user-doc -->
293
   * @generated NOT
294
   */
295
  public String convertDecimal(BigDecimal instanceValue)
296
  {
297
    return instanceValue == null ? null : instanceValue.toString();
298
  }
299
300
  /**
301
   * <!-- begin-user-doc -->
302
   * <!-- end-user-doc -->
303
   * @generated NOT
304
   */
305
  public double createDouble(String literal)
306
  {
307
    return literal == null ? 0.0 : Double.parseDouble(collapseWhiteSpace(literal));
308
  }
309
  
310
  /**
311
   * <!-- begin-user-doc -->
312
   * <!-- end-user-doc -->
313
   * @generated NOT
314
   */
315
  public String convertDouble(double instanceValue)
316
  {
317
    return Double.toString(instanceValue);
318
  }	
319
    
320
  /**
321
   * <!-- begin-user-doc -->
322
   * <!-- end-user-doc -->
323
   * @generated NOT
324
   */
325
  public Double createDoubleObject(String literal)
326
  {
327
    return literal == null ? null : Double.valueOf(collapseWhiteSpace(literal));
328
  }
329
330
  /**
331
   * <!-- begin-user-doc -->
332
   * <!-- end-user-doc -->
333
   * @generated NOT
334
   */
335
  public String convertDoubleObject(Double instanceValue)
336
  {
337
    return instanceValue == null ? null : instanceValue.toString();
338
  }
339
340
  /**
341
   * <!-- begin-user-doc -->
342
   * <!-- end-user-doc -->
343
   * @generated NOT
344
   */
345
  public Object createDuration(String literal)
346
  {
347
    return literal == null ? null : new XMLDuration(collapseWhiteSpace(literal));
348
  }
349
350
  /**
351
   * <!-- begin-user-doc -->
352
   * <!-- end-user-doc -->
353
   * @generated NOT
354
   */
355
  public String convertDuration(Object instanceValue)
356
  {
357
    return instanceValue == null ? null : instanceValue.toString();
358
  }
359
360
  /**
361
   * <!-- begin-user-doc -->
362
   * <!-- end-user-doc -->
363
   * @generated NOT
364
   */
365
  public List createENTITIES(String literal)
366
  {
367
    return createENTITIESBase(literal);
368
  }
369
370
  /**
371
   * <!-- begin-user-doc -->
372
   * <!-- end-user-doc -->
373
   * @generated
374
   */
375
  public List createENTITIESFromString(EDataType eDataType, String initialValue)
376
  {
377
    return (List)createENTITIESBaseFromString(XMLTypePackage.Literals.ENTITIES_BASE, initialValue);
378
  }
379
380
  /**
381
   * <!-- begin-user-doc -->
382
   * <!-- end-user-doc -->
383
   * @generated
384
   */
385
  public String convertENTITIES(List instanceValue)
386
  {
387
    return convertENTITIESBase(instanceValue);
388
  }
389
390
  /**
391
   * <!-- begin-user-doc -->
392
   * <!-- end-user-doc -->
393
   * @generated
394
   */
395
  public String convertENTITIESToString(EDataType eDataType, Object instanceValue)
396
  {
397
    return convertENTITIESBaseToString(XMLTypePackage.Literals.ENTITIES_BASE, instanceValue);
398
  }
399
400
  /**
401
   * <!-- begin-user-doc -->
402
   * <!-- end-user-doc -->
403
   * @generated
404
   */
405
  public List createENTITIESBase(String literal)
406
  {
407
    if (literal == null) return null;
408
    List result = new ArrayList();
409
    for (StringTokenizer stringTokenizer = new StringTokenizer(literal); stringTokenizer.hasMoreTokens(); )
410
    {
411
      String item = stringTokenizer.nextToken();
412
      result.add(createENTITY(item));
413
    }
414
    return result;
415
  }
416
417
  /**
418
   * <!-- begin-user-doc -->
419
   * <!-- end-user-doc -->
420
   * @generated
421
   */
422
  public List createENTITIESBaseFromString(EDataType eDataType, String initialValue)
423
  {
424
    return createENTITIESBase(initialValue);
425
  }
426
427
  /**
428
   * <!-- begin-user-doc -->
429
   * <!-- end-user-doc -->
430
   * @generated
431
   */
432
  public String convertENTITIESBase(List instanceValue)
433
  {
434
    if (instanceValue == null) return null;
435
    if (instanceValue.isEmpty()) return "";
436
    StringBuffer result = new StringBuffer();
437
    for (Iterator i = instanceValue.iterator(); i.hasNext(); )
438
    {
439
      result.append(convertENTITY((String)i.next()));
440
      result.append(' ');
441
    }
442
    return result.substring(0, result.length() - 1);
443
  }
444
445
  /**
446
   * <!-- begin-user-doc -->
447
   * <!-- end-user-doc -->
448
   * @generated NOT
449
   */
450
  public String convertENTITIESBaseToString(EDataType eDataType, Object instanceValue)
451
  {
452
    if (instanceValue == null) return null;
453
    List list = (List)instanceValue;
454
    if (list.isEmpty()) return "";
455
    StringBuffer result = new StringBuffer();
456
    for (Iterator i = list.iterator(); i.hasNext(); )
457
    {
458
      result.append(convertENTITYToString(XMLTypePackage.Literals.ENTITY, i.next()));
459
      result.append(' ');
460
    }
461
    return result.substring(0, result.length() - 1);
462
  }
463
464
  /**
465
   * <!-- begin-user-doc -->
466
   * <!-- end-user-doc -->
467
   * @generated NOT
468
   */
469
  public String createENTITY(String literal)
470
  {
471
    return literal;
472
  }
473
474
  /**
475
   * <!-- begin-user-doc -->
476
   * <!-- end-user-doc -->
477
   * @generated NOT
478
   */
479
  public String convertENTITY(String instanceValue)
480
  {
481
    return instanceValue;
482
  }
483
484
  /**
485
   * <!-- begin-user-doc -->
486
   * <!-- end-user-doc -->
487
   * @generated NOT
488
   */
489
  public float createFloat(String literal)
490
  {
491
    return literal == null ? 0.0F : Float.parseFloat(collapseWhiteSpace(literal));
492
  }
493
  
494
  /**
495
   * <!-- begin-user-doc -->
496
   * <!-- end-user-doc -->
497
   * @generated NOT
498
   */
499
  public String convertFloat(float instanceValue)
500
  {
501
    return Float.toString(instanceValue);
502
  }	
503
    
504
  /**
505
   * <!-- begin-user-doc -->
506
   * <!-- end-user-doc -->
507
   * @generated NOT
508
   */
509
  public Float createFloatObject(String literal)
510
  {
511
    return literal == null ? null : Float.valueOf(collapseWhiteSpace(literal));
512
  }
513
514
  /**
515
   * <!-- begin-user-doc -->
516
   * <!-- end-user-doc -->
517
   * @generated NOT
518
   */
519
  public String convertFloatObject(Float instanceValue)
520
  {
521
    return instanceValue == null ? null : instanceValue.toString();
522
  }
523
524
  /**
525
   * <!-- begin-user-doc -->
526
   * <!-- end-user-doc -->
527
   * @generated NOT
528
   */
529
  public Object createGDay(String literal)
530
  {
531
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.GDAY);
532
  }
533
534
  /**
535
   * <!-- begin-user-doc -->
536
   * <!-- end-user-doc -->
537
   * @generated NOT
538
   */
539
  public String convertGDay(Object instanceValue)
540
  {
541
    return instanceValue == null ? null : instanceValue.toString();
542
  }
543
544
  /**
545
   * <!-- begin-user-doc -->
546
   * <!-- end-user-doc -->
547
   * @generated NOT
548
   */
549
  public Object createGMonth(String literal)
550
  {
551
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.GMONTH);
552
  }
553
554
  /**
555
   * <!-- begin-user-doc -->
556
   * <!-- end-user-doc -->
557
   * @generated NOT
558
   */
559
  public String convertGMonth(Object instanceValue)
560
  {
561
    return instanceValue == null ? null : instanceValue.toString();
562
  }
563
564
  /**
565
   * <!-- begin-user-doc -->
566
   * <!-- end-user-doc -->
567
   * @generated NOT
568
   */
569
  public Object createGMonthDay(String literal)
570
  {
571
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.GMONTHDAY);
572
  }
573
574
  /**
575
   * <!-- begin-user-doc -->
576
   * <!-- end-user-doc -->
577
   * @generated NOT
578
   */
579
  public String convertGMonthDay(Object instanceValue)
580
  {
581
    return instanceValue == null ? null : instanceValue.toString();
582
  }
583
584
  /**
585
   * <!-- begin-user-doc -->
586
   * <!-- end-user-doc -->
587
   * @generated NOT
588
   */
589
  public Object createGYear(String literal)
590
  {
591
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.GYEAR);
592
  }
593
594
  /**
595
   * <!-- begin-user-doc -->
596
   * <!-- end-user-doc -->
597
   * @generated NOT
598
   */
599
  public String convertGYear(Object instanceValue)
600
  {
601
    return instanceValue == null ? null : instanceValue.toString();
602
  }
603
604
  /**
605
   * <!-- begin-user-doc -->
606
   * <!-- end-user-doc -->
607
   * @generated NOT
608
   */
609
  public Object createGYearMonth(String literal)
610
  {
611
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.GYEARMONTH);
612
  }
613
614
  /**
615
   * <!-- begin-user-doc -->
616
   * <!-- end-user-doc -->
617
   * @generated NOT
618
   */
619
  public String convertGYearMonth(Object instanceValue)
620
  {
621
    return instanceValue == null ? null : instanceValue.toString();
622
  }
623
624
  /**
625
   * <!-- begin-user-doc -->
626
   * <!-- end-user-doc -->
627
   * @generated NOT
628
   */
629
  public byte[] createHexBinary(String literal)
630
  {
631
    if (literal == null) return null;
632
    byte[] value = HexBin.decode(collapseWhiteSpace(literal));
633
    if (value == null)
634
    {
635
      throw new InvalidDatatypeValueException("Invalid hexBinary value: '" + literal + "'");
636
    }
637
    return value;
638
  }
639
640
  /**
641
   * <!-- begin-user-doc -->
642
   * <!-- end-user-doc -->
643
   * @generated NOT
644
   */
645
  public String convertHexBinary(byte[] instanceValue)
646
  {
647
    return instanceValue == null ? null : HexBin.encode((byte[])instanceValue);
648
  }
649
650
  /**
651
   * <!-- begin-user-doc -->
652
   * <!-- end-user-doc -->
653
   * @generated NOT
654
   */
655
  public String createID(String literal)
656
  {
657
    return (String)createNCNameFromString(XMLTypePackage.Literals.NC_NAME, literal);
658
  }
659
660
  /**
661
   * <!-- begin-user-doc -->
662
   * <!-- end-user-doc -->
663
   * @generated NOT
664
   */
665
  public String createIDFromString(EDataType eDataType, String initialValue)
666
  {
667
    return initialValue;
668
  }
669
670
  /**
671
   * <!-- begin-user-doc -->
672
   * <!-- end-user-doc -->
673
   * @generated NOT
674
   */
675
  public String convertID(String instanceValue)
676
  {
677
    return instanceValue;
678
  }
679
680
  /**
681
   * <!-- begin-user-doc -->
682
   * <!-- end-user-doc -->
683
   * @generated NOT
684
   */
685
  public String createIDREF(String literal)
686
  {
687
    return literal;
688
  }
689
690
  /**
691
   * <!-- begin-user-doc -->
692
   * <!-- end-user-doc -->
693
   * @generated NOT
694
   */
695
  public String createIDREFFromString(EDataType eDataType, String initialValue)
696
  {
697
    return initialValue;
698
  }
699
700
  /**
701
   * <!-- begin-user-doc -->
702
   * <!-- end-user-doc -->
703
   * @generated NOT
704
   */
705
  public String convertIDREF(String instanceValue)
706
  {
707
    return instanceValue;
708
  }
709
710
  /**
711
   * <!-- begin-user-doc -->
712
   * <!-- end-user-doc -->
713
   * @generated NOT
714
   */
715
  public List createIDREFS(String literal)
716
  {
717
    return createIDREFSBase(literal);
718
  }
719
720
  /**
721
   * <!-- begin-user-doc -->
722
   * <!-- end-user-doc -->
723
   * @generated
724
   */
725
  public List createIDREFSFromString(EDataType eDataType, String initialValue)
726
  {
727
    return (List)createIDREFSBaseFromString(XMLTypePackage.Literals.IDREFS_BASE, initialValue);
728
  }
729
730
  /**
731
   * <!-- begin-user-doc -->
732
   * <!-- end-user-doc -->
733
   * @generated
734
   */
735
  public String convertIDREFS(List instanceValue)
736
  {
737
    return convertIDREFSBase(instanceValue);
738
  }
739
740
  /**
741
   * <!-- begin-user-doc -->
742
   * <!-- end-user-doc -->
743
   * @generated
744
   */
745
  public String convertIDREFSToString(EDataType eDataType, Object instanceValue)
746
  {
747
    return convertIDREFSBaseToString(XMLTypePackage.Literals.IDREFS_BASE, instanceValue);
748
  }
749
750
  /**
751
   * <!-- begin-user-doc -->
752
   * <!-- end-user-doc -->
753
   * @generated
754
   */
755
  public List createIDREFSBase(String literal)
756
  {
757
    if (literal == null) return null;
758
    List result = new ArrayList();
759
    for (StringTokenizer stringTokenizer = new StringTokenizer(literal); stringTokenizer.hasMoreTokens(); )
760
    {
761
      String item = stringTokenizer.nextToken();
762
      result.add(createIDREF(item));
763
    }
764
    return result;
765
  }
766
767
  /**
768
   * <!-- begin-user-doc -->
769
   * <!-- end-user-doc -->
770
   * @generated
771
   */
772
  public List createIDREFSBaseFromString(EDataType eDataType, String initialValue)
773
  {
774
    return createIDREFSBase(initialValue);
775
  }
776
777
  /**
778
   * <!-- begin-user-doc -->
779
   * <!-- end-user-doc -->
780
   * @generated
781
   */
782
  public String convertIDREFSBase(List instanceValue)
783
  {
784
    if (instanceValue == null) return null;
785
    if (instanceValue.isEmpty()) return "";
786
    StringBuffer result = new StringBuffer();
787
    for (Iterator i = instanceValue.iterator(); i.hasNext(); )
788
    {
789
      result.append(convertIDREF((String)i.next()));
790
      result.append(' ');
791
    }
792
    return result.substring(0, result.length() - 1);
793
  }
794
795
  /**
796
   * <!-- begin-user-doc -->
797
   * <!-- end-user-doc -->
798
   * @generated
799
   */
800
  public String convertIDREFSBaseToString(EDataType eDataType, Object instanceValue)
801
  {
802
    return convertIDREFSBase((List)instanceValue);
803
  }
804
805
  /**
806
   * <!-- begin-user-doc -->
807
   * <!-- end-user-doc -->
808
   * @generated NOT
809
   */
810
  public int createInt(String initialValue)
811
  {
812
    return initialValue == null ? 0 : Integer.parseInt(collapseWhiteSpace(initialValue));
813
  }	
814
815
  /**
816
   * <!-- begin-user-doc -->
817
   * <!-- end-user-doc -->
818
   * @generated NOT
819
   */
820
  public String convertInt(int instanceValue)
821
  {
822
    return Integer.toString(instanceValue);
823
  }
824
    
825
  /**
826
   * <!-- begin-user-doc -->
827
   * <!-- end-user-doc -->
828
   * @generated NOT
829
   */
830
  public BigInteger createInteger(String literal)
831
  {
832
    return literal == null ? null : new BigInteger(collapseWhiteSpace(literal));
833
  }
834
835
  /**
836
   * <!-- begin-user-doc -->
837
   * <!-- end-user-doc -->
838
   * @generated NOT
839
   */
840
  public String convertInteger(BigInteger instanceValue)
841
  {
842
    return instanceValue == null ? null : instanceValue.toString();
843
  }
844
845
  /**
846
   * <!-- begin-user-doc -->
847
   * <!-- end-user-doc -->
848
   * @generated NOT
849
   */
850
  public Integer createIntObject(String literal)
851
  {
852
    return literal == null ? null : Integer.valueOf(collapseWhiteSpace(literal));
853
  }
854
855
  /**
856
   * <!-- begin-user-doc -->
857
   * <!-- end-user-doc -->
858
   * @generated NOT
859
   */
860
  public String convertIntObject(Integer instanceValue)
861
  {
862
    return instanceValue == null ? null : instanceValue.toString();
863
  }
864
865
  /**
866
   * <!-- begin-user-doc -->
867
   * <!-- end-user-doc -->
868
   * @generated NOT
869
   */
870
  public String createLanguage(String literal)
871
  {
872
    return collapseWhiteSpace(literal);
873
  }
874
875
  /**
876
   * <!-- begin-user-doc -->
877
   * <!-- end-user-doc -->
878
   * @generated NOT
879
   */
880
  public String convertLanguage(String instanceValue)
881
  {
882
    return (String)instanceValue;
883
  }
884
885
  /**
886
   * <!-- begin-user-doc -->
887
   * <!-- end-user-doc -->
888
   * @generated NOT
889
   */
890
  public long createLong(String literal)
891
  {
892
    return literal == null ? 0L : Long.parseLong(literal);
893
  }
894
  
895
  /**
896
   * <!-- begin-user-doc -->
897
   * <!-- end-user-doc -->
898
   * @generated NOT
899
   */
900
  public String convertLong(long instanceValue)
901
  {
902
    return Long.toString(instanceValue);
903
  }
904
    
905
  /**
906
   * <!-- begin-user-doc -->
907
   * <!-- end-user-doc -->
908
   * @generated NOT
909
   */
910
  public Long createLongObject(String literal)
911
  {
912
    return literal == null ? null : Long.valueOf(collapseWhiteSpace(literal));
913
  }
914
915
  /**
916
   * <!-- begin-user-doc -->
917
   * <!-- end-user-doc -->
918
   * @generated NOT
919
   */
920
  public String convertLongObject(Long instanceValue)
921
  {
922
    return instanceValue == null ? null : instanceValue.toString();
923
  }
924
925
  /**
926
   * <!-- begin-user-doc -->
927
   * <!-- end-user-doc -->
928
   * @generated NOT
929
   */
930
  public String createName(String literal)
931
  {
932
    return literal;
933
  }
934
935
  /**
936
   * <!-- begin-user-doc -->
937
   * <!-- end-user-doc -->
938
   * @generated NOT
939
   */
940
  public String convertName(String instanceValue)
941
  {
942
    return (String)instanceValue;
943
  }
944
945
  /**
946
   * <!-- begin-user-doc -->
947
   * <!-- end-user-doc -->
948
   * @generated NOT
949
   */
950
  public String createNCName(String literal)
951
  {
952
    return literal;
953
  }
954
955
  /**
956
   * <!-- begin-user-doc -->
957
   * <!-- end-user-doc -->
958
   * @generated NOT
959
   */
960
  public String convertNCName(String instanceValue)
961
  {
962
    return (String)instanceValue;
963
  }
964
965
  /**
966
   * <!-- begin-user-doc -->
967
   * <!-- end-user-doc -->
968
   * @generated NOT
969
   */
970
  public BigInteger createNegativeInteger(String literal)
971
  {
972
    return (BigInteger)createNonPositiveIntegerFromString(XMLTypePackage.Literals.NON_POSITIVE_INTEGER, literal);
973
  }
974
975
  /**
976
   * <!-- begin-user-doc -->
977
   * <!-- end-user-doc -->
978
   * @generated
979
   */
980
  public BigInteger createNegativeIntegerFromString(EDataType eDataType, String initialValue)
981
  {
982
    return (BigInteger)createNonPositiveIntegerFromString(XMLTypePackage.Literals.NON_POSITIVE_INTEGER, initialValue);
983
  }
984
985
  /**
986
   * <!-- begin-user-doc -->
987
   * <!-- end-user-doc -->
988
   * @generated
989
   */
990
  public String convertNegativeInteger(BigInteger instanceValue)
991
  {
992
    return convertNonPositiveInteger(instanceValue);
993
  }
994
995
  /**
996
   * <!-- begin-user-doc -->
997
   * <!-- end-user-doc -->
998
   * @generated
999
   */
1000
  public String convertNegativeIntegerToString(EDataType eDataType, Object instanceValue)
1001
  {
1002
    return convertNonPositiveIntegerToString(XMLTypePackage.Literals.NON_POSITIVE_INTEGER, instanceValue);
1003
  }
1004
1005
  /**
1006
   * <!-- begin-user-doc -->
1007
   * <!-- end-user-doc -->
1008
   * @generated NOT
1009
   */
1010
  public String createNMTOKEN(String literal)
1011
  {
1012
    if (literal == null) return null;
1013
    return literal;  
1014
  }
1015
1016
  /**
1017
   * <!-- begin-user-doc -->
1018
   * <!-- end-user-doc -->
1019
   * @generated NOT
1020
   */
1021
  public String convertNMTOKEN(String instanceValue)
1022
  {
1023
    return (String)instanceValue;
1024
  }
1025
1026
  /**
1027
   * <!-- begin-user-doc -->
1028
   * <!-- end-user-doc -->
1029
   * @generated
1030
   */
1031
  public List createNMTOKENS(String literal)
1032
  {
1033
    return createNMTOKENSBase(literal);
1034
  }
1035
1036
  /**
1037
   * <!-- begin-user-doc -->
1038
   * <!-- end-user-doc -->
1039
   * @generated
1040
   */
1041
  public List createNMTOKENSFromString(EDataType eDataType, String initialValue)
1042
  {
1043
    return (List)createNMTOKENSBaseFromString(XMLTypePackage.Literals.NMTOKENS_BASE, initialValue);
1044
  }
1045
1046
  /**
1047
   * <!-- begin-user-doc -->
1048
   * <!-- end-user-doc -->
1049
   * @generated
1050
   */
1051
  public String convertNMTOKENS(List instanceValue)
1052
  {
1053
    return convertNMTOKENSBase(instanceValue);
1054
  }
1055
1056
  /**
1057
   * <!-- begin-user-doc -->
1058
   * <!-- end-user-doc -->
1059
   * @generated
1060
   */
1061
  public String convertNMTOKENSToString(EDataType eDataType, Object instanceValue)
1062
  {
1063
    return convertNMTOKENSBaseToString(XMLTypePackage.Literals.NMTOKENS_BASE, instanceValue);
1064
  }
1065
1066
  /**
1067
   * <!-- begin-user-doc -->
1068
   * <!-- end-user-doc -->
1069
   * @generated
1070
   */
1071
  public List createNMTOKENSBase(String literal)
1072
  {
1073
    if (literal == null) return null;
1074
    List result = new ArrayList();
1075
    for (StringTokenizer stringTokenizer = new StringTokenizer(literal); stringTokenizer.hasMoreTokens(); )
1076
    {
1077
      String item = stringTokenizer.nextToken();
1078
      result.add(createNMTOKEN(item));
1079
    }
1080
    return result;
1081
  }
1082
1083
  /**
1084
   * <!-- begin-user-doc -->
1085
   * <!-- end-user-doc -->
1086
   * @generated
1087
   */
1088
  public List createNMTOKENSBaseFromString(EDataType eDataType, String initialValue)
1089
  {
1090
    return createNMTOKENSBase(initialValue);
1091
  }
1092
1093
  /**
1094
   * <!-- begin-user-doc -->
1095
   * <!-- end-user-doc -->
1096
   * @generated
1097
   */
1098
  public String convertNMTOKENSBase(List instanceValue)
1099
  {
1100
    if (instanceValue == null) return null;
1101
    if (instanceValue.isEmpty()) return "";
1102
    StringBuffer result = new StringBuffer();
1103
    for (Iterator i = instanceValue.iterator(); i.hasNext(); )
1104
    {
1105
      result.append(convertNMTOKEN((String)i.next()));
1106
      result.append(' ');
1107
    }
1108
    return result.substring(0, result.length() - 1);
1109
  }
1110
1111
  public String convertNMTOKENSBaseToString(EDataType eDataType, Object instanceValue)
1112
  {
1113
    if (instanceValue == null) return null;
1114
    List list = (List)instanceValue;
1115
    if (list.isEmpty()) return "";
1116
    StringBuffer result = new StringBuffer();
1117
    for (Iterator i = list.iterator(); i.hasNext(); )
1118
    {
1119
      result.append(convertNMTOKENToString(XMLTypePackage.Literals.NMTOKEN, i.next()));
1120
      result.append(' ');
1121
    }
1122
    return result.substring(0, result.length() - 1);
1123
  }
1124
1125
  /**
1126
   * <!-- begin-user-doc -->
1127
   * <!-- end-user-doc -->
1128
   * @generated NOT
1129
   */
1130
  public BigInteger createNonNegativeInteger(String literal)
1131
  {
1132
    return literal == null ? null : new BigInteger(collapseWhiteSpace(literal));
1133
  }
1134
1135
  /**
1136
   * <!-- begin-user-doc -->
1137
   * <!-- end-user-doc -->
1138
   * @generated NOT
1139
   */
1140
  public String convertNonNegativeInteger(BigInteger instanceValue)
1141
  {
1142
    return instanceValue == null ? null : instanceValue.toString();
1143
  }
1144
1145
  /**
1146
   * <!-- begin-user-doc -->
1147
   * <!-- end-user-doc -->
1148
   * @generated NOT
1149
   */
1150
  public BigInteger createNonPositiveInteger(String literal)
1151
  {
1152
    return literal == null ? null : new BigInteger(collapseWhiteSpace(literal));
1153
  }
1154
1155
  /**
1156
   * <!-- begin-user-doc -->
1157
   * <!-- end-user-doc -->
1158
   * @generated NOT
1159
   */
1160
  public String convertNonPositiveInteger(BigInteger instanceValue)
1161
  {
1162
    return instanceValue == null ? null : instanceValue.toString();
1163
  }
1164
1165
  /**
1166
   * <!-- begin-user-doc -->
1167
   * <!-- end-user-doc -->
1168
   * @generated NOT
1169
   */
1170
  public String createNormalizedString(String literal)
1171
  {
1172
    return replaceWhiteSpace(literal);
1173
  }
1174
1175
  /**
1176
   * <!-- begin-user-doc -->
1177
   * <!-- end-user-doc -->
1178
   * @generated NOT
1179
   */
1180
  public String convertNormalizedString(String instanceValue)
1181
  {
1182
    return (String)instanceValue;
1183
  }
1184
1185
  /**
1186
   * <!-- begin-user-doc -->
1187
   * <!-- end-user-doc -->
1188
   * @generated NOT
1189
   */
1190
  public Object createNOTATION(String literal)
1191
  {
1192
    return literal == null ? null : new QName(collapseWhiteSpace(literal)); 
1193
  }
1194
1195
  /**
1196
   * <!-- begin-user-doc -->
1197
   * <!-- end-user-doc -->
1198
   * @generated NOT
1199
   */
1200
  public String convertNOTATION(Object instanceValue)
1201
  {
1202
    return instanceValue == null ? null : instanceValue.toString();
1203
  }
1204
1205
  /**
1206
   * <!-- begin-user-doc -->
1207
   * <!-- end-user-doc -->
1208
   * @generated
1209
   */
1210
  public BigInteger createPositiveInteger(String literal)
1211
  {
1212
    return createNonNegativeInteger(literal);
1213
  }
1214
1215
  /**
1216
   * <!-- begin-user-doc -->
1217
   * <!-- end-user-doc -->
1218
   * @generated
1219
   */
1220
  public BigInteger createPositiveIntegerFromString(EDataType eDataType, String initialValue)
1221
  {
1222
    return (BigInteger)createNonNegativeIntegerFromString(XMLTypePackage.Literals.NON_NEGATIVE_INTEGER, initialValue);
1223
  }
1224
1225
  /**
1226
   * <!-- begin-user-doc -->
1227
   * <!-- end-user-doc -->
1228
   * @generated
1229
   */
1230
  public String convertPositiveInteger(BigInteger instanceValue)
1231
  {
1232
    return convertNonNegativeInteger(instanceValue);
1233
  }
1234
1235
  /**
1236
   * <!-- begin-user-doc -->
1237
   * <!-- end-user-doc -->
1238
   * @generated
1239
   */
1240
  public String convertPositiveIntegerToString(EDataType eDataType, Object instanceValue)
1241
  {
1242
    return convertNonNegativeIntegerToString(XMLTypePackage.Literals.NON_NEGATIVE_INTEGER, instanceValue);
1243
  }
1244
1245
  /**
1246
   * <!-- begin-user-doc -->
1247
   * <!-- end-user-doc -->
1248
   * @generated NOT
1249
   */
1250
  public Object createQName(String literal)
1251
  {
1252
    return literal == null ? null : new QName(collapseWhiteSpace(literal));    
1253
  }
1254
1255
  /**
1256
   * <!-- begin-user-doc -->
1257
   * <!-- end-user-doc -->
1258
   * @generated NOT
1259
   */
1260
  public String convertQName(Object instanceValue)
1261
  {
1262
    return instanceValue == null ? null : instanceValue.toString();
1263
  }
1264
1265
  /**
1266
   * <!-- begin-user-doc -->
1267
   * <!-- end-user-doc -->
1268
   * @generated NOT
1269
   */
1270
  public short createShort(String literal)
1271
  {
1272
    return literal == null ? 0 : Short.parseShort(literal);
1273
  }
1274
  
1275
  /**
1276
   * <!-- begin-user-doc -->
1277
   * <!-- end-user-doc -->
1278
   * @generated NOT
1279
   */
1280
  public String convertShort(short instanceValue)
1281
  {
1282
    return Short.toString(instanceValue);
1283
  }	
1284
    
1285
  /**
1286
   * <!-- begin-user-doc -->
1287
   * <!-- end-user-doc -->
1288
   * @generated NOT
1289
   */
1290
  public Short createShortObject(String literal)
1291
  {
1292
    return literal == null ? null : Short.valueOf(collapseWhiteSpace(literal));
1293
  }
1294
1295
  /**
1296
   * <!-- begin-user-doc -->
1297
   * <!-- end-user-doc -->
1298
   * @generated NOT
1299
   */
1300
  public String convertShortObject(Short instanceValue)
1301
  {
1302
    return instanceValue == null ? null : instanceValue.toString();
1303
  }
1304
1305
  /**
1306
   * <!-- begin-user-doc -->
1307
   * <!-- end-user-doc -->
1308
   * @generated NOT
1309
   */
1310
  public String createString(String initialValue)
1311
  {	
1312
    return initialValue;
1313
  }	
1314
1315
  /**
1316
   * <!-- begin-user-doc -->
1317
   * <!-- end-user-doc -->
1318
   * @generated NOT
1319
   */
1320
  public String convertString(String instanceValue)
1321
  {
1322
    return (String)instanceValue;	
1323
  }	
1324
  
1325
  /**
1326
   * <!-- begin-user-doc -->
1327
   * <!-- end-user-doc -->
1328
   * @generated NOT
1329
   */
1330
  public Object createTime(String literal)
1331
  {
1332
    return literal == null ?  null : new XMLCalendar(collapseWhiteSpace(literal), XMLCalendar.TIME);
1333
  }
1334
1335
  /**
1336
   * <!-- begin-user-doc -->
1337
   * <!-- end-user-doc -->
1338
   * @generated NOT
1339
   */
1340
  public String convertTime(Object instanceValue)
1341
  {
1342
    return instanceValue == null ? null : instanceValue.toString();
1343
  }
1344
1345
  /**
1346
   * <!-- begin-user-doc -->
1347
   * <!-- end-user-doc -->
1348
   * @generated NOT
1349
   */
1350
  public String createToken(String literal)
1351
  {
1352
    return collapseWhiteSpace(literal);
1353
  }
1354
1355
  /**
1356
   * <!-- begin-user-doc -->
1357
   * <!-- end-user-doc -->
1358
   * @generated NOT
1359
   */
1360
  public String convertToken(String instanceValue)
1361
  {
1362
    return (String)instanceValue;
1363
  }
1364
1365
  /**
1366
   * <!-- begin-user-doc -->
1367
   * <!-- end-user-doc -->
1368
   * @generated NOT
1369
   */
1370
  public short createUnsignedByte(String literal)
1371
  {
1372
    return literal == null ? 0 : Short.parseShort(literal);
1373
  }	
1374
  
1375
  /**
1376
   * <!-- begin-user-doc -->
1377
   * <!-- end-user-doc -->
1378
   * @generated NOT
1379
   */
1380
  public String convertUnsignedByte(short instanceValue)
1381
  {
1382
    return Short.toString(instanceValue);
1383
  }	
1384
    
1385
  /**
1386
   * <!-- begin-user-doc -->
1387
   * <!-- end-user-doc -->
1388
   * @generated NOT
1389
   */
1390
  public Short createUnsignedByteObject(String literal)
1391
  {
1392
    return literal == null ? null : new Short(literal);
1393
  }
1394
1395
  /**
1396
   * <!-- begin-user-doc -->
1397
   * <!-- end-user-doc -->
1398
   * @generated NOT
1399
   */
1400
  public String convertUnsignedByteObject(Short instanceValue)
1401
  {
1402
    return instanceValue == null ? null : instanceValue.toString();
1403
  }
1404
1405
  /**
1406
   * <!-- begin-user-doc -->
1407
   * <!-- end-user-doc -->
1408
   * @generated NOT
1409
   */
1410
  public long createUnsignedInt(String literal)
1411
  {
1412
    return literal == null ? 0 : Long.parseLong(literal);
1413
  }
1414
  
1415
  /**
1416
   * <!-- begin-user-doc -->
1417
   * <!-- end-user-doc -->
1418
   * @generated NOT
1419
   */
1420
  public String convertUnsignedInt(long instanceValue)
1421
  {
1422
    return Long.toString(instanceValue);
1423
  }	
1424
    
1425
  /**
1426
   * <!-- begin-user-doc -->
1427
   * <!-- end-user-doc -->
1428
   * @generated NOT
1429
   */
1430
  public Long createUnsignedIntObject(String literal)
1431
  {
1432
    return literal == null ? null : Long.valueOf(collapseWhiteSpace(literal));
1433
  }
1434
1435
  /**
1436
   * <!-- begin-user-doc -->
1437
   * <!-- end-user-doc -->
1438
   * @generated NOT
1439
   */
1440
  public String convertUnsignedIntObject(Long instanceValue)
1441
  {
1442
    return instanceValue == null ? null : instanceValue.toString();
1443
  }
1444
1445
  /**
1446
   * <!-- begin-user-doc -->
1447
   * <!-- end-user-doc -->
1448
   * @generated
1449
   */
1450
  public BigInteger createUnsignedLong(String literal)
1451
  {
1452
    return createNonNegativeInteger(literal);
1453
  }
1454
1455
  /**
1456
   * <!-- begin-user-doc -->
1457
   * <!-- end-user-doc -->
1458
   * @generated
1459
   */
1460
  public BigInteger createUnsignedLongFromString(EDataType eDataType, String initialValue)
1461
  {
1462
    return (BigInteger)createNonNegativeIntegerFromString(XMLTypePackage.Literals.NON_NEGATIVE_INTEGER, initialValue);
1463
  }
1464
1465
  /**
1466
   * <!-- begin-user-doc -->
1467
   * <!-- end-user-doc -->
1468
   * @generated
1469
   */
1470
  public String convertUnsignedLong(BigInteger instanceValue)
1471
  {
1472
    return convertNonNegativeInteger(instanceValue);
1473
  }
1474
1475
  /**
1476
   * <!-- begin-user-doc -->
1477
   * <!-- end-user-doc -->
1478
   * @generated
1479
   */
1480
  public String convertUnsignedLongToString(EDataType eDataType, Object instanceValue)
1481
  {
1482
    return convertNonNegativeIntegerToString(XMLTypePackage.Literals.NON_NEGATIVE_INTEGER, instanceValue);
1483
  }
1484
1485
  /**
1486
   * <!-- begin-user-doc -->
1487
   * <!-- end-user-doc -->
1488
   * @generated NOT
1489
   */
1490
  public int createUnsignedShort(String literal)
1491
  {
1492
    return literal == null ? 0 : Integer.parseInt(literal);
1493
  }	
1494
  
1495
  /**
1496
   * <!-- begin-user-doc -->
1497
   * <!-- end-user-doc -->
1498
   * @generated NOT
1499
   */
1500
  public String convertUnsignedShort(int instanceValue)
1501
  {
1502
    return Integer.toString(instanceValue);
1503
  }	
1504
    
1505
  /**
1506
   * <!-- begin-user-doc -->
1507
   * <!-- end-user-doc -->
1508
   * @generated NOT
1509
   */
1510
  public Integer createUnsignedShortObject(String literal)
1511
  {
1512
    return literal == null ? null : Integer.valueOf(collapseWhiteSpace(literal));
1513
  }
1514
1515
  /**
1516
   * <!-- begin-user-doc -->
1517
   * <!-- end-user-doc -->
1518
   * @generated NOT
1519
   */
1520
  public String convertUnsignedShortObject(Integer instanceValue)
1521
  {
1522
    return instanceValue == null ? null : instanceValue.toString();
1523
  }
1524
1525
  /**
1526
   * Creates the default factory implementation.
1527
   * <!-- begin-user-doc -->
1528
   * <!-- end-user-doc -->
1529
   * @generated
1530
   */
1531
  public static XMLTypeFactory init()
1532
  {
1533
    try
1534
    {
1535
      XMLTypeFactory theXMLTypeFactory = (XMLTypeFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/emf/2003/XMLType"); 
1536
      if (theXMLTypeFactory != null)
1537
      {
1538
        return theXMLTypeFactory;
1539
      }
1540
    }
1541
    catch (Exception exception)
1542
    {
1543
      EcorePlugin.INSTANCE.log(exception);
1544
    }
1545
    return new XMLTypeFactoryImpl();
1546
  }
1547
1548
  protected static final DateFormat [] EDATE_FORMATS =
1549
  {
1550
    new SafeSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"),
1551
    new SafeSimpleDateFormat("yyyy-MM-ddZ")
1552
  };
1553
1554
  /**
1555
   * Creates an instance of the factory.
1556
   * <!-- begin-user-doc -->
1557
   * <!-- end-user-doc -->
1558
   * @generated
1559
   */
1560
  public XMLTypeFactoryImpl()
1561
  {
1562
    super();
1563
  }
1564
1565
  /**
1566
   * <!-- begin-user-doc -->
1567
   * <!-- end-user-doc -->
1568
   * @generated
1569
   */
1570
  public EObject create(EClass eClass)
1571
  {
1572
    switch (eClass.getClassifierID())
1573
    {
1574
      case XMLTypePackage.ANY_TYPE: return createAnyType();
1575
      case XMLTypePackage.SIMPLE_ANY_TYPE: return createSimpleAnyType();
1576
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT: return createXMLTypeDocumentRoot();
1577
      default:
1578
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
1579
    }
1580
  }
1581
1582
  /**
1583
   * <!-- begin-user-doc -->
1584
   * <!-- end-user-doc -->
1585
   * @generated
1586
   */
1587
  public Object createFromString(EDataType eDataType, String initialValue)
1588
  {
1589
    switch (eDataType.getClassifierID())
1590
    {
1591
      case XMLTypePackage.ANY_SIMPLE_TYPE:
1592
        return createAnySimpleTypeFromString(eDataType, initialValue);
1593
      case XMLTypePackage.ANY_URI:
1594
        return createAnyURIFromString(eDataType, initialValue);
1595
      case XMLTypePackage.BASE64_BINARY:
1596
        return createBase64BinaryFromString(eDataType, initialValue);
1597
      case XMLTypePackage.BOOLEAN:
1598
        return createBooleanFromString(eDataType, initialValue);
1599
      case XMLTypePackage.BOOLEAN_OBJECT:
1600
        return createBooleanObjectFromString(eDataType, initialValue);
1601
      case XMLTypePackage.BYTE:
1602
        return createByteFromString(eDataType, initialValue);
1603
      case XMLTypePackage.BYTE_OBJECT:
1604
        return createByteObjectFromString(eDataType, initialValue);
1605
      case XMLTypePackage.DATE:
1606
        return createDateFromString(eDataType, initialValue);
1607
      case XMLTypePackage.DATE_TIME:
1608
        return createDateTimeFromString(eDataType, initialValue);
1609
      case XMLTypePackage.DECIMAL:
1610
        return createDecimalFromString(eDataType, initialValue);
1611
      case XMLTypePackage.DOUBLE:
1612
        return createDoubleFromString(eDataType, initialValue);
1613
      case XMLTypePackage.DOUBLE_OBJECT:
1614
        return createDoubleObjectFromString(eDataType, initialValue);
1615
      case XMLTypePackage.DURATION:
1616
        return createDurationFromString(eDataType, initialValue);
1617
      case XMLTypePackage.ENTITIES:
1618
        return createENTITIESFromString(eDataType, initialValue);
1619
      case XMLTypePackage.ENTITIES_BASE:
1620
        return createENTITIESBaseFromString(eDataType, initialValue);
1621
      case XMLTypePackage.ENTITY:
1622
        return createENTITYFromString(eDataType, initialValue);
1623
      case XMLTypePackage.FLOAT:
1624
        return createFloatFromString(eDataType, initialValue);
1625
      case XMLTypePackage.FLOAT_OBJECT:
1626
        return createFloatObjectFromString(eDataType, initialValue);
1627
      case XMLTypePackage.GDAY:
1628
        return createGDayFromString(eDataType, initialValue);
1629
      case XMLTypePackage.GMONTH:
1630
        return createGMonthFromString(eDataType, initialValue);
1631
      case XMLTypePackage.GMONTH_DAY:
1632
        return createGMonthDayFromString(eDataType, initialValue);
1633
      case XMLTypePackage.GYEAR:
1634
        return createGYearFromString(eDataType, initialValue);
1635
      case XMLTypePackage.GYEAR_MONTH:
1636
        return createGYearMonthFromString(eDataType, initialValue);
1637
      case XMLTypePackage.HEX_BINARY:
1638
        return createHexBinaryFromString(eDataType, initialValue);
1639
      case XMLTypePackage.ID:
1640
        return createIDFromString(eDataType, initialValue);
1641
      case XMLTypePackage.IDREF:
1642
        return createIDREFFromString(eDataType, initialValue);
1643
      case XMLTypePackage.IDREFS:
1644
        return createIDREFSFromString(eDataType, initialValue);
1645
      case XMLTypePackage.IDREFS_BASE:
1646
        return createIDREFSBaseFromString(eDataType, initialValue);
1647
      case XMLTypePackage.INT:
1648
        return createIntFromString(eDataType, initialValue);
1649
      case XMLTypePackage.INTEGER:
1650
        return createIntegerFromString(eDataType, initialValue);
1651
      case XMLTypePackage.INT_OBJECT:
1652
        return createIntObjectFromString(eDataType, initialValue);
1653
      case XMLTypePackage.LANGUAGE:
1654
        return createLanguageFromString(eDataType, initialValue);
1655
      case XMLTypePackage.LONG:
1656
        return createLongFromString(eDataType, initialValue);
1657
      case XMLTypePackage.LONG_OBJECT:
1658
        return createLongObjectFromString(eDataType, initialValue);
1659
      case XMLTypePackage.NAME:
1660
        return createNameFromString(eDataType, initialValue);
1661
      case XMLTypePackage.NC_NAME:
1662
        return createNCNameFromString(eDataType, initialValue);
1663
      case XMLTypePackage.NEGATIVE_INTEGER:
1664
        return createNegativeIntegerFromString(eDataType, initialValue);
1665
      case XMLTypePackage.NMTOKEN:
1666
        return createNMTOKENFromString(eDataType, initialValue);
1667
      case XMLTypePackage.NMTOKENS:
1668
        return createNMTOKENSFromString(eDataType, initialValue);
1669
      case XMLTypePackage.NMTOKENS_BASE:
1670
        return createNMTOKENSBaseFromString(eDataType, initialValue);
1671
      case XMLTypePackage.NON_NEGATIVE_INTEGER:
1672
        return createNonNegativeIntegerFromString(eDataType, initialValue);
1673
      case XMLTypePackage.NON_POSITIVE_INTEGER:
1674
        return createNonPositiveIntegerFromString(eDataType, initialValue);
1675
      case XMLTypePackage.NORMALIZED_STRING:
1676
        return createNormalizedStringFromString(eDataType, initialValue);
1677
      case XMLTypePackage.NOTATION:
1678
        return createNOTATIONFromString(eDataType, initialValue);
1679
      case XMLTypePackage.POSITIVE_INTEGER:
1680
        return createPositiveIntegerFromString(eDataType, initialValue);
1681
      case XMLTypePackage.QNAME:
1682
        return createQNameFromString(eDataType, initialValue);
1683
      case XMLTypePackage.SHORT:
1684
        return createShortFromString(eDataType, initialValue);
1685
      case XMLTypePackage.SHORT_OBJECT:
1686
        return createShortObjectFromString(eDataType, initialValue);
1687
      case XMLTypePackage.STRING:
1688
        return createStringFromString(eDataType, initialValue);
1689
      case XMLTypePackage.TIME:
1690
        return createTimeFromString(eDataType, initialValue);
1691
      case XMLTypePackage.TOKEN:
1692
        return createTokenFromString(eDataType, initialValue);
1693
      case XMLTypePackage.UNSIGNED_BYTE:
1694
        return createUnsignedByteFromString(eDataType, initialValue);
1695
      case XMLTypePackage.UNSIGNED_BYTE_OBJECT:
1696
        return createUnsignedByteObjectFromString(eDataType, initialValue);
1697
      case XMLTypePackage.UNSIGNED_INT:
1698
        return createUnsignedIntFromString(eDataType, initialValue);
1699
      case XMLTypePackage.UNSIGNED_INT_OBJECT:
1700
        return createUnsignedIntObjectFromString(eDataType, initialValue);
1701
      case XMLTypePackage.UNSIGNED_LONG:
1702
        return createUnsignedLongFromString(eDataType, initialValue);
1703
      case XMLTypePackage.UNSIGNED_SHORT:
1704
        return createUnsignedShortFromString(eDataType, initialValue);
1705
      case XMLTypePackage.UNSIGNED_SHORT_OBJECT:
1706
        return createUnsignedShortObjectFromString(eDataType, initialValue);
1707
      default:
1708
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
1709
    }
1710
  }
1711
1712
  /**
1713
   * <!-- begin-user-doc -->
1714
   * <!-- end-user-doc -->
1715
   * @generated
1716
   */
1717
  public String convertToString(EDataType eDataType, Object instanceValue)
1718
  {
1719
    switch (eDataType.getClassifierID())
1720
    {
1721
      case XMLTypePackage.ANY_SIMPLE_TYPE:
1722
        return convertAnySimpleTypeToString(eDataType, instanceValue);
1723
      case XMLTypePackage.ANY_URI:
1724
        return convertAnyURIToString(eDataType, instanceValue);
1725
      case XMLTypePackage.BASE64_BINARY:
1726
        return convertBase64BinaryToString(eDataType, instanceValue);
1727
      case XMLTypePackage.BOOLEAN:
1728
        return convertBooleanToString(eDataType, instanceValue);
1729
      case XMLTypePackage.BOOLEAN_OBJECT:
1730
        return convertBooleanObjectToString(eDataType, instanceValue);
1731
      case XMLTypePackage.BYTE:
1732
        return convertByteToString(eDataType, instanceValue);
1733
      case XMLTypePackage.BYTE_OBJECT:
1734
        return convertByteObjectToString(eDataType, instanceValue);
1735
      case XMLTypePackage.DATE:
1736
        return convertDateToString(eDataType, instanceValue);
1737
      case XMLTypePackage.DATE_TIME:
1738
        return convertDateTimeToString(eDataType, instanceValue);
1739
      case XMLTypePackage.DECIMAL:
1740
        return convertDecimalToString(eDataType, instanceValue);
1741
      case XMLTypePackage.DOUBLE:
1742
        return convertDoubleToString(eDataType, instanceValue);
1743
      case XMLTypePackage.DOUBLE_OBJECT:
1744
        return convertDoubleObjectToString(eDataType, instanceValue);
1745
      case XMLTypePackage.DURATION:
1746
        return convertDurationToString(eDataType, instanceValue);
1747
      case XMLTypePackage.ENTITIES:
1748
        return convertENTITIESToString(eDataType, instanceValue);
1749
      case XMLTypePackage.ENTITIES_BASE:
1750
        return convertENTITIESBaseToString(eDataType, instanceValue);
1751
      case XMLTypePackage.ENTITY:
1752
        return convertENTITYToString(eDataType, instanceValue);
1753
      case XMLTypePackage.FLOAT:
1754
        return convertFloatToString(eDataType, instanceValue);
1755
      case XMLTypePackage.FLOAT_OBJECT:
1756
        return convertFloatObjectToString(eDataType, instanceValue);
1757
      case XMLTypePackage.GDAY:
1758
        return convertGDayToString(eDataType, instanceValue);
1759
      case XMLTypePackage.GMONTH:
1760
        return convertGMonthToString(eDataType, instanceValue);
1761
      case XMLTypePackage.GMONTH_DAY:
1762
        return convertGMonthDayToString(eDataType, instanceValue);
1763
      case XMLTypePackage.GYEAR:
1764
        return convertGYearToString(eDataType, instanceValue);
1765
      case XMLTypePackage.GYEAR_MONTH:
1766
        return convertGYearMonthToString(eDataType, instanceValue);
1767
      case XMLTypePackage.HEX_BINARY:
1768
        return convertHexBinaryToString(eDataType, instanceValue);
1769
      case XMLTypePackage.ID:
1770
        return convertIDToString(eDataType, instanceValue);
1771
      case XMLTypePackage.IDREF:
1772
        return convertIDREFToString(eDataType, instanceValue);
1773
      case XMLTypePackage.IDREFS:
1774
        return convertIDREFSToString(eDataType, instanceValue);
1775
      case XMLTypePackage.IDREFS_BASE:
1776
        return convertIDREFSBaseToString(eDataType, instanceValue);
1777
      case XMLTypePackage.INT:
1778
        return convertIntToString(eDataType, instanceValue);
1779
      case XMLTypePackage.INTEGER:
1780
        return convertIntegerToString(eDataType, instanceValue);
1781
      case XMLTypePackage.INT_OBJECT:
1782
        return convertIntObjectToString(eDataType, instanceValue);
1783
      case XMLTypePackage.LANGUAGE:
1784
        return convertLanguageToString(eDataType, instanceValue);
1785
      case XMLTypePackage.LONG:
1786
        return convertLongToString(eDataType, instanceValue);
1787
      case XMLTypePackage.LONG_OBJECT:
1788
        return convertLongObjectToString(eDataType, instanceValue);
1789
      case XMLTypePackage.NAME:
1790
        return convertNameToString(eDataType, instanceValue);
1791
      case XMLTypePackage.NC_NAME:
1792
        return convertNCNameToString(eDataType, instanceValue);
1793
      case XMLTypePackage.NEGATIVE_INTEGER:
1794
        return convertNegativeIntegerToString(eDataType, instanceValue);
1795
      case XMLTypePackage.NMTOKEN:
1796
        return convertNMTOKENToString(eDataType, instanceValue);
1797
      case XMLTypePackage.NMTOKENS:
1798
        return convertNMTOKENSToString(eDataType, instanceValue);
1799
      case XMLTypePackage.NMTOKENS_BASE:
1800
        return convertNMTOKENSBaseToString(eDataType, instanceValue);
1801
      case XMLTypePackage.NON_NEGATIVE_INTEGER:
1802
        return convertNonNegativeIntegerToString(eDataType, instanceValue);
1803
      case XMLTypePackage.NON_POSITIVE_INTEGER:
1804
        return convertNonPositiveIntegerToString(eDataType, instanceValue);
1805
      case XMLTypePackage.NORMALIZED_STRING:
1806
        return convertNormalizedStringToString(eDataType, instanceValue);
1807
      case XMLTypePackage.NOTATION:
1808
        return convertNOTATIONToString(eDataType, instanceValue);
1809
      case XMLTypePackage.POSITIVE_INTEGER:
1810
        return convertPositiveIntegerToString(eDataType, instanceValue);
1811
      case XMLTypePackage.QNAME:
1812
        return convertQNameToString(eDataType, instanceValue);
1813
      case XMLTypePackage.SHORT:
1814
        return convertShortToString(eDataType, instanceValue);
1815
      case XMLTypePackage.SHORT_OBJECT:
1816
        return convertShortObjectToString(eDataType, instanceValue);
1817
      case XMLTypePackage.STRING:
1818
        return convertStringToString(eDataType, instanceValue);
1819
      case XMLTypePackage.TIME:
1820
        return convertTimeToString(eDataType, instanceValue);
1821
      case XMLTypePackage.TOKEN:
1822
        return convertTokenToString(eDataType, instanceValue);
1823
      case XMLTypePackage.UNSIGNED_BYTE:
1824
        return convertUnsignedByteToString(eDataType, instanceValue);
1825
      case XMLTypePackage.UNSIGNED_BYTE_OBJECT:
1826
        return convertUnsignedByteObjectToString(eDataType, instanceValue);
1827
      case XMLTypePackage.UNSIGNED_INT:
1828
        return convertUnsignedIntToString(eDataType, instanceValue);
1829
      case XMLTypePackage.UNSIGNED_INT_OBJECT:
1830
        return convertUnsignedIntObjectToString(eDataType, instanceValue);
1831
      case XMLTypePackage.UNSIGNED_LONG:
1832
        return convertUnsignedLongToString(eDataType, instanceValue);
1833
      case XMLTypePackage.UNSIGNED_SHORT:
1834
        return convertUnsignedShortToString(eDataType, instanceValue);
1835
      case XMLTypePackage.UNSIGNED_SHORT_OBJECT:
1836
        return convertUnsignedShortObjectToString(eDataType, instanceValue);
1837
      default:
1838
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
1839
    }
1840
  }
1841
1842
  /**
1843
   * <!-- begin-user-doc -->
1844
   * <!-- end-user-doc -->
1845
   * @generated
1846
   */
1847
  public AnyType createAnyType()
1848
  {
1849
    AnyTypeImpl anyType = new AnyTypeImpl();
1850
    return anyType;
1851
  }
1852
1853
  /**
1854
   * <!-- begin-user-doc -->
1855
   * <!-- end-user-doc -->
1856
   * @generated
1857
   */
1858
  public SimpleAnyType createSimpleAnyType()
1859
  {
1860
    SimpleAnyTypeImpl simpleAnyType = new SimpleAnyTypeImpl();
1861
    return simpleAnyType;
1862
  }
1863
1864
  /**
1865
   * <!-- begin-user-doc -->
1866
   * <!-- end-user-doc -->
1867
   * @generated
1868
   */
1869
  public XMLTypeDocumentRoot createXMLTypeDocumentRoot()
1870
  {
1871
    XMLTypeDocumentRootImpl xmlTypeDocumentRoot = new XMLTypeDocumentRootImpl();
1872
    return xmlTypeDocumentRoot;
1873
  }
1874
1875
  /**
1876
   * <!-- begin-user-doc -->
1877
   * <!-- end-user-doc -->
1878
   * @generated NOT
1879
   */
1880
  public Object createAnySimpleTypeFromString(EDataType eDataType, String initialValue)
1881
  {
1882
    return createAnySimpleType(initialValue);
1883
  }
1884
1885
  /**
1886
   * <!-- begin-user-doc -->
1887
   * <!-- end-user-doc -->
1888
   * @generated NOT
1889
   */
1890
  public String convertAnySimpleTypeToString(EDataType eDataType, Object instanceValue)
1891
  {
1892
    return convertAnySimpleType(instanceValue);
1893
  }
1894
1895
  /**
1896
   * <!-- begin-user-doc -->
1897
   * <!-- end-user-doc -->
1898
   * @generated NOT
1899
   */
1900
  public String createAnyURIFromString(EDataType eDataType, String initialValue)
1901
  {
1902
    return createAnyURI(initialValue);
1903
  }
1904
1905
  /**
1906
   * <!-- begin-user-doc -->
1907
   * <!-- end-user-doc -->
1908
   * @generated NOT
1909
   */
1910
  public String convertAnyURIToString(EDataType eDataType, Object instanceValue)
1911
  {
1912
    return convertAnyURI((String)instanceValue);
1913
  }
1914
1915
  /**
1916
   * <!-- begin-user-doc -->
1917
   * <!-- end-user-doc -->
1918
   * @generated NOT
1919
   */
1920
  public byte[] createBase64BinaryFromString(EDataType eDataType, String initialValue)
1921
  {
1922
    return createBase64Binary(initialValue);
1923
  }
1924
1925
  /**
1926
   * <!-- begin-user-doc -->
1927
   * <!-- end-user-doc -->
1928
   * @generated NOT
1929
   */
1930
  public String convertBase64BinaryToString(EDataType eDataType, Object instanceValue)
1931
  {
1932
    return convertBase64Binary((byte[])instanceValue);
1933
  }
1934
1935
  /**
1936
   * <!-- begin-user-doc -->
1937
   * <!-- end-user-doc -->
1938
   * @generated NOT
1939
   */
1940
  public Boolean createBooleanFromString(EDataType eDataType, String initialValue)
1941
  {
1942
    return createBooleanObject(initialValue);
1943
  }
1944
1945
  /**
1946
   * <!-- begin-user-doc -->
1947
   * <!-- end-user-doc -->
1948
   * @generated NOT
1949
   */
1950
  public String convertBooleanToString(EDataType eDataType, Object instanceValue)
1951
  {
1952
    return instanceValue == null ? null : instanceValue.toString();
1953
  }
1954
1955
  /**
1956
   * <!-- begin-user-doc -->
1957
   * <!-- end-user-doc -->
1958
   * @generated NOT
1959
   */
1960
  public Boolean createBooleanObjectFromString(EDataType eDataType, String initialValue)
1961
  {
1962
    return initialValue == null ? null : booleanValueOf(initialValue);
1963
  }
1964
1965
  /**
1966
   * <!-- begin-user-doc -->
1967
   * <!-- end-user-doc -->
1968
   * @generated NOT
1969
   */
1970
  public String convertBooleanObjectToString(EDataType eDataType, Object instanceValue)
1971
  {
1972
    return instanceValue == null ? null : instanceValue.toString();
1973
  }
1974
1975
  /**
1976
   * <!-- begin-user-doc -->
1977
   * <!-- end-user-doc -->
1978
   * @generated NOT
1979
   */
1980
  public BigDecimal createDecimalFromString(EDataType eDataType, String initialValue)
1981
  {
1982
    return createDecimal(initialValue);
1983
  }
1984
1985
  /**
1986
   * <!-- begin-user-doc -->
1987
   * <!-- end-user-doc -->
1988
   * @generated NOT
1989
   */
1990
  public String convertDecimalToString(EDataType eDataType, Object instanceValue)
1991
  {
1992
    return instanceValue == null ? null : instanceValue.toString();
1993
  }
1994
1995
  /**
1996
   * <!-- begin-user-doc -->
1997
   * <!-- end-user-doc -->
1998
   * @generated NOT
1999
   */
2000
  public BigInteger createIntegerFromString(EDataType eDataType, String initialValue)
2001
  {
2002
    return createInteger(initialValue);
2003
  }
2004
2005
  /**
2006
   * <!-- begin-user-doc -->
2007
   * <!-- end-user-doc -->
2008
   * @generated NOT
2009
   */
2010
  public String convertIntegerToString(EDataType eDataType, Object instanceValue)
2011
  {
2012
    return instanceValue == null ? null : instanceValue.toString();
2013
  }
2014
2015
  /**
2016
   * <!-- begin-user-doc -->
2017
   * <!-- end-user-doc -->
2018
   * @generated NOT
2019
   */
2020
  public Integer createIntObjectFromString(EDataType eDataType, String initialValue)
2021
  {
2022
    return createIntObject(initialValue);
2023
  }
2024
2025
  /**
2026
   * <!-- begin-user-doc -->
2027
   * <!-- end-user-doc -->
2028
   * @generated NOT
2029
   */
2030
  public String convertIntObjectToString(EDataType eDataType, Object instanceValue)
2031
  {
2032
    return instanceValue == null ? null : instanceValue.toString();
2033
  }
2034
2035
  /**
2036
   * <!-- begin-user-doc -->
2037
   * <!-- end-user-doc -->
2038
   * @generated NOT
2039
   */
2040
  public Long createLongFromString(EDataType eDataType, String initialValue)
2041
  {
2042
    return createLongObject(initialValue);
2043
  }
2044
2045
  /**
2046
   * <!-- begin-user-doc -->
2047
   * <!-- end-user-doc -->
2048
   * @generated NOT
2049
   */
2050
  public String convertLongToString(EDataType eDataType, Object instanceValue)
2051
  {
2052
    return instanceValue == null ? null : instanceValue.toString();
2053
  }
2054
2055
  /**
2056
   * <!-- begin-user-doc -->
2057
   * <!-- end-user-doc -->
2058
   * @generated NOT
2059
   */
2060
  public Long createLongObjectFromString(EDataType eDataType, String initialValue)
2061
  {
2062
    return createLongObject(initialValue);
2063
  }
2064
2065
  /**
2066
   * <!-- begin-user-doc -->
2067
   * <!-- end-user-doc -->
2068
   * @generated NOT
2069
   */
2070
  public String convertLongObjectToString(EDataType eDataType, Object instanceValue)
2071
  {
2072
    return instanceValue == null ? null : instanceValue.toString();
2073
  }
2074
2075
  /**
2076
   * <!-- begin-user-doc -->
2077
   * <!-- end-user-doc -->
2078
   * @generated NOT
2079
   */
2080
  public Integer createIntFromString(EDataType eDataType, String initialValue)
2081
  {
2082
    return createIntObject(initialValue);
2083
  }
2084
2085
  /**
2086
   * <!-- begin-user-doc -->
2087
   * <!-- end-user-doc -->
2088
   * @generated NOT
2089
   */
2090
  public String convertIntToString(EDataType eDataType, Object instanceValue)
2091
  {
2092
    return instanceValue == null ? null : instanceValue.toString();
2093
  }
2094
2095
  /**
2096
   * <!-- begin-user-doc -->
2097
   * <!-- end-user-doc -->
2098
   * @generated NOT
2099
   */
2100
  public Short createShortFromString(EDataType eDataType, String initialValue)
2101
  {
2102
    return createShortObject(initialValue);
2103
  }
2104
2105
  /**
2106
   * <!-- begin-user-doc -->
2107
   * <!-- end-user-doc -->
2108
   * @generated NOT
2109
   */
2110
  public String convertShortToString(EDataType eDataType, Object instanceValue)
2111
  {
2112
    return instanceValue == null ? null : instanceValue.toString();
2113
  }
2114
2115
  /**
2116
   * <!-- begin-user-doc -->
2117
   * <!-- end-user-doc -->
2118
   * @generated NOT
2119
   */
2120
  public Short createShortObjectFromString(EDataType eDataType, String initialValue)
2121
  {
2122
    return createShortObject(initialValue);
2123
  }
2124
2125
  /**
2126
   * <!-- begin-user-doc -->
2127
   * <!-- end-user-doc -->
2128
   * @generated NOT
2129
   */
2130
  public String convertShortObjectToString(EDataType eDataType, Object instanceValue)
2131
  {
2132
    return instanceValue == null ? null : instanceValue.toString();
2133
  }
2134
2135
  /**
2136
   * <!-- begin-user-doc -->
2137
   * <!-- end-user-doc -->
2138
   * @generated NOT
2139
   */
2140
  public Byte createByteFromString(EDataType eDataType, String initialValue)
2141
  {
2142
    return createByteObject(initialValue);
2143
  }
2144
2145
  /**
2146
   * <!-- begin-user-doc -->
2147
   * <!-- end-user-doc -->
2148
   * @generated NOT
2149
   */
2150
  public String convertByteToString(EDataType eDataType, Object instanceValue)
2151
  {
2152
    return instanceValue == null ? null : instanceValue.toString();
2153
  }
2154
2155
  /**
2156
   * <!-- begin-user-doc -->
2157
   * <!-- end-user-doc -->
2158
   * @generated NOT
2159
   */
2160
  public Byte createByteObjectFromString(EDataType eDataType, String initialValue)
2161
  {
2162
    return createByteObject(initialValue);
2163
  }
2164
2165
  /**
2166
   * <!-- begin-user-doc -->
2167
   * <!-- end-user-doc -->
2168
   * @generated NOT
2169
   */
2170
  public String convertByteObjectToString(EDataType eDataType, Object instanceValue)
2171
  {
2172
    return instanceValue == null ? null : instanceValue.toString();
2173
  }
2174
2175
  /**
2176
   * <!-- begin-user-doc -->
2177
   * <!-- end-user-doc -->
2178
   * @generated NOT
2179
   */
2180
  public Object createDateFromString(EDataType eDataType, String initialValue)
2181
  {
2182
    return createDate(initialValue);
2183
  }
2184
2185
  /**
2186
   * <!-- begin-user-doc -->
2187
   * <!-- end-user-doc -->
2188
   * @generated NOT
2189
   */
2190
  public String convertDateToString(EDataType eDataType, Object instanceValue)
2191
  {
2192
    return convertDate(instanceValue);
2193
  }
2194
2195
  /**
2196
   * <!-- begin-user-doc -->
2197
   * <!-- end-user-doc -->
2198
   * @generated NOT
2199
   */
2200
  public Object createDateTimeFromString(EDataType eDataType, String initialValue)
2201
  {
2202
    return createDateTime(initialValue);
2203
  }
2204
2205
  /**
2206
   * <!-- begin-user-doc -->
2207
   * <!-- end-user-doc -->
2208
   * @generated NOT
2209
   */
2210
  public String convertDateTimeToString(EDataType eDataType, Object instanceValue)
2211
  {
2212
    return convertDateTime(instanceValue);
2213
  }
2214
2215
  /**
2216
   * <!-- begin-user-doc -->
2217
   * <!-- end-user-doc -->
2218
   * @generated NOT
2219
   */
2220
  public String createStringFromString(EDataType eDataType, String initialValue)
2221
  {
2222
    return initialValue;
2223
  }
2224
2225
  /**
2226
   * <!-- begin-user-doc -->
2227
   * <!-- end-user-doc -->
2228
   * @generated NOT
2229
   */
2230
  public String convertStringToString(EDataType eDataType, Object instanceValue)
2231
  {
2232
    return (String)instanceValue;
2233
  }
2234
2235
  /**
2236
   * <!-- begin-user-doc -->
2237
   * <!-- end-user-doc -->
2238
   * @generated NOT
2239
   */
2240
  public Double createDoubleFromString(EDataType eDataType, String initialValue)
2241
  {
2242
    return createDoubleObject(initialValue);
2243
  }
2244
2245
  /**
2246
   * <!-- begin-user-doc -->
2247
   * <!-- end-user-doc -->
2248
   * @generated NOT
2249
   */
2250
  public String convertDoubleToString(EDataType eDataType, Object instanceValue)
2251
  {
2252
    return instanceValue == null ? null : instanceValue.toString();
2253
  }
2254
2255
  /**
2256
   * <!-- begin-user-doc -->
2257
   * <!-- end-user-doc -->
2258
   * @generated NOT
2259
   */
2260
  public Double createDoubleObjectFromString(EDataType eDataType, String initialValue)
2261
  {
2262
    return createDoubleObject(initialValue);
2263
  }
2264
2265
  /**
2266
   * <!-- begin-user-doc -->
2267
   * <!-- end-user-doc -->
2268
   * @generated NOT
2269
   */
2270
  public String convertDoubleObjectToString(EDataType eDataType, Object instanceValue)
2271
  {
2272
    return instanceValue == null ? null : instanceValue.toString();
2273
  }
2274
2275
  /**
2276
   * <!-- begin-user-doc -->
2277
   * <!-- end-user-doc -->
2278
   * @generated NOT
2279
   */
2280
  public Object createDurationFromString(EDataType eDataType, String initialValue)
2281
  {
2282
    return createDuration(initialValue);
2283
  }
2284
2285
  /**
2286
   * <!-- begin-user-doc -->
2287
   * <!-- end-user-doc -->
2288
   * @generated NOT
2289
   */
2290
  public String convertDurationToString(EDataType eDataType, Object instanceValue)
2291
  {
2292
    return instanceValue == null ? null : instanceValue.toString();
2293
  }
2294
2295
  /**
2296
   * <!-- begin-user-doc -->
2297
   * <!-- end-user-doc -->
2298
   * @generated NOT
2299
   */
2300
  public String createNormalizedStringFromString(EDataType eDataType, String initialValue)
2301
  {
2302
    return createNormalizedString(initialValue);
2303
  }
2304
2305
  /**
2306
   * <!-- begin-user-doc -->
2307
   * <!-- end-user-doc -->
2308
   * @generated NOT
2309
   */
2310
  public String convertNormalizedStringToString(EDataType eDataType, Object instanceValue)
2311
  {    
2312
    return (String)instanceValue;
2313
  }
2314
2315
  /**
2316
   * <!-- begin-user-doc -->
2317
   * <!-- end-user-doc -->
2318
   * @generated NOT
2319
   */
2320
  public String createTokenFromString(EDataType eDataType, String initialValue)
2321
  {
2322
    return createToken(initialValue);
2323
  }
2324
2325
  /**
2326
   * <!-- begin-user-doc -->
2327
   * <!-- end-user-doc -->
2328
   * @generated NOT
2329
   */
2330
  public String convertTokenToString(EDataType eDataType, Object instanceValue)
2331
  {
2332
    return (String)instanceValue;
2333
  }
2334
2335
  /**
2336
   * <!-- begin-user-doc -->
2337
   * <!-- end-user-doc -->
2338
   * @generated NOT
2339
   */
2340
  public String createNameFromString(EDataType eDataType, String initialValue)
2341
  {
2342
    // do not validate on load. Check validity using Diagnostician.
2343
    return createName(initialValue);
2344
  }
2345
2346
  /**
2347
   * <!-- begin-user-doc -->
2348
   * <!-- end-user-doc -->
2349
   * @generated NOT
2350
   */
2351
  public String convertNameToString(EDataType eDataType, Object instanceValue)
2352
  {
2353
    return (String)instanceValue;
2354
  }
2355
2356
  /**
2357
   * <!-- begin-user-doc -->
2358
   * <!-- end-user-doc -->
2359
   * @generated NOT
2360
   */
2361
  public String createNCNameFromString(EDataType eDataType, String initialValue)
2362
  {
2363
    // do not validate on load. Check validity using Diagnostician.
2364
    return createNCName(initialValue);
2365
  }
2366
2367
  /**
2368
   * <!-- begin-user-doc -->
2369
   * <!-- end-user-doc -->
2370
   * @generated NOT
2371
   */
2372
  public String convertNCNameToString(EDataType eDataType, Object instanceValue)
2373
  {
2374
    return (String)instanceValue;
2375
  }
2376
2377
  /**
2378
   * <!-- begin-user-doc -->
2379
   * <!-- end-user-doc -->
2380
   * @generated NOT
2381
   */
2382
  public String createENTITYFromString(EDataType eDataType, String initialValue)
2383
  {
2384
    return createENTITY(initialValue);
2385
  }
2386
2387
  /**
2388
   * <!-- begin-user-doc -->
2389
   * <!-- end-user-doc -->
2390
   * @generated NOT
2391
   */
2392
  public String convertENTITYToString(EDataType eDataType, Object instanceValue)
2393
  {
2394
    return (String)instanceValue;
2395
  }
2396
2397
  /**
2398
   * <!-- begin-user-doc -->
2399
   * <!-- end-user-doc -->
2400
   * @generated NOT
2401
   */
2402
  public Float createFloatFromString(EDataType eDataType, String initialValue)
2403
  {
2404
    return createFloatObject(initialValue);
2405
  }
2406
2407
  /**
2408
   * <!-- begin-user-doc -->
2409
   * <!-- end-user-doc -->
2410
   * @generated NOT
2411
   */
2412
  public String convertFloatToString(EDataType eDataType, Object instanceValue)
2413
  {
2414
    return instanceValue == null ? null : instanceValue.toString();
2415
  }
2416
2417
  /**
2418
   * <!-- begin-user-doc -->
2419
   * <!-- end-user-doc -->
2420
   * @generated NOT
2421
   */
2422
  public Float createFloatObjectFromString(EDataType eDataType, String initialValue)
2423
  {
2424
    return createFloatObject(initialValue);
2425
  }
2426
2427
  /**
2428
   * <!-- begin-user-doc -->
2429
   * <!-- end-user-doc -->
2430
   * @generated NOT
2431
   */
2432
  public String convertFloatObjectToString(EDataType eDataType, Object instanceValue)
2433
  {
2434
    return instanceValue == null ? null : instanceValue.toString();
2435
  }
2436
2437
  /**
2438
   * <!-- begin-user-doc -->
2439
   * <!-- end-user-doc -->
2440
   * @generated NOT
2441
   */
2442
  public Object createGDayFromString(EDataType eDataType, String initialValue)
2443
  {
2444
    return createGDay(initialValue);
2445
  }
2446
2447
  /**
2448
   * <!-- begin-user-doc -->
2449
   * <!-- end-user-doc -->
2450
   * @generated NOT
2451
   */
2452
  public String convertGDayToString(EDataType eDataType, Object instanceValue)
2453
  {
2454
    return instanceValue == null ? null : instanceValue.toString();
2455
  }
2456
2457
  /**
2458
   * <!-- begin-user-doc -->
2459
   * <!-- end-user-doc -->
2460
   * @generated NOT
2461
   */
2462
  public Object createGMonthFromString(EDataType eDataType, String initialValue)
2463
  {
2464
    return createGMonth(initialValue);
2465
  }
2466
2467
  /**
2468
   * <!-- begin-user-doc -->
2469
   * <!-- end-user-doc -->
2470
   * @generated NOT
2471
   */
2472
  public String convertGMonthToString(EDataType eDataType, Object instanceValue)
2473
  {
2474
    return instanceValue == null ? null : instanceValue.toString();
2475
  }
2476
2477
  /**
2478
   * <!-- begin-user-doc -->
2479
   * <!-- end-user-doc -->
2480
   * @generated NOT
2481
   */
2482
  public Object createGMonthDayFromString(EDataType eDataType, String initialValue)
2483
  {
2484
    return createGMonthDay(initialValue);
2485
  }
2486
2487
  /**
2488
   * <!-- begin-user-doc -->
2489
   * <!-- end-user-doc -->
2490
   * @generated NOT
2491
   */
2492
  public String convertGMonthDayToString(EDataType eDataType, Object instanceValue)
2493
  {
2494
    return instanceValue == null ? null : instanceValue.toString();
2495
  }
2496
2497
  /**
2498
   * <!-- begin-user-doc -->
2499
   * <!-- end-user-doc -->
2500
   * @generated NOT
2501
   */
2502
  public Object createGYearFromString(EDataType eDataType, String initialValue)
2503
  {
2504
    return createGYear(initialValue);
2505
  }
2506
2507
  /**
2508
   * <!-- begin-user-doc -->
2509
   * <!-- end-user-doc -->
2510
   * @generated NOT
2511
   */
2512
  public String convertGYearToString(EDataType eDataType, Object instanceValue)
2513
  {
2514
    return instanceValue == null ? null : instanceValue.toString();
2515
  }
2516
2517
  /**
2518
   * <!-- begin-user-doc -->
2519
   * <!-- end-user-doc -->
2520
   * @generated NOT
2521
   */
2522
  public Object createGYearMonthFromString(EDataType eDataType, String initialValue)
2523
  {
2524
    return createGYearMonth(initialValue);
2525
}
2526
683
2527
  /**
684
	}
2528
   * <!-- begin-user-doc -->
2529
   * <!-- end-user-doc -->
2530
   * @generated NOT
2531
   */
2532
  public String convertGYearMonthToString(EDataType eDataType, Object instanceValue)
2533
  {
2534
    return instanceValue == null ? null : instanceValue.toString();
2535
  }
2536
2537
  /**
2538
   * <!-- begin-user-doc -->
2539
   * <!-- end-user-doc -->
2540
   * @generated NOT
2541
   */
2542
  public byte[] createHexBinaryFromString(EDataType eDataType, String initialValue)
2543
  {
2544
    return createHexBinary(initialValue);
2545
  }
2546
2547
  /**
2548
   * <!-- begin-user-doc -->
2549
   * <!-- end-user-doc -->
2550
   * @generated NOT
2551
   */
2552
  public String convertHexBinaryToString(EDataType eDataType, Object instanceValue)
2553
  {
2554
    return convertHexBinary((byte[])instanceValue);
2555
  }
2556
2557
  /**
2558
   * <!-- begin-user-doc -->
2559
   * <!-- end-user-doc -->
2560
   * @generated NOT
2561
   */
2562
  public String convertIDToString(EDataType eDataType, Object instanceValue)
2563
  {
2564
    return (String)instanceValue;
2565
  }
2566
2567
  /**
2568
   * <!-- begin-user-doc -->
2569
   * <!-- end-user-doc -->
2570
   * @generated NOT
2571
   */
2572
  public String convertIDREFToString(EDataType eDataType, Object instanceValue)
2573
  {
2574
    return (String)instanceValue;
2575
  }
2576
2577
  /**
2578
   * <!-- begin-user-doc -->
2579
   * <!-- end-user-doc -->
2580
   * @generated NOT
2581
   */
2582
  public String createLanguageFromString(EDataType eDataType, String initialValue)
2583
  {
2584
    return createLanguage(initialValue);
2585
  }
2586
2587
  /**
2588
   * <!-- begin-user-doc -->
2589
   * <!-- end-user-doc -->
2590
   * @generated NOT
2591
   */
2592
  public String convertLanguageToString(EDataType eDataType, Object instanceValue)
2593
  {
2594
    return (String)instanceValue;
2595
  }
2596
2597
  /**
2598
   * <!-- begin-user-doc -->
2599
   * <!-- end-user-doc -->
2600
   * @generated NOT
2601
   */
2602
  public BigInteger createNonPositiveIntegerFromString(EDataType eDataType, String initialValue)
2603
  {
2604
    return createNonPositiveInteger(initialValue);
2605
  }
2606
2607
  /**
2608
   * <!-- begin-user-doc -->
2609
   * <!-- end-user-doc -->
2610
   * @generated NOT
2611
   */
2612
  public String convertNonPositiveIntegerToString(EDataType eDataType, Object instanceValue)
2613
  {
2614
    return instanceValue == null ? null : instanceValue.toString();
2615
  }
2616
2617
  /**
2618
   * <!-- begin-user-doc -->
2619
   * <!-- end-user-doc -->
2620
   * @generated NOT
2621
   */
2622
  public String createNMTOKENFromString(EDataType eDataType, String initialValue)
2623
  {
2624
    return createNMTOKEN(initialValue);
2625
  }
2626
2627
  /**
2628
   * <!-- begin-user-doc -->
2629
   * <!-- end-user-doc -->
2630
   * @generated NOT
2631
   */
2632
  public String convertNMTOKENToString(EDataType eDataType, Object instanceValue)
2633
  {
2634
    return (String)instanceValue;
2635
  }
2636
2637
  /**
2638
   * <!-- begin-user-doc -->
2639
   * <!-- end-user-doc -->
2640
   * @generated NOT
2641
   */
2642
  public BigInteger createNonNegativeIntegerFromString(EDataType eDataType, String initialValue)
2643
  {
2644
    return createNonNegativeInteger(initialValue);
2645
  }
2646
2647
  /**
2648
   * <!-- begin-user-doc -->
2649
   * <!-- end-user-doc -->
2650
   * @generated NOT
2651
   */
2652
  public String convertNonNegativeIntegerToString(EDataType eDataType, Object instanceValue)
2653
  {
2654
    return instanceValue == null ? null : instanceValue.toString();
2655
  }
2656
2657
  /**
2658
   * <!-- begin-user-doc -->
2659
   * <!-- end-user-doc -->
2660
   * @generated NOT
2661
   */
2662
  public Object createNOTATIONFromString(EDataType eDataType, String initialValue)
2663
  {
2664
    return createNOTATION(initialValue);
2665
  }
2666
2667
  /**
2668
   * <!-- begin-user-doc -->
2669
   * <!-- end-user-doc -->
2670
   * @generated NOT
2671
   */
2672
  public String convertNOTATIONToString(EDataType eDataType, Object instanceValue)
2673
  {
2674
    return instanceValue == null ? null : instanceValue.toString();
2675
  }
2676
2677
  /**
2678
   * <!-- begin-user-doc -->
2679
   * <!-- end-user-doc -->
2680
   * @generated NOT
2681
   */
2682
  public Object createQNameFromString(EDataType eDataType, String initialValue)
2683
  {
2684
    return createQName(initialValue);
2685
  }
2686
2687
  /**
2688
   * <!-- begin-user-doc -->
2689
   * <!-- end-user-doc -->
2690
   * @generated NOT
2691
   */
2692
  public String convertQNameToString(EDataType eDataType, Object instanceValue)
2693
  {
2694
    return instanceValue == null ? null : instanceValue.toString();
2695
  }
2696
2697
  /**
2698
   * <!-- begin-user-doc -->
2699
   * <!-- end-user-doc -->
2700
   * @generated NOT
2701
   */
2702
  public Object createTimeFromString(EDataType eDataType, String initialValue)
2703
  {
2704
    return createTime(initialValue);
2705
  }
2706
2707
  /**
2708
   * <!-- begin-user-doc -->
2709
   * <!-- end-user-doc -->
2710
   * @generated NOT
2711
   */
2712
  public String convertTimeToString(EDataType eDataType, Object instanceValue)
2713
  {
2714
    return instanceValue == null ? null : instanceValue.toString();
2715
  }
2716
2717
  /**
2718
   * <!-- begin-user-doc -->
2719
   * <!-- end-user-doc -->
2720
   * @generated NOT
2721
   */
2722
  public Long createUnsignedIntFromString(EDataType eDataType, String initialValue)
2723
  {
2724
    return createUnsignedIntObject(initialValue);
2725
  }
2726
2727
  /**
2728
   * <!-- begin-user-doc -->
2729
   * <!-- end-user-doc -->
2730
   * @generated NOT
2731
   */
2732
  public String convertUnsignedIntToString(EDataType eDataType, Object instanceValue)
2733
  {
2734
    return instanceValue == null ? null : instanceValue.toString();
2735
  }
2736
2737
  /**
2738
   * <!-- begin-user-doc -->
2739
   * <!-- end-user-doc -->
2740
   * @generated NOT
2741
   */
2742
  public Long createUnsignedIntObjectFromString(EDataType eDataType, String initialValue)
2743
  {
2744
    return createUnsignedIntObject(initialValue);
2745
  }
2746
2747
  /**
2748
   * <!-- begin-user-doc -->
2749
   * <!-- end-user-doc -->
2750
   * @generated NOT
2751
   */
2752
  public String convertUnsignedIntObjectToString(EDataType eDataType, Object instanceValue)
2753
  {
2754
    return instanceValue == null ? null : instanceValue.toString();
2755
  }
2756
2757
  /**
2758
   * <!-- begin-user-doc -->
2759
   * <!-- end-user-doc -->
2760
   * @generated NOT
2761
   */
2762
  public Integer createUnsignedShortFromString(EDataType eDataType, String initialValue)
2763
  {
2764
    return createUnsignedShortObject(initialValue);
2765
  }
2766
2767
  /**
2768
   * <!-- begin-user-doc -->
2769
   * <!-- end-user-doc -->
2770
   * @generated NOT
2771
   */
2772
  public String convertUnsignedShortToString(EDataType eDataType, Object instanceValue)
2773
  {
2774
    return instanceValue == null ? null : instanceValue.toString();
2775
  }
2776
2777
  /**
2778
   * <!-- begin-user-doc -->
2779
   * <!-- end-user-doc -->
2780
   * @generated NOT
2781
   */
2782
  public Integer createUnsignedShortObjectFromString(EDataType eDataType, String initialValue)
2783
  {
2784
    return initialValue == null ? null : Integer.valueOf(collapseWhiteSpace(initialValue));
2785
  }
2786
2787
  /**
2788
   * <!-- begin-user-doc -->
2789
   * <!-- end-user-doc -->
2790
   * @generated NOT
2791
   */
2792
  public String convertUnsignedShortObjectToString(EDataType eDataType, Object instanceValue)
2793
  {
2794
    return instanceValue == null ? null : instanceValue.toString();
2795
  }
2796
2797
  /**
2798
   * <!-- begin-user-doc -->
2799
   * <!-- end-user-doc -->
2800
   * @generated NOT
2801
   */
2802
  public Short createUnsignedByteFromString(EDataType eDataType, String initialValue)
2803
  {
2804
    return createUnsignedByteObject(initialValue);
2805
  }
2806
2807
  /**
2808
   * <!-- begin-user-doc -->
2809
   * <!-- end-user-doc -->
2810
   * @generated NOT
2811
   */
2812
  public String convertUnsignedByteToString(EDataType eDataType, Object instanceValue)
2813
  {
2814
    return instanceValue == null ? null : instanceValue.toString();
2815
  }
2816
2817
  /**
2818
   * <!-- begin-user-doc -->
2819
   * <!-- end-user-doc -->
2820
   * @generated NOT
2821
   */
2822
  public Short createUnsignedByteObjectFromString(EDataType eDataType, String initialValue)
2823
  {
2824
    return createUnsignedByteObject(initialValue);
2825
  }
2826
2827
  /**
2828
   * <!-- begin-user-doc -->
2829
   * <!-- end-user-doc -->
2830
   * @generated NOT
2831
   */
2832
  public String convertUnsignedByteObjectToString(EDataType eDataType, Object instanceValue)
2833
  {
2834
    return instanceValue == null ? null : instanceValue.toString();
2835
  }
2836
2837
  /**
2838
   * <!-- begin-user-doc -->
2839
   * <!-- end-user-doc -->
2840
   * @generated
2841
   */
2842
  public XMLTypePackage getXMLTypePackage()
2843
  {
2844
    return (XMLTypePackage)getEPackage();
2845
  }
2846
2847
  /**
2848
   * <!-- begin-user-doc -->
2849
   * <!-- end-user-doc -->
2850
   * @deprecated
2851
   * @generated
2852
   */
2853
  public static XMLTypePackage getPackage()
2854
  {
2855
    return XMLTypePackage.eINSTANCE;
2856
  }
2857
2858
  protected Boolean booleanValueOf(String initialValue)
2859
  {
2860
    initialValue = collapseWhiteSpace(initialValue);
2861
    if ("true".equals(initialValue) || "1".equals(initialValue))
2862
    {
2863
      return Boolean.TRUE;
2864
    }
2865
    else if ("false".equals(initialValue) || "0".equals(initialValue))
2866
    {
2867
      return Boolean.FALSE;
2868
    }
2869
    throw new InvalidDatatypeValueException("Invalid boolean value: '" + initialValue + "'");
2870
  }
2871
  
2872
  protected boolean primitiveBooleanValueOf(String initialValue)
2873
  {
2874
    initialValue = collapseWhiteSpace(initialValue);
2875
    if ("true".equals(initialValue) || "1".equals(initialValue))
2876
    {
2877
      return true;
2878
    }
2879
    else if ("false".equals(initialValue) || "0".equals(initialValue))
2880
    {
2881
      return false;
2882
    }
2883
    throw new InvalidDatatypeValueException("Invalid boolean value: '" + initialValue + "'");
2884
  }
2885
2886
  private static class SafeSimpleDateFormat extends SimpleDateFormat
2887
  {
2888
    public SafeSimpleDateFormat(String pattern)
2889
    {
2890
      super(pattern);
2891
    }
2892
2893
    public synchronized Date parse(String source) throws ParseException
2894
    {
2895
      return super.parse(source);
2896
    }
2897
2898
    public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
2899
    {
2900
      StringBuffer result = super.format(date, toAppendTo, pos);
2901
      result.insert(result.length() - 2, ":");
2902
      return result;
2903
    }
2904
  }
2905
685
2906
} //XMLTypeFactoryImpl
686
}
(-)src/org/eclipse/emf/ecore/xml/type/impl/XMLTypeDocumentRootImpl.java (-388 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypeDocumentRootImpl.java,v 1.9 2005/11/25 17:49:49 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.impl;
18
19
20
import org.eclipse.emf.common.notify.NotificationChain;
21
import org.eclipse.emf.common.util.EMap;
22
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EStructuralFeature;
24
import org.eclipse.emf.ecore.EcorePackage;
25
import org.eclipse.emf.ecore.InternalEObject;
26
import org.eclipse.emf.ecore.impl.EObjectImpl;
27
import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
28
import org.eclipse.emf.ecore.util.BasicFeatureMap;
29
import org.eclipse.emf.ecore.util.EcoreEMap;
30
import org.eclipse.emf.ecore.util.FeatureMap;
31
import org.eclipse.emf.ecore.util.InternalEList;
32
import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
33
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
34
35
36
/**
37
 * <!-- begin-user-doc -->
38
 * An implementation of the model object '<em><b>Document Root</b></em>'.
39
 * <!-- end-user-doc -->
40
 * <p>
41
 * The following features are implemented:
42
 * <ul>
43
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getMixed <em>Mixed</em>}</li>
44
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}</li>
45
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getXSISchemaLocation <em>XSI Schema Location</em>}</li>
46
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getCDATA <em>CDATA</em>}</li>
47
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getComment <em>Comment</em>}</li>
48
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.XMLTypeDocumentRootImpl#getText <em>Text</em>}</li>
49
 * </ul>
50
 * </p>
51
 *
52
 * @generated
53
 */
54
public class XMLTypeDocumentRootImpl extends EObjectImpl implements XMLTypeDocumentRoot
55
{
56
  /**
57
   * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
58
   * <!-- begin-user-doc -->
59
   * <!-- end-user-doc -->
60
   * @see #getMixed()
61
   * @generated
62
   * @ordered
63
   */
64
  protected FeatureMap mixed = null;
65
66
  /**
67
   * The cached value of the '{@link #getXMLNSPrefixMap() <em>XMLNS Prefix Map</em>}' map.
68
   * <!-- begin-user-doc -->
69
   * <!-- end-user-doc -->
70
   * @see #getXMLNSPrefixMap()
71
   * @generated
72
   * @ordered
73
   */
74
  protected EMap xMLNSPrefixMap = null;
75
76
  /**
77
   * The cached value of the '{@link #getXSISchemaLocation() <em>XSI Schema Location</em>}' map.
78
   * <!-- begin-user-doc -->
79
   * <!-- end-user-doc -->
80
   * @see #getXSISchemaLocation()
81
   * @generated
82
   * @ordered
83
   */
84
  protected EMap xSISchemaLocation = null;
85
86
  /**
87
   * The default value of the '{@link #getCDATA() <em>CDATA</em>}' attribute.
88
   * <!-- begin-user-doc -->
89
   * <!-- end-user-doc -->
90
   * @see #getCDATA()
91
   * @generated
92
   * @ordered
93
   */
94
  protected static final String CDATA_EDEFAULT = null;
95
96
  /**
97
   * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
98
   * <!-- begin-user-doc -->
99
   * <!-- end-user-doc -->
100
   * @see #getComment()
101
   * @generated
102
   * @ordered
103
   */
104
  protected static final String COMMENT_EDEFAULT = null;
105
106
  /**
107
   * The default value of the '{@link #getText() <em>Text</em>}' attribute.
108
   * <!-- begin-user-doc -->
109
   * <!-- end-user-doc -->
110
   * @see #getText()
111
   * @generated
112
   * @ordered
113
   */
114
  protected static final String TEXT_EDEFAULT = null;
115
116
  /**
117
   * <!-- begin-user-doc -->
118
   * <!-- end-user-doc -->
119
   * @generated
120
   */
121
  protected XMLTypeDocumentRootImpl()
122
  {
123
    super();
124
  }
125
126
  /**
127
   * <!-- begin-user-doc -->
128
   * <!-- end-user-doc -->
129
   * @generated
130
   */
131
  protected EClass eStaticClass()
132
  {
133
    return XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT;
134
  }
135
136
  /**
137
   * <!-- begin-user-doc -->
138
   * <!-- end-user-doc -->
139
   * @generated
140
   */
141
  public FeatureMap getMixed()
142
  {
143
    if (mixed == null)
144
    {
145
      mixed = new BasicFeatureMap(this, XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED);
146
    }
147
    return mixed;
148
  }
149
150
  /**
151
   * <!-- begin-user-doc -->
152
   * <!-- end-user-doc -->
153
   * @generated
154
   */
155
  public EMap getXMLNSPrefixMap()
156
  {
157
    if (xMLNSPrefixMap == null)
158
    {
159
      xMLNSPrefixMap = new EcoreEMap(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
160
    }
161
    return xMLNSPrefixMap;
162
  }
163
164
  /**
165
   * <!-- begin-user-doc -->
166
   * <!-- end-user-doc -->
167
   * @generated
168
   */
169
  public EMap getXSISchemaLocation()
170
  {
171
    if (xSISchemaLocation == null)
172
    {
173
      xSISchemaLocation = new EcoreEMap(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
174
    }
175
    return xSISchemaLocation;
176
  }
177
178
  /**
179
   * <!-- begin-user-doc -->
180
   * <!-- end-user-doc -->
181
   * @generated
182
   */
183
  public String getText()
184
  {
185
    return (String)getMixed().get(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, true);
186
  }
187
188
  /**
189
   * <!-- begin-user-doc -->
190
   * <!-- end-user-doc -->
191
   * @generated
192
   */
193
  public void setText(String newText)
194
  {
195
    ((FeatureMap.Internal)getMixed()).set(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, newText);
196
  }
197
198
  /**
199
   * <!-- begin-user-doc -->
200
   * <!-- end-user-doc -->
201
   * @generated
202
   */
203
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
204
  {
205
    switch (featureID)
206
    {
207
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED:
208
        return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs);
209
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
210
        return ((InternalEList)getXMLNSPrefixMap()).basicRemove(otherEnd, msgs);
211
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
212
        return ((InternalEList)getXSISchemaLocation()).basicRemove(otherEnd, msgs);
213
    }
214
    return eDynamicInverseRemove(otherEnd, featureID, msgs);
215
  }
216
217
  /**
218
   * <!-- begin-user-doc -->
219
   * <!-- end-user-doc -->
220
   * @generated
221
   */
222
  public Object eGet(int featureID, boolean resolve, boolean coreType)
223
  {
224
    switch (featureID)
225
    {
226
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED:
227
        if (coreType) return getMixed();
228
        return ((FeatureMap.Internal)getMixed()).getWrapper();
229
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
230
        if (coreType) return getXMLNSPrefixMap();
231
        else return getXMLNSPrefixMap().map();
232
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
233
        if (coreType) return getXSISchemaLocation();
234
        else return getXSISchemaLocation().map();
235
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
236
        return getCDATA();
237
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__COMMENT:
238
        return getComment();
239
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
240
        return getText();
241
    }
242
    return eDynamicGet(featureID, resolve, coreType);
243
  }
244
245
  /**
246
   * <!-- begin-user-doc -->
247
   * <!-- end-user-doc -->
248
   * @generated
249
   */
250
  public void eSet(int featureID, Object newValue)
251
  {
252
    switch (featureID)
253
    {
254
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED:
255
        ((FeatureMap.Internal)getMixed()).set(newValue);
256
        return;
257
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
258
        ((EStructuralFeature.Setting)getXMLNSPrefixMap()).set(newValue);
259
        return;
260
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
261
        ((EStructuralFeature.Setting)getXSISchemaLocation()).set(newValue);
262
        return;
263
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
264
        setCDATA((String)newValue);
265
        return;
266
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__COMMENT:
267
        setComment((String)newValue);
268
        return;
269
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
270
        setText((String)newValue);
271
        return;
272
    }
273
    eDynamicSet(featureID, newValue);
274
  }
275
276
  /**
277
   * <!-- begin-user-doc -->
278
   * <!-- end-user-doc -->
279
   * @generated
280
   */
281
  public void eUnset(int featureID)
282
  {
283
    switch (featureID)
284
    {
285
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED:
286
        getMixed().clear();
287
        return;
288
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
289
        getXMLNSPrefixMap().clear();
290
        return;
291
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
292
        getXSISchemaLocation().clear();
293
        return;
294
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
295
        setCDATA(CDATA_EDEFAULT);
296
        return;
297
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__COMMENT:
298
        setComment(COMMENT_EDEFAULT);
299
        return;
300
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
301
        setText(TEXT_EDEFAULT);
302
        return;
303
    }
304
    eDynamicUnset(featureID);
305
  }
306
307
  /**
308
   * <!-- begin-user-doc -->
309
   * <!-- end-user-doc -->
310
   * @generated
311
   */
312
  public boolean eIsSet(int featureID)
313
  {
314
    switch (featureID)
315
    {
316
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__MIXED:
317
        return mixed != null && !mixed.isEmpty();
318
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
319
        return xMLNSPrefixMap != null && !xMLNSPrefixMap.isEmpty();
320
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
321
        return xSISchemaLocation != null && !xSISchemaLocation.isEmpty();
322
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
323
        return CDATA_EDEFAULT == null ? getCDATA() != null : !CDATA_EDEFAULT.equals(getCDATA());
324
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__COMMENT:
325
        return COMMENT_EDEFAULT == null ? getComment() != null : !COMMENT_EDEFAULT.equals(getComment());
326
      case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
327
        return TEXT_EDEFAULT == null ? getText() != null : !TEXT_EDEFAULT.equals(getText());
328
    }
329
    return eDynamicIsSet(featureID);
330
  }
331
332
  /**
333
   * <!-- begin-user-doc -->
334
   * <!-- end-user-doc -->
335
   * @generated
336
   */
337
  public String getCDATA()
338
  {
339
    return (String)getMixed().get(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA, true);
340
  }
341
342
  /**
343
   * <!-- begin-user-doc -->
344
   * <!-- end-user-doc -->
345
   * @generated
346
   */
347
  public void setCDATA(String newCDATA)
348
  {
349
    ((FeatureMap.Internal)getMixed()).set(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA, newCDATA);
350
  }
351
352
  /**
353
   * <!-- begin-user-doc -->
354
   * <!-- end-user-doc -->
355
   * @generated
356
   */
357
  public String getComment()
358
  {
359
    return (String)getMixed().get(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT, true);
360
  }
361
362
  /**
363
   * <!-- begin-user-doc -->
364
   * <!-- end-user-doc -->
365
   * @generated
366
   */
367
  public void setComment(String newComment)
368
  {
369
    ((FeatureMap.Internal)getMixed()).set(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT, newComment);
370
  }
371
372
  /**
373
   * <!-- begin-user-doc -->
374
   * <!-- end-user-doc -->
375
   * @generated
376
   */
377
  public String toString()
378
  {
379
    if (eIsProxy()) return super.toString();
380
381
    StringBuffer result = new StringBuffer(super.toString());
382
    result.append(" (mixed: ");
383
    result.append(mixed);
384
    result.append(')');
385
    return result.toString();
386
  }
387
388
} //DocumentRootImpl
(-)src/org/eclipse/emf/ecore/xml/type/impl/XMLTypePackageImpl.java (-2135 / +545 lines)
Lines 1-2147 Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLTypePackageImpl.java,v 1.16 2005/12/02 18:07:47 davidms Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.impl;
1
package org.eclipse.emf.ecore.xml.type.impl;
18
2
19
3
import org.eclipse.emf.common.notify.Notification;
20
import java.math.BigDecimal;
4
import org.eclipse.emf.common.util.EList;
21
import java.math.BigInteger;
5
import org.eclipse.emf.common.util.TreeIterator;
22
import java.util.List;
6
import org.eclipse.emf.ecore.EAnnotation;
23
24
import org.eclipse.emf.ecore.EAttribute;
7
import org.eclipse.emf.ecore.EAttribute;
25
import org.eclipse.emf.ecore.EClass;
8
import org.eclipse.emf.ecore.EClass;
9
import org.eclipse.emf.ecore.EClassifier;
26
import org.eclipse.emf.ecore.EDataType;
10
import org.eclipse.emf.ecore.EDataType;
11
import org.eclipse.emf.ecore.EFactory;
12
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.emf.ecore.EPackage;
13
import org.eclipse.emf.ecore.EPackage;
28
import org.eclipse.emf.ecore.EReference;
14
import org.eclipse.emf.ecore.EReference;
29
import org.eclipse.emf.ecore.EValidator;
15
import org.eclipse.emf.ecore.EStructuralFeature;
30
16
import org.eclipse.emf.ecore.resource.Resource;
31
import org.eclipse.emf.ecore.impl.EPackageImpl;
32
import org.eclipse.emf.ecore.xml.type.AnyType;
33
import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
34
import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
35
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
17
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
36
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
18
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
37
19
20
public class XMLTypePackageImpl implements XMLTypePackage {
38
21
39
import org.eclipse.emf.ecore.xml.type.util.XMLTypeValidator;
22
	public static XMLTypePackage init() {
23
		// TODO Auto-generated method stub
24
		return null;
25
	}
26
27
	public EDataType getAnySimpleType() {
28
		// TODO Auto-generated method stub
29
		return null;
30
	}
31
32
	public EClass getAnyType() {
33
		// TODO Auto-generated method stub
34
		return null;
35
	}
36
37
	public EAttribute getAnyType_Any() {
38
		// TODO Auto-generated method stub
39
		return null;
40
	}
41
42
	public EAttribute getAnyType_AnyAttribute() {
43
		// TODO Auto-generated method stub
44
		return null;
45
	}
46
47
	public EAttribute getAnyType_Mixed() {
48
		// TODO Auto-generated method stub
49
		return null;
50
	}
51
52
	public EDataType getAnyURI() {
53
		// TODO Auto-generated method stub
54
		return null;
55
	}
56
57
	public EDataType getBase64Binary() {
58
		// TODO Auto-generated method stub
59
		return null;
60
	}
61
62
	public EDataType getBoolean() {
63
		// TODO Auto-generated method stub
64
		return null;
65
	}
66
67
	public EDataType getBooleanObject() {
68
		// TODO Auto-generated method stub
69
		return null;
70
	}
71
72
	public EDataType getByte() {
73
		// TODO Auto-generated method stub
74
		return null;
75
	}
76
77
	public EDataType getByteObject() {
78
		// TODO Auto-generated method stub
79
		return null;
80
	}
81
82
	public EDataType getDate() {
83
		// TODO Auto-generated method stub
84
		return null;
85
	}
86
87
	public EDataType getDateTime() {
88
		// TODO Auto-generated method stub
89
		return null;
90
	}
91
92
	public EDataType getDecimal() {
93
		// TODO Auto-generated method stub
94
		return null;
95
	}
96
97
	public EDataType getDouble() {
98
		// TODO Auto-generated method stub
99
		return null;
100
	}
101
102
	public EDataType getDoubleObject() {
103
		// TODO Auto-generated method stub
104
		return null;
105
	}
106
107
	public EDataType getDuration() {
108
		// TODO Auto-generated method stub
109
		return null;
110
	}
111
112
	public EDataType getENTITIES() {
113
		// TODO Auto-generated method stub
114
		return null;
115
	}
116
117
	public EDataType getENTITIESBase() {
118
		// TODO Auto-generated method stub
119
		return null;
120
	}
121
122
	public EDataType getENTITY() {
123
		// TODO Auto-generated method stub
124
		return null;
125
	}
126
127
	public EDataType getFloat() {
128
		// TODO Auto-generated method stub
129
		return null;
130
	}
131
132
	public EDataType getFloatObject() {
133
		// TODO Auto-generated method stub
134
		return null;
135
	}
136
137
	public EDataType getGDay() {
138
		// TODO Auto-generated method stub
139
		return null;
140
	}
141
142
	public EDataType getGMonth() {
143
		// TODO Auto-generated method stub
144
		return null;
145
	}
146
147
	public EDataType getGMonthDay() {
148
		// TODO Auto-generated method stub
149
		return null;
150
	}
151
152
	public EDataType getGYear() {
153
		// TODO Auto-generated method stub
154
		return null;
155
	}
156
157
	public EDataType getGYearMonth() {
158
		// TODO Auto-generated method stub
159
		return null;
160
	}
161
162
	public EDataType getHexBinary() {
163
		// TODO Auto-generated method stub
164
		return null;
165
	}
166
167
	public EDataType getID() {
168
		// TODO Auto-generated method stub
169
		return null;
170
	}
171
172
	public EDataType getIDREF() {
173
		// TODO Auto-generated method stub
174
		return null;
175
	}
176
177
	public EDataType getIDREFS() {
178
		// TODO Auto-generated method stub
179
		return null;
180
	}
181
182
	public EDataType getIDREFSBase() {
183
		// TODO Auto-generated method stub
184
		return null;
185
	}
186
187
	public EDataType getInt() {
188
		// TODO Auto-generated method stub
189
		return null;
190
	}
191
192
	public EDataType getIntObject() {
193
		// TODO Auto-generated method stub
194
		return null;
195
	}
196
197
	public EDataType getInteger() {
198
		// TODO Auto-generated method stub
199
		return null;
200
	}
201
202
	public EDataType getLanguage() {
203
		// TODO Auto-generated method stub
204
		return null;
205
	}
206
207
	public EDataType getLong() {
208
		// TODO Auto-generated method stub
209
		return null;
210
	}
211
212
	public EDataType getLongObject() {
213
		// TODO Auto-generated method stub
214
		return null;
215
	}
216
217
	public EDataType getNCName() {
218
		// TODO Auto-generated method stub
219
		return null;
220
	}
221
222
	public EDataType getNMTOKEN() {
223
		// TODO Auto-generated method stub
224
		return null;
225
	}
226
227
	public EDataType getNMTOKENS() {
228
		// TODO Auto-generated method stub
229
		return null;
230
	}
231
232
	public EDataType getNMTOKENSBase() {
233
		// TODO Auto-generated method stub
234
		return null;
235
	}
236
237
	public EDataType getNOTATION() {
238
		// TODO Auto-generated method stub
239
		return null;
240
	}
241
242
	public EDataType getName_() {
243
		// TODO Auto-generated method stub
244
		return null;
245
	}
246
247
	public EDataType getNegativeInteger() {
248
		// TODO Auto-generated method stub
249
		return null;
250
	}
251
252
	public EDataType getNonNegativeInteger() {
253
		// TODO Auto-generated method stub
254
		return null;
255
	}
256
257
	public EDataType getNonPositiveInteger() {
258
		// TODO Auto-generated method stub
259
		return null;
260
	}
261
262
	public EDataType getNormalizedString() {
263
		// TODO Auto-generated method stub
264
		return null;
265
	}
266
267
	public EDataType getPositiveInteger() {
268
		// TODO Auto-generated method stub
269
		return null;
270
	}
271
272
	public EDataType getQName() {
273
		// TODO Auto-generated method stub
274
		return null;
275
	}
276
277
	public EDataType getShort() {
278
		// TODO Auto-generated method stub
279
		return null;
280
	}
281
282
	public EDataType getShortObject() {
283
		// TODO Auto-generated method stub
284
		return null;
285
	}
286
287
	public EClass getSimpleAnyType() {
288
		// TODO Auto-generated method stub
289
		return null;
290
	}
291
292
	public EReference getSimpleAnyType_InstanceType() {
293
		// TODO Auto-generated method stub
294
		return null;
295
	}
296
297
	public EAttribute getSimpleAnyType_RawValue() {
298
		// TODO Auto-generated method stub
299
		return null;
300
	}
301
302
	public EAttribute getSimpleAnyType_Value() {
303
		// TODO Auto-generated method stub
304
		return null;
305
	}
306
307
	public EDataType getString() {
308
		// TODO Auto-generated method stub
309
		return null;
310
	}
311
312
	public EDataType getTime() {
313
		// TODO Auto-generated method stub
314
		return null;
315
	}
316
317
	public EDataType getToken() {
318
		// TODO Auto-generated method stub
319
		return null;
320
	}
321
322
	public EDataType getUnsignedByte() {
323
		// TODO Auto-generated method stub
324
		return null;
325
	}
326
327
	public EDataType getUnsignedByteObject() {
328
		// TODO Auto-generated method stub
329
		return null;
330
	}
331
332
	public EDataType getUnsignedInt() {
333
		// TODO Auto-generated method stub
334
		return null;
335
	}
336
337
	public EDataType getUnsignedIntObject() {
338
		// TODO Auto-generated method stub
339
		return null;
340
	}
341
342
	public EDataType getUnsignedLong() {
343
		// TODO Auto-generated method stub
344
		return null;
345
	}
346
347
	public EDataType getUnsignedShort() {
348
		// TODO Auto-generated method stub
349
		return null;
350
	}
351
352
	public EDataType getUnsignedShortObject() {
353
		// TODO Auto-generated method stub
354
		return null;
355
	}
356
357
	public EClass getXMLTypeDocumentRoot() {
358
		// TODO Auto-generated method stub
359
		return null;
360
	}
361
362
	public EAttribute getXMLTypeDocumentRoot_CDATA() {
363
		// TODO Auto-generated method stub
364
		return null;
365
	}
366
367
	public EAttribute getXMLTypeDocumentRoot_Comment() {
368
		// TODO Auto-generated method stub
369
		return null;
370
	}
371
372
	public EAttribute getXMLTypeDocumentRoot_Mixed() {
373
		// TODO Auto-generated method stub
374
		return null;
375
	}
376
377
	public EAttribute getXMLTypeDocumentRoot_Text() {
378
		// TODO Auto-generated method stub
379
		return null;
380
	}
381
382
	public EReference getXMLTypeDocumentRoot_XMLNSPrefixMap() {
383
		// TODO Auto-generated method stub
384
		return null;
385
	}
386
387
	public EReference getXMLTypeDocumentRoot_XSISchemaLocation() {
388
		// TODO Auto-generated method stub
389
		return null;
390
	}
391
392
	public EClassifier getEClassifier(String name) {
393
		// TODO Auto-generated method stub
394
		return null;
395
	}
396
397
	public EList getEClassifiers() {
398
		// TODO Auto-generated method stub
399
		return null;
400
	}
401
402
	public EFactory getEFactoryInstance() {
403
		// TODO Auto-generated method stub
404
		return null;
405
	}
406
407
	public EList getESubpackages() {
408
		// TODO Auto-generated method stub
409
		return null;
410
	}
411
412
	public EPackage getESuperPackage() {
413
		// TODO Auto-generated method stub
414
		return null;
415
	}
416
417
	public String getNsPrefix() {
418
		// TODO Auto-generated method stub
419
		return null;
420
	}
421
422
	public String getNsURI() {
423
		// TODO Auto-generated method stub
424
		return null;
425
	}
426
427
	public void setEFactoryInstance(EFactory value) {
428
		// TODO Auto-generated method stub
429
430
	}
431
432
	public void setNsPrefix(String value) {
433
		// TODO Auto-generated method stub
434
435
	}
436
437
	public void setNsURI(String value) {
438
		// TODO Auto-generated method stub
439
440
	}
441
442
	public String getName() {
443
		// TODO Auto-generated method stub
444
		return null;
445
	}
446
447
	public void setName(String value) {
448
		// TODO Auto-generated method stub
449
450
	}
451
452
	public EAnnotation getEAnnotation(String source) {
453
		// TODO Auto-generated method stub
454
		return null;
455
	}
456
457
	public EList getEAnnotations() {
458
		// TODO Auto-generated method stub
459
		return null;
460
	}
461
462
	public TreeIterator eAllContents() {
463
		// TODO Auto-generated method stub
464
		return null;
465
	}
466
467
	public EClass eClass() {
468
		// TODO Auto-generated method stub
469
		return null;
470
	}
471
472
	public EObject eContainer() {
473
		// TODO Auto-generated method stub
474
		return null;
475
	}
476
477
	public EStructuralFeature eContainingFeature() {
478
		// TODO Auto-generated method stub
479
		return null;
480
	}
481
482
	public EReference eContainmentFeature() {
483
		// TODO Auto-generated method stub
484
		return null;
485
	}
486
487
	public EList eContents() {
488
		// TODO Auto-generated method stub
489
		return null;
490
	}
491
492
	public EList eCrossReferences() {
493
		// TODO Auto-generated method stub
494
		return null;
495
	}
496
497
	public Object eGet(EStructuralFeature feature) {
498
		// TODO Auto-generated method stub
499
		return null;
500
	}
501
502
	public Object eGet(EStructuralFeature feature, boolean resolve) {
503
		// TODO Auto-generated method stub
504
		return null;
505
	}
506
507
	public boolean eIsProxy() {
508
		// TODO Auto-generated method stub
509
		return false;
510
	}
511
512
	public boolean eIsSet(EStructuralFeature feature) {
513
		// TODO Auto-generated method stub
514
		return false;
515
	}
516
517
	public Resource eResource() {
518
		// TODO Auto-generated method stub
519
		return null;
520
	}
521
522
	public void eSet(EStructuralFeature feature, Object newValue) {
523
		// TODO Auto-generated method stub
524
525
	}
526
527
	public void eUnset(EStructuralFeature feature) {
528
		// TODO Auto-generated method stub
529
530
	}
531
532
	public EList eAdapters() {
533
		// TODO Auto-generated method stub
534
		return null;
535
	}
536
537
	public boolean eDeliver() {
538
		// TODO Auto-generated method stub
539
		return false;
540
	}
541
542
	public void eNotify(Notification notification) {
543
		// TODO Auto-generated method stub
544
545
	}
546
547
	public void eSetDeliver(boolean deliver) {
548
		// TODO Auto-generated method stub
549
550
	}
551
552
	public XMLTypeFactory getXMLTypeFactory() {
553
		// TODO Auto-generated method stub
554
		return null;
555
	}
40
556
41
/**
557
}
42
 * <!-- begin-user-doc -->
43
 * An implementation of the model <b>Package</b>.
44
 * <!-- end-user-doc -->
45
 * @generated
46
 */
47
public class XMLTypePackageImpl extends EPackageImpl implements XMLTypePackage
48
{
49
  /**
50
   * <!-- begin-user-doc -->
51
   * <!-- end-user-doc -->
52
   * @generated
53
   */
54
  private EClass anyTypeEClass = null;
55
56
  /**
57
   * <!-- begin-user-doc -->
58
   * <!-- end-user-doc -->
59
   * @generated
60
   */
61
  private EClass simpleAnyTypeEClass = null;
62
63
  /**
64
   * <!-- begin-user-doc -->
65
   * <!-- end-user-doc -->
66
   * @generated
67
   */
68
  private EClass xmlTypeDocumentRootEClass = null;
69
70
  /**
71
   * <!-- begin-user-doc -->
72
   * <!-- end-user-doc -->
73
   * @generated
74
   */
75
  private EDataType anySimpleTypeEDataType = null;
76
77
  /**
78
   * <!-- begin-user-doc -->
79
   * <!-- end-user-doc -->
80
   * @generated
81
   */
82
  private EDataType anyURIEDataType = null;
83
84
  /**
85
   * <!-- begin-user-doc -->
86
   * <!-- end-user-doc -->
87
   * @generated
88
   */
89
  private EDataType base64BinaryEDataType = null;
90
91
  /**
92
   * <!-- begin-user-doc -->
93
   * <!-- end-user-doc -->
94
   * @generated
95
   */
96
  private EDataType booleanEDataType = null;
97
98
  /**
99
   * <!-- begin-user-doc -->
100
   * <!-- end-user-doc -->
101
   * @generated
102
   */
103
  private EDataType booleanObjectEDataType = null;
104
105
  /**
106
   * <!-- begin-user-doc -->
107
   * <!-- end-user-doc -->
108
   * @generated
109
   */
110
  private EDataType decimalEDataType = null;
111
112
  /**
113
   * <!-- begin-user-doc -->
114
   * <!-- end-user-doc -->
115
   * @generated
116
   */
117
  private EDataType integerEDataType = null;
118
119
  /**
120
   * <!-- begin-user-doc -->
121
   * <!-- end-user-doc -->
122
   * @generated
123
   */
124
  private EDataType intObjectEDataType = null;
125
126
  /**
127
   * <!-- begin-user-doc -->
128
   * <!-- end-user-doc -->
129
   * @generated
130
   */
131
  private EDataType longEDataType = null;
132
133
  /**
134
   * <!-- begin-user-doc -->
135
   * <!-- end-user-doc -->
136
   * @generated
137
   */
138
  private EDataType longObjectEDataType = null;
139
140
  /**
141
   * <!-- begin-user-doc -->
142
   * <!-- end-user-doc -->
143
   * @generated
144
   */
145
  private EDataType intEDataType = null;
146
147
  /**
148
   * <!-- begin-user-doc -->
149
   * <!-- end-user-doc -->
150
   * @generated
151
   */
152
  private EDataType shortEDataType = null;
153
154
  /**
155
   * <!-- begin-user-doc -->
156
   * <!-- end-user-doc -->
157
   * @generated
158
   */
159
  private EDataType shortObjectEDataType = null;
160
161
  /**
162
   * <!-- begin-user-doc -->
163
   * <!-- end-user-doc -->
164
   * @generated
165
   */
166
  private EDataType byteEDataType = null;
167
168
  /**
169
   * <!-- begin-user-doc -->
170
   * <!-- end-user-doc -->
171
   * @generated
172
   */
173
  private EDataType byteObjectEDataType = null;
174
175
  /**
176
   * <!-- begin-user-doc -->
177
   * <!-- end-user-doc -->
178
   * @generated
179
   */
180
  private EDataType dateEDataType = null;
181
182
  /**
183
   * <!-- begin-user-doc -->
184
   * <!-- end-user-doc -->
185
   * @generated
186
   */
187
  private EDataType dateTimeEDataType = null;
188
189
  /**
190
   * <!-- begin-user-doc -->
191
   * <!-- end-user-doc -->
192
   * @generated
193
   */
194
  private EDataType stringEDataType = null;
195
196
  /**
197
   * <!-- begin-user-doc -->
198
   * <!-- end-user-doc -->
199
   * @generated
200
   */
201
  private EDataType doubleEDataType = null;
202
203
  /**
204
   * <!-- begin-user-doc -->
205
   * <!-- end-user-doc -->
206
   * @generated
207
   */
208
  private EDataType doubleObjectEDataType = null;
209
210
  /**
211
   * <!-- begin-user-doc -->
212
   * <!-- end-user-doc -->
213
   * @generated
214
   */
215
  private EDataType durationEDataType = null;
216
217
  /**
218
   * <!-- begin-user-doc -->
219
   * <!-- end-user-doc -->
220
   * @generated
221
   */
222
  private EDataType entitiesBaseEDataType = null;
223
224
  /**
225
   * <!-- begin-user-doc -->
226
   * <!-- end-user-doc -->
227
   * @generated
228
   */
229
  private EDataType normalizedStringEDataType = null;
230
231
  /**
232
   * <!-- begin-user-doc -->
233
   * <!-- end-user-doc -->
234
   * @generated
235
   */
236
  private EDataType tokenEDataType = null;
237
238
  /**
239
   * <!-- begin-user-doc -->
240
   * <!-- end-user-doc -->
241
   * @generated
242
   */
243
  private EDataType nameEDataType = null;
244
245
  /**
246
   * <!-- begin-user-doc -->
247
   * <!-- end-user-doc -->
248
   * @generated
249
   */
250
  private EDataType ncNameEDataType = null;
251
252
  /**
253
   * <!-- begin-user-doc -->
254
   * <!-- end-user-doc -->
255
   * @generated
256
   */
257
  private EDataType entityEDataType = null;
258
259
  /**
260
   * <!-- begin-user-doc -->
261
   * <!-- end-user-doc -->
262
   * @generated
263
   */
264
  private EDataType entitiesEDataType = null;
265
266
  /**
267
   * <!-- begin-user-doc -->
268
   * <!-- end-user-doc -->
269
   * @generated
270
   */
271
  private EDataType floatEDataType = null;
272
273
  /**
274
   * <!-- begin-user-doc -->
275
   * <!-- end-user-doc -->
276
   * @generated
277
   */
278
  private EDataType floatObjectEDataType = null;
279
280
  /**
281
   * <!-- begin-user-doc -->
282
   * <!-- end-user-doc -->
283
   * @generated
284
   */
285
  private EDataType gDayEDataType = null;
286
287
  /**
288
   * <!-- begin-user-doc -->
289
   * <!-- end-user-doc -->
290
   * @generated
291
   */
292
  private EDataType gMonthEDataType = null;
293
294
  /**
295
   * <!-- begin-user-doc -->
296
   * <!-- end-user-doc -->
297
   * @generated
298
   */
299
  private EDataType gMonthDayEDataType = null;
300
301
  /**
302
   * <!-- begin-user-doc -->
303
   * <!-- end-user-doc -->
304
   * @generated
305
   */
306
  private EDataType gYearEDataType = null;
307
308
  /**
309
   * <!-- begin-user-doc -->
310
   * <!-- end-user-doc -->
311
   * @generated
312
   */
313
  private EDataType gYearMonthEDataType = null;
314
315
  /**
316
   * <!-- begin-user-doc -->
317
   * <!-- end-user-doc -->
318
   * @generated
319
   */
320
  private EDataType hexBinaryEDataType = null;
321
322
  /**
323
   * <!-- begin-user-doc -->
324
   * <!-- end-user-doc -->
325
   * @generated
326
   */
327
  private EDataType idEDataType = null;
328
329
  /**
330
   * <!-- begin-user-doc -->
331
   * <!-- end-user-doc -->
332
   * @generated
333
   */
334
  private EDataType idrefEDataType = null;
335
336
  /**
337
   * <!-- begin-user-doc -->
338
   * <!-- end-user-doc -->
339
   * @generated
340
   */
341
  private EDataType idrefsBaseEDataType = null;
342
343
  /**
344
   * <!-- begin-user-doc -->
345
   * <!-- end-user-doc -->
346
   * @generated
347
   */
348
  private EDataType idrefsEDataType = null;
349
350
  /**
351
   * <!-- begin-user-doc -->
352
   * <!-- end-user-doc -->
353
   * @generated
354
   */
355
  private EDataType languageEDataType = null;
356
357
  /**
358
   * <!-- begin-user-doc -->
359
   * <!-- end-user-doc -->
360
   * @generated
361
   */
362
  private EDataType nonPositiveIntegerEDataType = null;
363
364
  /**
365
   * <!-- begin-user-doc -->
366
   * <!-- end-user-doc -->
367
   * @generated
368
   */
369
  private EDataType negativeIntegerEDataType = null;
370
371
  /**
372
   * <!-- begin-user-doc -->
373
   * <!-- end-user-doc -->
374
   * @generated
375
   */
376
  private EDataType nmtokenEDataType = null;
377
378
  /**
379
   * <!-- begin-user-doc -->
380
   * <!-- end-user-doc -->
381
   * @generated
382
   */
383
  private EDataType nmtokensBaseEDataType = null;
384
385
  /**
386
   * <!-- begin-user-doc -->
387
   * <!-- end-user-doc -->
388
   * @generated
389
   */
390
  private EDataType nmtokensEDataType = null;
391
392
  /**
393
   * <!-- begin-user-doc -->
394
   * <!-- end-user-doc -->
395
   * @generated
396
   */
397
  private EDataType nonNegativeIntegerEDataType = null;
398
399
  /**
400
   * <!-- begin-user-doc -->
401
   * <!-- end-user-doc -->
402
   * @generated
403
   */
404
  private EDataType notationEDataType = null;
405
406
  /**
407
   * <!-- begin-user-doc -->
408
   * <!-- end-user-doc -->
409
   * @generated
410
   */
411
  private EDataType positiveIntegerEDataType = null;
412
413
  /**
414
   * <!-- begin-user-doc -->
415
   * <!-- end-user-doc -->
416
   * @generated
417
   */
418
  private EDataType qNameEDataType = null;
419
420
  /**
421
   * <!-- begin-user-doc -->
422
   * <!-- end-user-doc -->
423
   * @generated
424
   */
425
  private EDataType timeEDataType = null;
426
427
  /**
428
   * <!-- begin-user-doc -->
429
   * <!-- end-user-doc -->
430
   * @generated
431
   */
432
  private EDataType unsignedLongEDataType = null;
433
434
  /**
435
   * <!-- begin-user-doc -->
436
   * <!-- end-user-doc -->
437
   * @generated
438
   */
439
  private EDataType unsignedIntEDataType = null;
440
441
  /**
442
   * <!-- begin-user-doc -->
443
   * <!-- end-user-doc -->
444
   * @generated
445
   */
446
  private EDataType unsignedIntObjectEDataType = null;
447
448
  /**
449
   * <!-- begin-user-doc -->
450
   * <!-- end-user-doc -->
451
   * @generated
452
   */
453
  private EDataType unsignedShortEDataType = null;
454
455
  /**
456
   * <!-- begin-user-doc -->
457
   * <!-- end-user-doc -->
458
   * @generated
459
   */
460
  private EDataType unsignedShortObjectEDataType = null;
461
462
  /**
463
   * <!-- begin-user-doc -->
464
   * <!-- end-user-doc -->
465
   * @generated
466
   */
467
  private EDataType unsignedByteEDataType = null;
468
469
  /**
470
   * <!-- begin-user-doc -->
471
   * <!-- end-user-doc -->
472
   * @generated
473
   */
474
  private EDataType unsignedByteObjectEDataType = null;
475
476
  /**
477
   * Creates an instance of the model <b>Package</b>, registered with
478
   * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
479
   * package URI value.
480
   * <p>Note: the correct way to create the package is via the static
481
   * factory method {@link #init init()}, which also performs
482
   * initialization of the package, or returns the registered package,
483
   * if one already exists.
484
   * <!-- begin-user-doc -->
485
   * <!-- end-user-doc -->
486
   * @see org.eclipse.emf.ecore.EPackage.Registry
487
   * @see org.eclipse.emf.ecore.xml.type.XMLTypePackage#eNS_URI
488
   * @see #init()
489
   * @generated
490
   */
491
  private XMLTypePackageImpl()
492
  {
493
    super(eNS_URI, XMLTypeFactory.eINSTANCE);
494
  }
495
496
  /**
497
   * <!-- begin-user-doc -->
498
   * <!-- end-user-doc -->
499
   * @generated
500
   */
501
  private static boolean isInited = false;
502
503
  /**
504
   * Creates, registers, and initializes the <b>Package</b> for this
505
   * model, and for any others upon which it depends.  Simple
506
   * dependencies are satisfied by calling this method on all
507
   * dependent packages before doing anything else.  This method drives
508
   * initialization for interdependent packages directly, in parallel
509
   * with this package, itself.
510
   * <p>Of this package and its interdependencies, all packages which
511
   * have not yet been registered by their URI values are first created
512
   * and registered.  The packages are then initialized in two steps:
513
   * meta-model objects for all of the packages are created before any
514
   * are initialized, since one package's meta-model objects may refer to
515
   * those of another.
516
   * <p>Invocation of this method will not affect any packages that have
517
   * already been initialized.
518
   * <!-- begin-user-doc -->
519
   * <!-- end-user-doc -->
520
   * @see #eNS_URI
521
   * @see #createPackageContents()
522
   * @see #initializePackageContents()
523
   * @generated
524
   */
525
  public static XMLTypePackage init()
526
  {
527
    if (isInited) return (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI);
528
529
    // Obtain or create and register package
530
    XMLTypePackageImpl theXMLTypePackage = (XMLTypePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof XMLTypePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new XMLTypePackageImpl());
531
532
    isInited = true;
533
534
    // Create package meta-data objects
535
    theXMLTypePackage.createPackageContents();
536
537
    // Initialize created meta-data
538
    theXMLTypePackage.initializePackageContents();
539
540
    // Register package validator
541
    EValidator.Registry.INSTANCE.put
542
      (theXMLTypePackage, 
543
       new EValidator.Descriptor()
544
       {
545
         public EValidator getEValidator()
546
         {
547
           return XMLTypeValidator.INSTANCE;
548
         }
549
       });
550
551
    // Mark meta-data to indicate it can't be changed
552
    theXMLTypePackage.freeze();
553
554
    return theXMLTypePackage;
555
  }
556
557
  /**
558
   * <!-- begin-user-doc -->
559
   * <!-- end-user-doc -->
560
   * @generated
561
   */
562
  public EClass getAnyType()
563
  {
564
    return anyTypeEClass;
565
  }
566
567
  /**
568
   * <!-- begin-user-doc -->
569
   * <!-- end-user-doc -->
570
   * @generated
571
   */
572
  public EAttribute getAnyType_Mixed()
573
  {
574
    return (EAttribute)anyTypeEClass.getEStructuralFeatures().get(0);
575
  }
576
577
  /**
578
   * <!-- begin-user-doc -->
579
   * <!-- end-user-doc -->
580
   * @generated
581
   */
582
  public EAttribute getAnyType_Any()
583
  {
584
    return (EAttribute)anyTypeEClass.getEStructuralFeatures().get(1);
585
  }
586
587
  /**
588
   * <!-- begin-user-doc -->
589
   * <!-- end-user-doc -->
590
   * @generated
591
   */
592
  public EAttribute getAnyType_AnyAttribute()
593
  {
594
    return (EAttribute)anyTypeEClass.getEStructuralFeatures().get(2);
595
  }
596
597
  /**
598
   * <!-- begin-user-doc -->
599
   * <!-- end-user-doc -->
600
   * @generated
601
   */
602
  public EClass getSimpleAnyType()
603
  {
604
    return simpleAnyTypeEClass;
605
  }
606
607
  /**
608
   * <!-- begin-user-doc -->
609
   * <!-- end-user-doc -->
610
   * @generated
611
   */
612
  public EAttribute getSimpleAnyType_RawValue()
613
  {
614
    return (EAttribute)simpleAnyTypeEClass.getEStructuralFeatures().get(0);
615
  }
616
617
  /**
618
   * <!-- begin-user-doc -->
619
   * <!-- end-user-doc -->
620
   * @generated
621
   */
622
  public EAttribute getSimpleAnyType_Value()
623
  {
624
    return (EAttribute)simpleAnyTypeEClass.getEStructuralFeatures().get(1);
625
  }
626
627
  /**
628
   * <!-- begin-user-doc -->
629
   * <!-- end-user-doc -->
630
   * @generated
631
   */
632
  public EReference getSimpleAnyType_InstanceType()
633
  {
634
    return (EReference)simpleAnyTypeEClass.getEStructuralFeatures().get(2);
635
  }
636
637
  /**
638
   * <!-- begin-user-doc -->
639
   * <!-- end-user-doc -->
640
   * @generated
641
   */
642
  public EClass getXMLTypeDocumentRoot()
643
  {
644
    return xmlTypeDocumentRootEClass;
645
  }
646
647
  /**
648
   * <!-- begin-user-doc -->
649
   * <!-- end-user-doc -->
650
   * @generated
651
   */
652
  public EAttribute getXMLTypeDocumentRoot_Mixed()
653
  {
654
    return (EAttribute)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(0);
655
  }
656
657
  /**
658
   * <!-- begin-user-doc -->
659
   * <!-- end-user-doc -->
660
   * @generated
661
   */
662
  public EReference getXMLTypeDocumentRoot_XMLNSPrefixMap()
663
  {
664
    return (EReference)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(1);
665
  }
666
667
  /**
668
   * <!-- begin-user-doc -->
669
   * <!-- end-user-doc -->
670
   * @generated
671
   */
672
  public EReference getXMLTypeDocumentRoot_XSISchemaLocation()
673
  {
674
    return (EReference)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(2);
675
  }
676
677
  /**
678
   * <!-- begin-user-doc -->
679
   * <!-- end-user-doc -->
680
   * @generated
681
   */
682
  public EAttribute getXMLTypeDocumentRoot_CDATA()
683
  {
684
    return (EAttribute)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(3);
685
  }
686
687
  /**
688
   * <!-- begin-user-doc -->
689
   * <!-- end-user-doc -->
690
   * @generated
691
   */
692
  public EAttribute getXMLTypeDocumentRoot_Comment()
693
  {
694
    return (EAttribute)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(4);
695
  }
696
697
  /**
698
   * <!-- begin-user-doc -->
699
   * <!-- end-user-doc -->
700
   * @generated
701
   */
702
  public EAttribute getXMLTypeDocumentRoot_Text()
703
  {
704
    return (EAttribute)xmlTypeDocumentRootEClass.getEStructuralFeatures().get(5);
705
  }
706
707
  /**
708
   * <!-- begin-user-doc -->
709
   * <!-- end-user-doc -->
710
   * @generated
711
   */
712
  public EDataType getAnySimpleType()
713
  {
714
    return anySimpleTypeEDataType;
715
  }
716
717
  /**
718
   * <!-- begin-user-doc -->
719
   * <!-- end-user-doc -->
720
   * @generated
721
   */
722
  public EDataType getAnyURI()
723
  {
724
    return anyURIEDataType;
725
  }
726
727
  /**
728
   * <!-- begin-user-doc -->
729
   * <!-- end-user-doc -->
730
   * @generated
731
   */
732
  public EDataType getBase64Binary()
733
  {
734
    return base64BinaryEDataType;
735
  }
736
737
  /**
738
   * <!-- begin-user-doc -->
739
   * <!-- end-user-doc -->
740
   * @generated
741
   */
742
  public EDataType getBoolean()
743
  {
744
    return booleanEDataType;
745
  }
746
747
  /**
748
   * <!-- begin-user-doc -->
749
   * <!-- end-user-doc -->
750
   * @generated
751
   */
752
  public EDataType getBooleanObject()
753
  {
754
    return booleanObjectEDataType;
755
  }
756
757
  /**
758
   * <!-- begin-user-doc -->
759
   * <!-- end-user-doc -->
760
   * @generated
761
   */
762
  public EDataType getDecimal()
763
  {
764
    return decimalEDataType;
765
  }
766
767
  /**
768
   * <!-- begin-user-doc -->
769
   * <!-- end-user-doc -->
770
   * @generated
771
   */
772
  public EDataType getInteger()
773
  {
774
    return integerEDataType;
775
  }
776
777
  /**
778
   * <!-- begin-user-doc -->
779
   * <!-- end-user-doc -->
780
   * @generated
781
   */
782
  public EDataType getIntObject()
783
  {
784
    return intObjectEDataType;
785
  }
786
787
  /**
788
   * <!-- begin-user-doc -->
789
   * <!-- end-user-doc -->
790
   * @generated
791
   */
792
  public EDataType getLong()
793
  {
794
    return longEDataType;
795
  }
796
797
  /**
798
   * <!-- begin-user-doc -->
799
   * <!-- end-user-doc -->
800
   * @generated
801
   */
802
  public EDataType getLongObject()
803
  {
804
    return longObjectEDataType;
805
  }
806
807
  /**
808
   * <!-- begin-user-doc -->
809
   * <!-- end-user-doc -->
810
   * @generated
811
   */
812
  public EDataType getInt()
813
  {
814
    return intEDataType;
815
  }
816
817
  /**
818
   * <!-- begin-user-doc -->
819
   * <!-- end-user-doc -->
820
   * @generated
821
   */
822
  public EDataType getShort()
823
  {
824
    return shortEDataType;
825
  }
826
827
  /**
828
   * <!-- begin-user-doc -->
829
   * <!-- end-user-doc -->
830
   * @generated
831
   */
832
  public EDataType getShortObject()
833
  {
834
    return shortObjectEDataType;
835
  }
836
837
  /**
838
   * <!-- begin-user-doc -->
839
   * <!-- end-user-doc -->
840
   * @generated
841
   */
842
  public EDataType getByte()
843
  {
844
    return byteEDataType;
845
  }
846
847
  /**
848
   * <!-- begin-user-doc -->
849
   * <!-- end-user-doc -->
850
   * @generated
851
   */
852
  public EDataType getByteObject()
853
  {
854
    return byteObjectEDataType;
855
  }
856
857
  /**
858
   * <!-- begin-user-doc -->
859
   * <!-- end-user-doc -->
860
   * @generated
861
   */
862
  public EDataType getDate()
863
  {
864
    return dateEDataType;
865
  }
866
867
  /**
868
   * <!-- begin-user-doc -->
869
   * <!-- end-user-doc -->
870
   * @generated
871
   */
872
  public EDataType getDateTime()
873
  {
874
    return dateTimeEDataType;
875
  }
876
877
  /**
878
   * <!-- begin-user-doc -->
879
   * <!-- end-user-doc -->
880
   * @generated
881
   */
882
  public EDataType getString()
883
  {
884
    return stringEDataType;
885
  }
886
887
  /**
888
   * <!-- begin-user-doc -->
889
   * <!-- end-user-doc -->
890
   * @generated
891
   */
892
  public EDataType getDouble()
893
  {
894
    return doubleEDataType;
895
  }
896
897
  /**
898
   * <!-- begin-user-doc -->
899
   * <!-- end-user-doc -->
900
   * @generated
901
   */
902
  public EDataType getDoubleObject()
903
  {
904
    return doubleObjectEDataType;
905
  }
906
907
  /**
908
   * <!-- begin-user-doc -->
909
   * <!-- end-user-doc -->
910
   * @generated
911
   */
912
  public EDataType getDuration()
913
  {
914
    return durationEDataType;
915
  }
916
917
  /**
918
   * <!-- begin-user-doc -->
919
   * <!-- end-user-doc -->
920
   * @generated
921
   */
922
  public EDataType getENTITIESBase()
923
  {
924
    return entitiesBaseEDataType;
925
  }
926
927
  /**
928
   * <!-- begin-user-doc -->
929
   * <!-- end-user-doc -->
930
   * @generated
931
   */
932
  public EDataType getNormalizedString()
933
  {
934
    return normalizedStringEDataType;
935
  }
936
937
  /**
938
   * <!-- begin-user-doc -->
939
   * <!-- end-user-doc -->
940
   * @generated
941
   */
942
  public EDataType getToken()
943
  {
944
    return tokenEDataType;
945
  }
946
947
  /**
948
   * <!-- begin-user-doc -->
949
   * <!-- end-user-doc -->
950
   * @generated
951
   */
952
  public EDataType getName_()
953
  {
954
    return nameEDataType;
955
  }
956
957
  /**
958
   * <!-- begin-user-doc -->
959
   * <!-- end-user-doc -->
960
   * @generated
961
   */
962
  public EDataType getNCName()
963
  {
964
    return ncNameEDataType;
965
  }
966
967
  /**
968
   * <!-- begin-user-doc -->
969
   * <!-- end-user-doc -->
970
   * @generated
971
   */
972
  public EDataType getENTITY()
973
  {
974
    return entityEDataType;
975
  }
976
977
  /**
978
   * <!-- begin-user-doc -->
979
   * <!-- end-user-doc -->
980
   * @generated
981
   */
982
  public EDataType getENTITIES()
983
  {
984
    return entitiesEDataType;
985
  }
986
987
  /**
988
   * <!-- begin-user-doc -->
989
   * <!-- end-user-doc -->
990
   * @generated
991
   */
992
  public EDataType getFloat()
993
  {
994
    return floatEDataType;
995
  }
996
997
  /**
998
   * <!-- begin-user-doc -->
999
   * <!-- end-user-doc -->
1000
   * @generated
1001
   */
1002
  public EDataType getFloatObject()
1003
  {
1004
    return floatObjectEDataType;
1005
  }
1006
1007
  /**
1008
   * <!-- begin-user-doc -->
1009
   * <!-- end-user-doc -->
1010
   * @generated
1011
   */
1012
  public EDataType getGDay()
1013
  {
1014
    return gDayEDataType;
1015
  }
1016
1017
  /**
1018
   * <!-- begin-user-doc -->
1019
   * <!-- end-user-doc -->
1020
   * @generated
1021
   */
1022
  public EDataType getGMonth()
1023
  {
1024
    return gMonthEDataType;
1025
  }
1026
1027
  /**
1028
   * <!-- begin-user-doc -->
1029
   * <!-- end-user-doc -->
1030
   * @generated
1031
   */
1032
  public EDataType getGMonthDay()
1033
  {
1034
    return gMonthDayEDataType;
1035
  }
1036
1037
  /**
1038
   * <!-- begin-user-doc -->
1039
   * <!-- end-user-doc -->
1040
   * @generated
1041
   */
1042
  public EDataType getGYear()
1043
  {
1044
    return gYearEDataType;
1045
  }
1046
1047
  /**
1048
   * <!-- begin-user-doc -->
1049
   * <!-- end-user-doc -->
1050
   * @generated
1051
   */
1052
  public EDataType getGYearMonth()
1053
  {
1054
    return gYearMonthEDataType;
1055
  }
1056
1057
  /**
1058
   * <!-- begin-user-doc -->
1059
   * <!-- end-user-doc -->
1060
   * @generated
1061
   */
1062
  public EDataType getHexBinary()
1063
  {
1064
    return hexBinaryEDataType;
1065
  }
1066
1067
  /**
1068
   * <!-- begin-user-doc -->
1069
   * <!-- end-user-doc -->
1070
   * @generated
1071
   */
1072
  public EDataType getID()
1073
  {
1074
    return idEDataType;
1075
  }
1076
1077
  /**
1078
   * <!-- begin-user-doc -->
1079
   * <!-- end-user-doc -->
1080
   * @generated
1081
   */
1082
  public EDataType getIDREF()
1083
  {
1084
    return idrefEDataType;
1085
  }
1086
1087
  /**
1088
   * <!-- begin-user-doc -->
1089
   * <!-- end-user-doc -->
1090
   * @generated
1091
   */
1092
  public EDataType getIDREFSBase()
1093
  {
1094
    return idrefsBaseEDataType;
1095
  }
1096
1097
  /**
1098
   * <!-- begin-user-doc -->
1099
   * <!-- end-user-doc -->
1100
   * @generated
1101
   */
1102
  public EDataType getIDREFS()
1103
  {
1104
    return idrefsEDataType;
1105
  }
1106
1107
  /**
1108
   * <!-- begin-user-doc -->
1109
   * <!-- end-user-doc -->
1110
   * @generated
1111
   */
1112
  public EDataType getLanguage()
1113
  {
1114
    return languageEDataType;
1115
  }
1116
1117
  /**
1118
   * <!-- begin-user-doc -->
1119
   * <!-- end-user-doc -->
1120
   * @generated
1121
   */
1122
  public EDataType getNonPositiveInteger()
1123
  {
1124
    return nonPositiveIntegerEDataType;
1125
  }
1126
1127
  /**
1128
   * <!-- begin-user-doc -->
1129
   * <!-- end-user-doc -->
1130
   * @generated
1131
   */
1132
  public EDataType getNegativeInteger()
1133
  {
1134
    return negativeIntegerEDataType;
1135
  }
1136
1137
  /**
1138
   * <!-- begin-user-doc -->
1139
   * <!-- end-user-doc -->
1140
   * @generated
1141
   */
1142
  public EDataType getNMTOKEN()
1143
  {
1144
    return nmtokenEDataType;
1145
  }
1146
1147
  /**
1148
   * <!-- begin-user-doc -->
1149
   * <!-- end-user-doc -->
1150
   * @generated
1151
   */
1152
  public EDataType getNMTOKENSBase()
1153
  {
1154
    return nmtokensBaseEDataType;
1155
  }
1156
1157
  /**
1158
   * <!-- begin-user-doc -->
1159
   * <!-- end-user-doc -->
1160
   * @generated
1161
   */
1162
  public EDataType getNMTOKENS()
1163
  {
1164
    return nmtokensEDataType;
1165
  }
1166
1167
  /**
1168
   * <!-- begin-user-doc -->
1169
   * <!-- end-user-doc -->
1170
   * @generated
1171
   */
1172
  public EDataType getNonNegativeInteger()
1173
  {
1174
    return nonNegativeIntegerEDataType;
1175
  }
1176
1177
  /**
1178
   * <!-- begin-user-doc -->
1179
   * <!-- end-user-doc -->
1180
   * @generated
1181
   */
1182
  public EDataType getNOTATION()
1183
  {
1184
    return notationEDataType;
1185
  }
1186
1187
  /**
1188
   * <!-- begin-user-doc -->
1189
   * <!-- end-user-doc -->
1190
   * @generated
1191
   */
1192
  public EDataType getPositiveInteger()
1193
  {
1194
    return positiveIntegerEDataType;
1195
  }
1196
1197
  /**
1198
   * <!-- begin-user-doc -->
1199
   * <!-- end-user-doc -->
1200
   * @generated
1201
   */
1202
  public EDataType getQName()
1203
  {
1204
    return qNameEDataType;
1205
  }
1206
1207
  /**
1208
   * <!-- begin-user-doc -->
1209
   * <!-- end-user-doc -->
1210
   * @generated
1211
   */
1212
  public EDataType getTime()
1213
  {
1214
    return timeEDataType;
1215
  }
1216
1217
  /**
1218
   * <!-- begin-user-doc -->
1219
   * <!-- end-user-doc -->
1220
   * @generated
1221
   */
1222
  public EDataType getUnsignedLong()
1223
  {
1224
    return unsignedLongEDataType;
1225
  }
1226
1227
  /**
1228
   * <!-- begin-user-doc -->
1229
   * <!-- end-user-doc -->
1230
   * @generated
1231
   */
1232
  public EDataType getUnsignedInt()
1233
  {
1234
    return unsignedIntEDataType;
1235
  }
1236
1237
  /**
1238
   * <!-- begin-user-doc -->
1239
   * <!-- end-user-doc -->
1240
   * @generated
1241
   */
1242
  public EDataType getUnsignedIntObject()
1243
  {
1244
    return unsignedIntObjectEDataType;
1245
  }
1246
1247
  /**
1248
   * <!-- begin-user-doc -->
1249
   * <!-- end-user-doc -->
1250
   * @generated
1251
   */
1252
  public EDataType getUnsignedShort()
1253
  {
1254
    return unsignedShortEDataType;
1255
  }
1256
1257
  /**
1258
   * <!-- begin-user-doc -->
1259
   * <!-- end-user-doc -->
1260
   * @generated
1261
   */
1262
  public EDataType getUnsignedShortObject()
1263
  {
1264
    return unsignedShortObjectEDataType;
1265
  }
1266
1267
  /**
1268
   * <!-- begin-user-doc -->
1269
   * <!-- end-user-doc -->
1270
   * @generated
1271
   */
1272
  public EDataType getUnsignedByte()
1273
  {
1274
    return unsignedByteEDataType;
1275
  }
1276
1277
  /**
1278
   * <!-- begin-user-doc -->
1279
   * <!-- end-user-doc -->
1280
   * @generated
1281
   */
1282
  public EDataType getUnsignedByteObject()
1283
  {
1284
    return unsignedByteObjectEDataType;
1285
  }
1286
1287
  /**
1288
   * <!-- begin-user-doc -->
1289
   * <!-- end-user-doc -->
1290
   * @generated
1291
   */
1292
  public XMLTypeFactory getXMLTypeFactory()
1293
  {
1294
    return (XMLTypeFactory)getEFactoryInstance();
1295
  }
1296
1297
  /**
1298
   * <!-- begin-user-doc -->
1299
   * <!-- end-user-doc -->
1300
   * @generated
1301
   */
1302
  private boolean isCreated = false;
1303
1304
  /**
1305
   * Creates the meta-model objects for the package.  This method is
1306
   * guarded to have no affect on any invocation but its first.
1307
   * <!-- begin-user-doc -->
1308
   * <!-- end-user-doc -->
1309
   * @generated
1310
   */
1311
  public void createPackageContents()
1312
  {
1313
    if (isCreated) return;
1314
    isCreated = true;
1315
1316
    // Create classes and their features
1317
    anyTypeEClass = createEClass(ANY_TYPE);
1318
    createEAttribute(anyTypeEClass, ANY_TYPE__MIXED);
1319
    createEAttribute(anyTypeEClass, ANY_TYPE__ANY);
1320
    createEAttribute(anyTypeEClass, ANY_TYPE__ANY_ATTRIBUTE);
1321
1322
    simpleAnyTypeEClass = createEClass(SIMPLE_ANY_TYPE);
1323
    createEAttribute(simpleAnyTypeEClass, SIMPLE_ANY_TYPE__RAW_VALUE);
1324
    createEAttribute(simpleAnyTypeEClass, SIMPLE_ANY_TYPE__VALUE);
1325
    createEReference(simpleAnyTypeEClass, SIMPLE_ANY_TYPE__INSTANCE_TYPE);
1326
1327
    xmlTypeDocumentRootEClass = createEClass(XML_TYPE_DOCUMENT_ROOT);
1328
    createEAttribute(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__MIXED);
1329
    createEReference(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
1330
    createEReference(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
1331
    createEAttribute(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__CDATA);
1332
    createEAttribute(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__COMMENT);
1333
    createEAttribute(xmlTypeDocumentRootEClass, XML_TYPE_DOCUMENT_ROOT__TEXT);
1334
1335
    // Create data types
1336
    anySimpleTypeEDataType = createEDataType(ANY_SIMPLE_TYPE);
1337
    anyURIEDataType = createEDataType(ANY_URI);
1338
    base64BinaryEDataType = createEDataType(BASE64_BINARY);
1339
    booleanEDataType = createEDataType(BOOLEAN);
1340
    booleanObjectEDataType = createEDataType(BOOLEAN_OBJECT);
1341
    byteEDataType = createEDataType(BYTE);
1342
    byteObjectEDataType = createEDataType(BYTE_OBJECT);
1343
    dateEDataType = createEDataType(DATE);
1344
    dateTimeEDataType = createEDataType(DATE_TIME);
1345
    decimalEDataType = createEDataType(DECIMAL);
1346
    doubleEDataType = createEDataType(DOUBLE);
1347
    doubleObjectEDataType = createEDataType(DOUBLE_OBJECT);
1348
    durationEDataType = createEDataType(DURATION);
1349
    entitiesEDataType = createEDataType(ENTITIES);
1350
    entitiesBaseEDataType = createEDataType(ENTITIES_BASE);
1351
    entityEDataType = createEDataType(ENTITY);
1352
    floatEDataType = createEDataType(FLOAT);
1353
    floatObjectEDataType = createEDataType(FLOAT_OBJECT);
1354
    gDayEDataType = createEDataType(GDAY);
1355
    gMonthEDataType = createEDataType(GMONTH);
1356
    gMonthDayEDataType = createEDataType(GMONTH_DAY);
1357
    gYearEDataType = createEDataType(GYEAR);
1358
    gYearMonthEDataType = createEDataType(GYEAR_MONTH);
1359
    hexBinaryEDataType = createEDataType(HEX_BINARY);
1360
    idEDataType = createEDataType(ID);
1361
    idrefEDataType = createEDataType(IDREF);
1362
    idrefsEDataType = createEDataType(IDREFS);
1363
    idrefsBaseEDataType = createEDataType(IDREFS_BASE);
1364
    intEDataType = createEDataType(INT);
1365
    integerEDataType = createEDataType(INTEGER);
1366
    intObjectEDataType = createEDataType(INT_OBJECT);
1367
    languageEDataType = createEDataType(LANGUAGE);
1368
    longEDataType = createEDataType(LONG);
1369
    longObjectEDataType = createEDataType(LONG_OBJECT);
1370
    nameEDataType = createEDataType(NAME);
1371
    ncNameEDataType = createEDataType(NC_NAME);
1372
    negativeIntegerEDataType = createEDataType(NEGATIVE_INTEGER);
1373
    nmtokenEDataType = createEDataType(NMTOKEN);
1374
    nmtokensEDataType = createEDataType(NMTOKENS);
1375
    nmtokensBaseEDataType = createEDataType(NMTOKENS_BASE);
1376
    nonNegativeIntegerEDataType = createEDataType(NON_NEGATIVE_INTEGER);
1377
    nonPositiveIntegerEDataType = createEDataType(NON_POSITIVE_INTEGER);
1378
    normalizedStringEDataType = createEDataType(NORMALIZED_STRING);
1379
    notationEDataType = createEDataType(NOTATION);
1380
    positiveIntegerEDataType = createEDataType(POSITIVE_INTEGER);
1381
    qNameEDataType = createEDataType(QNAME);
1382
    shortEDataType = createEDataType(SHORT);
1383
    shortObjectEDataType = createEDataType(SHORT_OBJECT);
1384
    stringEDataType = createEDataType(STRING);
1385
    timeEDataType = createEDataType(TIME);
1386
    tokenEDataType = createEDataType(TOKEN);
1387
    unsignedByteEDataType = createEDataType(UNSIGNED_BYTE);
1388
    unsignedByteObjectEDataType = createEDataType(UNSIGNED_BYTE_OBJECT);
1389
    unsignedIntEDataType = createEDataType(UNSIGNED_INT);
1390
    unsignedIntObjectEDataType = createEDataType(UNSIGNED_INT_OBJECT);
1391
    unsignedLongEDataType = createEDataType(UNSIGNED_LONG);
1392
    unsignedShortEDataType = createEDataType(UNSIGNED_SHORT);
1393
    unsignedShortObjectEDataType = createEDataType(UNSIGNED_SHORT_OBJECT);
1394
  }
1395
1396
  /**
1397
   * <!-- begin-user-doc -->
1398
   * <!-- end-user-doc -->
1399
   * @generated
1400
   */
1401
  private boolean isInitialized = false;
1402
1403
  /**
1404
   * Complete the initialization of the package and its meta-model.  This
1405
   * method is guarded to have no affect on any invocation but its first.
1406
   * <!-- begin-user-doc -->
1407
   * <!-- end-user-doc -->
1408
   * @generated
1409
   */
1410
  public void initializePackageContents()
1411
  {
1412
    if (isInitialized) return;
1413
    isInitialized = true;
1414
1415
    // Initialize package
1416
    setName(eNAME);
1417
    setNsPrefix(eNS_PREFIX);
1418
    setNsURI(eNS_URI);
1419
1420
    // Obtain other dependent packages
1421
    XMLTypePackage theXMLTypePackage_1 = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI);
1422
1423
    // Add supertypes to classes
1424
    simpleAnyTypeEClass.getESuperTypes().add(this.getAnyType());
1425
1426
    // Initialize classes and features; add operations and parameters
1427
    initEClass(anyTypeEClass, AnyType.class, "AnyType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
1428
    initEAttribute(getAnyType_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, AnyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1429
    initEAttribute(getAnyType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, AnyType.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1430
    initEAttribute(getAnyType_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, AnyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1431
1432
    initEClass(simpleAnyTypeEClass, SimpleAnyType.class, "SimpleAnyType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
1433
    initEAttribute(getSimpleAnyType_RawValue(), theXMLTypePackage_1.getString(), "rawValue", null, 0, 1, SimpleAnyType.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1434
    initEAttribute(getSimpleAnyType_Value(), theXMLTypePackage_1.getAnySimpleType(), "value", null, 0, 1, SimpleAnyType.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1435
    initEReference(getSimpleAnyType_InstanceType(), ecorePackage.getEDataType(), null, "instanceType", null, 1, 1, SimpleAnyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1436
1437
    initEClass(xmlTypeDocumentRootEClass, XMLTypeDocumentRoot.class, "XMLTypeDocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
1438
    initEAttribute(getXMLTypeDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1439
    initEReference(getXMLTypeDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1440
    initEReference(getXMLTypeDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
1441
    initEAttribute(getXMLTypeDocumentRoot_CDATA(), this.getString(), "cDATA", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1442
    initEAttribute(getXMLTypeDocumentRoot_Comment(), this.getString(), "comment", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1443
    initEAttribute(getXMLTypeDocumentRoot_Text(), this.getString(), "text", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED);
1444
1445
    // Initialize data types
1446
    initEDataType(anySimpleTypeEDataType, Object.class, "AnySimpleType", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1447
    initEDataType(anyURIEDataType, String.class, "AnyURI", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1448
    initEDataType(base64BinaryEDataType, byte[].class, "Base64Binary", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1449
    initEDataType(booleanEDataType, boolean.class, "Boolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1450
    initEDataType(booleanObjectEDataType, Boolean.class, "BooleanObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1451
    initEDataType(byteEDataType, byte.class, "Byte", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1452
    initEDataType(byteObjectEDataType, Byte.class, "ByteObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1453
    initEDataType(dateEDataType, Object.class, "Date", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1454
    initEDataType(dateTimeEDataType, Object.class, "DateTime", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1455
    initEDataType(decimalEDataType, BigDecimal.class, "Decimal", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1456
    initEDataType(doubleEDataType, double.class, "Double", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1457
    initEDataType(doubleObjectEDataType, Double.class, "DoubleObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1458
    initEDataType(durationEDataType, Object.class, "Duration", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1459
    initEDataType(entitiesEDataType, List.class, "ENTITIES", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1460
    initEDataType(entitiesBaseEDataType, List.class, "ENTITIESBase", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1461
    initEDataType(entityEDataType, String.class, "ENTITY", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1462
    initEDataType(floatEDataType, float.class, "Float", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1463
    initEDataType(floatObjectEDataType, Float.class, "FloatObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1464
    initEDataType(gDayEDataType, Object.class, "GDay", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1465
    initEDataType(gMonthEDataType, Object.class, "GMonth", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1466
    initEDataType(gMonthDayEDataType, Object.class, "GMonthDay", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1467
    initEDataType(gYearEDataType, Object.class, "GYear", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1468
    initEDataType(gYearMonthEDataType, Object.class, "GYearMonth", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1469
    initEDataType(hexBinaryEDataType, byte[].class, "HexBinary", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1470
    initEDataType(idEDataType, String.class, "ID", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1471
    initEDataType(idrefEDataType, String.class, "IDREF", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1472
    initEDataType(idrefsEDataType, List.class, "IDREFS", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1473
    initEDataType(idrefsBaseEDataType, List.class, "IDREFSBase", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1474
    initEDataType(intEDataType, int.class, "Int", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1475
    initEDataType(integerEDataType, BigInteger.class, "Integer", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1476
    initEDataType(intObjectEDataType, Integer.class, "IntObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1477
    initEDataType(languageEDataType, String.class, "Language", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1478
    initEDataType(longEDataType, long.class, "Long", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1479
    initEDataType(longObjectEDataType, Long.class, "LongObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1480
    initEDataType(nameEDataType, String.class, "Name", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1481
    initEDataType(ncNameEDataType, String.class, "NCName", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1482
    initEDataType(negativeIntegerEDataType, BigInteger.class, "NegativeInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1483
    initEDataType(nmtokenEDataType, String.class, "NMTOKEN", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1484
    initEDataType(nmtokensEDataType, List.class, "NMTOKENS", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1485
    initEDataType(nmtokensBaseEDataType, List.class, "NMTOKENSBase", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1486
    initEDataType(nonNegativeIntegerEDataType, BigInteger.class, "NonNegativeInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1487
    initEDataType(nonPositiveIntegerEDataType, BigInteger.class, "NonPositiveInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1488
    initEDataType(normalizedStringEDataType, String.class, "NormalizedString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1489
    initEDataType(notationEDataType, Object.class, "NOTATION", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1490
    initEDataType(positiveIntegerEDataType, BigInteger.class, "PositiveInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1491
    initEDataType(qNameEDataType, Object.class, "QName", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1492
    initEDataType(shortEDataType, short.class, "Short", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1493
    initEDataType(shortObjectEDataType, Short.class, "ShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1494
    initEDataType(stringEDataType, String.class, "String", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1495
    initEDataType(timeEDataType, Object.class, "Time", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1496
    initEDataType(tokenEDataType, String.class, "Token", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1497
    initEDataType(unsignedByteEDataType, short.class, "UnsignedByte", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1498
    initEDataType(unsignedByteObjectEDataType, Short.class, "UnsignedByteObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1499
    initEDataType(unsignedIntEDataType, long.class, "UnsignedInt", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1500
    initEDataType(unsignedIntObjectEDataType, Long.class, "UnsignedIntObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1501
    initEDataType(unsignedLongEDataType, BigInteger.class, "UnsignedLong", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1502
    initEDataType(unsignedShortEDataType, int.class, "UnsignedShort", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1503
    initEDataType(unsignedShortObjectEDataType, Integer.class, "UnsignedShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
1504
1505
    // Create resource
1506
    createResource(eNS_URI);
1507
1508
    // Create annotations
1509
    // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
1510
    createExtendedMetaDataAnnotations();
1511
  }
1512
1513
  /**
1514
   * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
1515
   * <!-- begin-user-doc -->
1516
   * <!-- end-user-doc -->
1517
   * @generated
1518
   */
1519
  protected void createExtendedMetaDataAnnotations()
1520
  {
1521
    String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";		
1522
    addAnnotation
1523
      (anySimpleTypeEDataType, 
1524
       source, 
1525
       new String[] 
1526
       {
1527
       "name", "anySimpleType"
1528
       });		
1529
    addAnnotation
1530
      (anyTypeEClass, 
1531
       source, 
1532
       new String[] 
1533
       {
1534
       "name", "anyType",
1535
       "kind", "mixed"
1536
       });		
1537
    addAnnotation
1538
      (getAnyType_Mixed(), 
1539
       source, 
1540
       new String[] 
1541
       {
1542
       "kind", "elementWildcard",
1543
       "name", ":mixed"
1544
       });		
1545
    addAnnotation
1546
      (getAnyType_Any(), 
1547
       source, 
1548
       new String[] 
1549
       {
1550
       "kind", "elementWildcard",
1551
       "wildcards", "##any",
1552
       "name", ":1",
1553
       "processing", "lax"
1554
       });		
1555
    addAnnotation
1556
      (getAnyType_AnyAttribute(), 
1557
       source, 
1558
       new String[] 
1559
       {
1560
       "kind", "attributeWildcard",
1561
       "wildcards", "##any",
1562
       "name", ":2",
1563
       "processing", "lax"
1564
       });		
1565
    addAnnotation
1566
      (anyURIEDataType, 
1567
       source, 
1568
       new String[] 
1569
       {
1570
       "name", "anyURI",
1571
       "whiteSpace", "collapse"
1572
       });		
1573
    addAnnotation
1574
      (base64BinaryEDataType, 
1575
       source, 
1576
       new String[] 
1577
       {
1578
       "name", "base64Binary",
1579
       "whiteSpace", "collapse"
1580
       });		
1581
    addAnnotation
1582
      (booleanEDataType, 
1583
       source, 
1584
       new String[] 
1585
       {
1586
       "name", "boolean",
1587
       "whiteSpace", "collapse"
1588
       });		
1589
    addAnnotation
1590
      (booleanObjectEDataType, 
1591
       source, 
1592
       new String[] 
1593
       {
1594
       "name", "boolean:Object",
1595
       "baseType", "boolean"
1596
       });		
1597
    addAnnotation
1598
      (byteEDataType, 
1599
       source, 
1600
       new String[] 
1601
       {
1602
       "name", "byte"
1603
       });		
1604
    addAnnotation
1605
      (byteObjectEDataType, 
1606
       source, 
1607
       new String[] 
1608
       {
1609
       "name", "byte:Object",
1610
       "baseType", "byte"
1611
       });		
1612
    addAnnotation
1613
      (dateEDataType, 
1614
       source, 
1615
       new String[] 
1616
       {
1617
       "name", "date",
1618
       "baseType", "anySimpleType",
1619
       "whiteSpace", "collapse"
1620
       });		
1621
    addAnnotation
1622
      (dateTimeEDataType, 
1623
       source, 
1624
       new String[] 
1625
       {
1626
       "name", "dateTime",
1627
       "baseType", "anySimpleType",
1628
       "whiteSpace", "collapse"
1629
       });		
1630
    addAnnotation
1631
      (decimalEDataType, 
1632
       source, 
1633
       new String[] 
1634
       {
1635
       "name", "decimal",
1636
       "whiteSpace", "collapse"
1637
       });		
1638
    addAnnotation
1639
      (doubleEDataType, 
1640
       source, 
1641
       new String[] 
1642
       {
1643
       "name", "double",
1644
       "whiteSpace", "collapse"
1645
       });		
1646
    addAnnotation
1647
      (doubleObjectEDataType, 
1648
       source, 
1649
       new String[] 
1650
       {
1651
       "name", "double:Object",
1652
       "baseType", "double"
1653
       });		
1654
    addAnnotation
1655
      (durationEDataType, 
1656
       source, 
1657
       new String[] 
1658
       {
1659
       "name", "duration",
1660
       "baseType", "anySimpleType",
1661
       "whiteSpace", "collapse"
1662
       });		
1663
    addAnnotation
1664
      (entitiesEDataType, 
1665
       source, 
1666
       new String[] 
1667
       {
1668
       "name", "ENTITIES",
1669
       "baseType", "ENTITIES_._base",
1670
       "minLength", "1"
1671
       });		
1672
    addAnnotation
1673
      (entitiesBaseEDataType, 
1674
       source, 
1675
       new String[] 
1676
       {
1677
       "name", "ENTITIES_._base",
1678
       "itemType", "ENTITY"
1679
       });		
1680
    addAnnotation
1681
      (entityEDataType, 
1682
       source, 
1683
       new String[] 
1684
       {
1685
       "name", "ENTITY",
1686
       "baseType", "NCName"
1687
       });		
1688
    addAnnotation
1689
      (floatEDataType, 
1690
       source, 
1691
       new String[] 
1692
       {
1693
       "name", "float",
1694
       "whiteSpace", "collapse"
1695
       });		
1696
    addAnnotation
1697
      (floatObjectEDataType, 
1698
       source, 
1699
       new String[] 
1700
       {
1701
       "name", "float:Object",
1702
       "baseType", "float"
1703
       });		
1704
    addAnnotation
1705
      (gDayEDataType, 
1706
       source, 
1707
       new String[] 
1708
       {
1709
       "name", "gDay",
1710
       "baseType", "anySimpleType",
1711
       "whiteSpace", "collapse"
1712
       });		
1713
    addAnnotation
1714
      (gMonthEDataType, 
1715
       source, 
1716
       new String[] 
1717
       {
1718
       "name", "gMonth",
1719
       "baseType", "anySimpleType",
1720
       "whiteSpace", "collapse"
1721
       });		
1722
    addAnnotation
1723
      (gMonthDayEDataType, 
1724
       source, 
1725
       new String[] 
1726
       {
1727
       "name", "gMonthDay",
1728
       "baseType", "anySimpleType",
1729
       "whiteSpace", "collapse"
1730
       });		
1731
    addAnnotation
1732
      (gYearEDataType, 
1733
       source, 
1734
       new String[] 
1735
       {
1736
       "name", "gYear",
1737
       "baseType", "anySimpleType",
1738
       "whiteSpace", "collapse"
1739
       });		
1740
    addAnnotation
1741
      (gYearMonthEDataType, 
1742
       source, 
1743
       new String[] 
1744
       {
1745
       "name", "gYearMonth",
1746
       "baseType", "anySimpleType",
1747
       "whiteSpace", "collapse"
1748
       });		
1749
    addAnnotation
1750
      (hexBinaryEDataType, 
1751
       source, 
1752
       new String[] 
1753
       {
1754
       "name", "hexBinary",
1755
       "whiteSpace", "collapse"
1756
       });		
1757
    addAnnotation
1758
      (idEDataType, 
1759
       source, 
1760
       new String[] 
1761
       {
1762
       "name", "ID",
1763
       "baseType", "NCName"
1764
       });		
1765
    addAnnotation
1766
      (idrefEDataType, 
1767
       source, 
1768
       new String[] 
1769
       {
1770
       "name", "IDREF",
1771
       "baseType", "NCName"
1772
       });		
1773
    addAnnotation
1774
      (idrefsEDataType, 
1775
       source, 
1776
       new String[] 
1777
       {
1778
       "name", "IDREFS",
1779
       "baseType", "IDREFS_._base",
1780
       "minLength", "1"
1781
       });		
1782
    addAnnotation
1783
      (idrefsBaseEDataType, 
1784
       source, 
1785
       new String[] 
1786
       {
1787
       "name", "IDREFS_._base",
1788
       "itemType", "IDREF"
1789
       });		
1790
    addAnnotation
1791
      (intEDataType, 
1792
       source, 
1793
       new String[] 
1794
       {
1795
       "name", "int"
1796
       });		
1797
    addAnnotation
1798
      (integerEDataType, 
1799
       source, 
1800
       new String[] 
1801
       {
1802
       "name", "integer"
1803
       });		
1804
    addAnnotation
1805
      (intObjectEDataType, 
1806
       source, 
1807
       new String[] 
1808
       {
1809
       "name", "int:Object",
1810
       "baseType", "int"
1811
       });		
1812
    addAnnotation
1813
      (languageEDataType, 
1814
       source, 
1815
       new String[] 
1816
       {
1817
       "name", "language",
1818
       "baseType", "token",
1819
       "pattern", "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"
1820
       });		
1821
    addAnnotation
1822
      (longEDataType, 
1823
       source, 
1824
       new String[] 
1825
       {
1826
       "name", "long"
1827
       });		
1828
    addAnnotation
1829
      (longObjectEDataType, 
1830
       source, 
1831
       new String[] 
1832
       {
1833
       "name", "long:Object",
1834
       "baseType", "long"
1835
       });		
1836
    addAnnotation
1837
      (nameEDataType, 
1838
       source, 
1839
       new String[] 
1840
       {
1841
       "name", "Name",
1842
       "baseType", "token",
1843
       "pattern", "\\i\\c*"
1844
       });		
1845
    addAnnotation
1846
      (ncNameEDataType, 
1847
       source, 
1848
       new String[] 
1849
       {
1850
       "name", "NCName",
1851
       "baseType", "Name",
1852
       "pattern", "[\\i-[:]][\\c-[:]]*"
1853
       });		
1854
    addAnnotation
1855
      (negativeIntegerEDataType, 
1856
       source, 
1857
       new String[] 
1858
       {
1859
       "name", "negativeInteger",
1860
       "baseType", "nonPositiveInteger",
1861
       "maxInclusive", "-1"
1862
       });		
1863
    addAnnotation
1864
      (nmtokenEDataType, 
1865
       source, 
1866
       new String[] 
1867
       {
1868
       "name", "NMTOKEN",
1869
       "baseType", "token",
1870
       "pattern", "\\c+"
1871
       });		
1872
    addAnnotation
1873
      (nmtokensEDataType, 
1874
       source, 
1875
       new String[] 
1876
       {
1877
       "name", "NMTOKENS",
1878
       "baseType", "NMTOKENS_._base",
1879
       "minLength", "1"
1880
       });		
1881
    addAnnotation
1882
      (nmtokensBaseEDataType, 
1883
       source, 
1884
       new String[] 
1885
       {
1886
       "name", "NMTOKENS_._base",
1887
       "itemType", "NMTOKEN"
1888
       });		
1889
    addAnnotation
1890
      (nonNegativeIntegerEDataType, 
1891
       source, 
1892
       new String[] 
1893
       {
1894
       "name", "nonNegativeInteger",
1895
       "baseType", "integer",
1896
       "minInclusive", "0"
1897
       });		
1898
    addAnnotation
1899
      (nonPositiveIntegerEDataType, 
1900
       source, 
1901
       new String[] 
1902
       {
1903
       "name", "nonPositiveInteger",
1904
       "baseType", "integer",
1905
       "maxInclusive", "0"
1906
       });		
1907
    addAnnotation
1908
      (normalizedStringEDataType, 
1909
       source, 
1910
       new String[] 
1911
       {
1912
       "name", "normalizedString",
1913
       "baseType", "string",
1914
       "whiteSpace", "replace"
1915
       });		
1916
    addAnnotation
1917
      (notationEDataType, 
1918
       source, 
1919
       new String[] 
1920
       {
1921
       "name", "NOTATION",
1922
       "baseType", "anySimpleType",
1923
       "whiteSpace", "collapse"
1924
       });		
1925
    addAnnotation
1926
      (positiveIntegerEDataType, 
1927
       source, 
1928
       new String[] 
1929
       {
1930
       "name", "positiveInteger",
1931
       "baseType", "nonNegativeInteger",
1932
       "minInclusive", "1"
1933
       });		
1934
    addAnnotation
1935
      (qNameEDataType, 
1936
       source, 
1937
       new String[] 
1938
       {
1939
       "name", "QName",
1940
       "baseType", "anySimpleType",
1941
       "whiteSpace", "collapse"
1942
       });		
1943
    addAnnotation
1944
      (shortEDataType, 
1945
       source, 
1946
       new String[] 
1947
       {
1948
       "name", "short"
1949
       });		
1950
    addAnnotation
1951
      (shortObjectEDataType, 
1952
       source, 
1953
       new String[] 
1954
       {
1955
       "name", "short:Object",
1956
       "baseType", "short"
1957
       });		
1958
    addAnnotation
1959
      (simpleAnyTypeEClass, 
1960
       source, 
1961
       new String[] 
1962
       {
1963
       "name", "simpleAnyType",
1964
       "kind", "simple"
1965
       });		
1966
    addAnnotation
1967
      (getSimpleAnyType_RawValue(), 
1968
       source, 
1969
       new String[] 
1970
       {
1971
       "name", ":3",
1972
       "kind", "simple"
1973
       });		
1974
    addAnnotation
1975
      (getSimpleAnyType_Value(), 
1976
       source, 
1977
       new String[] 
1978
       {
1979
       "name", ":4",
1980
       "kind", "simple"
1981
       });		
1982
    addAnnotation
1983
      (getSimpleAnyType_InstanceType(), 
1984
       source, 
1985
       new String[] 
1986
       {
1987
       "name", ":5",
1988
       "kind", "simple"
1989
       });		
1990
    addAnnotation
1991
      (stringEDataType, 
1992
       source, 
1993
       new String[] 
1994
       {
1995
       "name", "string",
1996
       "whiteSpace", "preserve"
1997
       });		
1998
    addAnnotation
1999
      (timeEDataType, 
2000
       source, 
2001
       new String[] 
2002
       {
2003
       "name", "time",
2004
       "baseType", "anySimpleType",
2005
       "whiteSpace", "collapse"
2006
       });		
2007
    addAnnotation
2008
      (tokenEDataType, 
2009
       source, 
2010
       new String[] 
2011
       {
2012
       "name", "token",
2013
       "baseType", "normalizedString",
2014
       "whiteSpace", "collapse"
2015
       });		
2016
    addAnnotation
2017
      (unsignedByteEDataType, 
2018
       source, 
2019
       new String[] 
2020
       {
2021
       "name", "unsignedByte",
2022
       "maxInclusive", "255",
2023
       "minInclusive", "0"
2024
       });		
2025
    addAnnotation
2026
      (unsignedByteObjectEDataType, 
2027
       source, 
2028
       new String[] 
2029
       {
2030
       "name", "unsignedByte:Object",
2031
       "baseType", "unsignedByte"
2032
       });		
2033
    addAnnotation
2034
      (unsignedIntEDataType, 
2035
       source, 
2036
       new String[] 
2037
       {
2038
       "name", "unsignedInt",
2039
       "maxInclusive", "4294967295",
2040
       "minInclusive", "0"
2041
       });		
2042
    addAnnotation
2043
      (unsignedIntObjectEDataType, 
2044
       source, 
2045
       new String[] 
2046
       {
2047
       "name", "unsignedInt:Object",
2048
       "baseType", "unsignedInt"
2049
       });		
2050
    addAnnotation
2051
      (unsignedLongEDataType, 
2052
       source, 
2053
       new String[] 
2054
       {
2055
       "name", "unsignedLong",
2056
       "baseType", "nonNegativeInteger",
2057
       "maxInclusive", "18446744073709551615",
2058
       "minInclusive", "0"
2059
       });		
2060
    addAnnotation
2061
      (unsignedShortEDataType, 
2062
       source, 
2063
       new String[] 
2064
       {
2065
       "name", "unsignedShort",
2066
       "maxInclusive", "65535",
2067
       "minInclusive", "0"
2068
       });		
2069
    addAnnotation
2070
      (unsignedShortObjectEDataType, 
2071
       source, 
2072
       new String[] 
2073
       {
2074
       "name", "unsignedShort:Object",
2075
       "baseType", "unsignedShort"
2076
       });		
2077
    addAnnotation
2078
      (xmlTypeDocumentRootEClass, 
2079
       source, 
2080
       new String[] 
2081
       {
2082
       "name", "",
2083
       "kind", "mixed"
2084
       });		
2085
    addAnnotation
2086
      (getXMLTypeDocumentRoot_Mixed(), 
2087
       source, 
2088
       new String[] 
2089
       {
2090
       "kind", "elementWildcard",
2091
       "name", ":mixed"
2092
       });		
2093
    addAnnotation
2094
      (getXMLTypeDocumentRoot_XMLNSPrefixMap(), 
2095
       source, 
2096
       new String[] 
2097
       {
2098
       "kind", "attribute",
2099
       "name", "xmlns:prefix"
2100
       });		
2101
    addAnnotation
2102
      (getXMLTypeDocumentRoot_XSISchemaLocation(), 
2103
       source, 
2104
       new String[] 
2105
       {
2106
       "kind", "attribute",
2107
       "name", "xsi:schemaLocation"
2108
       });		
2109
    addAnnotation
2110
      (getXMLTypeDocumentRoot_CDATA(), 
2111
       source, 
2112
       new String[] 
2113
       {
2114
       "kind", "element",
2115
       "name", "cDATA",
2116
       "namespace", "##targetNamespace"
2117
       });		
2118
    addAnnotation
2119
      (getXMLTypeDocumentRoot_Comment(), 
2120
       source, 
2121
       new String[] 
2122
       {
2123
       "kind", "element",
2124
       "name", "comment",
2125
       "namespace", "##targetNamespace"
2126
       });		
2127
    addAnnotation
2128
      (getXMLTypeDocumentRoot_Text(), 
2129
       source, 
2130
       new String[] 
2131
       {
2132
       "kind", "element",
2133
       "name", "text",
2134
       "namespace", "##targetNamespace"
2135
       });
2136
  }
2137
2138
  /**
2139
   * Initializes the annotations for <b>null</b>.
2140
   * <!-- begin-user-doc -->
2141
   * <!-- end-user-doc -->
2142
   * @generated NOT
2143
   */
2144
  protected void createNullAnnotations()
2145
  {
2146
  }
2147
} //XMLTypePackageImpl
(-)src/org/eclipse/emf/ecore/xml/type/impl/SimpleAnyTypeImpl.java (-288 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: SimpleAnyTypeImpl.java,v 1.6 2005/11/23 18:10:02 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.impl;
18
19
import java.util.Iterator;
20
21
import org.eclipse.emf.common.notify.Notification;
22
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EDataType;
24
import org.eclipse.emf.ecore.impl.ENotificationImpl;
25
import org.eclipse.emf.ecore.util.EcoreUtil;
26
import org.eclipse.emf.ecore.util.FeatureMap;
27
import org.eclipse.emf.ecore.xml.type.SimpleAnyType;
28
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
29
30
/**
31
 * <!-- begin-user-doc -->
32
 * An implementation of the model object '<em><b>Simple Any Type</b></em>'.
33
 * <!-- end-user-doc -->
34
 * <p>
35
 * The following features are implemented:
36
 * <ul>
37
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.SimpleAnyTypeImpl#getRawValue <em>Raw Value</em>}</li>
38
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.SimpleAnyTypeImpl#getValue <em>Value</em>}</li>
39
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.SimpleAnyTypeImpl#getInstanceType <em>Instance Type</em>}</li>
40
 * </ul>
41
 * </p>
42
 *
43
 * @generated
44
 */
45
public class SimpleAnyTypeImpl extends AnyTypeImpl implements SimpleAnyType
46
{
47
  /**
48
   * The default value of the '{@link #getRawValue() <em>Raw Value</em>}' attribute.
49
   * <!-- begin-user-doc -->
50
   * <!-- end-user-doc -->
51
   * @see #getRawValue()
52
   * @generated
53
   * @ordered
54
   */
55
  protected static final String RAW_VALUE_EDEFAULT = null;
56
57
  /**
58
   * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
59
   * <!-- begin-user-doc -->
60
   * <!-- end-user-doc -->
61
   * @see #getValue()
62
   * @generated
63
   * @ordered
64
   */
65
  protected static final Object VALUE_EDEFAULT = null;
66
67
  /**
68
   * The cached value of the '{@link #getInstanceType() <em>Instance Type</em>}' reference.
69
   * <!-- begin-user-doc -->
70
   * <!-- end-user-doc -->
71
   * @see #getInstanceType()
72
   * @generated
73
   * @ordered
74
   */
75
  protected EDataType instanceType = null;
76
77
  /**
78
   * <!-- begin-user-doc -->
79
   * <!-- end-user-doc -->
80
   * @generated
81
   */
82
  protected SimpleAnyTypeImpl()
83
  {
84
    super();
85
  }
86
87
  /**
88
   * <!-- begin-user-doc -->
89
   * <!-- end-user-doc -->
90
   * @generated
91
   */
92
  protected EClass eStaticClass()
93
  {
94
    return XMLTypePackage.Literals.SIMPLE_ANY_TYPE;
95
  }
96
97
  /**
98
   * <!-- begin-user-doc -->
99
   * <!-- end-user-doc -->
100
   * @generated NOT
101
   */
102
  public String getRawValue()
103
  {
104
    StringBuffer value = new StringBuffer();
105
    for (Iterator i = getMixed().iterator(); i.hasNext(); )
106
    {
107
      FeatureMap.Entry entry = (FeatureMap.Entry)i.next();
108
      if (entry.getEStructuralFeature() == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text())
109
      {
110
        value.append(entry.getValue());
111
      }
112
    }
113
    return value.toString();
114
  }
115
116
  /**
117
   * <!-- begin-user-doc -->
118
   * <!-- end-user-doc -->
119
   * @generated NOT
120
   */
121
  public void setRawValue(String newRawValue)
122
  {
123
    getMixed().clear();
124
    if (newRawValue != null)
125
    {
126
      getMixed().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), newRawValue);
127
    }
128
  }
129
130
  /**
131
   * <!-- begin-user-doc -->
132
   * <!-- end-user-doc -->
133
   * @generated NOT
134
   */
135
  public Object getValue()
136
  {
137
    return EcoreUtil.createFromString(instanceType, getRawValue());
138
  }
139
140
  /**
141
   * <!-- begin-user-doc -->
142
   * <!-- end-user-doc -->
143
   * @generated NOT
144
   */
145
  public void setValue(Object newValue)
146
  {
147
    setRawValue(EcoreUtil.convertToString(instanceType, newValue));
148
  }
149
150
  /**
151
   * <!-- begin-user-doc -->
152
   * <!-- end-user-doc -->
153
   * @generated
154
   */
155
  public EDataType getInstanceType()
156
  {
157
    return instanceType;
158
  }
159
160
  /**
161
   * <!-- begin-user-doc -->
162
   * <!-- end-user-doc -->
163
   * @generated
164
   */
165
  public void setInstanceType(EDataType newInstanceType)
166
  {
167
    EDataType oldInstanceType = instanceType;
168
    instanceType = newInstanceType;
169
    if (eNotificationRequired())
170
      eNotify(new ENotificationImpl(this, Notification.SET, XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE, oldInstanceType, instanceType));
171
  }
172
173
  /**
174
   * <!-- begin-user-doc -->
175
   * <!-- end-user-doc -->
176
   * @generated
177
   */
178
  public Object eGet(int featureID, boolean resolve, boolean coreType)
179
  {
180
    switch (featureID)
181
    {
182
      case XMLTypePackage.SIMPLE_ANY_TYPE__MIXED:
183
        if (coreType) return getMixed();
184
        return ((FeatureMap.Internal)getMixed()).getWrapper();
185
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY:
186
        if (coreType) return getAny();
187
        return ((FeatureMap.Internal)getAny()).getWrapper();
188
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY_ATTRIBUTE:
189
        if (coreType) return getAnyAttribute();
190
        return ((FeatureMap.Internal)getAnyAttribute()).getWrapper();
191
      case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE:
192
        return getRawValue();
193
      case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE:
194
        return getValue();
195
      case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE:
196
        return getInstanceType();
197
    }
198
    return eDynamicGet(featureID, resolve, coreType);
199
  }
200
201
  /**
202
   * <!-- begin-user-doc -->
203
   * <!-- end-user-doc -->
204
   * @generated
205
   */
206
  public void eSet(int featureID, Object newValue)
207
  {
208
    switch (featureID)
209
    {
210
      case XMLTypePackage.SIMPLE_ANY_TYPE__MIXED:
211
        ((FeatureMap.Internal)getMixed()).set(newValue);
212
        return;
213
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY:
214
        ((FeatureMap.Internal)getAny()).set(newValue);
215
        return;
216
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY_ATTRIBUTE:
217
        ((FeatureMap.Internal)getAnyAttribute()).set(newValue);
218
        return;
219
      case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE:
220
        setRawValue((String)newValue);
221
        return;
222
      case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE:
223
        setValue((Object)newValue);
224
        return;
225
      case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE:
226
        setInstanceType((EDataType)newValue);
227
        return;
228
    }
229
    eDynamicSet(featureID, newValue);
230
  }
231
232
  /**
233
   * <!-- begin-user-doc -->
234
   * <!-- end-user-doc -->
235
   * @generated
236
   */
237
  public void eUnset(int featureID)
238
  {
239
    switch (featureID)
240
    {
241
      case XMLTypePackage.SIMPLE_ANY_TYPE__MIXED:
242
        getMixed().clear();
243
        return;
244
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY:
245
        getAny().clear();
246
        return;
247
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY_ATTRIBUTE:
248
        getAnyAttribute().clear();
249
        return;
250
      case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE:
251
        setRawValue(RAW_VALUE_EDEFAULT);
252
        return;
253
      case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE:
254
        setValue(VALUE_EDEFAULT);
255
        return;
256
      case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE:
257
        setInstanceType((EDataType)null);
258
        return;
259
    }
260
    eDynamicUnset(featureID);
261
  }
262
263
  /**
264
   * <!-- begin-user-doc -->
265
   * <!-- end-user-doc -->
266
   * @generated
267
   */
268
  public boolean eIsSet(int featureID)
269
  {
270
    switch (featureID)
271
    {
272
      case XMLTypePackage.SIMPLE_ANY_TYPE__MIXED:
273
        return mixed != null && !mixed.isEmpty();
274
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY:
275
        return !getAny().isEmpty();
276
      case XMLTypePackage.SIMPLE_ANY_TYPE__ANY_ATTRIBUTE:
277
        return anyAttribute != null && !anyAttribute.isEmpty();
278
      case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE:
279
        return RAW_VALUE_EDEFAULT == null ? getRawValue() != null : !RAW_VALUE_EDEFAULT.equals(getRawValue());
280
      case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE:
281
        return VALUE_EDEFAULT == null ? getValue() != null : !VALUE_EDEFAULT.equals(getValue());
282
      case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE:
283
        return instanceType != null;
284
    }
285
    return eDynamicIsSet(featureID);
286
  }
287
288
} //SimpleAnyTypeImpl
(-)src/org/eclipse/emf/ecore/xml/type/impl/AnyTypeImpl.java (-246 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: AnyTypeImpl.java,v 1.7 2005/11/25 17:49:49 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.type.impl;
18
19
import org.eclipse.emf.common.notify.NotificationChain;
20
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.InternalEObject;
22
import org.eclipse.emf.ecore.impl.EObjectImpl;
23
import org.eclipse.emf.ecore.util.BasicFeatureMap;
24
import org.eclipse.emf.ecore.util.FeatureMap;
25
import org.eclipse.emf.ecore.util.InternalEList;
26
import org.eclipse.emf.ecore.xml.type.AnyType;
27
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
28
29
/**
30
 * <!-- begin-user-doc -->
31
 * An implementation of the model object '<em><b>Any Type</b></em>'.
32
 * <!-- end-user-doc -->
33
 * <p>
34
 * The following features are implemented:
35
 * <ul>
36
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl#getMixed <em>Mixed</em>}</li>
37
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl#getAny <em>Any</em>}</li>
38
 *   <li>{@link org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl#getAnyAttribute <em>Any Attribute</em>}</li>
39
 * </ul>
40
 * </p>
41
 *
42
 * @generated
43
 */
44
public class AnyTypeImpl extends EObjectImpl implements AnyType
45
{
46
  /**
47
   * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
48
   * <!-- begin-user-doc -->
49
   * <!-- end-user-doc -->
50
   * @see #getMixed()
51
   * @generated
52
   * @ordered
53
   */
54
  protected FeatureMap mixed = null;
55
56
  /**
57
   * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list.
58
   * <!-- begin-user-doc -->
59
   * <!-- end-user-doc -->
60
   * @see #getAnyAttribute()
61
   * @generated
62
   * @ordered
63
   */
64
  protected FeatureMap anyAttribute = null;
65
66
  /**
67
   * <!-- begin-user-doc -->
68
   * <!-- end-user-doc -->
69
   * @generated
70
   */
71
  protected AnyTypeImpl()
72
  {
73
    super();
74
  }
75
76
  /**
77
   * <!-- begin-user-doc -->
78
   * <!-- end-user-doc -->
79
   * @generated
80
   */
81
  protected EClass eStaticClass()
82
  {
83
    return XMLTypePackage.Literals.ANY_TYPE;
84
  }
85
86
  /**
87
   * <!-- begin-user-doc -->
88
   * <!-- end-user-doc -->
89
   * @generated
90
   */
91
  public FeatureMap getMixed()
92
  {
93
    if (mixed == null)
94
    {
95
      mixed = new BasicFeatureMap(this, XMLTypePackage.ANY_TYPE__MIXED);
96
    }
97
    return mixed;
98
  }
99
100
  /**
101
   * <!-- begin-user-doc -->
102
   * <!-- end-user-doc -->
103
   * @generated
104
   */
105
  public FeatureMap getAny()
106
  {
107
    return (FeatureMap)((FeatureMap)getMixed()).list(XMLTypePackage.Literals.ANY_TYPE__ANY);
108
  }
109
110
  /**
111
   * <!-- begin-user-doc -->
112
   * <!-- end-user-doc -->
113
   * @generated
114
   */
115
  public FeatureMap getAnyAttribute()
116
  {
117
    if (anyAttribute == null)
118
    {
119
      anyAttribute = new BasicFeatureMap(this, XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE);
120
    }
121
    return anyAttribute;
122
  }
123
124
  /**
125
   * <!-- begin-user-doc -->
126
   * <!-- end-user-doc -->
127
   * @generated
128
   */
129
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
130
  {
131
    switch (featureID)
132
    {
133
      case XMLTypePackage.ANY_TYPE__MIXED:
134
        return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs);
135
      case XMLTypePackage.ANY_TYPE__ANY:
136
        return ((InternalEList)getAny()).basicRemove(otherEnd, msgs);
137
      case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE:
138
        return ((InternalEList)getAnyAttribute()).basicRemove(otherEnd, msgs);
139
    }
140
    return eDynamicInverseRemove(otherEnd, featureID, msgs);
141
  }
142
143
  /**
144
   * <!-- begin-user-doc -->
145
   * <!-- end-user-doc -->
146
   * @generated
147
   */
148
  public Object eGet(int featureID, boolean resolve, boolean coreType)
149
  {
150
    switch (featureID)
151
    {
152
      case XMLTypePackage.ANY_TYPE__MIXED:
153
        if (coreType) return getMixed();
154
        return ((FeatureMap.Internal)getMixed()).getWrapper();
155
      case XMLTypePackage.ANY_TYPE__ANY:
156
        if (coreType) return getAny();
157
        return ((FeatureMap.Internal)getAny()).getWrapper();
158
      case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE:
159
        if (coreType) return getAnyAttribute();
160
        return ((FeatureMap.Internal)getAnyAttribute()).getWrapper();
161
    }
162
    return eDynamicGet(featureID, resolve, coreType);
163
  }
164
165
  /**
166
   * <!-- begin-user-doc -->
167
   * <!-- end-user-doc -->
168
   * @generated
169
   */
170
  public void eSet(int featureID, Object newValue)
171
  {
172
    switch (featureID)
173
    {
174
      case XMLTypePackage.ANY_TYPE__MIXED:
175
        ((FeatureMap.Internal)getMixed()).set(newValue);
176
        return;
177
      case XMLTypePackage.ANY_TYPE__ANY:
178
        ((FeatureMap.Internal)getAny()).set(newValue);
179
        return;
180
      case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE:
181
        ((FeatureMap.Internal)getAnyAttribute()).set(newValue);
182
        return;
183
    }
184
    eDynamicSet(featureID, newValue);
185
  }
186
187
  /**
188
   * <!-- begin-user-doc -->
189
   * <!-- end-user-doc -->
190
   * @generated
191
   */
192
  public void eUnset(int featureID)
193
  {
194
    switch (featureID)
195
    {
196
      case XMLTypePackage.ANY_TYPE__MIXED:
197
        getMixed().clear();
198
        return;
199
      case XMLTypePackage.ANY_TYPE__ANY:
200
        getAny().clear();
201
        return;
202
      case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE:
203
        getAnyAttribute().clear();
204
        return;
205
    }
206
    eDynamicUnset(featureID);
207
  }
208
209
  /**
210
   * <!-- begin-user-doc -->
211
   * <!-- end-user-doc -->
212
   * @generated
213
   */
214
  public boolean eIsSet(int featureID)
215
  {
216
    switch (featureID)
217
    {
218
      case XMLTypePackage.ANY_TYPE__MIXED:
219
        return mixed != null && !mixed.isEmpty();
220
      case XMLTypePackage.ANY_TYPE__ANY:
221
        return !getAny().isEmpty();
222
      case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE:
223
        return anyAttribute != null && !anyAttribute.isEmpty();
224
    }
225
    return eDynamicIsSet(featureID);
226
  }
227
228
  /**
229
   * <!-- begin-user-doc -->
230
   * <!-- end-user-doc -->
231
   * @generated
232
   */
233
  public String toString()
234
  {
235
    if (eIsProxy()) return super.toString();
236
237
    StringBuffer result = new StringBuffer(super.toString());
238
    result.append(" (mixed: ");
239
    result.append(mixed);
240
    result.append(", anyAttribute: ");
241
    result.append(anyAttribute);
242
    result.append(')');
243
    return result.toString();
244
  }
245
246
} //AnyTypeImpl
(-)src/org/eclipse/emf/ecore/xml/namespace/XMLNamespaceDocumentRoot.java (-241 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespaceDocumentRoot.java,v 1.6 2005/09/23 17:46:24 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace;
18
19
20
import org.eclipse.emf.common.util.EMap;
21
import org.eclipse.emf.ecore.EObject;
22
import org.eclipse.emf.ecore.util.FeatureMap;
23
24
25
/**
26
 * <!-- begin-user-doc -->
27
 * A representation of the model object '<em><b>Document Root</b></em>'.
28
 * <!-- end-user-doc -->
29
 *
30
 * <p>
31
 * The following features are supported:
32
 * <ul>
33
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getMixed <em>Mixed</em>}</li>
34
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}</li>
35
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXSISchemaLocation <em>XSI Schema Location</em>}</li>
36
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getBase <em>Base</em>}</li>
37
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getId <em>Id</em>}</li>
38
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getLang <em>Lang</em>}</li>
39
 *   <li>{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace <em>Space</em>}</li>
40
 * </ul>
41
 * </p>
42
 *
43
 * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot()
44
 * @model extendedMetaData="name='' kind='mixed'"
45
 * @generated
46
 */
47
public interface XMLNamespaceDocumentRoot extends EObject
48
{
49
  /**
50
   * Returns the value of the '<em><b>Mixed</b></em>' attribute list.
51
   * The list contents are of type {@link org.eclipse.emf.ecore.util.FeatureMap.Entry}.
52
   * <!-- begin-user-doc -->
53
   * <p>
54
   * If the meaning of the '<em>Mixed</em>' attribute list isn't clear,
55
   * there really should be more of a description here...
56
   * </p>
57
   * <!-- end-user-doc -->
58
   * @return the value of the '<em>Mixed</em>' attribute list.
59
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_Mixed()
60
   * @model unique="false" dataType="org.eclipse.emf.ecore.EFeatureMapEntry" many="true"
61
   *        extendedMetaData="kind='elementWildcard' name=':mixed'"
62
   * @generated
63
   */
64
  FeatureMap getMixed();
65
66
  /**
67
   * Returns the value of the '<em><b>XMLNS Prefix Map</b></em>' map.
68
   * The key is of type {@link java.lang.String},
69
   * and the value is of type {@link java.lang.String},
70
   * <!-- begin-user-doc -->
71
   * <p>
72
   * If the meaning of the '<em>XMLNS Prefix Map</em>' map isn't clear,
73
   * there really should be more of a description here...
74
   * </p>
75
   * <!-- end-user-doc -->
76
   * @return the value of the '<em>XMLNS Prefix Map</em>' map.
77
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_XMLNSPrefixMap()
78
   * @model mapType="org.eclipse.emf.ecore.EStringToStringMapEntry" keyType="java.lang.String" valueType="java.lang.String" transient="true"
79
   *        extendedMetaData="kind='attribute' name='xmlns:prefix'"
80
   * @generated
81
   */
82
  EMap getXMLNSPrefixMap();
83
84
  /**
85
   * Returns the value of the '<em><b>XSI Schema Location</b></em>' map.
86
   * The key is of type {@link java.lang.String},
87
   * and the value is of type {@link java.lang.String},
88
   * <!-- begin-user-doc -->
89
   * <p>
90
   * If the meaning of the '<em>XSI Schema Location</em>' map isn't clear,
91
   * there really should be more of a description here...
92
   * </p>
93
   * <!-- end-user-doc -->
94
   * @return the value of the '<em>XSI Schema Location</em>' map.
95
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_XSISchemaLocation()
96
   * @model mapType="org.eclipse.emf.ecore.EStringToStringMapEntry" keyType="java.lang.String" valueType="java.lang.String" transient="true"
97
   *        extendedMetaData="kind='attribute' name='xsi:schemaLocation'"
98
   * @generated
99
   */
100
  EMap getXSISchemaLocation();
101
102
  /**
103
   * Returns the value of the '<em><b>Base</b></em>' attribute.
104
   * <!-- begin-user-doc -->
105
   * <p>
106
   * If the meaning of the '<em>Base</em>' attribute isn't clear,
107
   * there really should be more of a description here...
108
   * </p>
109
   * <!-- end-user-doc -->
110
   * @return the value of the '<em>Base</em>' attribute.
111
   * @see #setBase(String)
112
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_Base()
113
   * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.AnyURI"
114
   *        extendedMetaData="kind='attribute' name='base' namespace='##targetNamespace'"
115
   * @generated
116
   */
117
  String getBase();
118
119
  /**
120
   * Sets the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getBase <em>Base</em>}' attribute.
121
   * <!-- begin-user-doc -->
122
   * <!-- end-user-doc -->
123
   * @param value the new value of the '<em>Base</em>' attribute.
124
   * @see #getBase()
125
   * @generated
126
   */
127
  void setBase(String value);
128
129
  /**
130
   * Returns the value of the '<em><b>Id</b></em>' attribute.
131
   * <!-- begin-user-doc -->
132
   * <p>
133
   * If the meaning of the '<em>Id</em>' attribute isn't clear,
134
   * there really should be more of a description here...
135
   * </p>
136
   * <!-- end-user-doc -->
137
   * @return the value of the '<em>Id</em>' attribute.
138
   * @see #setId(String)
139
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_Id()
140
   * @model unique="false" id="true" dataType="org.eclipse.emf.ecore.xml.type.ID"
141
   *        extendedMetaData="kind='attribute' name='id' namespace='##targetNamespace'"
142
   * @generated
143
   */
144
  String getId();
145
146
  /**
147
   * Sets the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getId <em>Id</em>}' attribute.
148
   * <!-- begin-user-doc -->
149
   * <!-- end-user-doc -->
150
   * @param value the new value of the '<em>Id</em>' attribute.
151
   * @see #getId()
152
   * @generated
153
   */
154
  void setId(String value);
155
156
  /**
157
   * Returns the value of the '<em><b>Lang</b></em>' attribute.
158
   * <!-- begin-user-doc -->
159
   * <p>
160
   * If the meaning of the '<em>Lang</em>' attribute isn't clear,
161
   * there really should be more of a description here...
162
   * </p>
163
   * <!-- end-user-doc -->
164
   * @return the value of the '<em>Lang</em>' attribute.
165
   * @see #setLang(String)
166
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_Lang()
167
   * @model unique="false" dataType="org.eclipse.emf.ecore.xml.namespace.LangType"
168
   *        extendedMetaData="kind='attribute' name='lang' namespace='##targetNamespace'"
169
   * @generated
170
   */
171
  String getLang();
172
173
  /**
174
   * Sets the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getLang <em>Lang</em>}' attribute.
175
   * <!-- begin-user-doc -->
176
   * <!-- end-user-doc -->
177
   * @param value the new value of the '<em>Lang</em>' attribute.
178
   * @see #getLang()
179
   * @generated
180
   */
181
  void setLang(String value);
182
183
  /**
184
   * Returns the value of the '<em><b>Space</b></em>' attribute.
185
   * The default value is <code>"preserve"</code>.
186
   * The literals are from the enumeration {@link org.eclipse.emf.ecore.xml.namespace.SpaceType}.
187
   * <!-- begin-user-doc -->
188
   * <p>
189
   * If the meaning of the '<em>Space</em>' attribute isn't clear,
190
   * there really should be more of a description here...
191
   * </p>
192
   * <!-- end-user-doc -->
193
   * @return the value of the '<em>Space</em>' attribute.
194
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
195
   * @see #isSetSpace()
196
   * @see #unsetSpace()
197
   * @see #setSpace(SpaceType)
198
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getXMLNamespaceDocumentRoot_Space()
199
   * @model default="preserve" unique="false" unsettable="true"
200
   *        extendedMetaData="kind='attribute' name='space' namespace='##targetNamespace'"
201
   * @generated
202
   */
203
  SpaceType getSpace();
204
205
  /**
206
   * Sets the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace <em>Space</em>}' attribute.
207
   * <!-- begin-user-doc -->
208
   * <!-- end-user-doc -->
209
   * @param value the new value of the '<em>Space</em>' attribute.
210
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
211
   * @see #isSetSpace()
212
   * @see #unsetSpace()
213
   * @see #getSpace()
214
   * @generated
215
   */
216
  void setSpace(SpaceType value);
217
218
  /**
219
   * Unsets the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace <em>Space</em>}' attribute.
220
   * <!-- begin-user-doc -->
221
   * <!-- end-user-doc -->
222
   * @see #isSetSpace()
223
   * @see #getSpace()
224
   * @see #setSpace(SpaceType)
225
   * @generated
226
   */
227
  void unsetSpace();
228
229
  /**
230
   * Returns whether the value of the '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace <em>Space</em>}' attribute is set.
231
   * <!-- begin-user-doc -->
232
   * <!-- end-user-doc -->
233
   * @return whether the value of the '<em>Space</em>' attribute is set.
234
   * @see #unsetSpace()
235
   * @see #getSpace()
236
   * @see #setSpace(SpaceType)
237
   * @generated
238
   */
239
  boolean isSetSpace();
240
241
} // DocumentRoot
(-)src/org/eclipse/emf/ecore/xml/namespace/XMLNamespaceFactory.java (-56 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespaceFactory.java,v 1.3 2005/11/23 13:56:58 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace;
18
19
import org.eclipse.emf.ecore.EFactory;
20
21
/**
22
 * <!-- begin-user-doc -->
23
 * The <b>Factory</b> for the model.
24
 * It provides a create method for each non-abstract class of the model.
25
 * <!-- end-user-doc -->
26
 * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage
27
 * @generated
28
 */
29
public interface XMLNamespaceFactory extends EFactory{
30
  /**
31
   * The singleton instance of the factory.
32
   * <!-- begin-user-doc -->
33
   * <!-- end-user-doc -->
34
   * @generated
35
   */
36
  XMLNamespaceFactory eINSTANCE = org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceFactoryImpl.init();
37
38
  /**
39
   * Returns a new object of class '<em>Document Root</em>'.
40
   * <!-- begin-user-doc -->
41
   * <!-- end-user-doc -->
42
   * @return a new object of class '<em>Document Root</em>'.
43
   * @generated
44
   */
45
  XMLNamespaceDocumentRoot createXMLNamespaceDocumentRoot();
46
47
  /**
48
   * Returns the package supported by this factory.
49
   * <!-- begin-user-doc -->
50
   * <!-- end-user-doc -->
51
   * @return the package supported by this factory.
52
   * @generated
53
   */
54
  XMLNamespacePackage getXMLNamespacePackage();
55
56
} //XMLNamespaceFactory
(-)src/org/eclipse/emf/ecore/xml/namespace/SpaceType.java (-172 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2004 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: SpaceType.java,v 1.3 2005/11/08 12:59:06 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace;
18
19
import java.util.Arrays;
20
import java.util.Collections;
21
import java.util.List;
22
23
import org.eclipse.emf.common.util.AbstractEnumerator;
24
25
/**
26
 * <!-- begin-user-doc -->
27
 * A representation of the literals of the enumeration '<em><b>Space Type</b></em>',
28
 * and utility methods for working with them.
29
 * <!-- end-user-doc -->
30
 * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage#getSpaceType()
31
 * @model
32
 * @generated
33
 */
34
public final class SpaceType extends AbstractEnumerator
35
{
36
  /**
37
   * The '<em><b>Default</b></em>' literal value.
38
   * <!-- begin-user-doc -->
39
   * <!-- end-user-doc -->
40
   * @see #DEFAULT_LITERAL
41
   * @model name="default"
42
   * @generated
43
   * @ordered
44
   */
45
  public static final int DEFAULT = 0;
46
47
  /**
48
   * The '<em><b>Preserve</b></em>' literal value.
49
   * <!-- begin-user-doc -->
50
   * <!-- end-user-doc -->
51
   * @see #PRESERVE_LITERAL
52
   * @model name="preserve"
53
   * @generated
54
   * @ordered
55
   */
56
  public static final int PRESERVE = 1;
57
58
  /**
59
   * The '<em><b>Default</b></em>' literal object.
60
   * <!-- begin-user-doc -->
61
   * <p>
62
   * If the meaning of '<em><b>Default</b></em>' literal object isn't clear,
63
   * there really should be more of a description here...
64
   * </p>
65
   * <!-- end-user-doc -->
66
   * @see #DEFAULT
67
   * @generated
68
   * @ordered
69
   */
70
  public static final SpaceType DEFAULT_LITERAL = new SpaceType(DEFAULT, "default", "default");
71
72
  /**
73
   * The '<em><b>Preserve</b></em>' literal object.
74
   * <!-- begin-user-doc -->
75
   * <p>
76
   * If the meaning of '<em><b>Preserve</b></em>' literal object isn't clear,
77
   * there really should be more of a description here...
78
   * </p>
79
   * <!-- end-user-doc -->
80
   * @see #PRESERVE
81
   * @generated
82
   * @ordered
83
   */
84
  public static final SpaceType PRESERVE_LITERAL = new SpaceType(PRESERVE, "preserve", "preserve");
85
86
  /**
87
   * An array of all the '<em><b>Space Type</b></em>' enumerators.
88
   * <!-- begin-user-doc -->
89
   * <!-- end-user-doc -->
90
   * @generated
91
   */
92
  private static final SpaceType[] VALUES_ARRAY =
93
    new SpaceType[]
94
    {
95
      DEFAULT_LITERAL,
96
      PRESERVE_LITERAL,
97
    };
98
99
  /**
100
   * A public read-only list of all the '<em><b>Space Type</b></em>' enumerators.
101
   * <!-- begin-user-doc -->
102
   * <!-- end-user-doc -->
103
   * @generated
104
   */
105
  public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
106
107
  /**
108
   * Returns the '<em><b>Space Type</b></em>' literal with the specified literal value.
109
   * <!-- begin-user-doc -->
110
   * <!-- end-user-doc -->
111
   * @generated
112
   */
113
  public static SpaceType get(String literal)
114
  {
115
    for (int i = 0; i < VALUES_ARRAY.length; ++i)
116
    {
117
      SpaceType result = VALUES_ARRAY[i];
118
      if (result.toString().equals(literal))
119
      {
120
        return result;
121
      }
122
    }
123
    return null;
124
  }
125
126
  /**
127
   * Returns the '<em><b>Space Type</b></em>' literal with the specified name.
128
   * <!-- begin-user-doc -->
129
   * <!-- end-user-doc -->
130
   * @generated
131
   */
132
  public static SpaceType getByName(String name)
133
  {
134
    for (int i = 0; i < VALUES_ARRAY.length; ++i)
135
    {
136
      SpaceType result = VALUES_ARRAY[i];
137
      if (result.getName().equals(name))
138
      {
139
        return result;
140
      }
141
    }
142
    return null;
143
  }
144
145
  /**
146
   * Returns the '<em><b>Space Type</b></em>' literal with the specified integer value.
147
   * <!-- begin-user-doc -->
148
   * <!-- end-user-doc -->
149
   * @generated
150
   */
151
  public static SpaceType get(int value)
152
  {
153
    switch (value)
154
    {
155
      case DEFAULT: return DEFAULT_LITERAL;
156
      case PRESERVE: return PRESERVE_LITERAL;
157
    }
158
    return null;	
159
  }
160
161
  /**
162
   * Only this class can construct instances.
163
   * <!-- begin-user-doc -->
164
   * <!-- end-user-doc -->
165
   * @generated
166
   */
167
  private SpaceType(int value, String name, String literal)
168
  {
169
    super(value, name, literal);
170
  }
171
172
} //SpaceType
(-)src/org/eclipse/emf/ecore/xml/namespace/XMLNamespacePackage.java (-463 lines)
Removed Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2003-2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: XMLNamespacePackage.java,v 1.8 2005/11/23 18:10:02 emerks Exp $
16
 */
17
package org.eclipse.emf.ecore.xml.namespace;
18
19
20
import org.eclipse.emf.ecore.EAttribute;
21
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EDataType;
23
import org.eclipse.emf.ecore.EEnum;
24
import org.eclipse.emf.ecore.EPackage;
25
import org.eclipse.emf.ecore.EReference;
26
27
28
/**
29
 * <!-- begin-user-doc -->
30
 * The <b>Package</b> for the model.
31
 * It contains accessors for the meta objects to represent
32
 * <ul>
33
 *   <li>each class,</li>
34
 *   <li>each feature of each class,</li>
35
 *   <li>each enum,</li>
36
 *   <li>and each data type</li>
37
 * </ul>
38
 * <!-- end-user-doc -->
39
 * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceFactory
40
 * @model kind="package"
41
 * @generated
42
 */
43
public interface XMLNamespacePackage extends EPackage{
44
  /**
45
   * The package name.
46
   * <!-- begin-user-doc -->
47
   * <!-- end-user-doc -->
48
   * @generated
49
   */
50
  String eNAME = "namespace";
51
52
  /**
53
   * The package namespace URI.
54
   * <!-- begin-user-doc -->
55
   * <!-- end-user-doc -->
56
   * @generated
57
   */
58
  String eNS_URI = "http://www.w3.org/XML/1998/namespace";
59
60
  /**
61
   * The package namespace name.
62
   * <!-- begin-user-doc -->
63
   * <!-- end-user-doc -->
64
   * @generated
65
   */
66
  String eNS_PREFIX = "xml";
67
68
  /**
69
   * The singleton instance of the package.
70
   * <!-- begin-user-doc -->
71
   * <!-- end-user-doc -->
72
   * @generated
73
   */
74
  XMLNamespacePackage eINSTANCE = org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl.init();
75
76
  /**
77
   * The meta object id for the '{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl <em>Document Root</em>}' class.
78
   * <!-- begin-user-doc -->
79
   * <!-- end-user-doc -->
80
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl
81
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getXMLNamespaceDocumentRoot()
82
   * @generated
83
   */
84
  int XML_NAMESPACE_DOCUMENT_ROOT = 0;
85
86
  /**
87
   * The feature id for the '<em><b>Mixed</b></em>' attribute list.
88
   * <!-- begin-user-doc -->
89
   * <!-- end-user-doc -->
90
   * @generated
91
   * @ordered
92
   */
93
  int XML_NAMESPACE_DOCUMENT_ROOT__MIXED = 0;
94
95
  /**
96
   * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map.
97
   * <!-- begin-user-doc -->
98
   * <!-- end-user-doc -->
99
   * @generated
100
   * @ordered
101
   */
102
  int XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1;
103
104
  /**
105
   * The feature id for the '<em><b>XSI Schema Location</b></em>' map.
106
   * <!-- begin-user-doc -->
107
   * <!-- end-user-doc -->
108
   * @generated
109
   * @ordered
110
   */
111
  int XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2;
112
113
  /**
114
   * The feature id for the '<em><b>Base</b></em>' attribute.
115
   * <!-- begin-user-doc -->
116
   * <!-- end-user-doc -->
117
   * @generated
118
   * @ordered
119
   */
120
  int XML_NAMESPACE_DOCUMENT_ROOT__BASE = 3;
121
122
  /**
123
   * The feature id for the '<em><b>Id</b></em>' attribute.
124
   * <!-- begin-user-doc -->
125
   * <!-- end-user-doc -->
126
   * @generated
127
   * @ordered
128
   */
129
  int XML_NAMESPACE_DOCUMENT_ROOT__ID = 4;
130
131
  /**
132
   * The feature id for the '<em><b>Lang</b></em>' attribute.
133
   * <!-- begin-user-doc -->
134
   * <!-- end-user-doc -->
135
   * @generated
136
   * @ordered
137
   */
138
  int XML_NAMESPACE_DOCUMENT_ROOT__LANG = 5;
139
140
  /**
141
   * The feature id for the '<em><b>Space</b></em>' attribute.
142
   * <!-- begin-user-doc -->
143
   * <!-- end-user-doc -->
144
   * @generated
145
   * @ordered
146
   */
147
  int XML_NAMESPACE_DOCUMENT_ROOT__SPACE = 6;
148
149
  /**
150
   * The number of structural features of the '<em>Document Root</em>' class.
151
   * <!-- begin-user-doc -->
152
   * <!-- end-user-doc -->
153
   * @generated
154
   * @ordered
155
   */
156
  int XML_NAMESPACE_DOCUMENT_ROOT_FEATURE_COUNT = 7;
157
158
  /**
159
   * The meta object id for the '{@link org.eclipse.emf.ecore.xml.namespace.SpaceType <em>Space Type</em>}' enum.
160
   * <!-- begin-user-doc -->
161
   * <!-- end-user-doc -->
162
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
163
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getSpaceType()
164
   * @generated
165
   */
166
  int SPACE_TYPE = 1;
167
168
  /**
169
   * The meta object id for the '<em>Lang Type</em>' data type.
170
   * <!-- begin-user-doc -->
171
   * <!-- end-user-doc -->
172
   * @see java.lang.String
173
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getLangType()
174
   * @generated
175
   */
176
  int LANG_TYPE = 2;
177
178
  /**
179
   * The meta object id for the '<em>Lang Type Null</em>' data type.
180
   * <!-- begin-user-doc -->
181
   * <!-- end-user-doc -->
182
   * @see java.lang.String
183
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getLangTypeNull()
184
   * @generated
185
   */
186
  int LANG_TYPE_NULL = 3;
187
188
  /**
189
   * The meta object id for the '<em>Space Type Object</em>' data type.
190
   * <!-- begin-user-doc -->
191
   * <!-- end-user-doc -->
192
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
193
   * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getSpaceTypeObject()
194
   * @generated
195
   */
196
  int SPACE_TYPE_OBJECT = 4;
197
198
199
  /**
200
   * Returns the meta object for class '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot <em>Document Root</em>}'.
201
   * <!-- begin-user-doc -->
202
   * <!-- end-user-doc -->
203
   * @return the meta object for class '<em>Document Root</em>'.
204
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot
205
   * @generated
206
   */
207
  EClass getXMLNamespaceDocumentRoot();
208
209
  /**
210
   * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getMixed <em>Mixed</em>}'.
211
   * <!-- begin-user-doc -->
212
   * <!-- end-user-doc -->
213
   * @return the meta object for the attribute list '<em>Mixed</em>'.
214
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getMixed()
215
   * @see #getXMLNamespaceDocumentRoot()
216
   * @generated
217
   */
218
  EAttribute getXMLNamespaceDocumentRoot_Mixed();
219
220
  /**
221
   * Returns the meta object for the map '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'.
222
   * <!-- begin-user-doc -->
223
   * <!-- end-user-doc -->
224
   * @return the meta object for the map '<em>XMLNS Prefix Map</em>'.
225
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXMLNSPrefixMap()
226
   * @see #getXMLNamespaceDocumentRoot()
227
   * @generated
228
   */
229
  EReference getXMLNamespaceDocumentRoot_XMLNSPrefixMap();
230
231
  /**
232
   * Returns the meta object for the map '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXSISchemaLocation <em>XSI Schema Location</em>}'.
233
   * <!-- begin-user-doc -->
234
   * <!-- end-user-doc -->
235
   * @return the meta object for the map '<em>XSI Schema Location</em>'.
236
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getXSISchemaLocation()
237
   * @see #getXMLNamespaceDocumentRoot()
238
   * @generated
239
   */
240
  EReference getXMLNamespaceDocumentRoot_XSISchemaLocation();
241
242
  /**
243
   * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getBase <em>Base</em>}'.
244
   * <!-- begin-user-doc -->
245
   * <!-- end-user-doc -->
246
   * @return the meta object for the attribute '<em>Base</em>'.
247
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getBase()
248
   * @see #getXMLNamespaceDocumentRoot()
249
   * @generated
250
   */
251
  EAttribute getXMLNamespaceDocumentRoot_Base();
252
253
  /**
254
   * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getId <em>Id</em>}'.
255
   * <!-- begin-user-doc -->
256
   * <!-- end-user-doc -->
257
   * @return the meta object for the attribute '<em>Id</em>'.
258
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getId()
259
   * @see #getXMLNamespaceDocumentRoot()
260
   * @generated
261
   */
262
  EAttribute getXMLNamespaceDocumentRoot_Id();
263
264
  /**
265
   * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getLang <em>Lang</em>}'.
266
   * <!-- begin-user-doc -->
267
   * <!-- end-user-doc -->
268
   * @return the meta object for the attribute '<em>Lang</em>'.
269
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getLang()
270
   * @see #getXMLNamespaceDocumentRoot()
271
   * @generated
272
   */
273
  EAttribute getXMLNamespaceDocumentRoot_Lang();
274
275
  /**
276
   * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace <em>Space</em>}'.
277
   * <!-- begin-user-doc -->
278
   * <!-- end-user-doc -->
279
   * @return the meta object for the attribute '<em>Space</em>'.
280
   * @see org.eclipse.emf.ecore.xml.namespace.XMLNamespaceDocumentRoot#getSpace()
281
   * @see #getXMLNamespaceDocumentRoot()
282
   * @generated
283
   */
284
  EAttribute getXMLNamespaceDocumentRoot_Space();
285
286
  /**
287
   * Returns the meta object for enum '{@link org.eclipse.emf.ecore.xml.namespace.SpaceType <em>Space Type</em>}'.
288
   * <!-- begin-user-doc -->
289
   * <!-- end-user-doc -->
290
   * @return the meta object for enum '<em>Space Type</em>'.
291
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
292
   * @generated
293
   */
294
  EEnum getSpaceType();
295
296
  /**
297
   * Returns the meta object for data type '{@link java.lang.String <em>Lang Type</em>}'.
298
   * <!-- begin-user-doc -->
299
   * <!-- end-user-doc -->
300
   * @return the meta object for data type '<em>Lang Type</em>'.
301
   * @see java.lang.String
302
   * @model instanceClass="java.lang.String"
303
   *        extendedMetaData="name='lang_._1_._type' memberTypes='http://www.eclipse.org/emf/2003/XMLType#language lang_._1_._type_._member_._1'" 
304
   * @generated
305
   */
306
  EDataType getLangType();
307
308
  /**
309
   * Returns the meta object for data type '{@link java.lang.String <em>Lang Type Null</em>}'.
310
   * <!-- begin-user-doc -->
311
   * <!-- end-user-doc -->
312
   * @return the meta object for data type '<em>Lang Type Null</em>'.
313
   * @see java.lang.String
314
   * @model instanceClass="java.lang.String"
315
   *        extendedMetaData="name='lang_._1_._type_._member_._1' baseType='http://www.eclipse.org/emf/2003/XMLType#string' enumeration=''" 
316
   * @generated
317
   */
318
  EDataType getLangTypeNull();
319
320
  /**
321
   * Returns the meta object for data type '{@link org.eclipse.emf.ecore.xml.namespace.SpaceType <em>Space Type Object</em>}'.
322
   * <!-- begin-user-doc -->
323
   * <!-- end-user-doc -->
324
   * @return the meta object for data type '<em>Space Type Object</em>'.
325
   * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
326
   * @model instanceClass="org.eclipse.emf.ecore.xml.namespace.SpaceType"
327
   *        extendedMetaData="name='space_._type:Object' baseType='space_._type'" 
328
   * @generated
329
   */
330
  EDataType getSpaceTypeObject();
331
332
  /**
333
   * Returns the factory that creates the instances of the model.
334
   * <!-- begin-user-doc -->
335
   * <!-- end-user-doc -->
336
   * @return the factory that creates the instances of the model.
337
   * @generated
338
   */
339
  XMLNamespaceFactory getXMLNamespaceFactory();
340
341
  /**
342
   * <!-- begin-user-doc -->
343
   * Defines literals for the meta objects that represent
344
   * <ul>
345
   *   <li>each class,</li>
346
   *   <li>each feature of each class,</li>
347
   *   <li>each enum,</li>
348
   *   <li>and each data type</li>
349
   * </ul>
350
   * <!-- end-user-doc -->
351
   * @generated
352
   */
353
  interface Literals
354
  {
355
    /**
356
     * The meta object literal for the '{@link org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl <em>Document Root</em>}' class.
357
     * <!-- begin-user-doc -->
358
     * <!-- end-user-doc -->
359
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespaceDocumentRootImpl
360
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getXMLNamespaceDocumentRoot()
361
     * @generated
362
     */
363
    EClass XML_NAMESPACE_DOCUMENT_ROOT = eINSTANCE.getXMLNamespaceDocumentRoot();
364
365
    /**
366
     * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature.
367
     * <!-- begin-user-doc -->
368
     * <!-- end-user-doc -->
369
     * @generated
370
     */
371
    EAttribute XML_NAMESPACE_DOCUMENT_ROOT__MIXED = eINSTANCE.getXMLNamespaceDocumentRoot_Mixed();
372
373
    /**
374
     * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature.
375
     * <!-- begin-user-doc -->
376
     * <!-- end-user-doc -->
377
     * @generated
378
     */
379
    EReference XML_NAMESPACE_DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getXMLNamespaceDocumentRoot_XMLNSPrefixMap();
380
381
    /**
382
     * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature.
383
     * <!-- begin-user-doc -->
384
     * <!-- end-user-doc -->
385
     * @generated
386
     */
387
    EReference XML_NAMESPACE_DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getXMLNamespaceDocumentRoot_XSISchemaLocation();
388
389
    /**
390
     * The meta object literal for the '<em><b>Base</b></em>' attribute feature.
391
     * <!-- begin-user-doc -->
392
     * <!-- end-user-doc -->
393
     * @generated
394
     */
395
    EAttribute XML_NAMESPACE_DOCUMENT_ROOT__BASE = eINSTANCE.getXMLNamespaceDocumentRoot_Base();
396
397
    /**
398
     * The meta object literal for the '<em><b>Id</b></em>' attribute feature.
399
     * <!-- begin-user-doc -->
400
     * <!-- end-user-doc -->
401
     * @generated
402
     */
403
    EAttribute XML_NAMESPACE_DOCUMENT_ROOT__ID = eINSTANCE.getXMLNamespaceDocumentRoot_Id();
404
405
    /**
406
     * The meta object literal for the '<em><b>Lang</b></em>' attribute feature.
407
     * <!-- begin-user-doc -->
408
     * <!-- end-user-doc -->
409
     * @generated
410
     */
411
    EAttribute XML_NAMESPACE_DOCUMENT_ROOT__LANG = eINSTANCE.getXMLNamespaceDocumentRoot_Lang();
412
413
    /**
414
     * The meta object literal for the '<em><b>Space</b></em>' attribute feature.
415
     * <!-- begin-user-doc -->
416
     * <!-- end-user-doc -->
417
     * @generated
418
     */
419
    EAttribute XML_NAMESPACE_DOCUMENT_ROOT__SPACE = eINSTANCE.getXMLNamespaceDocumentRoot_Space();
420
421
    /**
422
     * The meta object literal for the '{@link org.eclipse.emf.ecore.xml.namespace.SpaceType <em>Space Type</em>}' enum.
423
     * <!-- begin-user-doc -->
424
     * <!-- end-user-doc -->
425
     * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
426
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getSpaceType()
427
     * @generated
428
     */
429
    EEnum SPACE_TYPE = eINSTANCE.getSpaceType();
430
431
    /**
432
     * The meta object literal for the '<em>Lang Type</em>' data type.
433
     * <!-- begin-user-doc -->
434
     * <!-- end-user-doc -->
435
     * @see java.lang.String
436
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getLangType()
437
     * @generated
438
     */
439
    EDataType LANG_TYPE = eINSTANCE.getLangType();
440
441
    /**
442
     * The meta object literal for the '<em>Lang Type Null</em>' data type.
443
     * <!-- begin-user-doc -->
444
     * <!-- end-user-doc -->
445
     * @see java.lang.String
446
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getLangTypeNull()
447
     * @generated
448
     */
449
    EDataType LANG_TYPE_NULL = eINSTANCE.getLangTypeNull();
450
451
    /**
452
     * The meta object literal for the '<em>Space Type Object</em>' data type.
453
     * <!-- begin-user-doc -->
454
     * <!-- end-user-doc -->
455
     * @see org.eclipse.emf.ecore.xml.namespace.SpaceType
456
     * @see org.eclipse.emf.ecore.xml.namespace.impl.XMLNamespacePackageImpl#getSpaceTypeObject()
457
     * @generated
458
     */
459
    EDataType SPACE_TYPE_OBJECT = eINSTANCE.getSpaceTypeObject();
460
461
  }
462
463
} //XMLNamespacePackage
(-)src/org/eclipse/emf/ecore/EcorePackage.java (-64 / +64 lines)
Lines 1816-1841 Link Here
1816
   * @ordered
1816
   * @ordered
1817
   */
1817
   */
1818
  int ESTRING_TO_STRING_MAP_ENTRY_FEATURE_COUNT = 2;
1818
  int ESTRING_TO_STRING_MAP_ENTRY_FEATURE_COUNT = 2;
1819
1819
//XXX GWT CHANGE No Big-Values
1820
  /**
1820
//  /**
1821
   * The meta object id for the '<em>EBig Decimal</em>' data type.
1821
//   * The meta object id for the '<em>EBig Decimal</em>' data type.
1822
   * <!-- begin-user-doc -->
1822
//   * <!-- begin-user-doc -->
1823
   * <!-- end-user-doc -->
1823
//   * <!-- end-user-doc -->
1824
   * @see java.math.BigDecimal
1824
//   * @see java.math.BigDecimal
1825
   * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigDecimal()
1825
//   * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigDecimal()
1826
   * @generated
1826
//   * @generated
1827
   */
1827
//   */
1828
  int EBIG_DECIMAL = 18;
1828
//  int EBIG_DECIMAL = 18;
1829
1829
//
1830
  /**
1830
//  /**
1831
   * The meta object id for the '<em>EBig Integer</em>' data type.
1831
//   * The meta object id for the '<em>EBig Integer</em>' data type.
1832
   * <!-- begin-user-doc -->
1832
//   * <!-- begin-user-doc -->
1833
   * <!-- end-user-doc -->
1833
//   * <!-- end-user-doc -->
1834
   * @see java.math.BigInteger
1834
//   * @see java.math.BigInteger
1835
   * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigInteger()
1835
//   * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigInteger()
1836
   * @generated
1836
//   * @generated
1837
   */
1837
//   */
1838
  int EBIG_INTEGER = 19;
1838
//  int EBIG_INTEGER = 19;
1839
1839
1840
  /**
1840
  /**
1841
   * The meta object id for the '<em>EE List</em>' data type.
1841
   * The meta object id for the '<em>EE List</em>' data type.
Lines 3069-3098 Link Here
3069
   * @generated
3069
   * @generated
3070
   */
3070
   */
3071
  EAttribute getEStringToStringMapEntry_Value();
3071
  EAttribute getEStringToStringMapEntry_Value();
3072
3072
//XXX GWT CHANGE No Big-Values
3073
  /**
3073
//  /**
3074
   * Returns the meta object for data type '{@link java.math.BigDecimal <em>EBig Decimal</em>}'.
3074
//   * Returns the meta object for data type '{@link java.math.BigDecimal <em>EBig Decimal</em>}'.
3075
   * <!-- begin-user-doc -->
3075
//   * <!-- begin-user-doc -->
3076
   * <!-- end-user-doc -->
3076
//   * <!-- end-user-doc -->
3077
   * @return the meta object for data type '<em>EBig Decimal</em>'.
3077
//   * @return the meta object for data type '<em>EBig Decimal</em>'.
3078
   * @see java.math.BigDecimal
3078
//   * @see java.math.BigDecimal
3079
   * @model instanceClass="java.math.BigDecimal"
3079
//   * @model instanceClass="java.math.BigDecimal"
3080
   *        extendedMetaData="baseType='http://www.w3.org/2001/XMLSchema#decimal'" 
3080
//   *        extendedMetaData="baseType='http://www.w3.org/2001/XMLSchema#decimal'"
3081
   * @generated
3081
//   * @generated
3082
   */
3082
//   */
3083
  EDataType getEBigDecimal();
3083
//  EDataType getEBigDecimal();
3084
3084
//
3085
  /**
3085
//  /**
3086
   * Returns the meta object for data type '{@link java.math.BigInteger <em>EBig Integer</em>}'.
3086
//   * Returns the meta object for data type '{@link java.math.BigInteger <em>EBig Integer</em>}'.
3087
   * <!-- begin-user-doc -->
3087
//   * <!-- begin-user-doc -->
3088
   * <!-- end-user-doc -->
3088
//   * <!-- end-user-doc -->
3089
   * @return the meta object for data type '<em>EBig Integer</em>'.
3089
//   * @return the meta object for data type '<em>EBig Integer</em>'.
3090
   * @see java.math.BigInteger
3090
//   * @see java.math.BigInteger
3091
   * @model instanceClass="java.math.BigInteger"
3091
//   * @model instanceClass="java.math.BigInteger"
3092
   *        extendedMetaData="baseType='http://www.w3.org/2001/XMLSchema#integer'" 
3092
//   *        extendedMetaData="baseType='http://www.w3.org/2001/XMLSchema#integer'"
3093
   * @generated
3093
//   * @generated
3094
   */
3094
//   */
3095
  EDataType getEBigInteger();
3095
//  EDataType getEBigInteger();
3096
3096
3097
  /**
3097
  /**
3098
   * Returns the meta object for data type '{@link org.eclipse.emf.common.util.EList <em>EE List</em>}'.
3098
   * Returns the meta object for data type '{@link org.eclipse.emf.common.util.EList <em>EE List</em>}'.
Lines 4162-4187 Link Here
4162
     * @generated
4162
     * @generated
4163
     */
4163
     */
4164
    EAttribute ESTRING_TO_STRING_MAP_ENTRY__VALUE = eINSTANCE.getEStringToStringMapEntry_Value();
4164
    EAttribute ESTRING_TO_STRING_MAP_ENTRY__VALUE = eINSTANCE.getEStringToStringMapEntry_Value();
4165
4165
//XXX GWT CHANGE No Big-Values
4166
    /**
4166
//    /**
4167
     * The meta object literal for the '<em>EBig Decimal</em>' data type.
4167
//     * The meta object literal for the '<em>EBig Decimal</em>' data type.
4168
     * <!-- begin-user-doc -->
4168
//     * <!-- begin-user-doc -->
4169
     * <!-- end-user-doc -->
4169
//     * <!-- end-user-doc -->
4170
     * @see java.math.BigDecimal
4170
//     * @see java.math.BigDecimal
4171
     * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigDecimal()
4171
//     * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigDecimal()
4172
     * @generated
4172
//     * @generated
4173
     */
4173
//     */
4174
    EDataType EBIG_DECIMAL = eINSTANCE.getEBigDecimal();
4174
//    EDataType EBIG_DECIMAL = eINSTANCE.getEBigDecimal();
4175
4175
//
4176
    /**
4176
//    /**
4177
     * The meta object literal for the '<em>EBig Integer</em>' data type.
4177
//     * The meta object literal for the '<em>EBig Integer</em>' data type.
4178
     * <!-- begin-user-doc -->
4178
//     * <!-- begin-user-doc -->
4179
     * <!-- end-user-doc -->
4179
//     * <!-- end-user-doc -->
4180
     * @see java.math.BigInteger
4180
//     * @see java.math.BigInteger
4181
     * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigInteger()
4181
//     * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEBigInteger()
4182
     * @generated
4182
//     * @generated
4183
     */
4183
//     */
4184
    EDataType EBIG_INTEGER = eINSTANCE.getEBigInteger();
4184
//    EDataType EBIG_INTEGER = eINSTANCE.getEBigInteger();
4185
4185
4186
    /**
4186
    /**
4187
     * The meta object literal for the '<em>EBoolean</em>' data type.
4187
     * The meta object literal for the '<em>EBoolean</em>' data type.
(-).classpath (-4 / +6 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
    <classpathentry kind="src" path="src/"/>
3
	<classpathentry kind="src" path="src"/>
4
    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6
    <classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="lib" path="/org.eclipse.equinox.common.gwt/dist/org.eclipse.equinox.common.jar"/>
7
	<classpathentry kind="lib" path="libs/gwt-widgets-0.1.5.jar"/>
8
	<classpathentry kind="output" path="bin"/>
7
</classpath>
9
</classpath>
(-)src/org/eclipse/emf/ecore/EMFEcoreLib.gwt.xml (+8 lines)
Added Link Here
1
<module>
2
	<!-- Inherit the core Web Toolkit stuff.                  -->
3
	<inherits name='com.google.gwt.user.User'/>
4
	<inherits name='org.eclipse.core.RuntimeCoreLib' />
5
	<inherits name='org.eclipse.emf.EMFCommonLib' />
6
7
	<source path="ecore" />
8
</module>

Return to bug 209435