blob: 602b16064b39e6fc1c5c1e3f9a939d78a42fd01e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*******************************************************************************
* Copyright (c) 2002, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jens Lukowski/Innoopract - initial renaming/restructuring
*
*******************************************************************************/
package org.eclipse.wst.xml.core.internal.contentmodel;
import java.util.List;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.wst.xml.core.internal.contentmodel.factory.CMDocumentFactory;
import org.eclipse.wst.xml.core.internal.contentmodel.factory.CMDocumentFactoryRegistry;
import org.eclipse.wst.xml.core.internal.contentmodel.factory.CMDocumentFactoryRegistryReader;
import org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation.AnnotationFileRegistry;
import org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation.AnnotationFileRegistryReader;
/**
* ContentModelManager class
*/
public class ContentModelManager extends Plugin {
// private static InferredGrammarFactory inferredGrammarFactory;
private CMDocumentFactoryRegistry cmDocumentFactoryRegistry;
private AnnotationFileRegistry annotationFileRegistry;
private static ContentModelManager instance;
public ContentModelManager() {
super();
}
public static ContentModelManager getInstance() {
if (instance == null) {
instance = new ContentModelManager();
}
return instance;
}
public CMDocument createCMDocument(String uri, String resourceType) {
if (resourceType == null && uri != null) {
int index = uri.lastIndexOf("."); //$NON-NLS-1$
resourceType = uri.substring(index + 1);
}
if (resourceType != null) {
resourceType = resourceType.toLowerCase();
}
CMDocumentFactory factory = getCMDocumentFactoryRegistry().getFactory(resourceType);
return factory != null ? factory.createCMDocument(uri) : null;
}
private CMDocumentFactoryRegistry getCMDocumentFactoryRegistry() {
if (cmDocumentFactoryRegistry == null) {
cmDocumentFactoryRegistry = new CMDocumentFactoryRegistry();
new CMDocumentFactoryRegistryReader(cmDocumentFactoryRegistry).readRegistry();
}
return cmDocumentFactoryRegistry;
}
public List getAnnotationFilesInfos(String publicId) {
return getAnnotationFileRegistry().getAnnotationFilesInfos(publicId);
}
private AnnotationFileRegistry getAnnotationFileRegistry() {
if (annotationFileRegistry == null) {
annotationFileRegistry = new AnnotationFileRegistry();
new AnnotationFileRegistryReader(annotationFileRegistry).readRegistry();
}
return annotationFileRegistry;
}
}
|