Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.core')
-rw-r--r--bundles/org.eclipse.wst.xml.core/.classpath43
-rw-r--r--bundles/org.eclipse.wst.xml.core/.cvsignore8
-rw-r--r--bundles/org.eclipse.wst.xml.core/.options6
-rw-r--r--bundles/org.eclipse.wst.xml.core/.project27
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.runtime.prefs3
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.core.prefs79
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.ltk.core.refactoring.prefs3
-rw-r--r--bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.pde.prefs16
-rw-r--r--bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XML10Names.jFlex100
-rw-r--r--bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XMLHeadTokenizer.jFlex254
-rw-r--r--bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildNames.xml32
-rw-r--r--bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildParser.xml32
-rw-r--r--bundles/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF327
-rw-r--r--bundles/org.eclipse.wst.xml.core/README.txt1
-rw-r--r--bundles/org.eclipse.wst.xml.core/about.html34
-rw-r--r--bundles/org.eclipse.wst.xml.core/build.properties33
-rw-r--r--bundles/org.eclipse.wst.xml.core/component.xml21
-rw-r--r--bundles/org.eclipse.wst.xml.core/plugin.properties28
-rw-r--r--bundles/org.eclipse.wst.xml.core/plugin.xml209
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/annotationFiles.exsd113
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/catalogContributions.exsd283
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/documentFactories.exsd116
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/errorCustomizer.exsd123
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/externalSchemaLocations.exsd102
-rw-r--r--bundles/org.eclipse.wst.xml.core/schema/modelQueryExtensions.exsd102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java795
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogContributorRegistryReader.java269
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogElement.java174
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEntry.java73
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEvent.java47
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogReader.java321
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogSet.java69
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogWriter.java367
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DelegateCatalog.java68
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/NextCatalog.java59
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/OASISCatalogConstants.java96
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/RewriteEntry.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/SuffixEntry.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/TypedCatalogElement.java41
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/XMLCatalogURIResolverExtension.java102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalog.java255
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogElement.java97
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEntry.java71
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEvent.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogListener.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IDelegateCatalog.java72
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/INextCatalog.java53
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IRewriteEntry.java64
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ISuffixEntry.java64
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/contentmodel/modelquery/IExternalSchemaLocationProvider.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAnyElement.java24
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAttributeDeclaration.java52
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMContent.java32
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDataType.java79
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocument.java38
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocumentation.java22
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMElementDeclaration.java68
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMEntityDeclaration.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMGroup.java39
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamedNodeMap.java41
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamespace.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNode.java61
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNodeList.java31
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/ContentModelManager.java80
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/Annotation.java53
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/AnnotationMap.java101
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAnyElementImpl.java51
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAttributeDeclarationImpl.java123
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMContentImpl.java46
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDataTypeImpl.java73
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDocumentImpl.java88
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMElementDeclarationImpl.java121
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMEntityDeclarationImpl.java47
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMGroupImpl.java43
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNamedNodeMapImpl.java100
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeImpl.java46
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeListImpl.java77
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactory.java22
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryDescriptor.java44
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistry.java53
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistryReader.java78
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileInfo.java44
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileParser.java207
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistry.java52
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistryReader.java77
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationUtility.java44
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/ResourceBundleHelper.java57
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/InferredGrammarFactory.java156
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionDescriptor.java65
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java125
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionRegistry.java102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMDataTypeValueHelper.java161
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMValidator.java1250
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/DOMValidator.java424
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManager.java141
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManagerListener.java23
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReference.java20
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReferenceProvider.java27
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/IExternalSchemaLocationProvider.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQuery.java195
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAction.java36
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAssociationProvider.java35
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryCMProvider.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java61
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/BaseAssociationProvider.java88
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentLoader.java278
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java318
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentReferenceImpl.java42
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ExternalSchemaLocationProviderRegistry.java56
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/GlobalCMDocumentCache.java121
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/InferredGrammarBuildingCMDocumentLoader.java189
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryActionHelper.java574
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java846
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/SimpleAssociationProvider.java49
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/XMLAssociationProvider.java485
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java140
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java203
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCacheListener.java33
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMVisitor.java135
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/ContentBuilder.java171
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilder.java53
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilderImpl.java636
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceHelper.java198
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceInfoManager.java225
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMVisitor.java133
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMWriter.java414
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/InferredGrammarFactory.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceAttributeVisitor.java110
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceInfo.java83
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceTable.java257
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSEAdapter.java494
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERenderer.java656
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERendererFactory.java32
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/ComponentSearchContributor.java73
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/TargetNamespaceReferencePattern.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentDeclarationPattern.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentReferencePattern.java37
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentSearchPattern.java96
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchParticipant.java387
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchPattern.java176
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/IXMLSearchConstants.java20
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/Messages.java73
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/XMLSearchDocument.java105
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/messages.properties10
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java79
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/SAXSearchElement.java78
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/XMLSearchPatternMatcher.java205
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScan.java117
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScanContentHandler.java212
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/AnnotationMsg.java41
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/MarkupValidator.java929
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ProblemIDsXML.java31
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java371
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLNestedValidatorContext.java55
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationConfiguration.java127
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationInfo.java199
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationMessages.java37
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationReport.java44
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java930
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java543
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/Helper.java259
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/LazyURLInputStream.java161
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java33
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java287
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationMessage.java202
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationReport.java45
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/CommandLineLogger.java32
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/EclipseLogger.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/ILogger.java35
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/LoggerFactory.java102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/ErrorCustomizationPluginRegistryReader.java81
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java173
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLMessageInfoHelper.java119
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLValidator.java49
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ElementInformation.java72
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationManager.java110
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationRegistry.java97
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorMessageCustomizerDelegate.java72
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/IErrorMessageCustomizer.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/.cvsignore1
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/DebugAdapterFactory.java77
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java284
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/IDebugAdapter.java19
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/Logger.java157
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCoreMessages.java63
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java86
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePluginResources.properties47
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java128
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/ElementNodeCleanupHandler.java557
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java63
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java142
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java103
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java107
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java135
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java237
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java84
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java65
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java196
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/AbstractResourceEncodingDetector.java258
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java108
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ContentDescriberForXML.java264
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java30
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java44
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java114
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/NullMemento.java37
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java156
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java1451
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java21
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLResourceEncodingDetector.java142
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java780
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java148
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java42
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java91
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java356
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterStringPool.java100
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java204
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.java43
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.properties17
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java981
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java81
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java1208
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapter.java51
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java119
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java228
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java1552
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java247
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java95
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/InvalidCharacterException.java67
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/JSPTag.java34
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java57
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java534
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java1171
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java257
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java157
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java144
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java233
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/RangeImpl.java630
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ReadOnlyController.java343
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/SourceValidator.java388
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionChecker.java143
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java435
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionManagementException.java33
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java369
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionUtil.java178
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TagAdapter.java35
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TextImpl.java1192
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/UserData.java56
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLGeneratorImpl.java735
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelContext.java237
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifier.java139
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifierImpl.java496
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelParser.java2422
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java1704
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentCharsetDetector.java37
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentLoader.java82
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java1713
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormatterFormatProcessor.java146
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingConstraints.java94
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingPreferences.java179
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java95
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/ModelHandlerForXML.java59
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/XMLModelLoader.java93
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForEmbeddedXML.java50
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java253
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryUtil.java64
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java60
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryImpl.java38
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java46
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java327
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java112
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java49
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java595
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java645
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java124
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java42
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java1913
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java92
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java165
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java162
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java90
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java101
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java102
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java29
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java209
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java89
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java93
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java98
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java188
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java175
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java175
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java25
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java107
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java103
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java82
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java298
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterFactoryImpl.java113
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterImpl.java144
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLCharEntity.java39
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLNamespace.java29
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLPreferenceNames.java55
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/NameValidator.java63
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocType.java53
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocumentTracker.java32
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMNodeWrapper.java21
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/ContentModelAdapter.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/NullContentModel.java101
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contenttype/ContentTypeIdForXML.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMAttr.java128
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocument.java100
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocumentType.java43
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMElement.java196
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMEntity.java33
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMImplementation.java48
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMModel.java59
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMNode.java272
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMText.java120
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/ISourceGenerator.java201
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java101
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/DocumentNodeFormatter.java55
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java425
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java115
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NoMoveFormatter.java28
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java753
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java81
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/TextNodeFormatter.java385
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/text/IXMLPartitions.java42
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/regions/DOMRegionContext.java69
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapter.java31
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapterImpl.java76
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/MovableModelQuery.java23
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLFileTaskScanner.java28
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/XMLStructuredDocumentRegion.java36
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/rules/StructuredTextPartitionerForXML.java132
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/AbstractPropagatingValidator.java66
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/Propagator.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/ValidationComponent.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/text/IXMLPartitions.java42
342 files changed, 0 insertions, 62359 deletions
diff --git a/bundles/org.eclipse.wst.xml.core/.classpath b/bundles/org.eclipse.wst.xml.core/.classpath
deleted file mode 100644
index 0f97d08f8d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.classpath
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src-contentmodel"/>
- <classpathentry kind="src" path="src-search"/>
- <classpathentry kind="src" path="src-validation"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="src-catalog"/>
- <classpathentry kind="src" path="src-emfModelSynch"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/wst/validation/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/common/internal/emf/resource/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/common/internal/emf/utilities/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/common/internal/emfworkbench/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4">
- <accessrules>
- <accessrule kind="accessible" pattern="org/apache/xerces/dom/TreeWalkerImpl"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/ranges/DocumentRange"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/ranges/Range"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/traversal/DocumentTraversal"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/traversal/NodeFilter"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/traversal/NodeIterator"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/traversal/TreeWalker"/>
- <accessrule kind="accessible" pattern="org/w3c/dom/ranges/RangeException"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/impl/XMLErrorReporter"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/parsers/StandardParserConfiguration"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/Augmentations"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/NamespaceContext"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/QName"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/XMLAttributes"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/XMLLocator"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/XMLResourceIdentifier"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/XNIException"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/parser/XMLEntityResolver"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/xni/parser/XMLInputSource"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/parsers/SAXParser"/>
- <accessrule kind="accessible" pattern="org/apache/xerces/parsers/AbstractSAXParser"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.wst.xml.core/.cvsignore b/bundles/org.eclipse.wst.xml.core/.cvsignore
deleted file mode 100644
index 273f8bc614..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-bin
-temp.folder
-build.xml
-xmlmodel.jar
-org.eclipse.wst.xml.core_1.0.0.jar
-@dot
-src.zip
-javaCompiler...args
diff --git a/bundles/org.eclipse.wst.xml.core/.options b/bundles/org.eclipse.wst.xml.core/.options
deleted file mode 100644
index d282f9e448..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.options
+++ /dev/null
@@ -1,6 +0,0 @@
-org.eclipse.wst.xml.core/debug=true
-org.eclipse.wst.xml.core/debug/tracefilter=
-org.eclipse.wst.xml.core/debug/cmdocumentmanager=false
-org.eclipse.wst.xml.core/debug/cmdocumentcache=false
-org.eclipse.wst.xml.core/debug/validation=false
-org.eclipse.wst.xml.core/externalSchemaLocation=false \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/.project b/bundles/org.eclipse.wst.xml.core/.project
deleted file mode 100644
index c4175149e1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.project
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.xml.core</name>
- <comment></comment>
- <projects></projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index afa5c91352..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Apr 04 03:36:32 EDT 2006
-eclipse.preferences.version=1
-encoding/<project>=ISO-8859-1
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.runtime.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.runtime.prefs
deleted file mode 100644
index 7ec5750225..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.core.runtime.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Apr 17 01:48:39 EDT 2006
-eclipse.preferences.version=1
-line.separator=\r\n
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 3405307322..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,79 +0,0 @@
-#Sat Mar 24 02:18:23 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=ignore
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 1ca5c5e8a5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Wed Nov 15 02:26:10 EST 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<templates/>
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.ltk.core.refactoring.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.ltk.core.refactoring.prefs
deleted file mode 100644
index c59368c5e1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.ltk.core.refactoring.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Apr 04 03:36:32 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.pde.prefs b/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 86ca5a7023..0000000000
--- a/bundles/org.eclipse.wst.xml.core/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,16 +0,0 @@
-#Wed Nov 15 02:13:31 EST 2006
-compilers.incompatible-environment=0
-compilers.p.build=0
-compilers.p.deprecated=1
-compilers.p.illegal-att-value=0
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=0
-compilers.p.unknown-attribute=0
-compilers.p.unknown-class=0
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=0
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.p.unused-element-or-attribute=0
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XML10Names.jFlex b/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XML10Names.jFlex
deleted file mode 100644
index c33e65b772..0000000000
--- a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XML10Names.jFlex
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*nlsXXX*/
-package org.eclipse.wst.xml.core.internal.parser;
-
-
-
-%%
-
-%table
-%public
-%final
-%class XML10Names
-%function isValidXML10Name
-%type boolean
-%unicode
-%ignorecase
-%buffer 2048
-%apiprivate
-
-S = (\x20 | \x09 | \x0D | \x0A)
-
-BaseChar = [\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3]
-
-Ideographic = [\u4E00-\u9FA5\u3007\u3021-\u3029]
-
-CombiningChar = [\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05A1\u05A3-\u05B9\u05BB-\u05BD\u05BF\u05C1-\u05C2\u05C4\u064B-\u0652\u0670\u06D6-\u06DC\u06DD-\u06DF\u06E0-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0901-\u0903\u093C\u093E-\u094C\u094D\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09BC\u09BE\u09BF\u09C0-\u09C4\u09C7-\u09C8\u09CB-\u09CD\u09D7\u09E2-\u09E3\u0A02\u0A3C\u0A3E\u0A3F\u0A40-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A70-\u0A71\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0B01-\u0B03\u0B3C\u0B3E-\u0B43\u0B47-\u0B48\u0B4B-\u0B4D\u0B56-\u0B57\u0B82-\u0B83\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C82-\u0C83\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86-\u0F8B\u0F90-\u0F95\u0F97\u0F99-\u0FAD\u0FB1-\u0FB7\u0FB9\u20D0-\u20DC\u20E1\u302A-\u302F\u3099\u309A]
-
-Digit = [\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE7-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29]
-
-Extender = [\u00B7\u02D0\u02D1\u0387\u0640\u0E46\u0EC6\u3005\u3031-\u3035\u309D-\u309E\u30FC-\u30FE]
-
-Letter = ({BaseChar} | {Ideographic})
-
-NameChar = ({Letter} | {Digit} | . | - | _ | : | {CombiningChar} | {Extender})
-
-Name = ({Letter} | _ | : ) ({NameChar})*
-
-
-
-%{
-
- /**
- * Creates a new scanner
- */
- public XML10Names() {
- this.zzReader = null;
- }
-
- public boolean isValidXML10Name(String stringToCheck) {
- boolean result = false;
- yyreset(new java.io.StringReader(stringToCheck));
- try {
- result = isValidXML10Name();
- }
- catch (java.io.IOException e) {
- // should be impossible with strings, but if occurs, just means
- // "not"
- result = false;
- }
- return result;
- }
-
-%}
-
-
-
-
-%%
-
-<YYINITIAL>
-{
-
- // don't match if contains trailing or embedded space
- {Name} {S}+ {return false;}
- {Name} {S}+ {Name} {return false;}
-
- {Name} {return true;}
-
- // match anything should come last
- . {return false;}
-
-}
-
-
-// this rule always in effect
-<<EOF>>
-{
- {return false;}
-}
-
-
diff --git a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XMLHeadTokenizer.jFlex b/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XMLHeadTokenizer.jFlex
deleted file mode 100644
index 15d5b0a34b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XMLHeadTokenizer.jFlex
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- *******************************************************************************/
-/*nlsXXX*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizerConstants;
-
-
-%%
-
-%{
-
-
- private boolean hasMore = true;
- private final static int MAX_TO_SCAN = 8000;
- StringBuffer string = new StringBuffer();
- // state stack for easier state handling
- private IntStack fStateStack = new IntStack();
- private String valueText = null;
-
-
- public XMLHeadTokenizer() {
- super();
- }
-
- public void reset (Reader in) {
- /* the input device */
- zzReader = in;
-
- /* the current state of the DFA */
- zzState = 0;
-
- /* the current lexical state */
- zzLexicalState = YYINITIAL;
-
- /* this buffer contains the current text to be matched and is
- the source of the yytext() string */
- java.util.Arrays.fill(zzBuffer, (char)0);
-
- /* the textposition at the last accepting state */
- zzMarkedPos = 0;
-
- /* the textposition at the last state to be included in yytext */
- zzPushbackPos = 0;
-
- /* the current text position in the buffer */
- zzCurrentPos = 0;
-
- /* startRead marks the beginning of the yytext() string in the buffer */
- zzStartRead = 0;
-
- /**
- * endRead marks the last character in the buffer, that has been read
- * from input
- */
- zzEndRead = 0;
-
- /* number of newlines encountered up to the start of the matched text */
- yyline = 0;
-
- /* the number of characters up to the start of the matched text */
- yychar = 0;
-
- /**
- * the number of characters from the last newline up to the start
- * of the matched text
- */
- yycolumn = 0;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning
- * of a line
- */
- zzAtBOL = true;
-
- /* yy_atEOF == true <=> the scanner has returned a value for EOF */
- zzAtEOF = false;
-
- /* denotes if the user-EOF-code has already been executed */
- zzEOFDone = false;
-
-
- fStateStack.clear();
-
- hasMore = true;
-
- }
-
-
- public final HeadParserToken getNextToken() throws IOException {
- String context = null;
- context = primGetNextToken();
- HeadParserToken result = null;
- if (valueText != null) {
- result = createToken(context, yychar, valueText);
- valueText = null;
- } else {
- result = createToken(context, yychar, yytext());
- }
- return result;
- }
-
- public final boolean hasMoreTokens() {
- return hasMore && yychar < MAX_TO_SCAN;
- }
- private void pushCurrentState() {
- fStateStack.push(yystate());
-
- }
-
- private void popState() {
- yybegin(fStateStack.pop());
- }
-
- private HeadParserToken createToken(String context, int start, String text) {
- return new HeadParserToken(context, start, text);
- }
-
-%}
-
-%eof{
- hasMore=false;
-%eof}
-
-%public
-%class XMLHeadTokenizer
-%function primGetNextToken
-%type String
-%char
-%unicode
-%ignorecase
-//%debug
-%switch
-%buffer 8192
-
-UTF16BE = \xFE\xFF
-UTF16LE = \xFF\xFE
-UTF83ByteBOM = \xEF\xBB\xBF
-
-//SpaceChar = [\x20\x09]
-
-// [3] S ::= (0x20 | 0x9 | 0xD | 0xA)+
-S = [\x20\x09\x0D\x0A]
-
-//BeginAttribeValue = {S}* \= {S}*
-
-LineTerminator = \r|\n
-
-// Z is the single-byte zero character to be used in parsing double-byte files
-Z = (\x00)?
-S_UTF = {Z}{S}{Z}
-BeginAttributeValueUTF = {S_UTF}* \= {S_UTF}*
-
-%state ST_XMLDecl
-%state QuotedAttributeValue
-%state DQ_STRING
-%state SQ_STRING
-%state UnDelimitedString
-
-%%
-
-
-<YYINITIAL>
-{
- // force to start at beginning of line (^) and at beginning of file (yychar == 0)
- ^{UTF16BE} {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16BE;}}
- ^{UTF16LE} {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16LE;}}
- ^{UTF83ByteBOM} {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF83ByteBOM;}}
-
- // force to be started on first line, but we do allow preceeding spaces
- ^ {S_UTF}* ({Z}<{Z}\?{Z}x{Z}m{Z}l{Z}){S_UTF}+ {if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;}}
-
-}
-
-<ST_XMLDecl>
-{
- ({Z}v{Z}e{Z}r{Z}s{Z}i{Z}o{Z}n{Z}) {BeginAttributeValueUTF} {pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDeclVersion;}
- ({Z}e{Z}n{Z}c{Z}o{Z}d{Z}i{Z}n{Z}g{Z}) {BeginAttributeValueUTF} {pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDelEncoding;}
- // note the "forced end" (via 'hasMore=false') once the end of XML Declaration found
- // This is since non-ascii chars may follow and may cause IOExceptions which would not occur once stream is
- // read with incorrect encoding (such as if platform encoding is in effect until true encoding detected).
- ({Z}\?{Z}>{Z}) {yybegin(YYINITIAL); hasMore = false; return XMLHeadTokenizerConstants.XMLDeclEnd;}
-}
-
-
-
-<QuotedAttributeValue>
-{
- {Z}\"{Z} { yybegin(DQ_STRING); string.setLength(0); }
- {Z}\'{Z} { yybegin(SQ_STRING); string.setLength(0); }
- // in this state, anything other than a space character can start an undelimited string
- {S_UTF}*. { yypushback(1); yybegin(UnDelimitedString); string.setLength(0);}
-
-}
-
-
-<DQ_STRING>
-{
-
- {Z}\"{Z} { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue; }
- {Z}{LineTerminator}{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}\?{Z}>{Z} { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}<{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- [^\x00] { string.append( yytext() ); }
-
-}
-
-<SQ_STRING>
-{
-
- {Z}\'{Z} { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue;}
- {Z}{LineTerminator}{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}%{Z}>{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}<{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- [^\x00] { string.append( yytext() ); }
-
-}
-
-<UnDelimitedString>
-{
-
- {S_UTF} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue; }
- {Z}{LineTerminator}{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}\?{Z}>{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- {Z}<{Z}
- { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;}
- // these are a bit special, since we started an undelimit string, but found a quote ... probably indicates a missing beginning quote
- {Z}\'{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;}
-
- {Z}\"{Z} { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;}
-
- [^\x00] { string.append( yytext() ); }
-
-}
-
-// The "match anything" rule should always be in effect except for when looking for end of string
-// (That is, remember to update state list if/when new states added)
-.|\n {if(yychar > MAX_TO_SCAN) {hasMore=false; return EncodingParserConstants.MAX_CHARS_REACHED;}}
-
-// this rule always in effect
-<<EOF>> {hasMore = false; return EncodingParserConstants.EOF;}
-
- \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildNames.xml b/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildNames.xml
deleted file mode 100644
index 6d97563384..0000000000
--- a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildNames.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="tokenizer" default="XML10Names">
-
- <!-- Note: for Eclipse env., the JFlex 1.4 jar should be added
- to the ant global entries -->
- <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" />
-
- <target name="init">
- <property name="src.file" value="XML10Names.jFlex"/>
- <property name="src.dir" value="HeadParsers"/>
- <property name="dest.dir" value="../src"/>
- <!-- touch causes to always build, remove for real 'make' behavior -->
- <touch file="${src.dir}/${src.file}"/>
-
- </target>
-
- <target name="XML10Names" depends="init">
- <antcall target="run-jflex"/>
- </target>
-
- <target name="run-jflex" depends="init">
- <jflex
- file="${src.dir}/${src.file}"
- destdir="${dest.dir}"
- verbose="true"
- nobak="true"
- time="on"
- />
- </target>
-
-
-</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildParser.xml b/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildParser.xml
deleted file mode 100644
index 49619df58f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/DevTimeSupport/buildParser.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="tokenizer" default="HeadTokenizer">
-
- <!-- Note: for Eclipse env., the JFlex 1.4 jar should be added
- to the ant global entries -->
- <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" />
-
- <target name="init">
- <property name="src.file" value="XMLHeadTokenizer.jFlex"/>
- <property name="src.dir" value="HeadParsers"/>
- <property name="dest.dir" value="../src"/>
- <!-- touch causes to always build, remove for real 'make' behavior -->
- <touch file="${src.dir}/${src.file}"/>
-
- </target>
-
- <target name="HeadTokenizer" depends="init">
- <antcall target="run-jflex"/>
- </target>
-
- <target name="run-jflex" depends="init">
- <jflex
- file="${src.dir}/${src.file}"
- destdir="${dest.dir}"
- verbose="true"
- nobak="true"
- time="on"
- />
- </target>
-
-
-</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF
deleted file mode 100644
index 7def97ca60..0000000000
--- a/bundles/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,327 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.wst.xml.core; singleton:=true
-Bundle-Version: 1.1.601.qualifier
-Bundle-Activator: org.eclipse.wst.xml.core.internal.XMLCorePlugin
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Export-Package: org.eclipse.wst.xml.core.contentmodel.modelquery,
- org.eclipse.wst.xml.core.internal;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.catalog;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.catalog.provisional;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.cleanup;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.commentelement;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.commentelement.impl;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.commentelement.util;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.annotation;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.basic;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.factory;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.internal.modelqueryimpl;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.internal.util;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.modelquery;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contentmodel.util;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.contenttype;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.document;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.emf2xml;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.encoding;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.formatter;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.modelhandler;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.modelquery;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.parser;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.parser.regions;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.preferences;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.propagate;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional.contentmodel;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional.contenttype;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional.document;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional.format;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.provisional.text;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.regions;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.search;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.search.impl;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.search.matching;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.search.quickscan;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.ssemodelquery;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.tasks;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.text;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.text.rules;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validate;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validation;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validation.core;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validation.core.logging;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validation.eclipse;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.internal.validation.errorcustomization;
- x-friends:="org.eclipse.wst.dtd.core,
- org.eclipse.wst.dtd.ui,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.xsd.core,
- org.eclipse.wst.xsd.ui",
- org.eclipse.wst.xml.core.text
-Import-Package: com.ibm.icu.util; version="3.8",
- com.ibm.icu.text; version="3.8"
-Require-Bundle: org.apache.xerces;bundle-version="[2.9.0,3.0.0)";visibility:=reexport,
- org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
- org.eclipse.wst.common.uriresolver;bundle-version="[1.1.301,1.2.0)",
- org.eclipse.wst.sse.core;bundle-version="[1.1.500,1.2.0)",
- org.eclipse.jem.util;bundle-version="[2.0.200,3.0.0)";resolution:=optional,
- org.eclipse.wst.validation;bundle-version="[1.2.100,1.3.0)";resolution:=optional,
- org.eclipse.wst.common.emf;bundle-version="[1.1.300,1.3.0)";resolution:=optional,
- org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)";resolution:=optional,
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.300,1.3.0)";resolution:=optional,
- org.eclipse.wst.common.core;bundle-version="[1.1.201,1.3.0)",
- org.eclipse.osgi.services;bundle-version="[3.2.0,4.0.0)"
-Bundle-ActivationPolicy: lazy; exclude:="org.eclipse.wst.xml.core.internal.contenttype"
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.wst.xml.core/README.txt b/bundles/org.eclipse.wst.xml.core/README.txt
deleted file mode 100644
index ffa6466947..0000000000
--- a/bundles/org.eclipse.wst.xml.core/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-THe XML specific model implementation. \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/about.html b/bundles/org.eclipse.wst.xml.core/about.html
deleted file mode 100644
index 2199df3f05..0000000000
--- a/bundles/org.eclipse.wst.xml.core/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor’s license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/bundles/org.eclipse.wst.xml.core/build.properties b/bundles/org.eclipse.wst.xml.core/build.properties
deleted file mode 100644
index 8d49b33ca6..0000000000
--- a/bundles/org.eclipse.wst.xml.core/build.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 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
-#
-###############################################################################
-bin.includes = plugin.xml,\
- .options,\
- plugin.properties,\
- META-INF/,\
- .,\
- about.html,\
- schema/
-bin.excludes = bin/**,\
- @dot/**,\
- temp.folder/**
-src.includes = component.xml,\
- schema/,\
- DevTimeSupport/
-source.. = src-catalog/,\
- src-contentmodel/,\
- src-validation/,\
- src/,\
- src-emfModelSynch/,\
- src-search/
-
-output.. = bin/
diff --git a/bundles/org.eclipse.wst.xml.core/component.xml b/bundles/org.eclipse.wst.xml.core/component.xml
deleted file mode 100644
index e061eb3051..0000000000
--- a/bundles/org.eclipse.wst.xml.core/component.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.wst.xml">
- <component-depends unrestricted="true"></component-depends>
- <plugin id="org.eclipse.wst.xmleditor.doc.user" fragment="false" />
- <plugin id="org.eclipse.wst.xml.core" fragment="false" />
- <plugin id="org.eclipse.wst.xml.ui" fragment="false" />
- <description url="http://eclipse.org/webtools/wst/components/xml/overview.html" />
- <package name="org.eclipse.wst.xml.ui" api="false">
- <type name="StructuredTextViewerConfigurationXML" subclass="true" instantiate="true" />
- </package>
- <package name="org.eclipse.wst.xml.ui.views.contentoutline" api="false">
- <type name="XMLContentOutlineConfiguration" subclass="true" instantiate="true" />
- </package>
- <package name="org.eclipse.wst.xml.ui.views.properties" api="false">
- <type name="XMLPropertySheetConfiguration" subclass="true" instantiate="true" />
- </package>
- <plugin id="org.eclipse.wst.xml.ui.infopop" fragment="false" />
- <plugin id="org.eclipse.wst.xml_core.feature.source" fragment="false" />
- <plugin id="org.eclipse.wst.xml_ui.feature.source" fragment="false" />
- <plugin id="org.apache.xerces" fragment="false" />
-</component>
diff --git a/bundles/org.eclipse.wst.xml.core/plugin.properties b/bundles/org.eclipse.wst.xml.core/plugin.properties
deleted file mode 100644
index 0e9ea2bd5d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/plugin.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2010 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
-#
-###############################################################################
-providerName=Eclipse Web Tools Platform
-pluginName=Structured Source XML Model
-Structured_XML_Document_Factory_Extension.name=Structured XML Document Factory Extension
-XML_Content_Type_Extension_Element.name=XML (Illformed)
-# contentmodel strings
-Content_Model_Document_Factories_Extension.name=Content Model Document Factories
-Content_Model_Annotation_Files_Extension.name=Content Model Annotation Files
-Model_Query_Extension.name=Model Query Extension
-XML_Catalog_Contributions_Extension_Point.name=XML Catalog Contributions Extension Point
-XSL_Content_Type_Extension_Element.name=XSL
-XMI_Content_Type=XMI
-XML_Validator.name=XML Validator
-XML_Validation_Error_Customizer.name=XML Validator Error Customizer Extension Point
-External_Schema_Location.name=XML External Schema Location Extension Point
-_validationMarker.name=XML Problem
-_taskMarker.name=XML Task
diff --git a/bundles/org.eclipse.wst.xml.core/plugin.xml b/bundles/org.eclipse.wst.xml.core/plugin.xml
deleted file mode 100644
index 38169629d5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/plugin.xml
+++ /dev/null
@@ -1,209 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-
- <!-- An extension for contributing a XML validation error customizer. -->
- <extension-point id="errorCustomizer" name="%XML_Validation_Error_Customizer.name" schema="schema/errorCustomizer.exsd"/>
- <extension-point id="externalSchemaLocations" name="%External_Schema_Location.name" schema="schema/externalSchemaLocations.exsd"/>
-
- <extension point="org.eclipse.wst.sse.core.modelHandler">
- <modelHandler
- default="true"
- class="org.eclipse.wst.xml.core.internal.modelhandler.ModelHandlerForXML"
- associatedContentTypeId="org.eclipse.core.runtime.xml"
- id="org.eclipse.wst.xml.core.internal.modelhandler">
- </modelHandler>
- </extension>
- <extension point="org.eclipse.wst.sse.core.modelHandler">
- <modelHandler
- default="true"
- class="org.eclipse.wst.xml.core.internal.modelhandler.ModelHandlerForXML"
- associatedContentTypeId="org.eclipse.wst.xml.core.xmlsource"
- id="org.eclipse.wst.xml.core.internal.modelhandler2">
- </modelHandler>
- </extension>
-
- <extension point="org.eclipse.wst.sse.core.embeddedTypeHandler">
- <embeddedTypeHandler
- class="org.eclipse.wst.xml.core.internal.modelhandler.EmbeddedXML">
- </embeddedTypeHandler>
- </extension>
-
- <extension point="org.eclipse.wst.sse.core.taskscanner">
- <scanner
- id="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner"
- class="org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner:org.eclipse.wst.xml.core.taskMarker"
- contentTypeIds="org.eclipse.core.runtime.xml" />
- </extension>
- <extension
- id="taskMarker"
- name="%_taskMarker.name"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.core.resources.taskmarker"/>
- <persistent value="true"/>
- </extension>
-
- <!-- Here we define a new extension point. This extension point is used
- to programmatically contribute catalog entries to the XML Catalog. -->
- <extension-point id="catalogContributions" name="%XML_Catalog_Contributions_Extension_Point.name" schema="schema/catalogContributions.exsd"/>
-
- <!-- This extension point extends the Common Extensbile URI Resolver so that
- the XML Catalog can participare in resolving processes. -->
- <extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
- <resolverExtension
- stage="postnormalization"
- class="org.eclipse.wst.xml.core.internal.catalog.XMLCatalogURIResolverExtension">
- </resolverExtension>
- </extension>
-
- <extension
- point="org.eclipse.core.filebuffers.documentCreation"
- id="org.eclipse.wst.xml.core.documentfactories"
- name="%Structured_XML_Document_Factory_Extension.name">
- <factory
- contentTypeId="org.eclipse.core.runtime.xml"
- class="org.eclipse.wst.sse.core.internal.filebuffers.BasicStructuredDocumentFactory" />
- </extension>
- <extension
- point="org.eclipse.core.filebuffers.documentCreation"
- id="org.eclipse.wst.xml.core.documentfactories2"
- name="%Structured_XML_Document_Factory_Extension.name">
- <factory
- contentTypeId="org.eclipse.wst.xml.core.xmlsource"
- class="org.eclipse.wst.sse.core.internal.filebuffers.BasicStructuredDocumentFactory" />
- </extension>
- <extension point="org.eclipse.team.core.fileTypes">
- <fileTypes
- type="text"
- extension="xsl">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xslt">
- </fileTypes>
- <fileTypes
- type="text"
- extension="dadx">
- </fileTypes>
- <fileTypes
- type="text"
- extension="wsdl">
- </fileTypes>
- <fileTypes
- type="text"
- extension="nst">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xmi">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xsd">
- </fileTypes>
- </extension>
-
- <extension point="org.eclipse.wst.sse.core.formatProcessors">
- <processor
- class="org.eclipse.wst.xml.core.internal.formatter.XMLFormatterFormatProcessor"
- contentTypeId="org.eclipse.core.runtime.xml">
- </processor>
- </extension>
-
- <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=103083 -->\
- <!-- FYI: this xmi type *should* be defined in EMF, but, since isn't
- we will here. In future versions is could be removed -->
- <extension point="org.eclipse.core.contenttype.contentTypes">
- <content-type
- file-extensions="xmi"
- priority="low"
- name="%XMI_Content_Type"
- id="org.eclipse.wst.xml.core.xmisource"
- base-type="org.eclipse.core.runtime.xml">
- </content-type>
-
- <content-type
- file-extensions="xml,xsl,xslt,wsdl,xsd,exsd,xmi"
- priority="low"
- name="%XML_Content_Type_Extension_Element.name"
- id="org.eclipse.wst.xml.core.xmlsource"
- base-type="org.eclipse.core.runtime.text"
- default-charset="UTF-8">
- <describer class="org.eclipse.wst.xml.core.internal.contenttype.ContentDescriberForXML" />
- </content-type>
-
- <content-type
- file-extensions="xsl,xslt"
- priority="high"
- name="%XSL_Content_Type_Extension_Element.name"
- id="org.eclipse.wst.xml.core.xslsource"
- base-type="org.eclipse.core.runtime.xml"
- default-charset="UTF-8">
- </content-type>
- </extension>
-
-
- <!-- initialize xml core preferences -->
- <extension point="org.eclipse.core.runtime.preferences">
- <initializer class="org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceInitializer" />
- </extension>
-
- <extension-point id="documentFactories" name="%Content_Model_Document_Factories_Extension.name" schema="schema/documentFactories.exsd"/>
-
- <extension-point id="modelQueryExtensions" name="%Model_Query_Extension.name" schema="schema/modelQueryExtensions.exsd"/>
-
- <extension-point id="annotationFiles" name="%Content_Model_Annotation_Files_Extension.name" schema="schema/annotationFiles.exsd"/>
-
- <extension
- point="org.eclipse.jem.util.uiContextSensitiveClass">
- <uiContextSensitiveClass
- context="UI"
- key="rendererFactory"
- className="org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERendererFactory">
- </uiContextSensitiveClass>
- </extension>
- <!-- ====================================================== -->
- <!-- Register the XML validator with the validation -->
- <!-- framework. -->
- <!-- ====================================================== -->
-
- <extension
- id="validationMarker"
- name="%_validationMarker.name"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.wst.validation.problemmarker"/>
- <persistent value="true"/>
- </extension>
-
- <extension id="xml" name="%XML_Validator.name" point="org.eclipse.wst.validation.validatorV2">
- <validator
- build="true"
- class="org.eclipse.wst.xml.core.internal.validation.eclipse.Validator"
- manual="true"
- sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML"
- version="3"
- markerId="org.eclipse.wst.xml.core.validationMarker">
- <include>
- <rules>
- <contentType id="org.eclipse.core.runtime.xml"></contentType>
- <contentType id="org.eclipse.wst.xml.core.xmlsource"></contentType>
- <contentType id="org.eclipse.wst.xml.core.xslsource"></contentType>
- <contentType id="org.eclipse.jst.jsp.core.tldsource"></contentType>
- <fileext
- caseSensitive="false"
- ext="xml">
- </fileext>
- </rules>
- </include>
- <exclude>
- <rules>
- <projectNature id="org.eclipse.jst.j2ee.ejb.EJBNature"/>
- <projectNature id="org.eclipse.jst.j2ee.EARNature"/>
- <file caseSensitive="true" name=".project" type="file"/>
- <file caseSensitive="true" name=".classpath" type="file"/>
- <file caseSensitive="true" name=".settings" type="folder"/>
- </rules>
- </exclude>
- </validator>
- </extension>
-</plugin>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/annotationFiles.exsd b/bundles/org.eclipse.wst.xml.core/schema/annotationFiles.exsd
deleted file mode 100644
index d417f55921..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/annotationFiles.exsd
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="annotationFiles" name="Content Model Annotation Files"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="annotationFile" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="annotationFile">
- <complexType>
- <attribute name="location" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="publicId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
-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 &lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/catalogContributions.exsd b/bundles/org.eclipse.wst.xml.core/schema/catalogContributions.exsd
deleted file mode 100644
index b7bad1b376..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/catalogContributions.exsd
+++ /dev/null
@@ -1,283 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="catalogContributions" name="XML Catalog Contributions Extension Point"/>
- </appInfo>
- <documentation>
- This extension point allows to specify entries for XML Catalog. Catalog entries have format specified in &lt;a href=&quot;http://www.oasis-open.org/committees/download.php/14041/xml-catalogs.html&quot;&gt;http://www.oasis-open.org/committees/entity/spec.html&lt;/a&gt;.
-Each catalog extension consists of a single catalogContribution element.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <choice>
- <element ref="catalogContribution"/>
- </choice>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="catalogContribution">
- <annotation>
- <documentation>
- The catalogContribution element may have id, and it is just a container for the contributed catalog entries.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="public" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="system" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="uri" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="nextCatalog" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id of the catalog to which entries will be added. Could be &quot;default&quot;, and if ommited, entries are added to the default workspace catalog.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="public">
- <annotation>
- <documentation>
- The public element associates a URI reference with the public identitier portion of an external identifier.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- </sequence>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id of the element, optional.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="publicId" type="string" use="required">
- <annotation>
- <documentation>
- The public identifier portion of an external identifier.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="uri" type="string" use="required">
- <annotation>
- <documentation>
- The value of the uri attribute could be relative to the plugin.xml file, use platform:/ or file:/ protocols.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="webURL" type="string">
- <annotation>
- <documentation>
- Alternative Web address for the public ID
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="system">
- <annotation>
- <documentation>
- The system elements associates a URI reference with the system identifier of an external identifier
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- </sequence>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id of the element, optional.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="systemId" type="string" use="required">
- <annotation>
- <documentation>
- The system identifier portion of an external identifier.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="uri" type="string" use="required">
- <annotation>
- <documentation>
- The value of the uri attribute could be relative to the plugin.xml file, use platform:/ or file:/ protocols.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="uri">
- <annotation>
- <documentation>
- The uri element associates a URI reference with the a URI reference that is not part of an external identifier.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- </sequence>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id of the element, optional.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="uri" type="string" use="required">
- <annotation>
- <documentation>
- The value of the uri attribute could be relative to the plugin.xml file, use platform:/ or file:/ protocols.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- A URI reference that is not part of an external identitier.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="nextCatalog">
- <annotation>
- <documentation>
- The nextCatalog elements indicate additional catalog entry file(s) to be considered during the process of resolution.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id of the element, optional.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="catalog" type="string" use="required">
- <annotation>
- <documentation>
- The value of the uri attribute could be relative to the plugin.xml file, use platform:/ or file:/ protocols.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;pre&gt;
- &lt;extension
- point=&quot;org.eclipse.wst.xml.core.catalogContributions&quot;&gt;
- &lt;catalogContribution&gt;
- &lt;system
- systemId=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
- uri=&quot;data/xsd/wsdl.xml&quot; &gt;
- &lt;property
- name=&quot;webURL&quot;
- value=&quot;http://schemas.xmlsoap.org/wsdl/&quot;/&gt;
- &lt;/system&gt;
- &lt;uri
- name=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
- uri=&quot;data/xsd/soap.xsd&quot;/&gt;
- &lt;public
- publicId=&quot;http://www.w3.org/1999/XSL/Transform&quot;
- uri=&quot;data/xsd/XSLSchema.xsd&quot;&gt;
- &lt;/public&gt;
- &lt;nextCatalog
- id=&quot;nestedCatalog&quot;
- catalog=&quot;data/catalog1.xml&quot;/&gt;
- &lt;/catalogContribution&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2005 IBM Corporation and others.&lt;br&gt;
-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 &lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/documentFactories.exsd b/bundles/org.eclipse.wst.xml.core/schema/documentFactories.exsd
deleted file mode 100644
index dd0d90624d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/documentFactories.exsd
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="documentFactories" name="Content Model Document Factories"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factory"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <complexType>
- <attribute name="type" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
-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 &lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/errorCustomizer.exsd b/bundles/org.eclipse.wst.xml.core/schema/errorCustomizer.exsd
deleted file mode 100644
index 608f190047..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/errorCustomizer.exsd
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="errorCustomizer" name="XML Validation Error Customizer"/>
- </appInfo>
- <documentation>
- The error customizer extension point allows a client to contribute an error customizer for a specific namespace. The error customizer can provide error messages that are more domain specific than the generic error messages provided by the underlying generic XML validator.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="errorCustomizer" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="errorCustomizer">
- <complexType>
- <attribute name="namespace" type="string" use="required">
- <annotation>
- <documentation>
- The namespace for which this error customizer will consider error customizations.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The class that implements &lt;code&gt;org.eclipse.wst.xml.core.internal.validation.errorcustomization.IErrorMessageCustomizer&lt;/code&gt;.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of an Error Customizer contribution:
-&lt;pre&gt;
- &lt;extension
- id=&quot;sampleErrorCustomizer&quot;
- name=&quot;Sample Error Customizer&quot;
- point=&quot;org.eclipse.wst.xml.core.errorCustomizer&quot;&gt;
- &lt;errorCustomizer
- namespace=&quot;http://sample.namespace&quot;
- class=&quot;org.eclipse.wst.xml.core.SampleErrorCustomizer&quot;/&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- The supplied class must implement &lt;code&gt;org.eclipse.wst.xml.core.internal.validation.errorcustomization.IErrorMessageCustomizer&lt;/code&gt;.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2006 IBM Corporation and others.&lt;br&gt;
-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 &lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/externalSchemaLocations.exsd b/bundles/org.eclipse.wst.xml.core/schema/externalSchemaLocations.exsd
deleted file mode 100644
index 0fe2a9074d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/externalSchemaLocations.exsd
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="externalSchemaLocations" name="External Schema Locations"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="provider"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="provider">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.core.contentmodel.modelquery.IExternalSchemaLocationProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/schema/modelQueryExtensions.exsd b/bundles/org.eclipse.wst.xml.core/schema/modelQueryExtensions.exsd
deleted file mode 100644
index 80f8365ad2..0000000000
--- a/bundles/org.eclipse.wst.xml.core/schema/modelQueryExtensions.exsd
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.xml.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.xml.core" id="modelQueryExtensions" name="Model Query Extension"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element internal="true" />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="modelQueryExtension"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="modelQueryExtension">
- <annotation>
- <documentation>
- Allows for the customization of returned vaues from a ModelQuery object.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension:"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="contentType" type="string" use="required">
- <annotation>
- <documentation>
- A comma-separated list of content types for which to use this extension.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- &lt;b&gt;This extension point is internal and should not be used by any other plugins.&lt;/b&gt;
- </documentation>
- </annotation>
-
-
-
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
-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 &lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java
deleted file mode 100644
index b6c322cda6..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java
+++ /dev/null
@@ -1,795 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEvent;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogListener;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-public class Catalog implements ICatalog
-{
-
- class CatalogLS
- {
- public void load()
- {
- }
-
- public synchronized void save()
- {
- try
- {
- new CatalogWriter().write(Catalog.this, location);
- } catch (Exception e)
- {
- Logger.logException(e);
- }
- }
- }
-
- class DefaultCatalogLS extends CatalogLS
- {
- public void load()
- {
- NextCatalog userCatalogReference = new NextCatalog();
- userCatalogReference.setId(XMLCorePlugin.USER_CATALOG_ID);
- userCatalogReference.setCatalogLocation(USER_CATALOG_FILE);
- addCatalogElement(userCatalogReference);
-
- NextCatalog systemCatalogReference = new NextCatalog();
- systemCatalogReference.setId(XMLCorePlugin.SYSTEM_CATALOG_ID);
- systemCatalogReference.setCatalogLocation(SYSTEM_CATALOG_FILE);
- addCatalogElement(systemCatalogReference);
-
- /*
- * Here we save the file in order to 'reflect' the catalog that
- * we've created from plug-in extensions to disk. The 'default'
- * catalog is only ever written to disk and never read from disk.
- */
- save();
- }
- }
-
- private static Comparator LONGEST_REWRITE_FIRST = new Comparator()
- {
- public int compare(Object entry1, Object entry2)
- {
- String start1 = ((IRewriteEntry)entry1).getStartString();
- String start2 = ((IRewriteEntry)entry2).getStartString();
-
- // Bigger is earlier
- return start2.length() - start1.length();
- }
- };
-
- private static Comparator LONGEST_SUFFIX_FIRST = new Comparator()
- {
- public int compare(Object entry1, Object entry2)
- {
- String suffix1 = ((ISuffixEntry)entry1).getSuffix();
- String suffix2 = ((ISuffixEntry)entry2).getSuffix();
-
- // Bigger is earlier
- return suffix2.length() - suffix1.length();
- }
- };
-
- private static Comparator LONGEST_DELEGATE_PREFIX_FIRST = new Comparator()
- {
- public int compare(Object entry1, Object entry2)
- {
- String prefix1 = ((IDelegateCatalog)entry1).getStartString();
- String prefix2 = ((IDelegateCatalog)entry2).getStartString();
-
- // Bigger is earlier
- return prefix2.length() - prefix1.length();
- }
- };
-
- class InternalResolver
- {
- protected Map publicMap = new HashMap();
-
- protected Map systemMap = new HashMap();
-
- protected Map uriMap = new HashMap();
-
- // These are sorted by longest "key" first.
- protected List rewriteSystemList = new LinkedList();
- protected List rewriteUriList = new LinkedList();
- protected List suffixSystemList = new LinkedList();
- protected List suffixUriList = new LinkedList();
- protected List delegatePublicList = new LinkedList();
- protected List delegateSystemList = new LinkedList();
- protected List delegateUriList = new LinkedList();
-
- InternalResolver()
- {
- synchronized (catalogElements) {
- for (Iterator i = catalogElements.iterator(); i.hasNext();)
- {
- ICatalogElement catalogElement = (ICatalogElement) i.next();
- if (catalogElement.getType() == ICatalogElement.TYPE_ENTRY)
- {
- ICatalogEntry entry = (ICatalogEntry) catalogElement;
- Map map = getEntryMap(entry.getEntryType());
- map.put(entry.getKey(), entry);
- }
- else if (catalogElement.getType() == ICatalogElement.TYPE_REWRITE)
- {
- IRewriteEntry entry = (IRewriteEntry) catalogElement;
- if (entry.getEntryType() == IRewriteEntry.REWRITE_TYPE_SYSTEM)
- {
- rewriteSystemList.add(entry);
- }
- else
- {
- rewriteUriList.add(entry);
- }
- }
- else if (catalogElement.getType() == ICatalogElement.TYPE_SUFFIX)
- {
- ISuffixEntry entry = (ISuffixEntry) catalogElement;
- if (entry.getEntryType() == ISuffixEntry.SUFFIX_TYPE_SYSTEM)
- {
- suffixSystemList.add(entry);
- }
- else
- {
- suffixUriList.add(entry);
- }
- }
- else if (catalogElement.getType() == ICatalogElement.TYPE_DELEGATE)
- {
- IDelegateCatalog delegate = (IDelegateCatalog) catalogElement;
- if (delegate.getEntryType() == IDelegateCatalog.DELEGATE_TYPE_PUBLIC)
- {
- delegatePublicList.add(delegate);
- }
- else if (delegate.getEntryType() == IDelegateCatalog.DELEGATE_TYPE_SYSTEM)
- {
- delegateSystemList.add(delegate);
- }
- else
- {
- delegateUriList.add(delegate);
- }
- }
- }
- }
-
- Collections.sort(rewriteSystemList, LONGEST_REWRITE_FIRST);
- Collections.sort(rewriteUriList, LONGEST_REWRITE_FIRST);
-
- Collections.sort(suffixSystemList, LONGEST_SUFFIX_FIRST);
- Collections.sort(suffixUriList, LONGEST_SUFFIX_FIRST);
-
- Collections.sort(delegatePublicList, LONGEST_DELEGATE_PREFIX_FIRST);
- Collections.sort(delegateSystemList, LONGEST_DELEGATE_PREFIX_FIRST);
- Collections.sort(delegateUriList, LONGEST_DELEGATE_PREFIX_FIRST);
- }
-
- private Map getEntryMap(int entryType)
- {
- Map map = systemMap;
- switch (entryType)
- {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC:
- map = publicMap;
- break;
- case ICatalogEntry.ENTRY_TYPE_URI:
- map = uriMap;
- break;
- default:
- break;
- }
- return map;
- }
-
- protected String getMappedURI(Map map, String key)
- {
- CatalogEntry entry = (CatalogEntry) map.get(key);
- if(entry == null) return null;
- String uri = entry.getURI();
- try
- {
- // TODO CS : do we really want to resolve these here?
- // I'm guessing we should return the 'platform:' form of the URI
- // to the caller.
- if (uri.startsWith("platform:")) //$NON-NLS-1$
- {
- URL entryURL = new URL(entry.getAbsolutePath(uri));
- uri = Platform.resolve(entryURL).toString();
-
- // we need to ensure URI's are of form "file:///D:/XXX" and NOT
- // "file:D:/XXX". Otherwise the EMF URI class gets confused
- // (see bug 103607)
- String FILE_SCHEME = "file:"; //$NON-NLS-1$
- if (uri.startsWith(FILE_SCHEME) && !uri.startsWith(FILE_SCHEME + "/")) //$NON-NLS-1$
- {
- uri = FILE_SCHEME + "///" + uri.substring(FILE_SCHEME.length()); //$NON-NLS-1$
- }
- }
- return uri;
- } catch (IOException e)
- {
- return null;
- }
- }
-
- public String resolvePublic(String publicId, String systemId)
- throws MalformedURLException, IOException
- {
- String result = getMappedURI(publicMap, publicId);
- if (result == null)
- {
- result = getMappedURI(systemMap, systemId);
- }
- // our clients used to pass namespace in place of public id, so we need to check uri map for those
- if (result == null)
- {
- result = getMappedURI(uriMap, publicId);
- }
- if (result == null)
- {
- result = resolveDelegateCatalogs(delegatePublicList, publicId, systemId);
- }
- if (result == null)
- {
- result = resolveSubordinateCatalogs(
- ICatalogEntry.ENTRY_TYPE_PUBLIC, publicId, systemId);
- }
- return result;
- }
-
- public String resolveSystem(String systemId)
- throws MalformedURLException, IOException
- {
- String result = getMappedURI(systemMap, systemId);
- if (result == null)
- {
- result = resolveRewrite(rewriteSystemList, systemId);
- }
- if (result == null)
- {
- result = resolveSuffix(suffixSystemList, systemId);
- }
- if (result == null)
- {
- result = resolveDelegateCatalogs(delegateSystemList, systemId, systemId); // systemId is the key for "startString"
- }
- if (result == null)
- {
- result = resolveSubordinateCatalogs(
- ICatalogEntry.ENTRY_TYPE_SYSTEM, null, systemId);
- }
- return result;
- }
-
- private String resolveRewrite(List rewriteList, String searchString)
- {
- for (Iterator it = rewriteList.iterator(); it.hasNext();)
- {
- IRewriteEntry entry = (IRewriteEntry) it.next();
- String startString = entry.getStartString();
- if (searchString.startsWith(startString))
- {
- return entry.getRewritePrefix() + searchString.substring(startString.length());
- }
- }
- return null;
- }
-
- private String resolveSuffix(List suffixList, String searchString) {
- for (Iterator it = suffixList.iterator(); it.hasNext();) {
- ISuffixEntry entry = (ISuffixEntry) it.next();
- if (searchString.endsWith(entry.getSuffix())) {
- return entry.getURI();
- }
- }
- return null;
- }
-
- protected String resolveDelegateCatalogs(List delegateCatalogs, String key,
- String systemId) throws MalformedURLException, IOException
- {
- String result = null;
- for (Iterator iterator = delegateCatalogs.iterator(); iterator
- .hasNext();) {
- IDelegateCatalog delegate = (IDelegateCatalog) iterator.next();
-
- if (key.startsWith(delegate.getStartString())) {
-
- ICatalog catalog = delegate.getReferencedCatalog();
- if (catalog != null)
- {
- switch (delegate.getEntryType())
- {
- case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
- result = catalog.resolvePublic(key, systemId);
- break;
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- result = catalog.resolveSystem(systemId);
- break;
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- result = catalog.resolveURI(systemId);
- break;
- default:
- break;
- }
- if (result != null)
- {
- return result;
- }
- }
- }
- }
- return null;
- }
-
- public String resolveURI(String uri) throws MalformedURLException,
- IOException
- {
- String result = getMappedURI(uriMap, uri);
- if (result == null)
- {
- result = resolveRewrite(rewriteUriList, uri);
- }
- if (result == null)
- {
- result = resolveSuffix(suffixUriList, uri);
- }
- if (result == null)
- {
- result = resolveDelegateCatalogs(delegateUriList, uri, uri); // uri is treated as the systemId
- }
- if (result == null)
- {
- result = resolveSubordinateCatalogs(
- ICatalogEntry.ENTRY_TYPE_URI, null, uri);
- }
- return result;
- }
- }
-
- class SystemCatalogLS extends CatalogLS
- {
- public void load()
- {
- new CatalogContributorRegistryReader(Catalog.this).readRegistry();
-
- /*
- * Here we save the file in order to 'reflect' the catalog that
- * we've created from plugin extensions to disk.
- * The 'system' catalog is only ever written to disk and never read from disk.
- */
- save();
- }
- }
-
- class UserCatalogLS extends CatalogLS
- {
- public void load()
- {
- InputStream inputStream = null;
- try
- {
- if (location != null && location.length() > 0)
- {
- URL url = new URL(location);
- inputStream = url.openStream();
- boolean oldNotificationEnabled = isNotificationEnabled();
- setNotificationEnabled(false);
- clear();
- try
- {
- CatalogReader.read(Catalog.this, inputStream);
- } finally
- {
- setNotificationEnabled(oldNotificationEnabled);
- }
- }
- else
- {
- clear();
- }
- notifyChanged();
- } catch (Exception e)
- {
- // This is OK since the catalog may not exist before we create it
- } finally
- {
- if (inputStream != null)
- {
- try
- {
- inputStream.close();
- } catch (Exception e)
- {
- }
- }
- }
- }
- }
-
- public static final String DEFAULT_CATALOG_FILE = "default_catalog.xml"; //$NON-NLS-1$
-
- public static final String SYSTEM_CATALOG_FILE = "system_catalog.xml"; //$NON-NLS-1$
-
- public static final String USER_CATALOG_FILE = "user_catalog.xml"; //$NON-NLS-1$
-
- protected String base;
-
- protected List catalogElements = new ArrayList();
-
- protected CatalogLS catalogLS;
-
- protected String id;
-
- protected InternalResolver internalResolver;
-
- protected boolean isNotificationEnabled;
-
- protected List listenerList = new ArrayList();
-
- protected String location;
-
- protected CatalogSet resourceSet;
-
- public Catalog(CatalogSet catalogResourceSet, String id, String location)
- {
- this.resourceSet = catalogResourceSet;
- this.id = id;
- this.location = location;
-
- if (XMLCorePlugin.DEFAULT_CATALOG_ID.equals(id))
- {
- catalogLS = new DefaultCatalogLS();
- } else if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(id))
- {
- catalogLS = new SystemCatalogLS();
- } else
- {
- catalogLS = new UserCatalogLS();
- }
- }
-
- public void addCatalogElement(ICatalogElement element)
- {
- synchronized (catalogElements) {
- catalogElements.add(element);
- }
- element.setOwnerCatalog(this);
- internalResolver = null;
- notifyAddElement(element);
- }
-
- public void addEntriesFromCatalog(ICatalog catalog)
- {
- try
- {
- setNotificationEnabled(false);
- if (catalog != null)
- {
- ICatalogElement[] entries = ((Catalog)catalog).getCatalogElements();
- for (int i = 0; i < entries.length; i++)
- {
- CatalogElement clone = (CatalogElement)((CatalogElement)entries[i]).clone();
- addCatalogElement(clone);
- }
- } else
- {
- Logger.log(Logger.ERROR, "argument was null in Catalog.addEntriesFromCatalog"); //$NON-NLS-1$
- }
- } finally
- {
- setNotificationEnabled(true);
- }
- internalResolver = null;
- notifyChanged();
- }
-
- public void addListener(ICatalogListener listener)
- {
- listenerList.add(listener);
- }
-
- public void clear()
- {
- synchronized (catalogElements) {
- catalogElements.clear();
- }
- internalResolver = null;
- notifyChanged();
- }
-
- public ICatalogElement createCatalogElement(int type)
- {
- switch (type)
- {
- case ICatalogElement.TYPE_ENTRY:
- return new CatalogEntry(); // TODO: Should be kind of deprecated
- case ICatalogElement.TYPE_NEXT_CATALOG:
- return new NextCatalog();
- case ICatalogEntry.ENTRY_TYPE_PUBLIC:
- case ICatalogEntry.ENTRY_TYPE_SYSTEM:
- case ICatalogEntry.ENTRY_TYPE_URI:
- return new CatalogEntry(type);
- case ICatalogElement.TYPE_REWRITE:
- case IRewriteEntry.REWRITE_TYPE_SYSTEM:
- case IRewriteEntry.REWRITE_TYPE_URI:
- return new RewriteEntry(type);
- case ICatalogElement.TYPE_SUFFIX:
- case ISuffixEntry.SUFFIX_TYPE_SYSTEM:
- case ISuffixEntry.SUFFIX_TYPE_URI:
- return new SuffixEntry(type);
- case ICatalogElement.TYPE_DELEGATE:
- case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- return new DelegateCatalog(type);
- default:
- throw new IllegalArgumentException("Unknown element type " + type);//$NON-NLS-1 // Makes no sense at all!
- }
- }
-
- public String getBase()
- {
- return base;
- }
-
- private List getCatalogElements(int type)
- {
- List result = new ArrayList();
- ICatalogElement[] elements = (ICatalogElement[]) catalogElements
- .toArray(new ICatalogElement[catalogElements.size()]);
- for (int i = 0; i < elements.length; i++)
- {
- ICatalogElement element = elements[i];
- if (element.getType() == type)
- {
- result.add(element);
- }
- }
- return result;
- }
-
- public ICatalogEntry[] getCatalogEntries()
- {
- List result = getCatalogElements(ICatalogElement.TYPE_ENTRY);
- return (ICatalogEntry[]) result
- .toArray(new ICatalogEntry[result.size()]);
- }
-
- public IDelegateCatalog[] getDelegateCatalogs()
- {
- List result = getCatalogElements(ICatalogElement.TYPE_DELEGATE);
- return (IDelegateCatalog[]) result
- .toArray(new IDelegateCatalog[result.size()]);
- }
-
- public IRewriteEntry[] getRewriteEntries()
- {
- List result = getCatalogElements(ICatalogElement.TYPE_REWRITE);
- return (IRewriteEntry[]) result
- .toArray(new IRewriteEntry[result.size()]);
- }
-
- public ISuffixEntry[] getSuffixEntries()
- {
- List result = getCatalogElements(ICatalogElement.TYPE_SUFFIX);
- return (ISuffixEntry[]) result
- .toArray(new ISuffixEntry[result.size()]);
- }
-
- protected CatalogSet getCatalogSet()
- {
- return resourceSet;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getLocation()
- {
- return location;
- }
-
- public INextCatalog[] getNextCatalogs()
- {
- List result = getCatalogElements(ICatalogElement.TYPE_NEXT_CATALOG);
- return (INextCatalog[]) result.toArray(new INextCatalog[result.size()]);
- }
-
- protected InternalResolver getOrCreateInternalResolver()
- {
- if (internalResolver == null)
- {
- internalResolver = new InternalResolver();
- }
- return internalResolver;
- }
-
- protected boolean isNotificationEnabled()
- {
- return isNotificationEnabled;
- }
-
- public void load() throws IOException
- {
- catalogLS.load();
- }
-
- protected void notifyAddElement(ICatalogElement entry)
- {
- if (isNotificationEnabled)
- {
- ICatalogEvent event = new CatalogEvent(this, entry,
- ICatalogEvent.ELEMENT_ADDED);
- notifyListeners(event);
- }
- }
-
- protected void notifyChanged()
- {
- ICatalogEvent event = new CatalogEvent(this, null,
- ICatalogEvent.CHANGED);
- notifyListeners(event);
- }
-
- protected void notifyListeners(ICatalogEvent event)
- {
- List list = new ArrayList();
- list.addAll(listenerList);
- for (Iterator i = list.iterator(); i.hasNext();)
- {
- ICatalogListener listener = (ICatalogListener) i.next();
- listener.catalogChanged(event);
- }
- }
-
- protected void notifyRemoveElement(ICatalogElement element)
- {
- if (isNotificationEnabled)
- {
- ICatalogEvent event = new CatalogEvent(this, element,
- ICatalogEvent.ELEMENT_REMOVED);
- notifyListeners(event);
- }
- }
-
- public void removeCatalogElement(ICatalogElement element)
- {
- synchronized (catalogElements) {
- catalogElements.remove(element);
- }
- internalResolver = null;
- notifyRemoveElement(element);
-
- }
-
- public void removeListener(ICatalogListener listener)
- {
- listenerList.remove(listener);
- }
-
- public String resolvePublic(String publicId, String systemId)
- throws MalformedURLException, IOException
- {
- return getOrCreateInternalResolver().resolvePublic(publicId, systemId);
- }
-
- protected String resolveSubordinateCatalogs(int entryType, String publicId,
- String systemId) throws MalformedURLException, IOException
- {
- String result = null;
- INextCatalog[] nextCatalogs = getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++)
- {
- INextCatalog nextCatalog = nextCatalogs[i];
- ICatalog catalog = nextCatalog.getReferencedCatalog();
- if (catalog != null)
- {
- switch (entryType)
- {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC:
- result = catalog.resolvePublic(publicId, systemId);
- break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM:
- result = catalog.resolveSystem(systemId);
- break;
- case ICatalogEntry.ENTRY_TYPE_URI:
- result = catalog.resolveURI(systemId);
- break;
- default:
- break;
- }
- if (result != null)
- {
- return result;
- }
- }
- }
- return null;
- }
-
- public String resolveSystem(String systemId) throws MalformedURLException,
- IOException
- {
- return getOrCreateInternalResolver().resolveSystem(systemId);
- }
-
- public String resolveURI(String uri) throws MalformedURLException,
- IOException
- {
- return getOrCreateInternalResolver().resolveURI(uri);
- }
-
- public void save() throws IOException
- {
- catalogLS.save();
- }
-
- public void setBase(String base)
- {
- this.base = base;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public void setLocation(String location)
- {
- this.location = location;
- }
-
- protected void setNotificationEnabled(boolean b)
- {
- isNotificationEnabled = b;
- }
-
- public ICatalogElement[] getCatalogElements()
- {
- return (ICatalogElement[]) catalogElements.toArray(new ICatalogElement[catalogElements.size()]);
- }
-
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogContributorRegistryReader.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogContributorRegistryReader.java
deleted file mode 100644
index 2f01c5fc67..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogContributorRegistryReader.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * 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.catalog;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.osgi.framework.Bundle;
-
-public class CatalogContributorRegistryReader
-{
- protected static final String EXTENSION_POINT_ID = "catalogContributions"; //$NON-NLS-1$
- protected static final String TAG_CONTRIBUTION = "catalogContribution"; //$NON-NLS-1$
- /*
- * this is a sample exptension
- * <extension point="org.eclipse.wst.xml.core.catalogContributions">
- * <catalogContribution>
- * <uri
- * name="http://schemas.xmlsoap.org/wsdl/soap/"
- * uri="xsd/soap.xsd"/>
- * <public
- * publicId="-//W3C//DTD XHTML 1.1//EN"
- * uri="dtds/xhtml11-flat.dtd"/>
- * <nextCatalog id="nestedCatalog" catalog="data/catalog1.xml"/>
- * </catalogContribution>
- * </extension>
- *
- */
- protected ICatalog catalog;
-
- protected String declaringExtensionId;
-
- protected CatalogContributorRegistryReader(ICatalog aCatalog)
- {
- catalog = aCatalog;
- }
-
- /**
- * read from plugin registry and parse it.
- */
- protected void readRegistry()
- {
- IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), EXTENSION_POINT_ID);
- if (point != null)
- {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++)
- {
- readElement(elements[i]);
- }
- }
-
- }
-
- public static String resolvePath(URL platformURL, String path)
- {
- String fileLocation = path;
- int jarPathStart = path.indexOf("jar:"); //$NON-NLS-1$
- jarPathStart = jarPathStart < 0 ? 0 : jarPathStart + "jar:".length(); //$NON-NLS-1$
- int jarPathEnd = path.indexOf("!"); //$NON-NLS-1$
- jarPathEnd = jarPathEnd < 0 ? path.length() : jarPathEnd;
- fileLocation = path.substring(jarPathStart, jarPathEnd);
-
- String result = path;
- String resolvedLocation = fileLocation;
- URL resolvedURL = null;
- if (fileLocation.startsWith("platform:/plugin")) //$NON-NLS-1$
- {
- // this is the speclial case, where the resource is located relative
- // to another plugin (not the one that declares the extension point)
- //
- try
- {
- resolvedURL = Platform.resolve(new URL(fileLocation));
- } catch (IOException e)
- {
- // do nothing
- }
- }
- else{
- // this is the typical case, where the resource is located relative
- // to the plugin that declares the extension point
- try {
- resolvedURL = new URL(Platform.resolve(platformURL), fileLocation);
- } catch (IOException e) {
- // do nothing
- }
- }
-
- if(resolvedURL != null){
- resolvedLocation = resolvedURL.toExternalForm().replace('\\', '/');
- result = result.replaceFirst(fileLocation, resolvedLocation);
- }
- return result;
- }
-
- public static URL getPlatformURL(String pluginId){
- Bundle bundle = Platform.getBundle(pluginId);
- if (bundle != null)
- {
- URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$
-
- if(bundleEntry != null){
- try
- {
- return Platform.resolve(bundleEntry);
- } catch (IOException e)
- {
- Logger.logException(e);
- }
- }
- }
- return null;
- }
-
- private String resolvePath(String path)
- {
- return resolvePath(getPlatformURL(declaringExtensionId), path);
- }
-
- protected void readElement(IConfigurationElement element)
- {
- try
- {
- declaringExtensionId = element.getDeclaringExtension().getNamespace();
- }
- catch (InvalidRegistryObjectException e)
- {
- Logger.logException(e);
- }
-
- if (TAG_CONTRIBUTION.equals(element.getName())){
- IConfigurationElement[] mappingInfoElementList = element.getChildren(OASISCatalogConstants.TAG_PUBLIC);
- processMappingInfoElements(mappingInfoElementList);
- mappingInfoElementList = element.getChildren(OASISCatalogConstants.TAG_SYSTEM);
- processMappingInfoElements(mappingInfoElementList);
- mappingInfoElementList = element.getChildren(OASISCatalogConstants.TAG_URI);
- processMappingInfoElements(mappingInfoElementList);
- IConfigurationElement[] nextCatalogElementList = element.getChildren(OASISCatalogConstants.TAG_NEXT_CATALOG);
- processNextCatalogElements(nextCatalogElementList);
-
- }
-
- }
-
- private void processMappingInfoElements(IConfigurationElement[] childElementList)
- {
- if (catalog == null)
- return;
- for (int i = 0; i < childElementList.length; i++)
- {
- IConfigurationElement childElement = childElementList[i];
- String name = childElement.getName();
- String key = null;
-
- int type = ICatalogEntry.ENTRY_TYPE_PUBLIC;
- if (OASISCatalogConstants.TAG_PUBLIC.equals(name))
- {
- key = childElement.getAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID);
- }
- else if (OASISCatalogConstants.TAG_SYSTEM.equals(name))
- {
- key = childElement.getAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID);
- type = ICatalogEntry.ENTRY_TYPE_SYSTEM;
- }
- else if (OASISCatalogConstants.TAG_URI.equals(name))
- {
- key = childElement.getAttribute(OASISCatalogConstants.ATTR_NAME);
- type = ICatalogEntry.ENTRY_TYPE_URI;
- }
- else if (OASISCatalogConstants.TAG_NEXT_CATALOG.equals(name))
- {
- processNextCatalogElements(new IConfigurationElement[]{childElement});
- continue;
- }
- if (key == null || key.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_key_not_set);
- continue;
- }
- String entryURI = childElement.getAttribute(OASISCatalogConstants.ATTR_URI); // mandatory
- if (entryURI == null || entryURI.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_uri_not_set);
- continue;
- }
- ICatalogElement catalogElement = catalog.createCatalogElement(type);
- if (catalogElement instanceof ICatalogEntry)
- {
- ICatalogEntry entry = (ICatalogEntry) catalogElement;
- entry.setKey(key);
- String resolvedPath = resolvePath(entryURI);
- entry.setURI(resolvedPath);
- String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID); // optional
- if (id != null && !id.equals("")) //$NON-NLS-1$
- {
- entry.setId(id);
- }
- }
- // process any other attributes
- for (int j = 0; j < childElement.getAttributeNames().length; j++)
- {
- String attrName = childElement.getAttributeNames()[j];
- if (!attrName.equals(OASISCatalogConstants.ATTR_URI) && !attrName.equals(OASISCatalogConstants.ATTR_NAME) && !attrName.equals(OASISCatalogConstants.ATTR_PUBLIC_ID)
- && !attrName.equals(OASISCatalogConstants.ATTR_SYSTEM_ID) && !attrName.equals(OASISCatalogConstants.ATTR_CATALOG) && !attrName.equals(OASISCatalogConstants.ATTR_ID)
- && !attrName.equals(OASISCatalogConstants.ATTR_BASE))
- {
- String attrValue = childElement.getAttribute(attrName);
- if (attrValue != null && !attrValue.equals("")) //$NON-NLS-1$
- {
- catalogElement.setAttributeValue(attrName, attrValue);
- }
- }
- }
- catalog.addCatalogElement(catalogElement);
- }
- }
-
- private void processNextCatalogElements(IConfigurationElement[] childElementList)
- {
- if (catalog == null)
- return;
- for (int i = 0; i < childElementList.length; i++)
- {
- IConfigurationElement childElement = childElementList[i];
- String location = childElement.getAttribute(OASISCatalogConstants.ATTR_CATALOG); // mandatory
- if (location == null || location.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_next_catalog_location_uri_not_set);
- continue;
- }
- INextCatalog nextCatalog = new NextCatalog();
- String resolvedPath = resolvePath(location);
- nextCatalog.setCatalogLocation(resolvedPath);
- String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID);
- if (id != null && !id.equals("")) //$NON-NLS-1$
- {
- nextCatalog.setId(id);
- }
- catalog.addCatalogElement(nextCatalog);
- }
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogElement.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogElement.java
deleted file mode 100644
index ef86e228ac..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogElement.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * Jesper Steen Moller - jesper@selskabet.org - bug 112284
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-
-
-public class CatalogElement implements ICatalogElement
-{
- int type;
-
- String id;
-
- String base;
-
- Map attributes = new HashMap();
-
- ICatalog ownerCatalog;
-
- public CatalogElement(int aType)
- {
- super();
- type = aType;
- }
-
- public int getType()
- {
- return type;
- }
-
- public String getBase()
- {
- return base;
- }
-
- public void setBase(String base)
- {
- this.base = base;
- }
-
- public String getAttributeValue(String name)
- {
- return (String) attributes.get(name);
- }
-
- public void setAttributeValue(String name, String value)
- {
- attributes.put(name, value);
- }
-
- public String[] getAttributes()
- {
- Collection c = attributes.values();
- String[] result = new String[c.size()];
- attributes.keySet().toArray(result);
- return result;
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public ICatalog getOwnerCatalog()
- {
- return ownerCatalog;
- }
-
- public void setOwnerCatalog(ICatalog catalog)
- {
- this.ownerCatalog = catalog;
- }
-
- protected static String makeAbsolute(String baseLocation, String location)
- {
- URL local = null;
- location = location.replace('\\', '/');
- try
- {
- URL baseURL = new URL(baseLocation);
- local = new URL(baseURL, location);
- } catch (MalformedURLException e)
- {
- }
-
- if (local != null)
- {
- return local.toString();
- } else
- {
- return location;
- }
- }
-
- public String getAbsolutePath(String path)
- {
- try
- {
- URI uri = new URI(path);
- if (uri.isAbsolute())
- {
- return path;
- }
- } catch (URISyntaxException e)
- {
- }
-
- if (this.base != null && !this.base.equals("")) //$NON-NLS-1$
- {
- return makeAbsolute(base, path);
- }
-
- String result = path;
- Catalog catalog = (Catalog) getOwnerCatalog();
- if (catalog != null)
- {
- String base = catalog.getBase();
- if (base == null || base.equals("")) //$NON-NLS-1$
- {
- base = catalog.getLocation();
- }
- result = makeAbsolute(base, path);
- }
- return result;
- }
-
- /*
- * Since we don't have events notifications for entry properties, clone()
- * could allow to copy and edit entry and then replace it in catalog. Entry
- * replacement will signal ICatalogEvent @return
- */
- public Object clone()
- {
- ICatalogElement element = ownerCatalog.createCatalogElement(type);
- String[] attributes = getAttributes();
- for (int i = 0; i < attributes.length; i++)
- {
- String attrName = attributes[i];
- String attrValue = getAttributeValue(attrName);
- element.setAttributeValue(attrName, attrValue);
- }
- element.setOwnerCatalog(ownerCatalog);
- element.setId(id);
- element.setBase(base);
- return element;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEntry.java
deleted file mode 100644
index 550a8e41d9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEntry.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * 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.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-
-public class CatalogEntry extends CatalogElement implements ICatalogEntry, Cloneable
-{
- int entryType = ICatalogEntry.ENTRY_TYPE_PUBLIC;
- String key;
- String uri;
-
- protected CatalogEntry(int anEntryType)
- {
- super(ICatalogElement.TYPE_ENTRY);
- entryType = anEntryType;
- }
-
- protected CatalogEntry()
- {
- super(ICatalogElement.TYPE_ENTRY);
- }
-
- public void setEntryType(int value)
- {
- entryType = value;
- }
-
- public int getEntryType()
- {
- return entryType;
- }
-
- public void setKey(String value)
- {
- key = value;
- }
-
- public String getKey()
- {
- return key;
- }
-
- public String getURI()
- {
- return uri;
- }
-
- public void setURI(String value)
- {
- uri = value;
- }
-
- public Object clone()
- {
- CatalogEntry entry = (CatalogEntry)super.clone();
- entry.setEntryType(entryType);
- entry.setKey(key);
- entry.setURI(uri);
- return entry;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEvent.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEvent.java
deleted file mode 100644
index 8fba64d62f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEvent;
-
-
-public class CatalogEvent implements ICatalogEvent
-{
- protected ICatalog catalog;
- protected ICatalogElement catalogElement;
- protected int eventType;
-
- public CatalogEvent(Catalog catalog, ICatalogElement element, int eventType)
- {
- this.catalog = catalog;
- this.catalogElement = element;
- this.eventType = eventType;
- }
-
- public ICatalog getCatalog()
- {
- return catalog;
- }
-
- public ICatalogElement getCatalogElement()
- {
- return catalogElement;
- }
-
- public int getEventType()
- {
- return eventType;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogReader.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogReader.java
deleted file mode 100644
index d53a15b02c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogReader.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Stack;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.wst.common.uriresolver.internal.URI;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- *
- */
-public final class CatalogReader
-{
- public static void read(Catalog xmlCatalog, InputStream input) throws IOException
- {
- try
- {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(false);
- factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);//$NON-NLS-1$
- SAXParser parser = factory.newSAXParser();
- parser.parse(new InputSource(input), new CatalogContentHandler(xmlCatalog));
- }
- catch (ParserConfigurationException e)
- {
- Logger.logException(e);
- }
- catch (SAXException e)
- {
- Logger.logException(e);
- }
- }
- protected static class CatalogContentHandler extends DefaultHandler
- {
- protected Catalog catalog;
- protected Stack baseURIStack = new Stack();
-
- public CatalogContentHandler(Catalog xmlCatalog)
- {
- this.catalog = xmlCatalog;
- String base = xmlCatalog.getBase();
- if(base == null || base == "") { //$NON-NLS-1$
- base = xmlCatalog.getLocation();
- }
- baseURIStack.push(base);
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- {
- // set base attribute xml:base
- String base = attributes.getValue(OASISCatalogConstants.ATTR_BASE); //$NON-NLS-1$
- if (base != null && !base.equals("")) //$NON-NLS-1$
- {
- // since the xml:base attribute can be relative to the enclosing element's effective base, we're maintaining a
- // stack of absolute URIs
- if (URI.createURI(base).isRelative())
- {
- base = URI.resolveRelativeURI(base, baseURIStack.peek().toString());
- }
-
- baseURIStack.push(URIHelper.ensureURIProtocolFormat(base));
- } else {
- baseURIStack.push(baseURIStack.peek());
- }
-
- // processing for backward compatibility start
- if (localName.equals(CompatabilityConstants.TAG_USER_ENTRY))
- {
- String typeName = attributes.getValue("", CompatabilityConstants.ATT_TYPE); //$NON-NLS-1$
- boolean isSystem = false;
- if (typeName != null)
- {
- isSystem = (typeName.compareToIgnoreCase("SYSTEM") == 0); //$NON-NLS-1$
- }
- ICatalogEntry catalogEntry = new CatalogEntry(isSystem ? ICatalogEntry.ENTRY_TYPE_SYSTEM : ICatalogEntry.ENTRY_TYPE_PUBLIC);
- catalogEntry.setKey(attributes.getValue("", CompatabilityConstants.ATT_ID)); //$NON-NLS-1$
- String entryUri = attributes.getValue("", CompatabilityConstants.ATT_URI); //$NON-NLS-1$
-
- // For relative URIs, try to resolve them using the corresponding base URI.
- catalogEntry.setURI(resolveRelative(entryUri));
-
- String webURL = attributes.getValue("", CompatabilityConstants.ATT_WEB_URL); //$NON-NLS-1$
- if (webURL != null)
- {
- catalogEntry.setAttributeValue(
- ICatalogEntry.ATTR_WEB_URL, webURL);
- }
- catalog.addCatalogElement(catalogEntry);
- return;
- }
- // processing for backward compatibility end
- ICatalogElement catalogElement = null;
-
- if (OASISCatalogConstants.TAG_PUBLIC.equals(localName))
- {
- // 6.5.3. The public Entry
- catalogElement = createEntry(attributes, ICatalogEntry.ENTRY_TYPE_PUBLIC, OASISCatalogConstants.ATTR_PUBLIC_ID);
- }
- else if (OASISCatalogConstants.TAG_SYSTEM.equals(localName))
- {
- // 6.5.4. The system Element
- catalogElement = createEntry(attributes, ICatalogEntry.ENTRY_TYPE_SYSTEM, OASISCatalogConstants.ATTR_SYSTEM_ID);
- }
- else if (OASISCatalogConstants.TAG_URI.equals(localName))
- {
- // 6.5.9. The uri Element
- catalogElement = createEntry(attributes, ICatalogEntry.ENTRY_TYPE_URI, OASISCatalogConstants.ATTR_NAME);
- }
- else if (OASISCatalogConstants.TAG_REWRITE_SYSTEM.equals(localName))
- {
- // 6.5.5. The rewriteSystem Element
- catalogElement = createRewrite(attributes, IRewriteEntry.REWRITE_TYPE_SYSTEM, OASISCatalogConstants.ATTR_SYSTEM_ID_START_STRING);
- }
- else if (OASISCatalogConstants.TAG_REWRITE_URI.equals(localName))
- {
- // 6.5.9. The uri Element
- catalogElement = createRewrite(attributes, IRewriteEntry.REWRITE_TYPE_URI, OASISCatalogConstants.ATTR_URI_START_STRING);
- }
- else if (OASISCatalogConstants.TAG_DELEGATE_PUBLIC.equals(localName))
- {
- // 6.5.7. The delegatePublic Element
- catalogElement = createDelegate(attributes, IDelegateCatalog.DELEGATE_TYPE_PUBLIC, OASISCatalogConstants.ATTR_PUBLIC_ID_START_STRING);
- }
- else if (OASISCatalogConstants.TAG_DELEGATE_SYSTEM.equals(localName))
- {
- // 6.5.8. The delegateSystem Element
- catalogElement = createDelegate(attributes, IDelegateCatalog.DELEGATE_TYPE_SYSTEM, OASISCatalogConstants.ATTR_SYSTEM_ID_START_STRING);
- }
- else if (OASISCatalogConstants.TAG_DELEGATE_URI.equals(localName))
- {
- // 6.5.12. The delegateURI Element
- catalogElement = createDelegate(attributes, IDelegateCatalog.DELEGATE_TYPE_URI, OASISCatalogConstants.ATTR_URI_START_STRING);
- }
- else if (OASISCatalogConstants.TAG_SYSTEM_SUFFIX.equals(localName))
- {
- // 6.5.6. The systemSuffix Element
- catalogElement = createSuffix(attributes, ISuffixEntry.SUFFIX_TYPE_SYSTEM, OASISCatalogConstants.ATTR_SYSTEM_ID_SUFFFIX);
- }
- else if (OASISCatalogConstants.TAG_URI_SUFFIX.equals(localName))
- {
- // 6.5.11. The uriSuffix Element
- catalogElement = createSuffix(attributes, ISuffixEntry.SUFFIX_TYPE_URI, OASISCatalogConstants.ATTR_URI_SUFFIX);
- }
- else if (OASISCatalogConstants.TAG_NEXT_CATALOG.equals(localName))
- {
- catalogElement = createNextCatalog(attributes);
- }
-
- if (catalogElement == null)
- {
- // do not set the extra information
- return;
- }
-
- String attrId = attributes.getValue("", OASISCatalogConstants.ATTR_ID);//$NON-NLS-1$
- if (attrId != null && ! "".equals(attrId)) catalogElement.setId(attrId);//$NON-NLS-1$
- // process any other attributes
- for (int j = 0; j < attributes.getLength(); j++)
- {
- String attrName = attributes.getLocalName(j);
- if (!attrName.equals(OASISCatalogConstants.ATTR_URI) && !attrName.equals(OASISCatalogConstants.ATTR_NAME) && !attrName.equals(OASISCatalogConstants.ATTR_PUBLIC_ID)
- && !attrName.equals(OASISCatalogConstants.ATTR_SYSTEM_ID) && !attrName.equals(OASISCatalogConstants.ATTR_CATALOG) && !attrName.equals(OASISCatalogConstants.ATTR_ID)
- && !attrName.equals(OASISCatalogConstants.ATTR_BASE))
- {
- String attrValue = attributes.getValue(attrName);
- if (attrValue != null && !attrValue.equals("")) //$NON-NLS-1$
- {
- catalogElement.setAttributeValue(attrName, attrValue);
- }
- }
- }
- catalog.addCatalogElement(catalogElement);
-
- }
-
- private ICatalogElement createNextCatalog(Attributes attributes) {
- String location = attributes.getValue("", OASISCatalogConstants.ATTR_CATALOG); //$NON-NLS-1$
- NextCatalog delegate = new NextCatalog();
- delegate.setBase((String)baseURIStack.peek());
- delegate.setCatalogLocation(location);
- return delegate;
- }
-
- private ICatalogEntry createEntry(Attributes attributes, int entryType, String keyAttributeName) {
- String key = attributes.getValue("", keyAttributeName); //$NON-NLS-1$
- if (key == null || key.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_key_not_set);
- return null;
- }
- String entryURI = attributes.getValue("", OASISCatalogConstants.ATTR_URI); //$NON-NLS-1$
- if (entryURI == null || entryURI.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_uri_not_set);
- return null;
- }
- CatalogEntry entry = new CatalogEntry(entryType);
- entry.setKey(key);
- entry.setURI(resolveRelative(entryURI));
- return entry;
- }
-
- private IRewriteEntry createRewrite(Attributes attributes, int entryType, String prefixStringName) {
- String startString = attributes.getValue("", prefixStringName); //$NON-NLS-1$
- if (startString == null || startString.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_rewrite_startString_not_set);
- return null;
- }
- String prefix = attributes.getValue("", OASISCatalogConstants.ATTR_REWRITE_PREFIX); //$NON-NLS-1$
- if (prefix == null || prefix.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_rewrite_prefix_not_set);
- return null;
- }
- RewriteEntry entry = new RewriteEntry(entryType);
- entry.setStartString(startString);
- entry.setRewritePrefix(resolveRelative(prefix));
- return entry;
- }
-
- private IDelegateCatalog createDelegate(Attributes attributes, int entryType, String startStringAttrName) {
- String startString = attributes.getValue("", startStringAttrName); //$NON-NLS-1$
- if (startString == null || startString.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_delegate_prefix_not_set);
- return null;
- }
- String catalogUri = attributes.getValue("", OASISCatalogConstants.ATTR_CATALOG); //$NON-NLS-1$
- if (catalogUri == null || catalogUri.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_delegate_prefix_not_set);
- return null;
- }
- DelegateCatalog entry = new DelegateCatalog(entryType);
- entry.setStartString(startString);
- entry.setCatalogLocation(catalogUri);
- return entry;
- }
-
- private ISuffixEntry createSuffix(Attributes attributes, int entryType, String suffixAttrName) {
- String suffix = attributes.getValue("", suffixAttrName); //$NON-NLS-1$
- if (suffix == null || suffix.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_suffix_string_not_set);
- return null;
- }
- String uri = attributes.getValue("", OASISCatalogConstants.ATTR_URI); //$NON-NLS-1$
- if (uri == null || uri.equals("")) //$NON-NLS-1$
- {
- Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_suffix_uri_not_set);
- return null;
- }
- SuffixEntry entry = new SuffixEntry(entryType);
- entry.setSuffix(suffix);
- entry.setURI(resolveRelative(uri));
- return entry;
- }
-
- private String resolveRelative(String entryURI)
- {
- if(URI.createURI(entryURI).isRelative())
- {
- entryURI = URI.resolveRelativeURI(entryURI, baseURIStack.peek().toString());
- }
- return URIHelper.ensureURIProtocolFormat(entryURI);
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException
- {
- if (baseURIStack.size() > 0)
- {
- baseURIStack.pop();
- }
- }
-
- }
-
- // for backward compatability
- interface CompatabilityConstants{
-
- public static final String TAG_ID_XML_CATALOG_SETTINGS = "XMLCatalogSettings"; //$NON-NLS-1$
- public static final String TAG_ID_USER_ENTRIES = "UserEntries"; //$NON-NLS-1$
- public static final String TAG_USER_ENTRY = "UserEntry"; //$NON-NLS-1$
- public static final String ATT_TYPE = "TYPE"; //$NON-NLS-1$
- public static final String ATT_ID = "ID"; //$NON-NLS-1$
- public static final String ATT_URI = "URI"; //$NON-NLS-1$
- public static final String ATT_WEB_URL = "WEB_URL"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogSet.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogSet.java
deleted file mode 100644
index e9e766152c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogSet.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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.catalog;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-
-public class CatalogSet {
- protected Map uriResourceMap = new HashMap();
- protected Map catalogPersistenceLocations = new HashMap();
- public CatalogSet() {
- super();
- }
-
- /**
- * Find a Catalog with the given ID. If one is not found, create one at the given URI.
- *
- * @param id
- * @param uri - the URI, the parent of this file path must already exist
- * @return
- */
- public Catalog lookupOrCreateCatalog(String id, String uri) {
- Catalog catalog = getCatalog(id, uri);
- if (catalog == null) {
- catalog = new Catalog(this, id, uri);
- try {
- catalog.load();
- uriResourceMap.put(uri, catalog);
- }
- catch (Exception e) {
- // we catch and log all exceptions, to disallow
- // one bad extension interfering with others
- Logger.logException("error loading catalog: " + id + " " + uri, e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return catalog;
- }
-
- private Catalog getCatalog(String id, String uri) {
- return (Catalog) uriResourceMap.get(uri);
- }
-
- public void putCatalogPersistenceLocation(String logicalURI, String actualURI) {
- catalogPersistenceLocations.put(logicalURI, actualURI);
- }
-
- // Never used?
- public String getCatalogPersistenceLocation(String id) {
- return (String) catalogPersistenceLocations.get(id);
- }
-
- public void clearResourceCache() {//Clearing only uriResourceMap is required
- uriResourceMap.clear();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogWriter.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogWriter.java
deleted file mode 100644
index 30d5169ed4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/CatalogWriter.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.catalog;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Write OASIS XML Catalog format
- *
- */
-public final class CatalogWriter
-{
- private Document doc;
-
- public void write(ICatalog xmlCatalog, String uri) throws FileNotFoundException, IOException
- {
- OutputStream outputStream = null;
- try {
- visitCatalog(xmlCatalog);
- outputStream = getOutputStream(uri);
- serialize(outputStream);
- }
- finally {
- if(outputStream != null) {
- outputStream.close();
- }
- }
- }
-
- public void write(ICatalog catalog, OutputStream os) throws FileNotFoundException, IOException
- {
- if (catalog != null)
- {
- visitCatalog(catalog);
- serialize(os);
- }
- }
-
- private void visitCatalog(ICatalog xmlCatalog)
- {
- try
- {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- }
- catch (ParserConfigurationException e)
- {
- Logger.logException(e);
- }
- if (doc == null)
- return;
- Element catalogElement = doc.createElementNS(OASISCatalogConstants.namespaceName, OASISCatalogConstants.TAG_CATALOG);
- doc.appendChild(catalogElement);
- processCatalogEntries(xmlCatalog, catalogElement);
- processNextCatalogs(xmlCatalog, catalogElement);
- processDelegateCatalogs(xmlCatalog, catalogElement);
- processSuffixEntries(xmlCatalog, catalogElement);
- processRewriteEntries(xmlCatalog, catalogElement);
- }
-
- private void processRewriteEntries(ICatalog catalog, Element parent)
- {
- IRewriteEntry[] catalogEntries = catalog.getRewriteEntries();
-
- for (int i = 0; i < catalogEntries.length; i++)
- {
- IRewriteEntry entry = catalogEntries[i];
- String startString = entry.getStartString();
- String prefix = entry.getRewritePrefix();
- Element childElement = null;
-
- switch (entry.getEntryType())
- {
- case IRewriteEntry.REWRITE_TYPE_SYSTEM :
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_REWRITE_SYSTEM);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID_START_STRING, startString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_REWRITE_PREFIX, prefix);
- }
- break;
- case IRewriteEntry.REWRITE_TYPE_URI:
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_REWRITE_URI);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI_START_STRING, startString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_REWRITE_PREFIX, prefix);
- }
- break;
- default :
- break;
- }
- if (childElement != null)
- {
- setAttributes(entry, childElement);
- parent.appendChild(childElement);
- }
- }
- }
-
- private void processSuffixEntries(ICatalog catalog, Element parent)
- {
- ISuffixEntry[] suffixEntries = catalog.getSuffixEntries();
-
- for (int i = 0; i < suffixEntries.length; i++)
- {
- ISuffixEntry entry = suffixEntries[i];
- String suffixString = entry.getSuffix();
- String uri = entry.getURI();
- Element childElement = null;
-
- switch (entry.getEntryType())
- {
- case ISuffixEntry.SUFFIX_TYPE_SYSTEM :
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_SYSTEM_SUFFIX);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID_SUFFFIX, suffixString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
- }
- break;
- case ISuffixEntry.SUFFIX_TYPE_URI:
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_URI_SUFFIX);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI_SUFFIX, suffixString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
- }
- break;
- default :
- break;
- }
- if (childElement != null)
- {
- setAttributes(entry, childElement);
- parent.appendChild(childElement);
- }
- }
- }
-
- private void processDelegateCatalogs(ICatalog catalog, Element parent)
- {
- IDelegateCatalog[] delegateCatalogs = catalog.getDelegateCatalogs();
-
- for (int i = 0; i < delegateCatalogs.length; i++)
- {
- IDelegateCatalog entry = delegateCatalogs[i];
- String prefixString = entry.getStartString();
- String catalogLocation = entry.getCatalogLocation();
- Element childElement = null;
-
- switch (entry.getEntryType())
- {
- case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_DELEGATE_PUBLIC);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID_START_STRING, prefixString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, catalogLocation);
- }
- break;
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_DELEGATE_SYSTEM);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID_START_STRING, prefixString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, catalogLocation);
- }
- break;
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_DELEGATE_URI);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI_START_STRING, prefixString);
- childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, catalogLocation);
- }
- break;
- default :
- break;
- }
- if (childElement != null)
- {
- setAttributes(entry, childElement);
- parent.appendChild(childElement);
- }
- }
- }
-
- private void processCatalogEntries(ICatalog catalog, Element parent)
- {
- ICatalogEntry[] catalogEntries = catalog.getCatalogEntries();
-
- for (int i = 0; i < catalogEntries.length; i++)
- {
- ICatalogEntry entry = catalogEntries[i];
- String key = entry.getKey();
- String uri = entry.getURI();
- Element childElement = null;
-
- switch (entry.getEntryType())
- {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC :
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_PUBLIC);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID, key);
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
- }
- break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM :
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_SYSTEM);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID, key);
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
- }
- break;
- case ICatalogEntry.ENTRY_TYPE_URI :
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_URI);
- if (childElement != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_NAME, key);
- childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
- }
- break;
- default :
- break;
- }
- if (childElement != null)
- {
- setAttributes(entry, childElement);
- parent.appendChild(childElement);
- }
- }
- }
-
- private void setAttributes(ICatalogElement entry, Element childElement)
- {
- String[] attributes = entry.getAttributes();
- for (int j = 0; j < attributes.length; j++)
- {
- String attrName = attributes[j];
- if (attrName != null && !attrName.equals("")) //$NON-NLS-1$
- {
- String attrValue = entry.getAttributeValue(attrName);
- if (childElement != null && attrValue != null)
- {
- childElement.setAttribute(attrName, attrValue);
- }
- }
- }
- String id = entry.getId();
- if (id != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_ID, id);
- }
- }
-
- private void processNextCatalogs(ICatalog catalog, Element parent)
- {
- // handle catalog entries
- INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
- Element childElement = null;
- //dw String attrValue = null;
- for (int i = 0; i < nextCatalogs.length; i++)
- {
- INextCatalog delegate = nextCatalogs[i];
- childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_NEXT_CATALOG);
- if (childElement != null)
- {
- parent.appendChild(childElement);
- String location = delegate.getCatalogLocation();
- if (location != null)
- {
- childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, location);
- }
- setAttributes(delegate, childElement);
- }
- }
- }
-
- private void serialize(OutputStream outputStream) throws FileNotFoundException, IOException
- {
- if (doc == null)
- return;
- try
- {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- // Unless a width is set, there will be only line breaks but no
- // indentation.
- // The IBM JDK and the Sun JDK don't agree on the property name,
- // so we set them both.
- //
- transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
- String encoding = "UTF-8"; // TBD //$NON-NLS-1$
- if (encoding != null)
- {
- transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
- }
- transformer.transform(new DOMSource(doc), new StreamResult(outputStream));
- }
- catch (TransformerException e)
- {
- Logger.logException(e);
- }
- }
-
- private OutputStream getOutputStream(String uri) throws FileNotFoundException, IOException
- {
- String filePath = removeProtocol(uri);
- File file = new File(filePath);
- OutputStream stream = new FileOutputStream(file);
- return stream;
- }
-
- protected static String removeProtocol(String uri)
- {
- String result = uri;
- String protocol_pattern = ":"; //$NON-NLS-1$
- if (uri != null)
- {
- int index = uri.indexOf(protocol_pattern);
- if (index > 2)
- {
- result = result.substring(index + protocol_pattern.length());
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DelegateCatalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DelegateCatalog.java
deleted file mode 100644
index 57e729ba78..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DelegateCatalog.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-
-
-
-public class DelegateCatalog extends TypedCatalogElement implements IDelegateCatalog
-{
- private String location;
- private ICatalog referencedCatalog;
- private String startString;
-
- public String getStartString()
- {
- return startString;
- }
-
- public void setStartString(String startString)
- {
- this.startString = startString;
- }
-
- public DelegateCatalog(int type)
- {
- super(ICatalogElement.TYPE_DELEGATE, type);
- }
-
- public String getCatalogLocation()
- {
- return location;
- }
-
- public ICatalog getReferencedCatalog()
- {
- if (referencedCatalog == null)
- {
- referencedCatalog = ((Catalog)ownerCatalog).getCatalogSet().lookupOrCreateCatalog(getId(), getAbsolutePath(location));
- }
- return referencedCatalog;
- }
-
- public void setCatalogLocation(String uri)
- {
- location = uri;
- referencedCatalog = null;
- }
-
- public Object clone()
- {
- DelegateCatalog nextCatalog = (DelegateCatalog)super.clone();
- nextCatalog.setCatalogLocation(location);
- nextCatalog.setStartString(startString);
- return nextCatalog;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/NextCatalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/NextCatalog.java
deleted file mode 100644
index 16f755ace9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/NextCatalog.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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
- * Raj Mandayam, IBM
- * 136400 NextCatalog.getReferencedCatalog() takes a lot of time computing constant information
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-
-
-
-public class NextCatalog extends CatalogElement implements INextCatalog
-{
- private String location;
- private ICatalog referencedCatalog;
-
- public NextCatalog()
- {
- super(ICatalogElement.TYPE_NEXT_CATALOG);
- }
-
- public String getCatalogLocation()
- {
- return location;
- }
-
- public ICatalog getReferencedCatalog()
- {
- if (referencedCatalog == null)
- {
- referencedCatalog = ((Catalog)ownerCatalog).getCatalogSet().lookupOrCreateCatalog(getId(), getAbsolutePath(location));
- }
- return referencedCatalog;
- }
-
- public void setCatalogLocation(String uri)
- {
- location = uri;
- referencedCatalog = null;
- }
-
- public Object clone()
- {
- NextCatalog nextCatalog = (NextCatalog)super.clone();
- nextCatalog.setCatalogLocation(location);
- return nextCatalog;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/OASISCatalogConstants.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/OASISCatalogConstants.java
deleted file mode 100644
index d716a62fe8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/OASISCatalogConstants.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-public interface OASISCatalogConstants
-{
- String namespaceName = "urn:oasis:names:tc:entity:xmlns:xml:catalog"; //$NON-NLS-1$
- /** Types of the catalog entries */
- /** The CATALOG element name. */
- String TAG_CATALOG = "catalog"; //$NON-NLS-1$
- /** The GROUP catalog entry. */
- String TAG_GROUP = "group"; //$NON-NLS-1$
- /** The PUBLIC catalog entry. */
- String TAG_PUBLIC = "public"; //$NON-NLS-1$
- /** The SYSTEM catalog etnry. */
- String TAG_SYSTEM = "system"; //$NON-NLS-1$
- /** The URI catalog entry. */
- String TAG_URI = "uri"; //$NON-NLS-1$
- /** The REWRITE_SYSTEM catalog entry. */
- String TAG_REWRITE_SYSTEM = "rewriteSystem"; //$NON-NLS-1$
- /** The REWRITE_URI catalog entry. */
- String TAG_REWRITE_URI = "rewriteURI"; //$NON-NLS-1$
- /** The systemSuffix catalog entry. */
- String TAG_SYSTEM_SUFFIX = "systemSuffix"; //$NON-NLS-1$
- /** The uriSuffix catalog entry. */
- String TAG_URI_SUFFIX = "uriSuffix"; //$NON-NLS-1$
- /** The DELEGATE_PUBLIC catalog entry. */
- String TAG_DELEGATE_PUBLIC = "delegatePublic"; //$NON-NLS-1$
- /** The DELEGATE_SYSTEM catalog entry. */
- String TAG_DELEGATE_SYSTEM = "delegateSystem"; //$NON-NLS-1$
- /** The DELEGATE_URI catalog entry. */
- String TAG_DELEGATE_URI = "delegateURI"; //$NON-NLS-1$
- /** The NEXT_CATALOG catalog entry. */
- String TAG_NEXT_CATALOG = "nextCatalog"; //$NON-NLS-1$
- /** Attributes */
- /** Attribute id used in all catalog entries */
- String ATTR_ID = "id"; //$NON-NLS-1$
- /** Attribute id base in all catalog entries */
- String ATTR_BASE = "xml:base"; //$NON-NLS-1$
- /** Attribute id prefer in catalog entries: CATALOG, GROUP */
- String ATTR_PREFERE = "prefer"; //$NON-NLS-1$
- /** Attribute used in catalog entries of type: PUBLIC */
- String ATTR_PUBLIC_ID = "publicId"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: SYSTEM
- */
- String ATTR_SYSTEM_ID = "systemId"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: SYSTEM_SUFFIX
- */
- String ATTR_SYSTEM_ID_SUFFFIX = "systemIdSuffix"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: URI
- */
- String ATTR_NAME = "name"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: PUBLIC, URI
- */
- String ATTR_URI = "uri"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: URI_SUFFIX
- */
- String ATTR_URI_SUFFIX = "uriSuffix"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: REWRITE_SYSTEM, DELEGATE_SYSTEM
- */
- String ATTR_SYSTEM_ID_START_STRING = "systemIdStartString"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: REWRITE_SYSTEM, REWRITE_URI
- */
- String ATTR_REWRITE_PREFIX = "rewritePrefix"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: DELEGATE_PUBLIC
- */
- String ATTR_PUBLIC_ID_START_STRING = "publicIdStartString"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: DELEGATE_PUBLIC,
- * DELEGATE_SYSTEM, DELEGATE_URI, NEXT_CATALOG
- */
- String ATTR_CATALOG = "catalog"; //$NON-NLS-1$
- /**
- * Attribute used in catalog entries of type: REWRITE_URI, DELEGATE_URI
- */
- String ATTR_URI_START_STRING = "uriStartString"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/RewriteEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/RewriteEntry.java
deleted file mode 100644
index 5d9590ea87..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/RewriteEntry.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-
-public class RewriteEntry extends TypedCatalogElement implements IRewriteEntry, Cloneable
-{
- String startString;
- String rewritePrefix;
-
- protected RewriteEntry(int anEntryType)
- {
- super(ICatalogElement.TYPE_REWRITE, anEntryType);
- }
-
- public String getStartString()
- {
- return startString;
- }
-
- public void setStartString(String startString)
- {
- this.startString = startString;
- }
-
- public String getRewritePrefix()
- {
- return rewritePrefix;
- }
-
- public void setRewritePrefix(String rewritePrefix)
- {
- this.rewritePrefix = rewritePrefix;
- }
-
- public Object clone()
- {
- RewriteEntry entry = (RewriteEntry) super.clone();
- entry.setRewritePrefix(rewritePrefix);
- entry.setStartString(startString);
- return entry;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/SuffixEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/SuffixEntry.java
deleted file mode 100644
index f9daaa563e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/SuffixEntry.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-
-public class SuffixEntry extends TypedCatalogElement implements ISuffixEntry, Cloneable
-{
- String suffix;
- String uri;
-
- protected SuffixEntry(int anEntryType)
- {
- super(ICatalogElement.TYPE_SUFFIX, anEntryType);
- }
-
- public void setSuffix(String value)
- {
- suffix = value;
- }
-
- public String getSuffix()
- {
- return suffix;
- }
-
- public String getURI()
- {
- return uri;
- }
-
- public void setURI(String value)
- {
- uri = value;
- }
-
- public Object clone()
- {
- SuffixEntry entry = (SuffixEntry)super.clone();
- entry.setSuffix(suffix);
- entry.setURI(uri);
- return entry;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/TypedCatalogElement.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/TypedCatalogElement.java
deleted file mode 100644
index 8592d6b04a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/TypedCatalogElement.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog;
-
-
-public class TypedCatalogElement extends CatalogElement
-{
- protected int entryType;
-
- public TypedCatalogElement(int type, int entryType)
- {
- super(type);
- this.entryType = entryType;
- }
-
- final public void setEntryType(int value)
- {
- entryType = value;
- }
-
- final public int getEntryType()
- {
- return entryType;
- }
-
- public Object clone()
- {
- TypedCatalogElement temp = (TypedCatalogElement)super.clone();
- temp.setEntryType(this.getEntryType());
- return temp;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/XMLCatalogURIResolverExtension.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/XMLCatalogURIResolverExtension.java
deleted file mode 100644
index 0b4af07ab5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/XMLCatalogURIResolverExtension.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * 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.catalog;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverExtension;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-
-/**
- * This class is used to inject the XMLCatalog resolution behaviour into the
- * Common Extensible URI Resolver. This class is referenced in the XML Catalog
- * plugin's plugin.xml file.
- */
-public class XMLCatalogURIResolverExtension implements URIResolverExtension
-{
- public String resolve(IFile file, String baseLocation, String publicId, String systemId)
- {
- // if we have catalog in a project we may add it
- // to the catalog manager first
- ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- if (catalog == null)
- {
- Logger.log(Logger.ERROR_DEBUG, XMLCoreMessages.Catalog_resolution_null_catalog);
- return null;
- }
- String resolved = null;
- if (systemId != null)
- {
- try
- {
- resolved = catalog.resolveSystem(systemId);
- if (resolved == null)
- {
- resolved = catalog.resolveURI(systemId);
- }
- }
- catch (MalformedURLException me)
- {
- Logger.log(Logger.ERROR_DEBUG, XMLCoreMessages.Catalog_resolution_malformed_url);
- resolved = null;
- }
- catch (IOException ie)
- {
- Logger.log(Logger.ERROR_DEBUG, XMLCoreMessages.Catalog_resolution_io_exception);
- resolved = null;
- }
- }
- if (resolved == null)
- {
- if (publicId != null)
- {
- // CS : this is a temporary workaround for bug 96772
- //
- // For schemas we always use locations where available and only use
- // namespace when no location is specified. For XML entities (such as DOCTYPE)
- // default always utilize the public catalog entry.
- //
- // This lame test below roughly discriminate between schema and XML entities.
- // TODO (bug 103243) remove this lame test once we move to the new URIResolver API
- // since the new API is explicit about namespace and publicId
- //
- if (!(systemId != null && systemId.endsWith(".xsd"))) //$NON-NLS-1$
- {
- try
- {
- resolved = catalog.resolvePublic(publicId, systemId);
- if (resolved == null)
- {
- resolved = catalog.resolveURI(publicId);
- }
- }
- catch (MalformedURLException me)
- {
- Logger.log(Logger.ERROR_DEBUG, XMLCoreMessages.Catalog_resolution_malformed_url);
- resolved = null;
- }
- catch (IOException ie)
- {
- Logger.log(Logger.ERROR_DEBUG, XMLCoreMessages.Catalog_resolution_io_exception);
- resolved = null;
- }
- }
- }
- }
- return resolved;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalog.java
deleted file mode 100644
index 6796b74f84..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalog.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog.provisional;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-
-
-/**
- * A representation of the model object '<em><b>Catalog</b></em>'.
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface ICatalog
-{
- /**
- * Returns catalog id string
- *
- * @return catalog id string
- */
- String getId();
-
- /**
- * Sets catalog id string
- *
- */
- void setId(String id);
-
-
- void setLocation(String location);
- String getLocation();
-
- /**
- * Return the applicable or SYSTEM identifier.
- *
- * <p>
- * This method searches the Catalog and returns the system identifier
- * specified for the given system or identifiers. If no appropriate
- * or SYSTEM entry is found in the Catalog, null is returned.
- * </p>
- *
- * @param publicId
- * The identifier to locate in the catalog. Public
- * identifiers are normalized before comparison.
- * @param systemId
- * The nominal system identifier for the entity in question (as
- * provided in the source document).
- *
- * @throws MalformedURLException
- * The formal system identifier of a subordinate catalog cannot
- * be turned into a valid URL.
- * @throws IOException
- * Error reading subordinate catalog file.
- *
- * @return The system identifier to use. Note that the nominal system
- * identifier is not returned if a match is not found in the
- * catalog, instead null is returned to indicate that no match was
- * found.
- */
- String resolvePublic(String publicId, String systemId)
- throws MalformedURLException, IOException;
-
- /**
- * Return the applicable SYSTEM system identifier.
- *
- * <p>
- * If a SYSTEM entry exists in the Catalog for the system ID specified,
- * return the mapped value.
- * </p>
- *
- * <p>
- * On Windows-based operating systems, the comparison between the system
- * identifier provided and the SYSTEM entries in the Catalog is
- * case-insensitive.
- * </p>
- *
- * @param systemId
- * The system ID to locate in the catalog.
- *
- * @return The resolved system identifier.
- *
- * @throws MalformedURLException
- * The formal system identifier of a subordinate catalog cannot
- * be turned into a valid URL.
- * @throws IOException
- * Error reading subordinate catalog file.
- */
- String resolveSystem(String systemId) throws MalformedURLException,
- IOException;
-
- /**
- * Return the applicable URI.
- *
- * <p>
- * If a URI entry exists in the Catalog for the URI specified, return the
- * mapped value.
- * </p>
- *
- * <p>
- * URI comparison is case sensitive.
- * </p>
- *
- * @param uri
- * The URI to locate in the catalog.
- *
- * @return The resolved URI.
- *
- * @throws MalformedURLException
- * The system identifier of a subordinate catalog cannot be
- * turned into a valid URL.
- * @throws IOException
- * Error reading subordinate catalog file.
- */
- String resolveURI(String uri) throws MalformedURLException,
- IOException;
-
- /**
- * Adds catalog element to the collection of the catalog elements.
- *
- * @param element -
- * catalog element
- */
- void addCatalogElement(ICatalogElement element);
-
- /**
- * Removes catalog element from the collection of the catalog elements.
- *
- * @param element -
- * catalog element
- */
- void removeCatalogElement(ICatalogElement element);
-
- /**
- * Returns an array of catalog elements of type ICatalogElement.TYPE_ENTRY
- *
- * @return an array of catalog elements
- */
- ICatalogEntry[] getCatalogEntries();
-
- /**
- * Returns an array of catalog elements of type ICatalogElement.TYPE_REWRITE
- *
- * @return an array of rewrite catalog elements
- */
- IRewriteEntry[] getRewriteEntries();
-
- /**
- * Returns an array of catalog elements of type ICatalogElement.TYPE_SUFFIX
- *
- * @return an array of suffix entry elements
- */
- ISuffixEntry[] getSuffixEntries();
-
- /**
- * Returns an array of catalog elements of type ICatalogElement.TYPE_DELEGATE
- *
- * @return an array of delegate catalog elements
- */
- IDelegateCatalog[] getDelegateCatalogs();
-
- /**
- * Returns an array of catalog elements of type
- * ICatalogElement.TYPE_DELEGATE
- *
- * @return an array of catalog elements
- */
- INextCatalog[] getNextCatalogs();
-
- /**
- * Returns new catalog element with the specified type. If the type is one
- * of ELEMENT_TYPE, the result entry will have corresponding interface.
- *
- * @return
- */
- ICatalogElement createCatalogElement(int type);
-
- /**
- * Removes all the elements from this catalog.
- *
- */
- void clear();
-
- //void load() throws IOException;
-
- void save() throws IOException;
-
- /*
- * Loads catalog from the specified location. Expecting OASIS XML Catalog
- * format
- *
- * @param location -
- * uri of the file where catalog will be saved
-
- * @throws IOException -
- * problem loading file
- *
- */
- //void load(InputStream inputStream) throws IOException;
-
- /*
- * Saves catalog to the specified location in OASIS XML Catalog format
- *
- * @param location -
- * uri of the file where catalog will be saved
-
- * @throws IOException -
- * problem saving file
- *
- */
- //void save(OutputStream outputStream) throws IOException;
-
- /**
- * This method copies all catalog entries from source catalog to this one.
- *
- * @param catalog -
- * source catalog
- * @param includeNested -
- * a boolean flag indicating wether to include entries of the
- * same type from the nested catalogs
- */
- void addEntriesFromCatalog(ICatalog catalog);
-
- /**
- * Adds a listener of the catalog events
- *
- * @param listener -
- * listener of the catalog events
- * @see ICatalogEvent
- */
- void addListener(ICatalogListener listener);
-
- /**
- * Removes a listener of the catalog events
- *
- * @param listener -
- * listener of the catalog events
- * @see ICatalogEvent
- */
- void removeListener(ICatalogListener listener);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogElement.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogElement.java
deleted file mode 100644
index e011c9bce1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogElement.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog.provisional;
-
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface ICatalogElement
-{
- /** Types of the catalog entries */
- /** The PUBLIC, URI or SYSTEM Catalog Entry. */
- int TYPE_ENTRY = 1;
-
- /** The NEXT_CATALOG Catalog Entry type. */
- int TYPE_NEXT_CATALOG = 10;
-
- /** Rewrite types (since XML Catalogs 1.1) */
- int TYPE_REWRITE = 20;
-
- /** Delegate types (sinceXML Catalogs 1.1) */
- int TYPE_DELEGATE = 30;
-
- /** Suffix types (since XML Catalogs 1.1) */
- int TYPE_SUFFIX = 40;
-
- /**
- * Returns the value of the '<em><b>Type</b></em>' attribute.
- *
- * @return the value of the '<em>Type</em>' attribute.
- */
- int getType();
-
- /**
- * Returns the value of the attribute with specified name.
- *
- * @return the value of the attribute with specified name.
- * @see #setAttributeValue(String)
- */
- String getAttributeValue(String name);
-
- /**
- * Sets the value of the named attribute.
- *
- * @param name
- * the name of the attribute that will be set
- * @param value
- * the new value of the named attribute.
- * @see #getAttributeValue()
- */
- void setAttributeValue(String name, String value);
-
- /**
- * Returns an array of attribute names for any dynamic attributes that may exist
- *
- * @return array of attribute names
- * @see #getAttributeValue()
- * @see #setAttributeValue(String)
- */
- String[] getAttributes();
-
- /**
- * Returns element's id string
- *
- * @return element's id string
- */
- public String getId();
-
- /**
- * Sets element's id string
- *
- */
- public void setId(String id);
-
- public void setOwnerCatalog(ICatalog catalog);
-
- public ICatalog getOwnerCatalog();
-
- void setBase(String base);
-
- String getBase();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEntry.java
deleted file mode 100644
index 372dbfe4f5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEntry.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.catalog.provisional;
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface ICatalogEntry extends ICatalogElement
-{
- /** The PUBLIC Catalog Entry type. */
- public static final int ENTRY_TYPE_PUBLIC = 2;
-
- /** The SYSTEM Catalog Entry type. */
- public static final int ENTRY_TYPE_SYSTEM = 3;
-
- /** The URI Catalog Entry type. */
- public static final int ENTRY_TYPE_URI = 4;
-
- /** Attribute name for Web address of catalog entry */
- public static final String ATTR_WEB_URL = "webURL"; //$NON-NLS-1$
-
- /**
- *
- * @param entryType
- */
- public void setEntryType(int entryType);
-
- /**
- *
- * @return
- */
- public int getEntryType();
-
- /**
- *
- * @param key
- */
- public void setKey(String key);
-
- /**
- *
- * @return
- */
- public String getKey();
-
- /**
- *
- * @return
- */
- public String getURI();
-
- /**
- *
- * @param uri
- */
- public void setURI(String uri);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEvent.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEvent.java
deleted file mode 100644
index 7825768172..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogEvent.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * 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.catalog.provisional;
-
-
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface ICatalogEvent
-{
- /** */
- public static final int CHANGED = 0;
-
- public static final int ELEMENT_ADDED = 1;
-
- /** */
- public static final int ELEMENT_REMOVED = 2;
-
- /** */
- public static final int ELEMENT_CHANGED = 3;
-
- /**
- *
- * @return
- */
- public int getEventType();
-
- /**
- *
- * @return
- */
- public ICatalog getCatalog();
-
- /**
- *
- * @return
- */
- public ICatalogElement getCatalogElement();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogListener.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogListener.java
deleted file mode 100644
index 7c3dc0d3fe..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ICatalogListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * 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.catalog.provisional;
-
-import java.util.EventListener;
-
-
-/**
- * The clients of the catalog that want to listen to catalog changes should
- * implement this interface.
- *
- * @see ICatalog, ICatalogEvent,
- *
- */
-public interface ICatalogListener extends EventListener
-{
- /**
- * This method allows to react to catalog events
- *
- * @param event -
- * an event that client should react to
- */
- public void catalogChanged(ICatalogEvent event);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IDelegateCatalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IDelegateCatalog.java
deleted file mode 100644
index 82040b0a7d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IDelegateCatalog.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog.provisional;
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface IDelegateCatalog extends ICatalogElement
-{
- /** The SYSTEM Catalog Entry type. */
- int DELEGATE_TYPE_PUBLIC = 31;
-
- /** The SYSTEM Catalog Entry type. */
- int DELEGATE_TYPE_SYSTEM = 32;
-
- /** The URI Catalog Entry type. */
- int DELEGATE_TYPE_URI = 33;
-
- /**
- *
- * @param entryType
- */
- void setEntryType(int entryType);
-
- /**
- *
- * @return
- */
- int getEntryType();
-
- /**
- *
- * @param key
- */
- void setStartString(String key);
-
- /**
- *
- * @return
- */
- String getStartString();
-
- /**
- * Set location of the referenced catalog.
- *
- * @param uri -
- * location uri of the referenced catalog
- */
- void setCatalogLocation(String uri);
-
- /**
- * Get location uri of the referenced catalog.
- *
- * @return location uri of the referenced catalog
- */
- String getCatalogLocation();
-
- ICatalog getReferencedCatalog();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/INextCatalog.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/INextCatalog.java
deleted file mode 100644
index 47c939cf80..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/INextCatalog.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.catalog.provisional;
-
-
-
-/**
- *
- * A representation of the nextCatalog OASIS XML catalog element. Object of the
- * class that implements this interface would serve as a reference to the
- * catalog object.
- *
- * @see ICatalog, ICatalogElement
- *
- * This interface currently is used only by the catalog itself. Need to find if
- * there are any clients that need it.
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface INextCatalog extends ICatalogElement
-{
- /**
- * Set location of the referenced catalog.
- *
- * @param uri -
- * location uri of the referenced catalog
- */
- public void setCatalogLocation(String uri);
-
- /**
- * Get location uri of the referenced catalog.
- *
- * @return location uri of the referenced catalog
- */
- public String getCatalogLocation();
-
- public ICatalog getReferencedCatalog();
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IRewriteEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IRewriteEntry.java
deleted file mode 100644
index 9d9559220e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/IRewriteEntry.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog.provisional;
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface IRewriteEntry extends ICatalogElement
-{
- /** The rewriteSystem Catalog type. */
- int REWRITE_TYPE_SYSTEM = 21;
-
- /** The URI Catalog Entry type. */
- int REWRITE_TYPE_URI = 22;
-
- /**
- *
- * @param entryType
- */
- void setEntryType(int entryType);
-
- /**
- *
- * @return
- */
- int getEntryType();
-
- /**
- *
- * @param key
- */
- void setStartString(String startString);
-
- /**
- *
- * @return
- */
- String getStartString();
-
- /**
- *
- * @return
- */
- String getRewritePrefix();
-
- /**
- *
- * @param uri
- */
- void setRewritePrefix(String uri);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ISuffixEntry.java b/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ISuffixEntry.java
deleted file mode 100644
index 0004014004..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/provisional/ISuffixEntry.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jesper Steen Moeller
- * 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:
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.catalog.provisional;
-
-/**
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- */
-public interface ISuffixEntry extends ICatalogElement
-{
- /** The rewriteSystem Catalog type. */
- int SUFFIX_TYPE_SYSTEM = 41;
-
- /** The URI Catalog Entry type. */
- int SUFFIX_TYPE_URI = 42;
-
- /**
- *
- * @param entryType
- */
- void setEntryType(int entryType);
-
- /**
- *
- * @return
- */
- int getEntryType();
-
- /**
- *
- * @param key
- */
- void setSuffix(String suffixString);
-
- /**
- *
- * @return
- */
- String getSuffix();
-
- /**
- *
- * @return
- */
- String getURI();
-
- /**
- *
- * @param uri
- */
- void setURI(String uri);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/contentmodel/modelquery/IExternalSchemaLocationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/contentmodel/modelquery/IExternalSchemaLocationProvider.java
deleted file mode 100644
index 0f0a43defa..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/contentmodel/modelquery/IExternalSchemaLocationProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2011 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
- ******************************************************************************/
-package org.eclipse.wst.xml.core.contentmodel.modelquery;
-
-import java.net.URI;
-import java.util.Map;
-
-public interface IExternalSchemaLocationProvider extends org.eclipse.wst.xml.core.internal.contentmodel.modelquery.IExternalSchemaLocationProvider {
- String SCHEMA_LOCATION = "http://apache.org/xml/properties/schema/external-schemaLocation"; //$NON-NLS-1$
- String NO_NAMESPACE_SCHEMA_LOCATION = "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"; //$NON-NLS-1$
-
- /**
- * Provided the file path URI, this will return the external schema location. The schema location is associated to a specific property,
- * which serves as the key in the map. The supported properties are:
- *
- * <p><b>http://apache.org/xml/properties/schema/external-schemaLocation</b> - The value for this property follows the same rules
- * as the schemaLocation attribute for an XML document (i.e., multiple schemas are acceptable and must be white-space separated).</p>
- *
- * <p><b>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</b> - The value for this property follows the same
- * rules as the noNamespaceSchemaLocation attribute for an XML document (i.e., only one schema is allowed).
- *
- * @param filePath the path for the XML file
- * @return a {@link Map} associating the external-schemaLocation and/or external-noNamespaceSchemaLocation to the schema location
- */
- Map getExternalSchemaLocation(URI fileURI);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAnyElement.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAnyElement.java
deleted file mode 100644
index 72a47024da..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAnyElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMAnyElement interface
- */
-public interface CMAnyElement extends CMContent {
-/**
- * getNamespaceURI method
- * @return java.lang.String
- */
-String getNamespaceURI();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAttributeDeclaration.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAttributeDeclaration.java
deleted file mode 100644
index c5f718fc13..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMAttributeDeclaration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * 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.Enumeration;
-
-/**
- * AttributeDeclaration interface
- */
-public interface CMAttributeDeclaration extends CMNode {
- public static final int OPTIONAL = 1;
- public static final int REQUIRED = 2;
- public static final int FIXED = 3;
- public static final int PROHIBITED = 4;
-/**
- * getAttrName method
- * @return java.lang.String
- */
-String getAttrName();
-/**
- * getAttrType method
- * @return CMDataType
- */
-CMDataType getAttrType();
-/**
- * getDefaultValue method
- * @return java.lang.String
- * @deprecated -- to be replaced in future with additional CMDataType methods (currently found on CMDataTypeHelper)
- */
-String getDefaultValue();
-/**
- * getEnumAttr method
- * @return java.util.Enumeration
- * @deprecated -- to be replaced in future with additional CMDataType methods (currently found on CMDataTypeHelper)
- */
-Enumeration getEnumAttr();
-/**
- * getUsage method
- * @return int
- */
-int getUsage();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMContent.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMContent.java
deleted file mode 100644
index 218b29751d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMContent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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;
-
-public interface CMContent extends CMNode
-{
-/**
- * getMaxOccur method
- * @return int
- *
- * If -1, it's UNBOUNDED.
- */
-int getMaxOccur();
-/**
- * getMinOccur method
- * @return int
- *
- * If 0, it's OPTIONAL.
- * If 1, it's REQUIRED.
- */
-int getMinOccur();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDataType.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDataType.java
deleted file mode 100644
index b6472284be..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDataType.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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;
-
-/**
- * CMDataType
- */
-public interface CMDataType extends CMNode {
-
- // todo... at some point we should remove these names to
- // avoid exposing implementation details via the interfaces
- //
- static final String CDATA = "CDATA"; //$NON-NLS-1$
- static final String ID = "ID"; //$NON-NLS-1$
- static final String IDREF = "IDREF"; //$NON-NLS-1$
- static final String IDREFS = "IDREFS"; //$NON-NLS-1$
- static final String ENTITY = "ENTITY"; //$NON-NLS-1$
- static final String ENTITIES = "ENTITIES"; //$NON-NLS-1$
- static final String NOTATION = "NOTATION"; //$NON-NLS-1$
- static final String NMTOKEN = "NMTOKEN"; //$NON-NLS-1$
- static final String NMTOKENS = "NMTOKENS"; //$NON-NLS-1$
- static final String NUMBER = "NUMBER"; //$NON-NLS-1$
- static final String URI = "URI"; //$NON-NLS-1$
- static final String ENUM = "ENUM"; //$NON-NLS-1$
-
- static final int IMPLIED_VALUE_NONE = 1;
- static final int IMPLIED_VALUE_FIXED = 2;
- static final int IMPLIED_VALUE_DEFAULT = 3;
-
-/**
- * getTypeName method
- * @return java.lang.String
- */
-String getDataTypeName();
-
-/**
- * getImpliedValueKind method
- * @return int
- *
- * Returns one of :
- * IMPLIED_VALUE_NONE, IMPLIED_VALUE_FIXED, IMPLIED_VALUE_DEFAULT.
- */
-
-int getImpliedValueKind();
-
-/**
- * getTypeName method
- * @return java.lang.String
- *
- * Returns the implied value or null if none exists.
- */
-String getImpliedValue();
-
-/**
- * getTypeName method
- * @return java.lang.String[]
- *
- */
-String[] getEnumeratedValues();
-
-/**
- * getTypeName method
- * @return java.lang.String
- *
- * This method returns a suitable default value that can be used when an instance of the data type is created.
- * This returns null of a suitable default is not available.
- */
-String generateInstanceValue();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocument.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocument.java
deleted file mode 100644
index 58d7a437f8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocument.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMDocument interface
- */
-public interface CMDocument extends CMNode {
-/**
- * getElements method
- * @return CMNamedNodeMap
- *
- * Returns CMNamedNodeMap of ElementDeclaration
- */
-CMNamedNodeMap getElements();
-/**
- * getEntities method
- * @return CMNamedNodeMap
- *
- * Returns CMNamedNodeMap of EntityDeclaration
- */
-CMNamedNodeMap getEntities();
-/**
- * getNamespace method
- * @return CMNamespace
- */
-CMNamespace getNamespace();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocumentation.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocumentation.java
deleted file mode 100644
index 88e4d8dc3b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMDocumentation.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMDocumentation interface
- */
-public interface CMDocumentation extends CMNode {
- public String getValue();
- public String getLanguage();
- public String getSource();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMElementDeclaration.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMElementDeclaration.java
deleted file mode 100644
index 2c48077e8a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMElementDeclaration.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMElementDeclaration interface
- */
-public interface CMElementDeclaration extends CMContent {
-
- public static final int ANY = 0;
- public static final int EMPTY = 1;
- public static final int ELEMENT = 2;
- public static final int MIXED = 3;
- public static final int PCDATA = 4;
- public static final int CDATA = 5; // todo... clarify this one
-/**
- * getAttributes method
- * @return CMNamedNodeMap
- *
- * Returns CMNamedNodeMap of AttributeDeclaration
- */
-CMNamedNodeMap getAttributes();
-/**
- * getCMContent method
- * @return CMContent
- *
- * Returns the root node of this element's content model.
- * This can be an CMElementDeclaration or a CMGroup
- */
-CMContent getContent();
-/**
- * getContentType method
- * @return int
- *
- * Returns one of :
- * ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA.
- */
-public int getContentType();
-/**
- * getElementName method
- * @return java.lang.String
- */
-String getElementName();
-
-/**
- * getDataType method
- * @return java.lang.String
- */
-CMDataType getDataType();
-
-/**
- * getLocalElements method
- * @return CMNamedNodeMap
- *
- * Returns a list of locally defined elements.
- */
-CMNamedNodeMap getLocalElements();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMEntityDeclaration.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMEntityDeclaration.java
deleted file mode 100644
index 99b5434385..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMEntityDeclaration.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMEntityDeclaration interface
- */
-public interface CMEntityDeclaration extends CMNode {
-
-/**
- * getName method
- * @return java.lang.String
- */
-String getName();
-/**
- * getValue method
- * @return java.lang.String
- */
-String getValue();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMGroup.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMGroup.java
deleted file mode 100644
index ce01ca7410..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMGroup.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMGroup interface
- */
-public interface CMGroup extends CMContent {
-
- static final int ALL = 3;
- static final int CHOICE = 2;
- static final int SEQUENCE = 1;
-/**
- * getChildNodes method
- * @return CMNodeList
- *
- * Returns child CMNodeList, which includes ElementDefinition or CMElement.
- */
-CMNodeList getChildNodes();
-
-/**
- * getOperation method
- * @return int
- *
- * Returns one of :
- * ALONE (a), SEQUENCE (a,b), CHOICE (a|b), ALL (a&b).
- */
-int getOperator();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamedNodeMap.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamedNodeMap.java
deleted file mode 100644
index 2c79b81f73..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamedNodeMap.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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.Iterator;
-/**
- * NamedCMNodeMap
- */
-public interface CMNamedNodeMap {
-/**
- * getLength method
- * @return int
- */
-int getLength();
-/**
- * getNamedItem method
- * @return CMNode
- * @param name java.lang.String
- */
-CMNode getNamedItem(String name);
-/**
- * item method
- * @return CMNode
- * @param index int
- */
-CMNode item(int index);
-
-/**
- *
- */
-Iterator iterator();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamespace.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamespace.java
deleted file mode 100644
index 100bcbc53c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNamespace.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMNamespace interface
- */
-public interface CMNamespace extends CMNode {
-
-/**
- * getPrefix method
- * @return java.lang.String
- */
-String getPrefix();
-/**
- * getURI method
- * @return java.lang.String
- */
-String getURI();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNode.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNode.java
deleted file mode 100644
index 8bd95e8a64..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNode.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMNode interface
- */
-public interface CMNode {
-
- static final int ANY_ELEMENT = 1;
- static final int ATTRIBUTE_DECLARATION = 2;
- static final int DATA_TYPE = 3;
- static final int DOCUMENT = 4;
- static final int ELEMENT_DECLARATION = 5;
- static final int ENTITY_DECLARATION = 6;
- static final int GROUP = 7;
- static final int NAME_SPACE = 8;
- static final int DOCUMENTATION = 9;
-/**
- * getNodeName method
- * @return java.lang.String
- */
-String getNodeName();
-/**
- * getNodeType method
- * @return int
- *
- * Returns one of :
- *
- */
-int getNodeType();
-
-/**
- * supports method
- * @return boolean
- *
- * Returns true if the CMNode supports a specified property
- *
- */
-boolean supports(String propertyName);
-
-/**
- * getProperty method
- * @return java.lang.Object
- *
- * Returns the object property desciped by the propertyName
- *
- */
-Object getProperty(String propertyName); //todo throw unsupported property exception
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNodeList.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNodeList.java
deleted file mode 100644
index 94adbf8c81..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/CMNodeList.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * 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;
-
-/**
- * CMNodeList interface
- */
-public interface CMNodeList {
-
-/**
- * getLength method
- * @return int
- */
-int getLength();
-/**
- * item method
- * @return CMNode
- * @param index int
- */
-CMNode item(int index);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/ContentModelManager.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/ContentModelManager.java
deleted file mode 100644
index 602b16064b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/ContentModelManager.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * 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;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/Annotation.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/Annotation.java
deleted file mode 100644
index e0a3b3927d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/Annotation.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.annotation;
-
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- *
- */
-public class Annotation
-{
- protected Hashtable hashtable = new Hashtable();
-
- public Annotation()
- {
- }
-
- public void setSpec(String spec)
- {
- hashtable.put("spec", spec); //$NON-NLS-1$
- }
-
- public String getSpec()
- {
- return (String)hashtable.get("spec"); //$NON-NLS-1$
- }
-
- public void setProperty(String name, String value)
- {
- hashtable.put(name, value);
- }
-
- public String getProperty(String propertyName)
- {
- return (String)hashtable.get(propertyName);
- }
-
- public List getAttributeList()
- {
- return null; // todo
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/AnnotationMap.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/AnnotationMap.java
deleted file mode 100644
index 4b930350cd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/annotation/AnnotationMap.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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.annotation;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import com.ibm.icu.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation.AnnotationFileInfo;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation.AnnotationFileParser;
-
-
-/**
- * AnnotationMap
- */
-public class AnnotationMap {
- protected List list = new Vector();
- protected Hashtable hashtable = new Hashtable();
- protected boolean isCaseSensitive = true;
-
- public AnnotationMap() {
- }
-
- public void setCaseSensitive(boolean isCaseSensitive) {
- this.isCaseSensitive = isCaseSensitive;
- }
-
- public void addAnnotation(Annotation annotation) {
- String spec = annotation.getSpec();
- if (spec != null) {
- list.add(annotation);
- StringTokenizer st = new StringTokenizer(spec, "[]|\t\n\r\f "); //$NON-NLS-1$
- while (st.hasMoreTokens()) {
- String cmNodeSpec = st.nextToken();
- addAnnotationForCMNodeSpec(cmNodeSpec, annotation);
- }
- }
- }
-
- protected void addAnnotationForCMNodeSpec(String cmNodeSpec, Annotation annotation) {
- String key = isCaseSensitive ? cmNodeSpec : cmNodeSpec.toLowerCase();
- List list = (List) hashtable.get(key);
- if (list == null) {
- list = new Vector();
-
- hashtable.put(key, list);
- }
- list.add(annotation);
- }
-
- public String getProperty(String cmNodeSpec, String propertyName) {
- String result = null;
- String key = isCaseSensitive ? cmNodeSpec : cmNodeSpec.toLowerCase();
- List annotationList = (List) hashtable.get(key);
- if (annotationList != null) {
- for (Iterator i = annotationList.iterator(); i.hasNext();) {
- Annotation annotation = (Annotation) i.next();
- result = annotation.getProperty(propertyName);
- if (result != null) {
- break;
- }
- }
- }
- return result;
- }
-
- public String getProperty(CMNode cmNode, String propertyName) {
- String result = null;
- String cmNodeSpec = (String) cmNode.getProperty("spec"); //$NON-NLS-1$
- if (cmNodeSpec == null) {
- cmNodeSpec = cmNode.getNodeName();
- }
- if (cmNodeSpec != null) {
- result = getProperty(cmNodeSpec, propertyName);
- }
- return result;
- }
-
- public List getAnnotations() {
- return list;
- }
-
- public void load(String uri, String bundleId) throws Exception {
- AnnotationFileParser parser = new AnnotationFileParser();
- AnnotationFileInfo fileInfo = new AnnotationFileInfo(uri, bundleId);
- parser.parse(this, fileInfo);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAnyElementImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAnyElementImpl.java
deleted file mode 100644
index 8300a90e14..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAnyElementImpl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-
-
-public class CMAnyElementImpl extends CMContentImpl implements CMAnyElement
-{
- protected String namespaceURI;
-
- public CMAnyElementImpl(String namespaceURI)
- {
- this.namespaceURI = namespaceURI;
- minOccur = -1;
- }
-
- public static String computeNodeName(String uri)
- {
- return uri != null ? ("any#" + uri) : "any"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // implements CMNode
- //
- public String getNodeName()
- {
- return computeNodeName(namespaceURI);
- }
-
- public int getNodeType()
- {
- return ANY_ELEMENT;
- }
-
- // implements CMAnyElement
- //
- public String getNamespaceURI()
- {
- return namespaceURI;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAttributeDeclarationImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAttributeDeclarationImpl.java
deleted file mode 100644
index 4b554b63cd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMAttributeDeclarationImpl.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.basic;
-
-import java.util.Enumeration;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-
-public class CMAttributeDeclarationImpl extends CMNodeImpl implements CMAttributeDeclaration
-{
- protected CMDataType dataType;
- protected String nodeName;
- protected int usage;
- protected CMDocument cmDocument;
- protected boolean prefixQualification;
- protected List xsiTypes;
-
- public CMAttributeDeclarationImpl(String nodeName, int usage)
- {
- this(nodeName, usage, new CMDataTypeImpl(CMDataType.CDATA, ""));
- }
-
- public CMAttributeDeclarationImpl(String nodeName, int usage, CMDataType dataType)
- {
- this.nodeName = nodeName;
- this.usage = usage;
- this.dataType = dataType;
- }
-
- public int getNodeType()
- {
- return CMNode.ATTRIBUTE_DECLARATION;
- }
-
- public Object getProperty(String propertyName)
- {
- Object result = null;
- if (propertyName.equals("CMDocument")) //$NON-NLS-1$
- {
- result = cmDocument;
- }
- else if (propertyName.equals("XSITypes")) //$NON-NLS-1$
- {
- result = xsiTypes;
- }
- else if (propertyName.equals("http://org.eclipse.wst/cm/properties/nsPrefixQualification")) //$NON-NLS-1$
- {
- result = prefixQualification ? "qualified" : "unqualified"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- {
- result = super.getProperty(propertyName);
- }
- return result;
- }
-
- public void setPrefixQualification(boolean qualified)
- {
- prefixQualification = qualified;
- }
-
- public void setXSITypes(List list)
- {
- xsiTypes = list;
- }
-
- public void setCMDocument(CMDocument cmDocument)
- {
- this.cmDocument = cmDocument;
- }
-
- public String getNodeName()
- {
- return nodeName;
- }
-
- public String getAttrName()
- {
- return nodeName;
- }
-
- public void setAttrType(CMDataType dataType)
- {
- this.dataType = dataType;
- }
-
- public CMDataType getAttrType()
- {
- return dataType;
- }
-
- public int getUsage()
- {
- return usage;
- }
-
- /** @deprecated */
- public String getDefaultValue()
- {
- return ""; //$NON-NLS-1$
- }
-
- /** @deprecated */
- public Enumeration getEnumAttr()
- {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMContentImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMContentImpl.java
deleted file mode 100644
index 2357eec6ee..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMContentImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-
-
-public abstract class CMContentImpl extends CMNodeImpl implements CMContent
-{
- protected int minOccur = 0;
- protected int maxOccur = -1;
-
- // implements CMContent
- //
- public int getMaxOccur()
- {
- return maxOccur;
- }
-
- public int getMinOccur()
- {
- return minOccur;
- }
-
- // implementation specific
- //
- public void setMaxOccur(int n)
- {
- maxOccur = n;
- }
-
- public void setMinOccur(int n)
- {
- minOccur = n;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDataTypeImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDataTypeImpl.java
deleted file mode 100644
index a004626c01..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDataTypeImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-public class CMDataTypeImpl extends CMNodeImpl implements CMDataType
-{
- protected String dataTypeName;
- protected String[] enumeratedValues;
- protected String instanceValue;
-
- public CMDataTypeImpl(String dataTypeName, String instanceValue)
- {
- this.dataTypeName = dataTypeName;
- this.instanceValue = instanceValue;
- this.enumeratedValues = new String[0];
- }
-
- public CMDataTypeImpl(String dataTypeName, String[] enumeratedValues)
- {
- this.dataTypeName = dataTypeName;
- this.enumeratedValues = enumeratedValues;
- this.instanceValue = enumeratedValues[0];
- }
-
-
- public int getNodeType()
- {
- return CMNode.DATA_TYPE;
- }
-
- public String getNodeName()
- {
- return getDataTypeName();
- }
-
- public String getDataTypeName()
- {
- return dataTypeName;
- }
-
- public int getImpliedValueKind()
- {
- return IMPLIED_VALUE_NONE;
- }
-
- public String getImpliedValue()
- {
- return null;
- }
-
- public String[] getEnumeratedValues()
- {
- return enumeratedValues;
- }
-
- public String generateInstanceValue()
- {
- return instanceValue;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDocumentImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDocumentImpl.java
deleted file mode 100644
index 7c76a8e453..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMDocumentImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamespace;
-
-
-public class CMDocumentImpl extends CMNodeImpl implements CMDocument
-{
- protected String targetNamespace;
- protected CMNamedNodeMapImpl elements = new CMNamedNodeMapImpl();
- protected CMNamedNodeMapImpl localElementPool;
- protected CMNamedNodeMapImpl anyElements;
-
- public CMDocumentImpl(String targetNamespace)
- {
- this.targetNamespace = targetNamespace;
- }
-
- public int getNodeType()
- {
- return DOCUMENT;
- }
-
- public String getNodeName()
- {
- return ""; //$NON-NLS-1$
- }
-
- public Object getProperty(String propertyName)
- {
- Object result = null;
- if (propertyName.equals("http://org.eclipse.wst/cm/properties/targetNamespaceURI")) //$NON-NLS-1$
- {
- result = targetNamespace;
- }
- else
- {
- result = super.getProperty(propertyName);
- }
- return result;
- }
-
- public CMNamedNodeMap getElements()
- {
- return elements;
- }
-
- public CMNamedNodeMapImpl getAnyElements()
- {
- if (anyElements == null)
- {
- anyElements = new CMNamedNodeMapImpl();
- }
- return anyElements;
- }
-
- public CMNamedNodeMapImpl getLocalElementPool()
- {
- if (localElementPool == null)
- {
- localElementPool = new CMNamedNodeMapImpl();
- }
- return localElementPool;
- }
-
- public CMNamedNodeMap getEntities()
- {
- return new CMNamedNodeMapImpl();
- }
-
- public CMNamespace getNamespace()
- {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMElementDeclarationImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMElementDeclarationImpl.java
deleted file mode 100644
index 1879b9f777..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMElementDeclarationImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-
-
-public class CMElementDeclarationImpl extends CMContentImpl implements CMElementDeclaration
-{
- protected String name;
- protected CMDocument cmDocument;
- protected CMNamedNodeMapImpl attributeMap = new CMNamedNodeMapImpl();
- protected CMNamedNodeMapImpl localElementMap = new CMNamedNodeMapImpl();
- protected CMContent content;
- protected CMDataType dataType;
- protected boolean isLocal;
-
- public CMElementDeclarationImpl(CMDocument cmDocument, String name)
- {
- this.cmDocument = cmDocument;
- this.name = name;
- }
-
- // implements CMNode
- //
- public String getNodeName()
- {
- return name;
- }
-
- public int getNodeType()
- {
- return ELEMENT_DECLARATION;
- }
-
- public Object getProperty(String propertyName)
- {
- Object result = null;
- if (propertyName.equals("http://org.eclipse.wst/cm/properties/nsPrefixQualification")) //$NON-NLS-1$
- {
- result = isLocal ? "unqualified" : "qualified"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if (propertyName.equals("CMDocument")) //$NON-NLS-1$
- {
- result = cmDocument;
- }
- else
- {
- result = super.getProperty(propertyName);
- }
- return result;
- }
-
- // implements CMElementDeclaration
- //
- public CMNamedNodeMap getAttributes()
- {
- return attributeMap;
- }
-
- public CMContent getContent()
- {
- return content;
- }
-
- public int getContentType()
- {
- return MIXED;
- }
-
- public String getElementName()
- {
- return name;
- }
-
- public CMDataType getDataType()
- {
- return dataType;
- }
-
- public CMNamedNodeMap getLocalElements()
- {
- return localElementMap;
- }
-
- //
- //
- public void setContent(CMContent cmContent)
- {
- content = cmContent;
- }
-
- public void setDataType(CMDataType cmDataType)
- {
- dataType = cmDataType;
- }
-
- public CMNamedNodeMapImpl getAttributeMap()
- {
- return attributeMap;
- }
-
- public void setLocal(boolean isLocal)
- {
- this.isLocal = isLocal;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMEntityDeclarationImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMEntityDeclarationImpl.java
deleted file mode 100644
index a5d97fae9b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMEntityDeclarationImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMEntityDeclaration;
-
-public class CMEntityDeclarationImpl extends CMNodeImpl implements CMEntityDeclaration
-{
- protected String name;
- protected String value;
-
- public CMEntityDeclarationImpl(String name, String value)
- {
- this.name = name;
- this.value = value;
- }
-
- public int getNodeType()
- {
- return ENTITY_DECLARATION;
- }
-
- public String getNodeName()
- {
- return name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getValue()
- {
- return value;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMGroupImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMGroupImpl.java
deleted file mode 100644
index 59c4eced52..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMGroupImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-
-public class CMGroupImpl extends CMContentImpl implements CMGroup
-{
- protected CMNodeList nodeList;
- protected int operator;
-
- public CMGroupImpl(CMNodeList nodeList, int operator)
- {
- this.nodeList = nodeList;
- this.operator = operator;
- }
-
- public int getNodeType()
- {
- return GROUP;
- }
-
- public CMNodeList getChildNodes()
- {
- return nodeList;
- }
-
- public int getOperator()
- {
- return operator;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNamedNodeMapImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNamedNodeMapImpl.java
deleted file mode 100644
index fee63d247c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNamedNodeMapImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-
-
-public class CMNamedNodeMapImpl implements CMNamedNodeMap
-{
- public static CMNamedNodeMapImpl EMPTY_NAMED_NODE_MAP = new CMNamedNodeMapImpl();
- protected Hashtable table = new Hashtable();
-
- /**
- * CMNamedNodeMapImpl constructor comment.
- */
- public CMNamedNodeMapImpl()
- {
- super();
- }
-
- public CMNamedNodeMapImpl(CMNamedNodeMap initialContentsMap) {
- super();
- if (initialContentsMap != null) {
- int length = initialContentsMap.getLength();
- for (int j = 0; j < length; j++) {
- put(initialContentsMap.item(j));
- }
- }
- }
- /**
- * getLength method
- * @return int
- */
- public int getLength()
- {
- return table.size();
- }
-
- /**
- * getNamedItem method
- * @return CMNode
- * @param name java.lang.String
- */
- public CMNode getNamedItem(String name)
- {
- return (CMNode)table.get(name);
- }
-
- /**
- * item method
- * @return CMNode
- * @param index int
- */
- public CMNode item(int index)
- {
- CMNode result = null;
- int size = table.size();
- if (index < size)
- {
- Enumeration values = table.elements();
- for(int i = 0; i <= index; i++)
- {
- result = (CMNode)values.nextElement();
- }
- }
- return result;
- }
-
- public Hashtable getHashtable()
- {
- return table;
- }
-
- public Iterator iterator()
- {
- return table.values().iterator();
- }
-
- public void put(CMNode cmNode)
- {
- table.put(cmNode.getNodeName(), cmNode);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeImpl.java
deleted file mode 100644
index a12e2acae9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-
-public abstract class CMNodeImpl implements CMNode
-{
- protected boolean isInferred = false;
-
- public String getNodeName()
- {
- return ""; //$NON-NLS-1$
- }
-
- public boolean supports(String propertyName)
- {
- return false;
- }
-
- public Object getProperty(String propertyName)
- {
- Object result = null;
- if ("isInferred".equals(propertyName)) //$NON-NLS-1$
- {
- result = isInferred ? Boolean.TRUE : Boolean.FALSE;
- }
- return result;
- }
-
- public void setInferred(boolean isInferred)
- {
- this.isInferred = isInferred;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeListImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeListImpl.java
deleted file mode 100644
index 6bcba3862b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/basic/CMNodeListImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.basic;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-
-
-public class CMNodeListImpl implements CMNodeList
-{
- public static CMNodeListImpl EMPTY_NODE_LIST = new CMNodeListImpl(Collections.EMPTY_LIST);
- protected List list;
-
- public CMNodeListImpl()
- {
- this(new Vector());
- }
-
- public CMNodeListImpl(List list)
- {
- this.list = list;
- }
-
- /**
- * getLength method
- * @return int
- */
- public int getLength()
- {
- return list.size();
- }
- /**
- * item method
- * @return CMNode
- * @param index int
- */
- public CMNode item(int index)
- {
- return (CMNode)list.get(index);
- }
-
- public List getList()
- {
- return list;
- }
-
- public Iterator iterator()
- {
- return list.iterator();
- }
-
- public boolean contains(CMNode cmNode)
- {
- return list.contains(cmNode);
- }
-
- public void add(CMNode cmNode)
- {
- list.add(cmNode);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactory.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactory.java
deleted file mode 100644
index a84be9551a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactory.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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.factory;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-
-// this interface is used to build a grammar document given a local file name
-//
-public interface CMDocumentFactory
-{
- public CMDocument createCMDocument(String uri);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryDescriptor.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryDescriptor.java
deleted file mode 100644
index c737b92df8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryDescriptor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.factory;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-public class CMDocumentFactoryDescriptor
-{
- private IConfigurationElement fElement;
- private CMDocumentFactory factory;
-
- public CMDocumentFactoryDescriptor(IConfigurationElement element)
- {
- this.fElement = element;
- }
-
- public CMDocumentFactory getFactory()
- {
- if (factory == null)
- {
- try
- {
- factory = (CMDocumentFactory) fElement.createExecutableExtension("class"); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- Logger.logException("Exception loading CMDocumentFactory",e); //$NON-NLS-1$
- }
- }
- return factory;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistry.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistry.java
deleted file mode 100644
index 9f403b9a16..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.factory;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-/**
- *
- *
- */
-public class CMDocumentFactoryRegistry
-{
- protected static CMDocumentFactoryRegistry instance;
-
- private static String DEFAULT_RESOURCE_TYPE = "*"; //$NON-NLS-1$
-
- protected Map resourceTypeMap = new HashMap();
-
- protected Vector documentBuilderList = new Vector();
-
- public CMDocumentFactoryRegistry() {
- }
-
- public void putFactory(String resourceType, CMDocumentFactoryDescriptor factoryDescriptor) {
- resourceTypeMap.put(resourceType, factoryDescriptor);
- }
-
- public CMDocumentFactory getFactory(String resourceType) {
- CMDocumentFactoryDescriptor factoryDescriptor = null;
- if (resourceType != null) {
- factoryDescriptor = (CMDocumentFactoryDescriptor) resourceTypeMap.get(resourceType);
- }
- if (factoryDescriptor == null) {
- // (dmw) issue: a default type of '*' means what? registered as
- // '*' is the way this works now. is that the intent? Or should it
- // mean registered as any other type?
- factoryDescriptor = (CMDocumentFactoryDescriptor) resourceTypeMap.get(DEFAULT_RESOURCE_TYPE);
- }
- return factoryDescriptor != null ? factoryDescriptor.getFactory() : null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistryReader.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistryReader.java
deleted file mode 100644
index 6c8b193604..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/factory/CMDocumentFactoryRegistryReader.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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.factory;
-
-import com.ibm.icu.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-
-
-public class CMDocumentFactoryRegistryReader
-{
- protected static final String EXTENSION_POINT_ID = "documentFactories"; //$NON-NLS-1$
- protected static final String TAG_NAME = "factory"; //$NON-NLS-1$
- protected static final String ATT_CLASS = "class"; //$NON-NLS-1$
- protected static final String ATT_TYPE = "type"; //$NON-NLS-1$
- protected String pluginId, extensionPointId;
-
- protected CMDocumentFactoryRegistry registry;
-
- public CMDocumentFactoryRegistryReader(CMDocumentFactoryRegistry registry)
- {
- this.registry = registry;
- }
-
- public void readRegistry()
- {
- String bundleid = "org.eclipse.wst.xml.core"; //$NON-NLS-1$
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(bundleid, EXTENSION_POINT_ID);
- if (point != null)
- {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++)
- {
- readElement(elements[i]);
- }
- }
- }
-
- protected void readElement(IConfigurationElement element)
- {
- if (element.getName().equals(TAG_NAME))
- {
- String factoryClass = element.getAttribute(ATT_CLASS);
- String filenameExtensions = element.getAttribute(ATT_TYPE);
- if (factoryClass != null && filenameExtensions != null)
- {
- try
- {
- CMDocumentFactoryDescriptor descriptor = new CMDocumentFactoryDescriptor(element);
- for (StringTokenizer st = new StringTokenizer(filenameExtensions, ","); st.hasMoreTokens(); ) //$NON-NLS-1$
- {
- String token = st.nextToken().trim();
- registry.putFactory(token, descriptor);
- }
- }
- catch (Exception e)
- {
- Logger.logException(e);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileInfo.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileInfo.java
deleted file mode 100644
index a9a372f01e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileInfo.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-/**
- * Contains information about annotation files
- */
-public class AnnotationFileInfo {
- private String fAnnotationFileLocation;
- private String fBundleId;
-
- public AnnotationFileInfo(String annotationFileLocation, String bundleId) {
- fAnnotationFileLocation = annotationFileLocation;
- fBundleId = bundleId;
- }
-
- /**
- * Get the location of the annotation file as originally specified.
- *
- * @return String
- */
- public String getAnnotationFileLocation() {
- return fAnnotationFileLocation;
- }
-
- /**
- * Get the bundle id where the annotation file is located.
- *
- * @return String
- */
- public String getBundleId() {
- return fBundleId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileParser.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileParser.java
deleted file mode 100644
index 641915df34..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileParser.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.annotation.Annotation;
-import org.eclipse.wst.xml.core.internal.contentmodel.annotation.AnnotationMap;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-
-/**
- *
- */
-public class AnnotationFileParser {
- public static final String TAG_ID_ANNOTATIONS = "abstractGrammarAnnotations"; //$NON-NLS-1$
- public static final String TAG_ID_ANNOTATION = "annotation"; //$NON-NLS-1$
- public static final String TAG_ID_PROPERTY = "property"; //$NON-NLS-1$
-
- /**
- * This method is called to parse an annotation file and store the
- * contents into an annotationMap
- */
- private void parse(AnnotationMap annotationMap, InputStream input, AnnotationFileInfo fileInfo) throws Exception {
- // move to Xerces-2.... add 'contextClassLoader' stuff
- ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- SAXParser parser = factory.newSAXParser();
- parser.parse(new InputSource(input), new AnnotationMapContentHandler(annotationMap, fileInfo));
- }
- finally {
- Thread.currentThread().setContextClassLoader(prevClassLoader);
- }
- }
-
- /**
- * This method is called to parse an annotation file and store the
- * contents into an annotationMap
- */
- public void parse(AnnotationMap map, AnnotationFileInfo fileInfo) throws Exception {
- InputStream inputStream = null;
- try {
- URL url = Platform.find(Platform.getBundle(fileInfo.getBundleId()), Path.fromOSString(fileInfo.getAnnotationFileLocation()));
- if (url != null) {
- inputStream = url.openStream();
- parse(map, inputStream, fileInfo);
- }
- }
- catch (Exception e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- throw (e);
- }
- finally {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- catch (IOException e) {
- }
- }
- }
-
- protected class AnnotationMapContentHandler extends DefaultHandler {
- private AnnotationMap annotationMap;
- private Annotation currentAnnotation;
- private String currentPropertyName;
- private StringBuffer propertyValueBuffer;
- private ResourceBundle resourceBundle;
- private AnnotationFileInfo fFileInfo;
-
- public AnnotationMapContentHandler(AnnotationMap annotationMap, AnnotationFileInfo fileInfo) {
- this.annotationMap = annotationMap;
- this.fFileInfo = fileInfo;
- }
-
- private URL generatePropertiesFileURL(AnnotationFileInfo fileInfo, String propertiesLocation) {
- URL propertiesURL = null;
-
- // prepend $nl$ variable to location
- IPath annotationPath = Path.fromOSString("$nl$/" + fileInfo.getAnnotationFileLocation()); //$NON-NLS-1$
- // remove the annotation.xml file
- IPath annotationFolder = annotationPath.removeLastSegments(1);
- // append location of propertiles file
- IPath propertiesFile = annotationFolder.append(propertiesLocation);
- // append .properties extension if needed
- if (propertiesFile.getFileExtension() == null)
- propertiesFile = propertiesFile.addFileExtension("properties"); //$NON-NLS-1$
- // create a URL out of the properties file location
- propertiesURL = Platform.find(Platform.getBundle(fileInfo.getBundleId()), propertiesFile);
- return propertiesURL;
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- propertyValueBuffer = new StringBuffer();
- if (localName.equals(TAG_ID_ANNOTATIONS)) {
- int attributesLength = attributes.getLength();
- for (int i = 0; i < attributesLength; i++) {
- String attributeName = attributes.getLocalName(i);
- String attributeValue = attributes.getValue(i);
- if (attributeName.equals("propertiesLocation")) //$NON-NLS-1$
- {
- URL bundleURL = generatePropertiesFileURL(fFileInfo, attributeValue);
- if (bundleURL != null) {
- InputStream bundleStream = null;
- try {
- bundleStream = bundleURL.openStream();
- resourceBundle = new PropertyResourceBundle(bundleStream);
- }
- catch (IOException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- try {
- if (bundleStream != null)
- bundleStream.close();
- }
- catch (IOException x) {
- Logger.log(Logger.WARNING_DEBUG, x.getMessage(), x);
- }
- }
- }
- }
- else if (attributeName.equals("caseSensitive")) //$NON-NLS-1$
- {
- if (attributeValue.trim().equals("false")) //$NON-NLS-1$
- {
- annotationMap.setCaseSensitive(false);
- }
- }
- }
- }
- else if (localName.equals(TAG_ID_ANNOTATION)) {
- currentAnnotation = null;
- String specValue = attributes.getValue("spec"); //$NON-NLS-1$
- if (specValue != null) {
- currentAnnotation = new Annotation();
- currentAnnotation.setSpec(specValue);
- }
- annotationMap.addAnnotation(currentAnnotation);
- }
- else if (localName.equals(TAG_ID_PROPERTY)) {
- if (currentAnnotation != null) {
- currentPropertyName = attributes.getValue("name"); //$NON-NLS-1$
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (currentPropertyName != null && currentAnnotation != null) {
- String propertyValue = propertyValueBuffer.toString();
- if (propertyValue != null) {
- if (propertyValue.startsWith("%") && resourceBundle != null) //$NON-NLS-1$
- {
- try {
- propertyValue = resourceBundle.getString(propertyValue.substring(1));
- }
- catch (Exception e) {
- // ignore any exception that occurs while trying
- // to fetch a resource
- }
- }
- currentAnnotation.setProperty(currentPropertyName, propertyValue);
- }
- }
-
- if (localName.equals(TAG_ID_ANNOTATION)) {
- currentAnnotation = null;
- }
- else if (localName.equals(TAG_ID_PROPERTY)) {
- currentPropertyName = null;
- }
- }
-
- public void characters(char[] ch, int start, int length) {
- if (currentPropertyName != null && currentAnnotation != null) {
- propertyValueBuffer.append(ch, start, length);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistry.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistry.java
deleted file mode 100644
index c8991fb56a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistry.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is used to associate one or more annotation files with a grammar
- * file.
- *
- */
-public class AnnotationFileRegistry {
- private Map map = new HashMap();
-
- public AnnotationFileRegistry() {
- new AnnotationFileRegistryReader(this).readRegistry();
- }
-
- public synchronized List getAnnotationFilesInfos(String publicId) {
- List theList = (List) map.get(publicId);
- return theList != null ? theList : new ArrayList();
- }
-
- public synchronized void addAnnotationFile(String publicId, AnnotationFileInfo fileInfo) {
- List fileInfos = (List) map.get(publicId);
- if (fileInfos == null) {
- fileInfos = new ArrayList();
- map.put(publicId, fileInfos);
- }
- fileInfos.add(fileInfo);
- }
-
- public synchronized void removeAnnotationFile(String publicId, AnnotationFileInfo fileInfo) {
- List fileInfos = (List) map.get(publicId);
- if (fileInfos != null) {
- fileInfos.remove(fileInfo);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistryReader.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistryReader.java
deleted file mode 100644
index 3c7c42345a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationFileRegistryReader.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-/**
- * This class reads the plugin manifests and adds each specified gramamr
- * annotation file with the AnnotationProvider
- */
-public class AnnotationFileRegistryReader {
- protected static final String EXTENSION_POINT_ID = "annotationFiles"; //$NON-NLS-1$
- protected static final String TAG_NAME = "annotationFile"; //$NON-NLS-1$
- protected static final String ATT_PUBLIC_ID = "publicId"; //$NON-NLS-1$
- protected static final String ATT_LOCATION = "location"; //$NON-NLS-1$
-
- private AnnotationFileRegistry annotationFileRegistry;
-
- public AnnotationFileRegistryReader(AnnotationFileRegistry annotationFileRegistry) {
- this.annotationFileRegistry = annotationFileRegistry;
- }
-
- /**
- * read from plugin registry and parse it.
- */
- public void readRegistry() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- String pluginId = "org.eclipse.wst.xml.core"; //$NON-NLS-1$
- IExtensionPoint point = extensionRegistry.getExtensionPoint(pluginId, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- readElement(elements[i]);
- }
- }
- }
-
- /**
- * readElement() - parse and deal with an extension like:
- *
- * <extension
- * point="org.eclipse.wst.xml.core.internal.contentmodel.util_implementation">
- * <util_implementation class =
- * corg.eclipse.wst.baseutil.CMUtilImplementationImpl /> </extension>
- */
- protected void readElement(IConfigurationElement element) {
- if (element.getName().equals(TAG_NAME)) {
- String publicId = element.getAttribute(ATT_PUBLIC_ID);
- String location = element.getAttribute(ATT_LOCATION);
- if (publicId != null && location != null) {
- try {
- String bundleId = element.getNamespace();
- AnnotationFileInfo fileInfo = new AnnotationFileInfo(location, bundleId);
- annotationFileRegistry.addAnnotationFile(publicId, fileInfo);
- }
- catch (Exception e) {
- Logger.logException("problem adding annotation file " + location, e); //$NON-NLS-1$
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationUtility.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationUtility.java
deleted file mode 100644
index 061088af50..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/AnnotationUtility.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.annotation.AnnotationMap;
-
-
-/**
- *
- */
-public class AnnotationUtility {
- public static void loadAnnotationsForGrammar(String publicId, CMDocument cmDocument) {
- List annotationFiles = ContentModelManager.getInstance().getAnnotationFilesInfos(publicId);
- AnnotationMap map = (AnnotationMap) cmDocument.getProperty("annotationMap"); //$NON-NLS-1$
- if (map != null) {
- for (Iterator i = annotationFiles.iterator(); i.hasNext();) {
- try {
- AnnotationFileInfo annotationFileInfo = (AnnotationFileInfo) i.next();
- AnnotationFileParser parser = new AnnotationFileParser();
- parser.parse(map, annotationFileInfo);
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/ResourceBundleHelper.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/ResourceBundleHelper.java
deleted file mode 100644
index 98eeba4e5c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/annotation/ResourceBundleHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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.internal.annotation;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Platform;
-
-
-public class ResourceBundleHelper
-{
- public static ResourceBundle getResourceBundle(String resourceURI, Locale targetLocale) throws Exception
- {
- // try to load bundle from the location specified in the resourceURI
- // we make the assumption that the resourceURI points to the local file system
-
- int index = resourceURI.lastIndexOf("/"); //$NON-NLS-1$
- if (index == -1)
- {
- throw new Exception("Invalid resourceURI"); //$NON-NLS-1$
- }
-
- // Below we set 'resourceDirectory' so that it ends with a '/'.
- // Here's an excerpt from the ClassLoader Javadoc ...
- // Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed
- // to refer to a JAR file which will be opened as needed.
- //
- String resourceDirectory = resourceURI.substring(0, index + 1);
- String resourceBundleName = resourceURI.substring(index + 1);
-
- // create a class loader with a class path that points to the resource bundle's location
- //
- URL[] classpath = new URL[1];
- classpath[0] = Platform.resolve(new URL(resourceDirectory));
- ClassLoader resourceLoader = new URLClassLoader(classpath, null);
-
- return ResourceBundle.getBundle(resourceBundleName, targetLocale, resourceLoader);
- }
-
- public static ResourceBundle getResourceBundle(String resourceURI) throws Exception
- {
- return getResourceBundle(resourceURI, Locale.getDefault());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/InferredGrammarFactory.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/InferredGrammarFactory.java
deleted file mode 100644
index 19d8131802..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/InferredGrammarFactory.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * 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.internal.modelqueryimpl;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMAnyElementImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMAttributeDeclarationImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMDocumentImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMElementDeclarationImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMGroupImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNodeListImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-
-
-public class InferredGrammarFactory
-{
- public InferredGrammarFactory()
- {
- }
-
- public CMDocument createCMDocument(String uri)
- {
- CMDocumentImpl cmdocument =new CMDocumentImpl(uri);
- cmdocument.setInferred(true);
- return cmdocument;
- }
-
- public CMElementDeclaration createCMElementDeclaration(CMDocument cmDocument, Element element, boolean isLocal)
- {
- String localName = element.getLocalName();
- CMDocumentImpl cmDocumentImpl = (CMDocumentImpl)cmDocument;
-
- CMNamedNodeMapImpl elementMap = isLocal ?
- (CMNamedNodeMapImpl)cmDocumentImpl.getLocalElementPool() :
- (CMNamedNodeMapImpl)cmDocumentImpl.getElements();
-
- CMElementDeclarationImpl ed = (CMElementDeclarationImpl)elementMap.getNamedItem(localName);
- if (ed == null)
- {
- //System.out.println("create ed " + localName);
- ed = new CMElementDeclarationImpl(cmDocument, localName);
- ed.setInferred(true);
- ed.setLocal(isLocal);
- ed.setMaxOccur(1);
- CMGroupImpl group = new CMGroupImpl(new CMNodeListImpl(), CMGroup.CHOICE);
- group.setInferred(true);
- group.setMinOccur(0);
- group.setMaxOccur(-1);
- ed.setContent(group);
- elementMap.put(ed);
- }
-
- // lookup or create the attributes
- //
- NamedNodeMap attributeMap = element.getAttributes();
- int attributeMapLength = attributeMap.getLength();
- for (int i = 0; i < attributeMapLength; i++)
- {
- Attr attr = (Attr)attributeMap.item(i);
- CMAttributeDeclarationImpl ad = (CMAttributeDeclarationImpl)ed.getAttributeMap().getNamedItem(attr.getNodeName());
- if (ad == null)
- {
- // todo... use an attribute pool to be more efficient?
- ad = new CMAttributeDeclarationImpl(attr.getNodeName(), CMAttributeDeclaration.OPTIONAL);
- ad.setInferred(true);
- ed.getAttributeMap().put(ad);
- }
- }
- return ed;
- }
-
- public void createCMContent(CMDocument parentCMDocument, CMElementDeclaration parentEd, CMDocument childCMDocument, CMElementDeclaration childEd, boolean isLocal, String uri)
- {
- // add element to the parent's content
- // consider all content to be of the form (A | B | C)*
- //
- CMGroupImpl group = (CMGroupImpl)parentEd.getContent();
- CMNodeListImpl groupChildNodeList = (CMNodeListImpl)group.getChildNodes();
-
- if (parentCMDocument == childCMDocument)
- {
- if (!groupChildNodeList.contains(childEd))
- {
- groupChildNodeList.add(childEd);
- }
- if (isLocal)
- {
- CMNamedNodeMapImpl localElementMap = (CMNamedNodeMapImpl)parentEd.getLocalElements();
- localElementMap.put(childEd);
- }
- }
- else
- {
- CMAnyElement cmAnyElement = lookupOrCreateCMAnyElement((CMDocumentImpl)parentCMDocument, uri);
- if (!groupChildNodeList.contains(cmAnyElement))
- {
- groupChildNodeList.add(cmAnyElement);
- }
- }
- }
-
- protected CMAnyElement lookupOrCreateCMAnyElement(CMDocumentImpl parentCMDocument, String uri)
- {
- CMNamedNodeMapImpl anyElementMap = parentCMDocument.getAnyElements();
- CMAnyElementImpl anyElement = (CMAnyElementImpl)anyElementMap.getNamedItem(CMAnyElementImpl.computeNodeName(uri));
- if (anyElement == null)
- {
- //System.out.println("create anyElement " + uri);
- anyElement = new CMAnyElementImpl(uri);
- anyElement.setInferred(true);
- anyElementMap.put(anyElement);
- }
- return anyElement;
- }
-
-
- public void debugPrint(Collection collection)
- {
- for (Iterator iter = collection.iterator(); iter.hasNext(); )
- {
- CMDocument cmDocument = (CMDocument)iter.next();
- System.out.println("-----------------------------------------------"); //$NON-NLS-1$
- System.out.println("cmDocument (" + cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") +")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CMNamedNodeMapImpl elementMap = (CMNamedNodeMapImpl)cmDocument.getElements();
- int size = elementMap.getLength();
- for (int i = 0; i < size; i++)
- {
- CMElementDeclaration ed = (CMElementDeclaration)elementMap.item(i);
- CMDescriptionBuilder builder = new CMDescriptionBuilder();
- System.out.println(" ELEMENT " + ed.getNodeName() + " = " + builder.buildDescription(ed)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionDescriptor.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionDescriptor.java
deleted file mode 100644
index c6d9490466..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionDescriptor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.internal.modelqueryimpl;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
-
-/**
- * Describes an extension to the <code>modelQueryExtension</code> extension
- * point.
- *
- */
-public class ModelQueryExtensionDescriptor
-{
- private static final String CONTENT_TYPE_ATTRIBUTE = "contentType"; //$NON-NLS-1$
- private static final String NAMESPACE_ATTRIBUTE = "namespace"; //$NON-NLS-1$
- private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
- private IConfigurationElement configuration;
- private String contentTypeId;
- private String namespace;
- private ModelQueryExtension extension;
-
- public ModelQueryExtensionDescriptor(IConfigurationElement element)
- {
- configuration = element;
- }
-
- public ModelQueryExtension createModelQueryExtension() throws CoreException
- {
- if (extension == null)
- {
- extension = (ModelQueryExtension) configuration.createExecutableExtension(CLASS_ATTRIBUTE);
- }
- return extension;
- }
-
- public String getContentTypeId()
- {
- if (contentTypeId == null)
- {
- contentTypeId = configuration.getAttribute(CONTENT_TYPE_ATTRIBUTE);
- }
- return contentTypeId;
- }
-
- public String getNamespace()
- {
- if (namespace == null)
- {
- namespace = configuration.getAttribute(NAMESPACE_ATTRIBUTE);
- }
- return namespace;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java
deleted file mode 100644
index 72c28fdb5e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.internal.modelqueryimpl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtensionManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-
-public class ModelQueryExtensionManagerImpl implements ModelQueryExtensionManager
-{
- protected ModelQueryExtensionRegistry modelQueryExtensionRegistry = new ModelQueryExtensionRegistry();
-
- public List getDataTypeValues(Element element, CMNode cmNode)
- {
- List list = new ArrayList();
- String contentTypeId = getContentTypeId(element);
- String namespace = getNamespace(cmNode);
- String name = cmNode.getNodeName();
-
- for (Iterator i = modelQueryExtensionRegistry.getApplicableExtensions(contentTypeId, namespace).iterator(); i.hasNext();)
- {
- ModelQueryExtension extension = (ModelQueryExtension)i.next();
- String[] values = null;
- if (cmNode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION)
- {
- values = extension.getAttributeValues(element, namespace, name);
- }
- else
- {
- values = extension.getElementValues(element, namespace, name);
- }
- if (values != null)
- {
- list.addAll(Arrays.asList(values));
- }
- }
- return list;
- }
-
- public void filterAvailableElementContent(List cmnodes, Element element, CMElementDeclaration ed)
- {
- filterAvailableElementContent(cmnodes, element, ed, ModelQuery.INCLUDE_CHILD_NODES);
- }
-
- public void filterAvailableElementContent(List cmnodes, Element element, CMElementDeclaration ed, int includeOptions)
- {
- String contentTypeId = getContentTypeId(element);
- String parentNamespace = element.getNamespaceURI();
-
- List modelQueryExtensions = modelQueryExtensionRegistry.getApplicableExtensions(contentTypeId, parentNamespace);
- if((includeOptions & ModelQuery.INCLUDE_CHILD_NODES) > 0)
- {
- for (Iterator j = cmnodes.iterator(); j.hasNext(); )
- {
- CMNode cmNode = (CMNode)j.next();
- String namespace = getNamespace(cmNode);
- String name = cmNode.getNodeName();
-
- boolean include = true;
- for(int k = 0; k < modelQueryExtensions.size() && include; k++) {
- {
- ModelQueryExtension extension = (ModelQueryExtension)modelQueryExtensions.get(k);
- include = extension.isApplicableChildElement(element, namespace, name);
- if (!include)
- {
- // remove the cmNode from the list
- j.remove();
- }
- }
- }
- }
- }
- // add MQE-provided content
- for(int k = 0; k < modelQueryExtensions.size(); k++)
- {
- ModelQueryExtension extension = (ModelQueryExtension)modelQueryExtensions.get(k);
- cmnodes.addAll(Arrays.asList(extension.getAvailableElementContent(element, parentNamespace, includeOptions)));
- }
- }
-
- private String getNamespace(CMNode cmNode)
- {
- String namespace = null;
- CMDocument cmDocument = (CMDocument)cmNode.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- namespace = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- }
- return namespace;
- }
-
- private String getContentTypeId(Node node)
- {
- String contentTypeId = "org.eclipse.core.runtime.xml"; //$NON-NLS-1$
- if (node instanceof IDOMNode)
- {
- IDOMNode domNode = (IDOMNode) node;
- contentTypeId = domNode.getModel().getContentTypeIdentifier();
- }
- return contentTypeId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionRegistry.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionRegistry.java
deleted file mode 100644
index 1c98b44897..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionRegistry.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.internal.modelqueryimpl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
-
-public class ModelQueryExtensionRegistry
-{
- protected static final String EXTENSION_POINT_ID = "modelQueryExtensions"; //$NON-NLS-1$
- protected static final String TAG_NAME = "modelQueryExtension"; //$NON-NLS-1$
- private List descriptors;
-
- public List getApplicableExtensions(String contentTypeId, String namespace)
- {
- List list = new ArrayList();
- if (contentTypeId != null)
- {
- ensureExtensionsLoaded();
- for (Iterator i = descriptors.iterator(); i.hasNext();)
- {
- ModelQueryExtensionDescriptor descriptor = (ModelQueryExtensionDescriptor) i.next();
- final String[] contentTypeIds = StringUtils.unpack(descriptor.getContentTypeId());
- for (int j = 0; j < contentTypeIds.length; j++) {
- if (contentTypeId.equals(contentTypeIds[j]))
- {
- if (descriptor.getNamespace() == null || descriptor.getNamespace().equals(namespace))
- {
- try
- {
- ModelQueryExtension extension = descriptor.createModelQueryExtension();
- list.add(extension);
- }
- catch (CoreException e) {
- Logger.logException("problem creating model query extension", e); //$NON-NLS-1$
- }
- }
- break;
- }
- }
- }
- }
- return list;
- }
-
- /*
- * TODO : consider providing a non-plugin means add/remove extensions
- *
- public void addExtension(ModelQueryExtension extension)
- {
- }
-
- public void removeExtension(ModelQueryExtensionDeprecated extension)
- {
- }*/
-
- /**
- * Reads all extensions.
- * <p>
- * This method can be called more than once in order to reload from a changed
- * extension registry.
- * </p>
- */
- private synchronized void reloadExtensions()
- {
- descriptors = new ArrayList();
- String bundleid = "org.eclipse.wst.xml.core"; //$NON-NLS-1$
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(bundleid, EXTENSION_POINT_ID);
- for (int i = 0; i < elements.length; i++)
- {
- ModelQueryExtensionDescriptor descriptor = new ModelQueryExtensionDescriptor(elements[i]);
- descriptors.add(descriptor);
- }
- }
-
- /**
- * Ensures the extensions have been loaded at least once.
- */
- private void ensureExtensionsLoaded()
- {
- if (descriptors == null)
- {
- reloadExtensions();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMDataTypeValueHelper.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMDataTypeValueHelper.java
deleted file mode 100644
index e09fa6c164..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMDataTypeValueHelper.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * 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.internal.util;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable;
-
-
-public class CMDataTypeValueHelper
-{
- protected int idCount = 0;
-
-
- public String getValue(CMAttributeDeclaration ad, NamespaceTable namespaceTable)
- {
- String value = null;
-
- if (isXSIType(ad))
- {
- List list = getQualifiedXSITypes(ad, namespaceTable);
- value = list.size() > 0 ? (String)list.get(0) : null;
- }
-
- // shameless hack
- //
- if (value == null)
- {
- if (ad.getAttrName().equals("xml:lang")) //$NON-NLS-1$
- {
- value = "EN"; //$NON-NLS-1$
- }
- }
-
- if (value == null)
- {
- CMDataType dataType = ad.getAttrType();
- if (dataType != null)
- {
- value = getValue(dataType);
- }
- }
- return value;
- }
-
-
- public String getValue(CMDataType dataType)
- {
- String value = null;
- value = dataType.getImpliedValue();
-
- if (value == null)
- {
- String[] values = dataType.getEnumeratedValues();
- if (values != null && values.length > 0)
- {
- value = values[0];
- }
- }
-
- if (value == null)
- {
- value = dataType.generateInstanceValue();
- }
-
- // Here is a special case where we handle DTD's ID related datatypes.
- // These values must be generated/validate by considering the entire xml file
- // so we can't rely on the 'generateInstanceValue' method.
- //
- // todo... find a nicer way to handle this
- if (value == null)
- {
- String dataTypeName = dataType.getDataTypeName();
- if (dataTypeName != null)
- {
- if (dataTypeName.equals("ID")) //$NON-NLS-1$
- {
- value = "idvalue" + idCount++; //$NON-NLS-1$
- }
- else if (dataTypeName.equals("IDREF") || dataTypeName.equals("IDREFS")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- value = "idvalue0"; //$NON-NLS-1$
- }
- }
- }
- return value;
- }
-
-
- public boolean isValidEmptyValue(CMAttributeDeclaration ad)
- {
- boolean result = true;
- CMDataType dataType = ad.getAttrType();
- if (dataType != null)
- {
- String propertyValue = (String)dataType.getProperty("isValidEmptyValue"); //$NON-NLS-1$
- if (propertyValue != null && propertyValue.equals("false")) //$NON-NLS-1$
- {
- result = false;
- }
- }
- return result;
- }
-
-
- public boolean isXSIType(CMAttributeDeclaration ad)
- {
- boolean result = false;
- if (ad.getNodeName().equals("type")) //$NON-NLS-1$
- {
- CMDocument cmDocument = (CMDocument)ad.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- String namespaceName = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- if (namespaceName != null && namespaceName.equals("http://www.w3.org/2001/XMLSchema-instance")) //$NON-NLS-1$
- {
- result = true;
- }
- }
- }
- return result;
- }
-
-
- public List getQualifiedXSITypes(CMAttributeDeclaration ad, NamespaceTable table)
- {
- List list = new Vector();
-
- List xsiTypes = (List)ad.getProperty("XSITypes"); //$NON-NLS-1$
- if (xsiTypes != null && xsiTypes.size() > 0)
- {
- for (Iterator i = xsiTypes.iterator(); i.hasNext(); )
- {
- String uriQualifiedName = (String)i.next();
- String[] components = DOMNamespaceHelper.getURIQualifiedNameComponents(uriQualifiedName);
- String prefix = table.getPrefixForURI(components[0] != null ? components[0] : ""); //$NON-NLS-1$
- String typeName = (prefix != null && prefix.length() > 0) ?
- prefix + ":" + components[1] : //$NON-NLS-1$
- components[1];
- list.add(typeName);
- }
- }
- return list;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMValidator.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMValidator.java
deleted file mode 100644
index 2de559049a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/CMValidator.java
+++ /dev/null
@@ -1,1250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * David Carver (STAR) - bug 297005 - Some static constants not made final.
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.internal.util;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Stack;
-import java.util.Vector;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor;
-
-
-
-public class CMValidator
-{
- protected static final StringElementContentComparator stringContentComparitor = new StringElementContentComparator();
- protected Hashtable graphNodeTable = new Hashtable();
-
- /**
- * GraphNode
- */
- protected static class GraphNode
- {
- public String name;
- public boolean isTerminal;
- public Vector arcList = new Vector();
-
- public GraphNode(String name)
- {
- this.name = name;
- }
-
- public void addArc(Arc arc)
- {
- arcList.addElement(arc);
- }
-
- public String toString()
- {
- return "[GraphNode " + name + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- /**
- * Arc
- */
- protected static class Arc
- {
- public static final int ELEMENT = 1;
- public static final int REPEAT = 2;
- public static final int OPTIONAL = 3;
- public static final int PREV_IN = 4;
- public static final int OUT_NEXT = 5;
- public static final int LINK = 6;
-
- public int kind;
- public String name;
- public GraphNode node;
- public CMNode cmNode;
-
- public Arc(int kind, GraphNode node, CMNode cmNode)
- {
- this(kind, "", node, cmNode); //$NON-NLS-1$
- }
-
- protected Arc(int kind, String name, GraphNode node, CMNode cmNode)
- {
- this.name = name;
- this.kind = kind;
- this.node = node;
- this.cmNode = cmNode;
- }
- }
-
-
- /**
- * GraphGenerator
- */
- protected static class GraphGenerator extends CMVisitor
- {
- public int indent;
- public int count;
- public GraphNode startGraphNode;
- public Context context;
-
- protected static class Context
- {
- GraphNode from;
- GraphNode to;
-
- Context(GraphNode from, GraphNode to)
- {
- this.from = from;
- this.to = to;
- }
-
- GraphNode getLastGraphNode()
- {
- return (to != null) ? to : from;
- }
- }
-
-
- protected GraphGenerator()
- {
- startGraphNode = new GraphNode(getGraphNodeName());
- context = new Context(startGraphNode, null);
- }
-
-
- protected void generateGraph(CMElementDeclaration ed)
- {
- int contentType = ed.getContentType();
-
- if (contentType == CMElementDeclaration.MIXED ||
- contentType == CMElementDeclaration.ELEMENT)
- {
- visitCMNode(ed.getContent());
- }
- // CMElementDeclaration.PCDATA... no graph required
- // CMElementDeclaration.ANY... no graph required
- context.getLastGraphNode().isTerminal = true;
- }
-
-
- protected String getGraphNodeName()
- {
- return "n" + count++; //$NON-NLS-1$
- }
-
-
- protected GraphNode getStartGraphNode()
- {
- return startGraphNode;
- }
-
-
- /**
- * repeat
- * +----#-----+
- * | |
- * v |
- * prev --#-> in --'x'-> out --#-> next
- * | ^
- * | |
- * +----------------#--------------+
- * optional
- *
- */
- protected void createArcs(GraphNode in, GraphNode out, CMContent cmContent)
- {
- createArcs(in, out, cmContent, false);
- }
-
- protected void createArcs(GraphNode in, GraphNode out, CMContent cmContent, boolean isAllGroup)
- {
- //println("+createArcs() " + ed.getDescription() + " " + ed.getMinOccur());
- GraphNode prev = context.from;
- GraphNode next = new GraphNode(getGraphNodeName());
-
- prev.addArc(new Arc(Arc.PREV_IN, in, cmContent));
- out.addArc(new Arc(Arc.OUT_NEXT, next, cmContent));
-
- if (context.to != null)
- {
- next.addArc(new Arc(Arc.LINK, context.to, cmContent));
- }
- else
- {
- context.from = next;
- }
-
- if (cmContent.getMinOccur() == 0)
- {
- // todo... should we see if an optional arc has already been added?
- prev.addArc(new Arc(Arc.OPTIONAL, next, cmContent));
- }
-
- if (cmContent.getMaxOccur() == -1 || cmContent.getMaxOccur() > 1 || isAllGroup)
- {
- out.addArc(new Arc(Arc.REPEAT, in, cmContent));
- }
- }
-
-
- public void visitCMGroup(CMGroup group)
- {
- Context prevContext = context;
- GraphNode in = new GraphNode("(" + getGraphNodeName()); //$NON-NLS-1$
- GraphNode out = new GraphNode(")" + getGraphNodeName()); //$NON-NLS-1$
-
- int groupOperator = group.getOperator();
- if (groupOperator == CMGroup.SEQUENCE)
- {
- context = new Context(in, null);
- super.visitCMGroup(group);
- context.from.addArc(new Arc(Arc.LINK, out, group));
- }
- else if (groupOperator == CMGroup.CHOICE ||
- groupOperator == CMGroup.ALL)
- {
- context = new Context(in, out);
- super.visitCMGroup(group);
- }
-
- context = prevContext;
- createArcs(in, out, group, groupOperator == CMGroup.ALL);
- }
-
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- GraphNode in = new GraphNode(getGraphNodeName());
- GraphNode out = new GraphNode(getGraphNodeName());
- createArcs(in, out, ed);
- in.addArc(new Arc(Arc.ELEMENT, ed.getElementName(), out, ed));
- }
-
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- GraphNode in = new GraphNode(getGraphNodeName());
- GraphNode out = new GraphNode(getGraphNodeName());
- createArcs(in, out, anyElement);
- in.addArc(new Arc(Arc.ELEMENT, "any", out, anyElement)); //$NON-NLS-1$
- }
- }
-
- // todo.. implement cache strategy hook, handle name spaces, locals etc.
- //
- public GraphNode lookupOrCreateGraph(CMElementDeclaration element)
- {
- Object key = element;
- GraphNode node = (GraphNode)graphNodeTable.get(key);
- if (node == null)
- {
- node = createGraph(element);
- graphNodeTable.put(key, node);
- }
- return node;
- }
-
- public GraphNode createGraph(CMElementDeclaration element)
- {
- GraphGenerator generator = new GraphGenerator();
- generator.generateGraph(element);
- return generator.getStartGraphNode();
- }
-
-
- public void printGraph(GraphNode node, Vector namedArcList, Vector unamedArcList, int indent)
- {
- //String decoration = node.isTerminal ? " *" : "";
- //printlnIndented(indent, "GraphNode:" + node.name + decoration);
-
- indent += 2;
- for (Enumeration e = node.arcList.elements() ; e.hasMoreElements() ;)
- {
- Arc arc = (Arc)e.nextElement();
- //boolean visit = false;
- //printlnIndented(indent, "Arc:" + arc.name + " (" + arc.kind + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (arc.kind == Arc.ELEMENT)
- {
- //table.add(currentGrammarObject, arc.grammarObject);
- if (!namedArcList.contains(arc))
- {
- namedArcList.add(arc);
- unamedArcList = new Vector();
- printGraph(arc.node, namedArcList, unamedArcList, indent + 2);
- }
- }
- else
- {
- if (!unamedArcList.contains(arc))
- {
- unamedArcList.add(arc);
- printGraph(arc.node, namedArcList, unamedArcList, indent + 2);
- }
- }
- }
- }
-
- public void printGraph(GraphNode node)
- {
- printGraph(node, new Vector(), new Vector(), 0);
- }
-
-
- public void validateElementList(ElementList initialList, GraphNode initialGraphNode, ElementContentComparator comparator, Result result, boolean initialLoopFlag) {
- Stack arcStack = new Stack();
- arcStack.push(new ArcStackItem(null, false));
- boolean loopFlag = initialLoopFlag;
- ElementList elementList = initialList;
- GraphNode graphNode = initialGraphNode;
- while(!arcStack.isEmpty() && !result.isValid) {
- ArcStackItem stackElement = (ArcStackItem) arcStack.peek();
- if(stackElement.isVisited) {
- arcStack.pop();
- if(stackElement.arc != null) {
- result.pop(stackElement.arc);
- continue;
- }
- } else {
- stackElement.isVisited = true;
- result.push(stackElement.arc);
- graphNode = stackElement.arc.node;
- loopFlag = stackElement.loopFlag;
- }
- if(elementList == null && graphNode.isTerminal) {
- result.isValid = true;
- } else {
- for(Iterator arcIterator = graphNode.arcList.iterator(); arcIterator.hasNext();) {
- Arc arc = (Arc)arcIterator.next();
- boolean traverseArc = false;
- if (arc.kind == Arc.ELEMENT) {
- if(elementList != null && comparator.matches(elementList.head, arc.cmNode)) {
- loopFlag = false;
- traverseArc = true;
- elementList = elementList.tail; // increment our position in the list
- }
- } else if(arc.kind == Arc.REPEAT) {
- if(!loopFlag) {
- traverseArc = true;
- }
- loopFlag = true;
- } else {
- traverseArc = true;
- }
- if(traverseArc) {
- if (result.canPush(arc)) { // test to see if we can push this arc due to facet constraints
- arcStack.push(new ArcStackItem(arc, loopFlag));
- }
- }
- }
- }
- }
- }
-
-
- private class ArcStackItem {
-
- Arc arc;
- boolean loopFlag;
- boolean isVisited;
-
- public ArcStackItem(Arc arc, boolean loopflag) {
- this.arc = arc;
- this.loopFlag = loopflag;
- this.isVisited = arc == null;
- }
-
- }
-
-
- /**
- *
- */
- protected static ElementList createElementList(int contentType, List v, ElementContentComparator comparator, Result result)
- {
- ElementList first = null;
- ElementList prev = null;
-
- int size = v.size();
- for (int i = 0; i < size; i++)
- {
- Object o = v.get(i);
- if (o != null && !comparator.isIgnorable(o))
- {
- if (comparator.isElement(o))
- {
- ElementList list = new ElementList();
- list.head = o;
-
- if (prev != null)
- {
- prev.tail = list;
- }
- else
- {
- first = list;
- }
- prev = list;
- }
- else if (contentType == CMElementDeclaration.ELEMENT)
- {
- result.isValid = false;
- result.errorIndex = i;
- result.errorMessage = "Element can not include PCDATA content"; //$NON-NLS-1$
- }
- }
- }
- return first;
- }
-
- /**
- *
- */
- public void validate(CMElementDeclaration ed, List elementContent, ElementContentComparator comparator, Result result)
- {
- int contentType = ed.getContentType();
-
- if (contentType == CMElementDeclaration.MIXED ||
- contentType == CMElementDeclaration.ELEMENT)
- {
- ElementList elementList = createElementList(contentType, elementContent, comparator, result);
- if (result.isValid == true)
- {
- boolean isGraphValidationNeeded = !(elementList == null && contentType == CMElementDeclaration.MIXED);
-
- // explicitly handle 'All' groups
- //
- CMContent content = ed.getContent();
- if (content != null && content.getNodeType() == CMNode.GROUP)
- {
- CMGroup group = (CMGroup)content;
- if (group.getOperator() == CMGroup.ALL)
- {
- isGraphValidationNeeded = false;
- validatAllGroupContent(elementContent, comparator, group, result);
- }
- }
-
- if (isGraphValidationNeeded)
- {
- // validate the elementList using a graph
- //
- result.isValid = false;
- GraphNode node = lookupOrCreateGraph(ed);
- validateElementList(elementList, node, comparator, result, false);
- }
- }
- }
- else if (contentType == CMElementDeclaration.PCDATA)
- {
- int size = elementContent.size();
- for (int i = 0; i < size; i++)
- {
- Object o = elementContent.get(i);
- if (comparator.isElement(o))
- {
- result.isValid = false;
- result.errorIndex = i;
- result.errorMessage = "Element may only include PCDATA content"; //$NON-NLS-1$
- break;
- }
- }
- }
- else if (contentType == CMElementDeclaration.EMPTY)
- {
- int size = elementContent.size();
- for (int i = 0; i < size; i++)
- {
- Object o = elementContent.get(i);
- if (!comparator.isIgnorable(o))
- {
- result.isValid = false;
- result.errorIndex = i;
- result.errorMessage = "Element may not contain PCDATA or Element content"; //$NON-NLS-1$
- break;
- }
- }
- }
- //else if (contentType == CMElementDeclaration.ANY)
- // {
- // assume elementContent will always be valid for this content type
- // }
- }
-
- static class ItemCount
- {
- int count = 0;
- }
-
- private void validatAllGroupContent(List elementContent, ElementContentComparator comparator, CMGroup allGroup, Result result)
- {
- boolean isValid = true;
- boolean isPartiallyValid = true;
- HashMap map = new HashMap();
- CMNodeList list = allGroup.getChildNodes();
- for (int j = list.getLength() - 1; j >= 0; j--)
- {
- CMNode node = list.item(j);
- if (map.get(node) == null)
- {
- map.put(node, new ItemCount());
- }
- }
- int validitionCount = 0;
- for (Iterator i = elementContent.iterator(); i.hasNext(); validitionCount++)
- {
- Object o = i.next();
- if (comparator.isElement(o))
- {
- // test to see if the element is listed in the all group
- //
- CMNode matchingCMNode = null;
- for (int j = list.getLength() - 1; j >= 0; j--)
- {
- CMNode node = list.item(j);
- if (comparator.matches(o, node))
- {
- matchingCMNode = node;
- break;
- }
- }
- if (matchingCMNode == null)
- {
- isPartiallyValid = false;
- isValid = false;
- break;
- }
- else
- {
- // test to see that the element occurs only once
- //
- ItemCount itemCount = (ItemCount)map.get(matchingCMNode);
- if (itemCount != null)
- {
- if (itemCount.count > 0)
- {
- // we don't want to allow too many elements!
- // we consider 'not enough' to be partially valid... but not 'too many'
- isPartiallyValid = false;
- break;
- }
- else
- {
- itemCount.count++;
- }
- }
- }
- }
- }
- if (isValid)
- {
- for (int j = list.getLength() - 1; j >= 0; j--)
- {
- CMNode node = list.item(j);
- if (node.getNodeType() == CMNode.ELEMENT_DECLARATION)
- {
- CMContent content = (CMContent)node;
- ItemCount itemCount = (ItemCount)map.get(node);
-// System.out.print("content " + content.getNodeName() + " " + content.getMinOccur());
- if (itemCount.count < content.getMinOccur())
- {
- isValid = false;
- break;
- }
- }
- }
- }
- if (result instanceof ElementPathRecordingResult && isPartiallyValid)
- {
- ((ElementPathRecordingResult)result).setPartialValidationCount(validitionCount);
- }
- result.isValid = isValid;
- }
-
-
- public void getOriginArray(CMElementDeclaration ed, List elementContent, ElementContentComparator comparator, ElementPathRecordingResult result)
- {
- CMNode[] cmNodeArray = null;
- validate(ed, elementContent, comparator, result);
- if (result.isValid)
- {
- CMDataType dataType = ed.getDataType();
- int size = elementContent.size();
- cmNodeArray = new CMNode[size];
- Vector originList = result.getElementOriginList();
- int originListSize = originList.size();
- int originListIndex = 0;
- for (int i = 0; i < size; i++)
- {
- Object o = elementContent.get(i);
- if (comparator.isElement(o))
- {
- if (originListIndex < originListSize)
- {
- cmNodeArray[i] = (CMNode)originList.get(originListIndex);
- originListIndex++;
- }
- }
- else if (comparator.isPCData(o))
- {
- cmNodeArray[i] = dataType;
- }
- // else the CMNode at this index is null
- }
- result.setOriginArray(cmNodeArray);
- }
- }
-
- private void collectNamedArcs(GraphNode node, List namedArcList, int indent)
- {
- //printlnIndented(indent, "GraphNode:" + node.name + decoration);
- indent += 2;
- for (Iterator i = node.arcList.iterator(); i.hasNext() ;)
- {
- Arc arc = (Arc)i.next();
- //printlnIndented(indent, "Arc:" + arc.name + " (" + arc.kind + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (arc.kind == Arc.ELEMENT)
- {
- if (!namedArcList.contains(arc))
- {
- namedArcList.add(arc);
- collectNamedArcs(arc.node, namedArcList, indent + 2);
- }
- }
- else if (arc.kind != Arc.REPEAT && arc.kind != Arc.OPTIONAL)
- {
- collectNamedArcs(arc.node, namedArcList, indent + 2);
- }
- }
- }
-
-
- private List getMatchingArcs(CMElementDeclaration ed, String elementName)
- {
- List arcList = new ArrayList();
- GraphNode graphNode = lookupOrCreateGraph(ed);
- if (elementName == null)
- {
- // here we add the 'root' arc
- for (Iterator i = graphNode.arcList.iterator(); i.hasNext() ;)
- {
- Arc arc = (Arc)i.next();
- if (arc.kind == Arc.PREV_IN)
- {
- arcList.add(arc);
- break;
- }
- }
- }
- else
- {
- List namedArcs = new ArrayList();
- collectNamedArcs(graphNode, namedArcs, 0);
- for (Iterator i = namedArcs.iterator(); i.hasNext(); )
- {
- Arc arc = (Arc)i.next();
- if (arc.cmNode != null && elementName.equals(arc.cmNode.getNodeName()))
- {
- arcList.add(arc);
- }
- }
- }
- return arcList;
- }
-
-
- private void collectNextSiblings(GraphNode node, List nextSiblingList, List namedArcList, List unamedArcList, int indent)
- {
- //printlnIndented(indent, "GraphNode:" + node.name + decoration);
- indent += 2;
- for (Iterator i = node.arcList.iterator(); i.hasNext(); )
- {
- Arc arc = (Arc)i.next();
- if (arc.kind == Arc.ELEMENT)
- {
- if (!namedArcList.contains(arc))
- {
- if (arc.cmNode != null)
- {
- nextSiblingList.add(arc.cmNode);
- if (arc.cmNode.getNodeType() == CMNode.ELEMENT_DECLARATION ||
- arc.cmNode.getNodeType() == CMNode.ANY_ELEMENT)
- {
- namedArcList.add(arc);
- CMContent cmNode = (CMContent)arc.cmNode;
- if (cmNode.getMinOccur() == 0)
- {
- unamedArcList = new ArrayList();
- collectNextSiblings(arc.node, nextSiblingList, namedArcList, unamedArcList, indent + 2);
- }
- }
- }
- }
- }
- else
- {
- if (!unamedArcList.contains(arc))
- {
- unamedArcList.add(arc);
- collectNextSiblings(arc.node, nextSiblingList, namedArcList, unamedArcList, indent + 2);
- }
- }
- }
- }
-
- public CMNode[] getNextSiblings(CMElementDeclaration ed, String elementName)
- {
- List arcList = getMatchingArcs(ed, elementName);
- List nextSiblingList = new ArrayList();
- for (Iterator i = arcList.iterator(); i.hasNext(); )
- {
- Arc arc = (Arc)i.next();
- collectNextSiblings(arc.node, nextSiblingList, new ArrayList(), new ArrayList(), 0);
- }
- CMNode[] result = new CMNode[nextSiblingList.size()];
- nextSiblingList.toArray(result);
- //System.out.print("getNextSibling(" +elementName + ")");
- //for (int i = 0; i < result.length; i++)
- //{
- // System.out.print("[" + result[i].getNodeName() + "]");
- //}
- //System.out.println();
- return result;
- }
-
- /**
- *
- */
- public static class Result
- {
- public boolean isValid = true;
- public int errorIndex = -1;
- public String errorMessage;
- public boolean isRepeatTraversed; // detects if a repeat has been traversed
-
- public boolean canPush(Arc arc)
- {
- return true;
- }
-
- public void push(Arc arc)
- {
- // overide this method to record traversed nodes
- }
- public void pop(Arc arc)
- {
- // overide this method to record traversed nodes
- }
- public CMNode[] getOriginArray()
- {
- return null;
- }
- }
-
- /**
- *
- */
- public static class ElementPathRecordingResult extends Result
- {
- protected List activeItemCountList = new ArrayList();
- protected List inactiveItemCountList = new ArrayList();
- protected Vector elementOriginStack = new Vector();
- protected CMNode[] originArray = null;
- protected int partialValidationCount = 0;
-
-
- // this method is used to support facet counts
- //
- public boolean canPush(Arc arc)
- {
- boolean result = true;
- try
- {
- if (arc.kind == Arc.REPEAT)
- {
- if (arc.cmNode instanceof CMContent)
- {
- CMContent content = (CMContent)arc.cmNode;
-
- // we only need to do 'special' facet checking if the maxOccurs is > 1
- // values of '0' and '-1' (unbounded) work 'for free' without any special checking
- //
- if (content.getMaxOccur() > 1)
- {
- ItemCount itemCount = (ItemCount)activeItemCountList.get(activeItemCountList.size() - 1);
-
- // here we need to compute if we can do another repeat
- // if we increase the repeat count by '1' will this violate the maxOccurs
- //
- if (itemCount.count + 1 >= content.getMaxOccur())
- {
- result = false;
- }
- }
- //System.out.println("canPush REPEAT (" + itemCount.count + ")" + content.getNodeName() + " result= " + result);
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- //System.out.flush();
- return result;
- }
-
- public void push(Arc arc)
- {
- if (arc.kind == Arc.ELEMENT)
- {
- //System.out.println("[X]push(" + arc.kind + ")" + arc.cmNode.getNodeName());
- elementOriginStack.add(arc.cmNode);
- partialValidationCount = Math.max(elementOriginStack.size(), partialValidationCount);
- }
- else if (arc.kind == Arc.PREV_IN)
- {
- //System.out.println("[X]push(" + arc.kind + ")" + arc.cmNode.getNodeName());
- activeItemCountList.add(new ItemCount());
- }
- else if (arc.kind == Arc.OUT_NEXT)
- {
- //System.out.println("[X]push(" + arc.kind + ")" + arc.cmNode.getNodeName() + "[" + arc + "]");
- int size = activeItemCountList.size();
- ItemCount itemCount = (ItemCount)activeItemCountList.get(size - 1);
- activeItemCountList.remove(size - 1);
- inactiveItemCountList.add(itemCount);
- }
- else if (arc.kind == Arc.REPEAT)
- {
- //System.out.println("[X]push(" + arc.kind + ")" + arc.cmNode.getNodeName());
- ItemCount itemCount = (ItemCount)activeItemCountList.get(activeItemCountList.size() - 1);
- itemCount.count++;
- //System.out.println("repeat(" + itemCount.count + ")" + arc.cmNode.getNodeName());
- }
- }
-
- public void pop(Arc arc)
- {
- if (arc.kind == Arc.ELEMENT)
- {
- //System.out.println("[X]pop(" + arc.kind + ")" + arc.cmNode.getNodeName());
- int size = elementOriginStack.size();
- elementOriginStack.remove(size - 1);
- }
- else if (arc.kind == Arc.PREV_IN)
- {
- //System.out.println("[X]pop(" + arc.kind + ")" + arc.cmNode.getNodeName());
- activeItemCountList.remove(activeItemCountList.size() - 1);
- }
- else if (arc.kind == Arc.OUT_NEXT)
- {
- //System.out.println("[X]pop(" + arc.kind + ")" + arc.cmNode.getNodeName());
- int size = inactiveItemCountList.size();
- ItemCount itemCount = (ItemCount)inactiveItemCountList.get(size - 1);
- inactiveItemCountList.remove(size - 1);
- activeItemCountList.add(itemCount);
- }
- else if (arc.kind == Arc.REPEAT)
- {
- //System.out.println("[X]pop(" + arc.kind + ")" + arc.cmNode.getNodeName());
- ItemCount itemCount = (ItemCount)activeItemCountList.get(activeItemCountList.size() - 1);
- itemCount.count--;
- }
- }
-
- public Vector getElementOriginList()
- {
- return elementOriginStack;
- }
-
- public CMNode[] getOriginArray()
- {
- return originArray;
- }
-
- public void setOriginArray(CMNode[] originArray)
- {
- this.originArray = originArray;
- }
-
- public int getPartialValidationCount()
- {
- return partialValidationCount;
- }
-
- public void setPartialValidationCount(int partialValidationCount)
- {
- this.partialValidationCount = partialValidationCount;
- }
- }
-
- /**
- *
- */
- public static class PathRecordingResult extends Result
- {
- protected Vector arcList = new Vector();
-
- public void push(Arc arc)
- {
- arcList.add(arc);
- }
-
- public void pop(Arc arc)
- {
- int size = arcList.size();
- arcList.remove(size - 1);
- }
-
- public List getArcList()
- {
- List list = new Vector();
- for (Iterator iterator = arcList.iterator(); iterator.hasNext(); )
- {
- Arc arc = (Arc)iterator.next();
- if (arc.kind == Arc.ELEMENT)
- {
- list.add(arc);
- }
- }
- return list;
- }
-
- public MatchModelNode getMatchModel()
- {
- MatchModelNodeBuilder builder = new MatchModelNodeBuilder(arcList);
- builder.buildMatchModel();
- return builder.getRoot();
- }
- }
-
- /**
- *
- */
- public static class MatchModelNode
- {
- public CMNode cmNode;
- public List children = new Vector();
- public Object data;
-
- public MatchModelNode(MatchModelNode parent, CMNode cmNode)
- {
- this.cmNode = cmNode;
- }
-
- public void printModel(int indent)
- {
- //String cmNodeName = cmNode != null ? cmNode.getNodeName() : "null";
- //printlnIndented(indent, "MatchModelNode : " + cmNodeName);
- for (Iterator iterator = children.iterator(); iterator.hasNext(); )
- {
- MatchModelNode child = (MatchModelNode)iterator.next();
- child.printModel(indent + 2);
- }
- }
- }
-
- public static class MatchModelNodeBuilder
- {
- protected List arcList;
- protected List stack = new Vector();
- protected MatchModelNode root;
- protected MatchModelNode current;
-
- public MatchModelNodeBuilder(List arcList)
- {
- this.arcList = arcList;
- root = new MatchModelNode(null, null);
- push(root);
- }
-
- protected void push(MatchModelNode node)
- {
- current = node;
- stack.add(node);
- }
-
- protected void pop()
- {
- int size = stack.size();
- stack.remove(size - 1);
- current = (MatchModelNode)stack.get(size - 2);
- }
-
- public boolean isCMGroup(CMNode cmNode)
- {
- return cmNode != null && cmNode.getNodeType() == CMNode.GROUP;
- }
-
- public void buildMatchModel()
- {
- for (Iterator iterator = arcList.iterator(); iterator.hasNext(); )
- {
- Arc arc = (Arc)iterator.next();
-
- if (arc.kind == Arc.ELEMENT)
- {
- current.children.add(new MatchModelNode(current, arc.cmNode));
- }
- else if (arc.kind == Arc.PREV_IN)
- {
- if (isCMGroup(arc.cmNode))
- {
- MatchModelNode newModelNode = new MatchModelNode(current, arc.cmNode);
- current.children.add(newModelNode);
- push(newModelNode);
- }
- }
- else if (arc.kind == Arc.OUT_NEXT)
- {
- if (isCMGroup(arc.cmNode))
- {
- pop();
- }
- }
- else if (arc.kind == Arc.REPEAT)
- {
- if (isCMGroup(arc.cmNode))
- {
- pop();
- MatchModelNode newModelNode = new MatchModelNode(current, arc.cmNode);
- current.children.add(newModelNode);
- push(newModelNode);
- }
- }
- }
- }
-
- public MatchModelNode getRoot()
- {
- return root;
- }
- }
-
-
- /**
- *
- */
- public interface ElementContentComparator
- {
- public boolean isIgnorable(Object o);
- public boolean isPCData(Object o);
- public boolean isElement(Object o);
- public boolean matches(Object o, CMNode cmNode);
- }
-
- /**
- * A linked list
- */
- public static class ElementList
- {
- protected Object head;
- protected ElementList tail;
-
- public static ElementList create(List v)
- {
- ElementList first = null;
- ElementList prev = null;
-
- for (Iterator iterator = v.iterator(); iterator.hasNext(); )
- {
- Object o = iterator.next();
- if (o != null)
- {
- ElementList list = new ElementList();
- list.head = o;
-
- if (prev != null)
- {
- prev.tail = list;
- }
- else
- {
- first = list;
- }
- prev = list;
- }
- }
- return first;
- }
-
-
- public String toString()
- {
- String string = "[" + head + "],"; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (tail != null)
- {
- string += tail.toString();
- }
-
- return string;
- }
- }
-
- /**
- * StringElementContentComparator
- */
- public static class StringElementContentComparator implements ElementContentComparator
- {
- public boolean isIgnorable(Object o)
- {
- String string = o.toString();
- return string.startsWith("!") || string.startsWith("?"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isPCData(Object o)
- {
- String string = o.toString();
- return string.startsWith("'") || string.startsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isElement(Object o)
- {
- return !isIgnorable(o) && !isPCData(o);
- }
-
- public boolean matches(Object o, CMNode cmNode)
- {
- boolean result = false;
- if (cmNode.getNodeType() == CMNode.ELEMENT_DECLARATION)
- {
- CMElementDeclaration element = (CMElementDeclaration)cmNode;
- String name = o.toString();
- int index = name.indexOf("]"); //$NON-NLS-1$
- if (index != -1)
- {
- name = name.substring(index + 1);
- }
- result = name.equalsIgnoreCase(element.getElementName());
-
- // TODO... here's we consider substitution groups... revisit to see if this should be moved into validator code
- if (!result)
- {
- CMNodeList cmNodeList = (CMNodeList)element.getProperty("SubstitutionGroup"); //$NON-NLS-1$
- if (cmNodeList != null)
- {
- int cmNodeListLength = cmNodeList.getLength();
- if (cmNodeListLength > 1)
- {
- for (int i = 0; i < cmNodeListLength; i++)
- {
- CMElementDeclaration alternativeCMElementDeclaration = (CMElementDeclaration)cmNodeList.item(i);
- String altName = alternativeCMElementDeclaration.getElementName();
- result = name.equalsIgnoreCase(altName);
- if (result)
- {
- break;
- }
- }
- }
- }
- }
- }
- else if (cmNode.getNodeType() == CMNode.ANY_ELEMENT)
- {
- String string = o.toString();
- if (string.equals("*")) //$NON-NLS-1$
- {
- result = true;
- }
- else
- {
- CMAnyElement anyElement = (CMAnyElement)cmNode;
- String anyElementURI = anyElement.getNamespaceURI();
- if (anyElementURI != null)
- {
- if (anyElementURI.equals("##any")) //$NON-NLS-1$
- {
- result = true;
- }
- else if (anyElementURI.equals("##other")) //$NON-NLS-1$
- {
- result = true;
- CMDocument cmDocument = (CMDocument)anyElement.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- String excludedURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- if (excludedURI != null)
- {
- String specifiedURI = getURIForContentSpecification(string);
- if (specifiedURI != null && excludedURI.equals(specifiedURI))
- {
- result = false;
- }
- }
- }
- }
- else if (anyElementURI.equals("##targetNamespace")) //$NON-NLS-1$
- {
- result = true;
- CMDocument cmDocument = (CMDocument)anyElement.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- String targetNamespaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- String specifiedURI = getURIForContentSpecification(string);
- if (specifiedURI != null && !targetNamespaceURI.equals(specifiedURI))
- {
- result = false;
- }
- }
- }
- else
- {
- result = true;
- String specifiedURI = getURIForContentSpecification(string);
- if (specifiedURI != null && !anyElementURI.equals(specifiedURI))
- {
- result = false;
- }
- }
- }
- else
- {
- result = true;
- }
- }
- }
- return result;
- }
-
-
- protected String getURIForContentSpecification(String specification)
- {
- String result = null;
- int index = specification.indexOf("]"); //$NON-NLS-1$
- if (index != -1)
- {
- result = specification.substring(1, index);
- }
- return result;
- }
- }
-
- public static List createStringList(String arg[], int startIndex)
- {
- Vector v = new Vector();
- for (int i = startIndex; i < arg.length; i++)
- {
- v.add(arg[i]);
- }
- return v;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/DOMValidator.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/DOMValidator.java
deleted file mode 100644
index 4a11a27922..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/util/DOMValidator.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * 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.internal.util;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-/**
- * A special CMValidator that knows about DOMs
- */
-public class DOMValidator extends CMValidator
-{
- protected String getNamespaceURI(Node node)
- {
- return DOMNamespaceHelper.getNamespaceURI(node);
- //return node.getNamespaceURI();
- }
-
-
- //
- // This is a temporary hack!!
- //
- protected String getFallbackNamepaceURI(CMElementDeclaration ed)
- {
- String fallbackNamepaceURI = null;
- CMDocument cmDocument = (CMDocument)ed.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- fallbackNamepaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- }
- return fallbackNamepaceURI;
- }
-
- /**
- * Encode the Element's NodeList as a List of strings that the validator recognizes
- */
- public List createContentSpecificationList(Element element, CMElementDeclaration ed)
- {
- boolean isNamespaceAware = isNamespaceAware(ed);
- Vector v = new Vector();
- for (Node childNode = element.getFirstChild(); childNode != null; childNode = childNode.getNextSibling())
- {
- v.add(createContentSpecification(childNode, isNamespaceAware, isNamespaceAware ? getFallbackNamepaceURI(ed) : null));
- }
- return v;
- }
-
-
- public List createContentSpecificationList(List nodeList, CMElementDeclaration ed)
- {
- boolean isNamespaceAware = isNamespaceAware(ed);
- Vector v = new Vector();
-
- for (Iterator i = nodeList.iterator(); i.hasNext(); )
- {
- Node node = (Node)i.next();
- v.add(createContentSpecification(node, isNamespaceAware, getFallbackNamepaceURI(ed)));
- }
- return v;
- }
-
-
- /**
- * Encode the Node as a string that the validator recognizes
- */
- public String createContentSpecification(Node node, boolean isNamespaceAware, String fallbackNamepaceURI)
- {
- String result = "!"; //$NON-NLS-1$
- switch (node.getNodeType())
- {
- case Node.ELEMENT_NODE :
- {
- String nodeName = node.getNodeName();
- if (nodeName.startsWith("jsp:")) //$NON-NLS-1$
- {
- result = "!"; // treat it as a comment so that it's ignored by the validator //$NON-NLS-1$
- }
- else
- {
- if (isNamespaceAware)
- {
- result = DOMNamespaceHelper.getUnprefixedName(nodeName);
- String uri = getNamespaceURI(node);
- if (uri != null)
- {
- result = "[" + uri + "]" + result; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if (fallbackNamepaceURI != null)
- {
- result = "[" + fallbackNamepaceURI + "]" + result; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- else
- {
- result = nodeName;
- }
- }
- //ContentModelManager.println("result " + result);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- result = "?"; //$NON-NLS-1$
- break;
- }
- case Node.COMMENT_NODE :
- {
- result = "!"; //$NON-NLS-1$
- break;
- }
- case Node.CDATA_SECTION_NODE :
- {
- result = "\"" + node.getNodeName() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- case Node.TEXT_NODE :
- {
- String data = ((Text)node).getData();
- // here we test to see if the test node is 'ignorable'
- if (data != null && data.trim().length() > 0)
- {
- result = "\"" + node.getNodeName() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- {
- result = "!"; // todo... use another symbol? //$NON-NLS-1$
- }
- break;
- }
- }
- return result;
- }
-
-
- /**
- *
- */
- public List createContentSpecificationList(CMNode cmNode)
- {
- List list = new Vector();
- switch (cmNode.getNodeType())
- {
- case CMNode.ELEMENT_DECLARATION :
- {
- list.add(createContentSpecificationForCMElementDeclaration((CMElementDeclaration)cmNode));
- break;
- }
- case CMNode.DATA_TYPE :
- {
- list.add("\"" + cmNode.getNodeName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- case CMNode.GROUP :
- {
- createContentSpecificationListForCMGroup((CMGroup)cmNode, list);
- break;
- }
- case CMNode.ANY_ELEMENT :
- {
- list.add("*"); //$NON-NLS-1$
- break;
- }
- default :
- {
- list.add("!"); //$NON-NLS-1$
- }
- }
- return list;
- }
-
-
- /**
- *
- */
- protected String createContentSpecificationForCMElementDeclaration(CMElementDeclaration ed)
- {
- CMDocument document = (CMDocument)ed.getProperty("CMDocument"); //$NON-NLS-1$
- String uri = document != null ? (String)document.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") : null; //$NON-NLS-1$
- String string = ed.getNodeName();
- if (uri != null)
- {
- string = "[" + uri + "]" + string; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return string;
- }
-
- /**
- *
- */
- protected void createContentSpecificationListForCMGroup(CMGroup group, List list)
- {
- CMGroupContentVisitor visitor = new CMGroupContentVisitor(group, list);
- visitor.visitCMNode(group);
- }
-
- protected class CMGroupContentVisitor extends CMVisitor
- {
- protected CMGroup root;
- protected List list;
-
- public CMGroupContentVisitor(CMGroup root, List list)
- {
- this.root = root;
- this.list = list;
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- if (ed.getMinOccur() > 0)
- {
- list.add(createContentSpecificationForCMElementDeclaration(ed));
- }
- }
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- list.add("*"); //$NON-NLS-1$
- }
-
- public void visitCMGroup(CMGroup group)
- {
- if (group == root || group.getMinOccur() > 0)
- {
- int op = group.getOperator();
- if (op == CMGroup.SEQUENCE)
- {
- super.visitCMGroup(group);
- }
- else if (op == CMGroup.CHOICE)
- {
- CMNodeList nodeList = group.getChildNodes();
- if (nodeList.getLength() > 0)
- {
- visitCMNode(nodeList.item(0));
- }
- }
- }
- }
- }
-
- public boolean isNamespaceAware(CMElementDeclaration ed)
- {
- return ed != null ? ed.getProperty("http://org.eclipse.wst/cm/properties/isNameSpaceAware") != null : false; //$NON-NLS-1$
- }
-
- /**
- *
- */
- public CMNode[] getOriginArray(CMElementDeclaration ed, Element element)
- {
- ElementPathRecordingResult result = new ElementPathRecordingResult();
- getOriginArray(ed, createContentSpecificationList(element, ed), stringContentComparitor, result);
- return result.getOriginArray();
- }
-
- /**
- *
- */
- public MatchModelNode getMatchModel(CMElementDeclaration ed, Element element)
- {
- MatchModelNode matchModelNode = null;
- PathRecordingResult result = new PathRecordingResult();
- validate(ed, createContentSpecificationList(element, ed), stringContentComparitor, result);
- if (result.isValid)
- {
- matchModelNode = result.getMatchModel();
- }
- return matchModelNode;
- }
-
-
- public List clone(List list)
- {
- List result = new Vector(list.size());
- result.addAll(list);
- return result;
- }
-
- /**
- *
- */
- public boolean canInsert(CMElementDeclaration ed, List contentSpecificationList, int insertIndex, CMNode cmNode)
- {
- List clonedList = clone(contentSpecificationList);
- insert(clonedList, insertIndex, cmNode);
- boolean result = isPartiallyValid(ed, clonedList);
- return result;
- }
-
- /**
- *
- */
- public boolean canInsert(CMElementDeclaration ed, List contentSpecificationList, int insertIndex, List cmNodeList)
- {
- List clonedList = clone(contentSpecificationList);
- insert(clonedList, insertIndex, cmNodeList);
- return isValid(ed, clonedList);
- }
-
- /**
- *
- */
- public boolean canRemove(CMElementDeclaration ed, List contentSpecificationList, int startRemoveIndex)
- {
- return canRemove(ed, contentSpecificationList, startRemoveIndex, startRemoveIndex);
- }
-
- /**
- *
- */
- public boolean canRemove(CMElementDeclaration ed, List contentSpecificationList, int startRemoveIndex, int endRemoveIndex)
- {
- List clonedList = clone(contentSpecificationList);
- remove(clonedList, startRemoveIndex, endRemoveIndex);
- return isValid(ed, clonedList);
- }
-
- /**
- *
- */
- public boolean canReplace(CMElementDeclaration ed, List contentSpecificationList, int startRemoveIndex, int endRemoveIndex, CMNode cmNode)
- {
- List clonedList = clone(contentSpecificationList);
- remove(clonedList, startRemoveIndex, endRemoveIndex);
- insert(clonedList, startRemoveIndex, cmNode);
- return isValid(ed, clonedList);
- }
-
- /**
- *
- */
- public boolean isValid(CMElementDeclaration ed, List contentSpecificationList)
- {
- Result result = new Result();
- validate(ed, contentSpecificationList, stringContentComparitor, result);
- return result.isValid;
- }
-
- public boolean isPartiallyValid(CMElementDeclaration ed, List contentSpecificationList)
- {
- CMValidator.ElementPathRecordingResult result = new CMValidator.ElementPathRecordingResult();
- validate(ed, contentSpecificationList, stringContentComparitor, result);
- int count = getElementCount(contentSpecificationList);
- //System.out.println("elementOriginList " + result.getPartialValidationCount() + "vs" + count);
- return result.getPartialValidationCount() >= count;
- }
-
- public int getElementCount(List contentSpecificationList)
- {
- int count = 0;
- for (Iterator i = contentSpecificationList.iterator(); i.hasNext(); )
- {
- if (stringContentComparitor.isElement(i.next()))
- {
- count++;
- }
- }
- return count;
- }
-
- protected Result validate(CMElementDeclaration ed, Element element)
- {
- Result result = new Result();
- validate(ed, createContentSpecificationList(element, ed), stringContentComparitor, result);
- return result;
- }
-
-
- protected void remove(List stringList, int startRemoveIndex, int endRemoveIndex)
- {
- if (startRemoveIndex != -1)
- {
- for (int i = startRemoveIndex; i <= endRemoveIndex; i++)
- {
- stringList.remove(i);
- }
- }
- }
-
- protected void insert(List stringList, int insertIndex, CMNode cmNode)
- {
- if (insertIndex != -1)
- {
- stringList.addAll(insertIndex, createContentSpecificationList(cmNode));
- }
- }
-
- protected void insert(List stringList, int insertIndex, List cmNodeList)
- {
- if (insertIndex != -1)
- {
- int insertListSize = cmNodeList.size();
- for (int i = insertListSize - 1; i >= 0; i--)
- {
- CMNode cmNode = (CMNode)cmNodeList.get(i);
- stringList.addAll(insertIndex, createContentSpecificationList(cmNode));
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManager.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManager.java
deleted file mode 100644
index 6fbee2aa9c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManager.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-
-
-/**
- * The CMDocumentManager can be visualized as a table of CMDocument
- * references, each with a corresponding entry in a CMDocument cache. The
- * CMDocumentManager also performs the task of loading CMDocuments providing
- * support for synchronous and asynchronous loading.
- *
- * publicIdTable CMDocumentCache ---------------------------
- * --------------------------------------- | publicId | resolvedURI | -> |
- * resolvedURI | status | CMDocument | ---------------------------
- * --------------------------------------- | (null) | file:/x.dtd | |
- * file:/x.dtd | loading | (null) | ---------------------------
- * --------------------------------------- | http:/... | file:/y.xsd | |
- * file:/y.xsd | loaded | | ---------------------------
- * ---------------------------------------
- *
- */
-public interface CMDocumentManager {
- /**
- * This property specifies WHEN CMDocuments are loaded. Setting this
- * property to true allows the CMDocumentManager to load CMDocuments on
- * demand. Settings this property a false puts the onus on the client to
- * call addCMDocumentReference() to explicity trigger a load. This allows
- * the client to control exactly when loading should take place. )
- */
- public static final String PROPERTY_AUTO_LOAD = "autoLoad"; //$NON-NLS-1$
-
- /**
- * This property specifies HOW CMDocuments are loaded. When set to false,
- * the getCMDocument() method will load the CMDocument synchronously and
- * return a CMDocument object when loading is successful. When set to
- * true, the getCMDocument() will load the CMDocument asynchronously and
- * will immediately return null. When loading is complete, the
- * CMDocumentManager will inform its listeners that the CMDocument has
- * been loaded.
- */
- public static final String PROPERTY_ASYNC_LOAD = "asyncLoad"; //$NON-NLS-1$
-
- /**
- *
- */
- public static final String PROPERTY_USE_CACHED_RESOLVED_URI = "useCachedResovledURI"; //$NON-NLS-1$
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=136399
- * Allows a client to control whether the document manager attempts to resolve a
- * CM document's URI. When set to false, the CM systemID will be assumed to point
- * to an already resolved URI. By default this property is set to true.
- */
- public static final String PROPERTY_PERFORM_URI_RESOLUTION = "performURIResolution"; //$NON-NLS-1$
-
- /**
- * Set the enabled state of a property.
- */
- public void setPropertyEnabled(String propertyName, boolean enabled);
-
- /**
- * Get the enabled state of the property.
- */
- public boolean getPropertyEnabled(String propertyName);
-
- /**
- * Adds a listener. Listeners should expect to receive call backs on a
- * secondary thread when asynchronously loading is used.
- */
- public void addListener(CMDocumentManagerListener listener);
-
- /**
- * Removes a listener.
- */
- public void removeListener(CMDocumentManagerListener listener);
-
- /**
- * Lookup or create a CMDocument (depending on PROPERTY_AUTO_LOAD).
- *
- * @param publicId
- * @param systemId
- * @param type -
- * 'dtd', 'xsd', 'tld', etc. if null is given as the type, then
- * the type is calculated as last segment (e.g. file extension)
- * of the resolved URI
- * @return
- */
- public CMDocument getCMDocument(String publicId, String systemId, String type);
-
- /**
- * Lookup a CMDocument.
- */
- public CMDocument getCMDocument(String publicId);
-
- /**
- * Get the status of a CMDocument.
- */
- public int getCMDocumentStatus(String publicId);
-
- /**
- * Creates a CMDocument and adds the associated CMDocument reference
- * information to the table. Calling this method always triggers a
- * CMDocument load.
- */
- public void addCMDocumentReference(String publicId, String systemId, String type);
-
- /**
- * Add an existingCMDocument and the reference information to the table.
- */
- public void addCMDocument(String publicId, String systemId, String resolvedURI, String type, CMDocument cmDocument);
-
- /**
- * Remove all entries from the table.
- */
- public void removeAllReferences();
-
- /**
- * Get the CMDocumentCache that is used to store loaded CMDocuments and
- * associated status.
- */
- public CMDocumentCache getCMDocumentCache();
-
- /**
- * Builds a CMDocument given a resoulvedURI. Note that no entries are
- * added to the table.
- */
- public CMDocument buildCMDocument(String publicId, String resolvedURI, String type);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManagerListener.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManagerListener.java
deleted file mode 100644
index bd607dccc8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentManagerListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCacheListener;
-
-/**
- *
- */
-public interface CMDocumentManagerListener extends CMDocumentCacheListener
-{
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReference.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReference.java
deleted file mode 100644
index 1d57f4612d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReference.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-
-public interface CMDocumentReference
-{
- public String getPublicId();
- public String getSystemId();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReferenceProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReferenceProvider.java
deleted file mode 100644
index d7dc8bfaa8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/CMDocumentReferenceProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import java.util.List;
-
-import org.w3c.dom.Node;
-
-/**
- * The interface is used to abstract the task of computing the document references associated with a DOM
- * or a particular node within the DOM.
- */
-public interface CMDocumentReferenceProvider
-{
- List getCMDocumentReferences(Node node, boolean deep);
- String resolveGrammarURI(String publicId, String systemId);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/IExternalSchemaLocationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/IExternalSchemaLocationProvider.java
deleted file mode 100644
index 4ce758335c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/IExternalSchemaLocationProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.modelquery;
-
-import java.net.URI;
-import java.util.Map;
-
-public interface IExternalSchemaLocationProvider {
- String SCHEMA_LOCATION = "http://apache.org/xml/properties/schema/external-schemaLocation"; //$NON-NLS-1$
- String NO_NAMESPACE_SCHEMA_LOCATION = "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"; //$NON-NLS-1$
-
- /**
- * Provided the file path URI, this will return the external schema location. The schema location is associated to a specific property,
- * which serves as the key in the map. The supported properties are:
- *
- * <p><b>http://apache.org/xml/properties/schema/external-schemaLocation</b> - The value for this property follows the same rules
- * as the schemaLocation attribute for an XML document (i.e., multiple schemas are acceptable and must be white-space separated).</p>
- *
- * <p><b>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</b> - The value for this property follows the same
- * rules as the noNamespaceSchemaLocation attribute for an XML document (i.e., only one schema is allowed).
- *
- * @param filePath the path for the XML file
- * @return a {@link Map} associating the external-schemaLocation and/or external-noNamespaceSchemaLocation to the schema location
- */
- Map getExternalSchemaLocation(URI fileURI);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQuery.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQuery.java
deleted file mode 100644
index 5d300e8d7c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQuery.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtensionManager;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * This class provides an interface for performing higher level queries based on
- * a xml model (DOM) and one or more associated content models (CMDocument).
- *
- * The queries provided can be organized into three groups:
- *
- * 1) DOM Node to CMNode mapping
- * Given a grammatically valid DOM Node the corresponding CMNode can be determined.
- * (i.e. Element -> CMElementDeclaration, Attr -> CMAttributeDeclaration, CharacterData -> CMDataType)
- *
- * 2) DOM editing tests ("Can I do this?")
- * Questions such as canInsert, canRemove, canReplace can assist in the editing of a DOM.
- *
- * The validityChecking argument determines the strictness of the validity testing that occurs.
- *
- * - VALIDITY_NONE : The current content of the Element is ignored.
- * Only the content model is considered.
- * This is most useful for codeassist related queries.
- *
- * - VALIDITY_STRICT : The current content of the Element is considered.
- * Returns true only if the operation preserves content validity.
- * This is useful when DOM editing needs to be constrained to maintain validity.
- *
- * - VALIDITY_PARTIAL : Some optimized compromise between the two options above.
- *
- * 3) DOM editing actions ("What can I do here?")
- * These methods return ModelQueryActions that are relevant at some specified DOM Node.
- * The actions indicate what kinds of DOM Node can be inserted where (at what index).
- */
-public interface ModelQuery
-{
- public static final int VALIDITY_NONE = 0;
- public static final int VALIDITY_PARTIAL = 1;
- public static final int VALIDITY_STRICT = 2;
-
- public static final int INCLUDE_ALL = 0xFF;
- public static final int INCLUDE_ATTRIBUTES = 0x01;
- public static final int INCLUDE_CHILD_NODES = 0x02;
- public static final int INCLUDE_SEQUENCE_GROUPS = 0x04;
- public static final int INCLUDE_TEXT_NODES = 0x08;
- public static final int INCLUDE_ENCLOSING_REPLACE_ACTIONS = 0x10;
-
- public static final int EDIT_MODE_UNCONSTRAINED = 0;
- public static final int EDIT_MODE_CONSTRAINED_LENIENT= 1;
- public static final int EDIT_MODE_CONSTRAINED_STRICT = 2;
-
-
- void setEditMode(int editMode);
-
- int getEditMode();
-
- /**
- * Returns the CMDocument that corresponds to the DOM Node.
- * or null if no CMDocument is appropriate for the DOM Node.
- */
- CMDocument getCorrespondingCMDocument(Node node);
-
- /**
- * Returns the corresponding CMNode for the DOM Node
- * or null if no CMNode is appropriate for the DOM Node.
- */
- CMNode getCMNode(Node node);
-
- /**
- * Returns the corresponding CMAttribute for the DOM Node
- * or null if no CMNode is appropriate for the DOM Node.
- */
- CMAttributeDeclaration getCMAttributeDeclaration(Attr attr);
-
- /**
- * Returns the corresponding CMAttribute for the DOM Node
- * or null if no CMNode is appropriate for the DOM Node.
- */
- CMElementDeclaration getCMElementDeclaration(Element element);
-
- /**
- * Returns true if the content of the element is valid
- */
- boolean isContentValid(Element element);
-
- /**
- * Returns the CMNode of the parent element's content model
- * that corresponds to the node
- */
- CMNode getOrigin(Node node);
-
- /**
- * Returns an array of CMNodes of the parent element's content model
- * that corresponds to the node
- */
- CMNode[] getOriginArray(Element element);
-
- /**
- * Returns a list of all CMNode 'meta data' that may be potentially added to the element.
- */
- List getAvailableContent(Element element, CMElementDeclaration ed, int includeOptions);
-
- /**
- * Can a DOM Node corresponding to the CMNode 'meta data' be added to the parent
- */
- boolean canInsert(Element parent, CMNode cmNode, int index, int validityChecking);
-
- /**
- * Can multiple DOM Nodes corresponding to the list of CMNode 'meta data' be added to the parent
- */
- boolean canInsert(Element parent, List cmNodeList, int index, int validityChecking);
-
- /**
- * Can the DOM Node be removed
- */
- boolean canRemove(Node node, int validityChecking);
-
- /**
- * Can the list of DOM Nodes be removed
- */
- boolean canRemove(List nodeList, int validityChecking);
-
- /**
- * Can the children within the indicated indices be replaced with a DOM Node corresponding to the CMNode 'meta data'
- */
- boolean canReplace(Element parent, int startIndex, int endIndex, CMNode cmNode, int validityChecking);
-
- /**
- * Can the children within the indicated indices be replaced with multiple DOM Nodes corresponding to the list of CMNode 'meta data'
- */
- boolean canReplace(Element parent, int startIndex, int endIndex, List cmNodeList, int validityChecking);
-
- /**
- *
- */
- void getInsertActions(Element parent, CMElementDeclaration ed, int index, int includeOptions, int validityChecking, List actionList);
-
- /**
- *
- */
- void getInsertActions(Document parent, CMDocument cmDocument, int index, int includeOptions, int validityChecking, List actionList);
-
- /**
- * Return a list of replace actions that can be performed on the parent's content
- */
- void getReplaceActions(Element parent, CMElementDeclaration ed, int includeOptions, int validityChecking, List actionList);
-
- /**
- * Return a list of replace actions that can be performed on the selected children of that parent
- */
- void getReplaceActions(Element parent, CMElementDeclaration ed, List selectedChildren, int includeOptions, int validityChecking, List actionList);
-
-
- /**
- * @deprecated - use getPossibleDataTypeValues()
- */
- List getDataTypeValues(Element element, CMNode cmNode);
-
- /**
- * This methods return an array of possible values corresponding to the datatype of the CMNode (either an CMAttributeDeclaration or a CMElementDeclaration)
- */
- String[] getPossibleDataTypeValues(Element element, CMNode cmNode);
-
- /**
- * This method may return null if a CMDocumentManager is not used by the ModelQuery
- */
- CMDocumentManager getCMDocumentManager();
-
- /**
- * This method may return null the ModelQuery doesn't support the use of extensions
- */
- ModelQueryExtensionManager getExtensionManager();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAction.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAction.java
deleted file mode 100644
index 059c4ff78b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Node;
-
-
-public interface ModelQueryAction
-{
- public static final int INSERT = 1;
- public static final int REMOVE = 2;
- public static final int REPLACE = 4;
-
- public int getKind();
- /**
- * if start index == -1 then no insert is possible
- * if start index != -1 and endIndex == -1 then an insert at any position is possible
- */
- public int getStartIndex();
- public int getEndIndex();
- public Node getParent();
- public CMNode getCMNode();
- public Object getUserData();
- public void setUserData(Object object);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAssociationProvider.java
deleted file mode 100644
index 77777560c4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryAssociationProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-/**
- *
- *
- */
-public interface ModelQueryAssociationProvider extends ModelQueryCMProvider
-{
- public CMNode getCMNode(Node node);
- public CMDataType getCMDataType(Text text);
- public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr);
- public CMElementDeclaration getCMElementDeclaration(Element element);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryCMProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryCMProvider.java
deleted file mode 100644
index f0f937396c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/ModelQueryCMProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.modelquery;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.w3c.dom.Node;
-
-
-
-/**
- *
- */
-public interface ModelQueryCMProvider
-{
- /**
- * Returns the CMDocument that corresponds to the DOM Node.
- * or null if no CMDocument is appropriate for the DOM Node.
- */
- CMDocument getCorrespondingCMDocument(Node node);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java
deleted file mode 100644
index b417f569d5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.modelquery.extension;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public abstract class ModelQueryExtension
-{
- protected static final String[] EMPTY_STRING_ARRAY = {};
- protected static final CMNode[] EMPTY_CMNODE_ARRAY = {};
-
- /**
- * @param ownerElement - the owner element
- * @param namespace - the active namespace
- * @param name - the name of an attribute node
- * @return valid values for the given attribute
- */
-public String[] getAttributeValues(Element ownerElement, String namespace, String name)
- {
- return EMPTY_STRING_ARRAY;
- }
-
- public String[] getElementValues(Node parentNode, String namespace, String name)
- {
- return EMPTY_STRING_ARRAY;
- }
-
- /**
- * @param parentNode
- * @param namespace
- * @param name
- * @return whether a child element of the given parentNode is valid given the active namespace
- */
-public boolean isApplicableChildElement(Node parentNode, String namespace, String name)
- {
- return true;
- }
-
- /**
- * @param parentElement - the parent Element when asking for children, the owner Element when asking for attributes
- * @param namespace - the active namespace
- * @param includeOptions - ModelQuery.INCLUDE_ATTRIBUTES or ModelQuery.INCLUDE_CHILD_NODES
- * @return additional valid CMAttributeDeclarations or CMElementDeclarations
- */
-public CMNode[] getAvailableElementContent(Element parentElement, String namespace, int includeOptions)
- {
- return EMPTY_CMNODE_ARRAY;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java
deleted file mode 100644
index 31c440fb11..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.modelquery.extension;
-
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Element;
-
-
-
-public interface ModelQueryExtensionManager
-{
- List getDataTypeValues(Element element, CMNode cmNode);
-
- void filterAvailableElementContent(List availableContent, Element element, CMElementDeclaration ed);
-
- void filterAvailableElementContent(List availableContent, Element element, CMElementDeclaration ed, int includeOptions);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/BaseAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/BaseAssociationProvider.java
deleted file mode 100644
index 54242f6654..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/BaseAssociationProvider.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAssociationProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-/**
- *
- */
-public abstract class BaseAssociationProvider implements ModelQueryAssociationProvider
-{
- public BaseAssociationProvider()
- {
- }
-
- public CMNode getCMNode(Node node)
- {
- CMNode result = null;
- switch (node.getNodeType())
- {
- case Node.ATTRIBUTE_NODE :
- {
- result = getCMAttributeDeclaration((Attr)node);
- break;
- }
- case Node.ELEMENT_NODE :
- {
- result = getCMElementDeclaration((Element)node);
- break;
- }
- case Node.CDATA_SECTION_NODE :
- case Node.TEXT_NODE :
- {
- result = getCMDataType((Text)node);
- break;
- }
- }
- return result;
- }
-
-
- public CMDataType getCMDataType(Text text)
- {
- CMDataType result = null;
- Node parentNode = text.getParentNode();
- if (parentNode != null && parentNode.getNodeType() == Node.ELEMENT_NODE)
- {
- CMElementDeclaration ed = getCMElementDeclaration((Element)parentNode);
- result = ed.getDataType();
- }
- return result;
- }
-
-
- public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr)
- {
- CMAttributeDeclaration result = null;
- Element element = attr.getOwnerElement();
- if (element != null)
- {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- if (ed != null)
- {
- result = (CMAttributeDeclaration)ed.getAttributes().getNamedItem(attr.getName());
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentLoader.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentLoader.java
deleted file mode 100644
index a4900efce8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentLoader.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import java.io.File;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.IExternalSchemaLocationProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- *
- */
-public class CMDocumentLoader
-{
- private final static boolean _trace = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.xml.core/externalSchemaLocation")).booleanValue(); //$NON-NLS-1$
- protected Document document;
- protected ModelQuery modelQuery;
- protected CMDocumentManager cmDocumentManager;
- protected boolean isInferredGrammarEnabled = true;
- protected CMDocumentLoadingNamespaceTable namespaceTable;
- protected int count = 0;
-
- public CMDocumentLoader(Document document, ModelQuery modelQuery)
- {
- this(document, modelQuery.getCMDocumentManager());
- }
-
- public CMDocumentLoader(Document document, CMDocumentManager cmDocumentManager)
- {
- this.document = document;
- this.cmDocumentManager = cmDocumentManager;
- }
-
- public void loadCMDocuments()
- {
- //System.out.println("----------loadCMDocuments ------------");
- //long time = System.currentTimeMillis();
-
- boolean walkDocument = false;
-
- cmDocumentManager.removeAllReferences();
-
- String[] doctypeInfo = XMLAssociationProvider.getDoctypeInfo(document);
- if (doctypeInfo != null)
- {
- // load the doctype if required
- walkDocument = handleGrammar(doctypeInfo[0], doctypeInfo[1], "DTD"); //$NON-NLS-1$
- }
- else
- {
- Element element = getRootElement(document);
- if (element != null)
- {
- namespaceTable = new CMDocumentLoadingNamespaceTable(document);
- namespaceTable.addElement(element);
- if (namespaceTable.isNamespaceEncountered())
- {
- walkDocument = true;
- //System.out.println("isNamespaceAware");
- }
- else
- {
- namespaceTable = null;
- walkDocument = isInferredGrammarEnabled;
- //System.out.println("is NOT namespaceAware");
- }
- }
- }
-
- if (walkDocument)
- {
- if (!checkExternalSchema())
- visitNode(document);
- }
-
- //System.out.println("--- elapsed time (" + count + ") = " + (System.currentTimeMillis() - time));
- }
-
- protected boolean checkExternalSchema() {
- boolean externalSchemaLoaded = false;
- if (document instanceof IDOMDocument) {
- final String baseLocation = ((IDOMDocument) document).getModel().getBaseLocation();
- if (baseLocation == null)
- return false;
- final IPath basePath = new Path(baseLocation);
- IFile file = null;
- if (basePath.segmentCount() > 1) {
- file = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
- }
- final URI uri = (file == null || !file.isAccessible()) ? new File(baseLocation).toURI() : file.getLocationURI();
- if (uri != null) {
- IExternalSchemaLocationProvider[] providers = ExternalSchemaLocationProviderRegistry.getInstance().getProviders();
- for (int i = 0; i < providers.length; i++) {
- long time = _trace ? System.currentTimeMillis(): 0;
- final Map locations = providers[i].getExternalSchemaLocation(uri);
- if (_trace) {
- long diff = System.currentTimeMillis() - time;
- if (diff > 250)
- Logger.log(Logger.INFO, "Schema location provider took [" + diff + "ms] for URI [" + uri + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- if (locations != null && !locations.isEmpty()) {
- // Use the externalSchemaLocation
- if (namespaceTable != null && namespaceTable.isNamespaceEncountered()) {
- final String location = locations.get(IExternalSchemaLocationProvider.SCHEMA_LOCATION).toString();
- if (location != null) {
- final String[] ids = StringUtils.asArray(location);
- // namespace : location pairs
- if (ids.length >= 2 && ids.length % 2 == 0) {
- if (!externalSchemaLoaded)
- cmDocumentManager.removeAllReferences();
- for (int j = 0; j < ids.length; j+=2) {
- handleGrammar(ids[j], ids[j + 1], "XSD"); //$NON-NLS-1$
- externalSchemaLoaded = true;
- }
- }
- }
- }
- else { // noNamespace
- handleGrammar(uri.toString(), locations.get(IExternalSchemaLocationProvider.NO_NAMESPACE_SCHEMA_LOCATION).toString(), "XSD"); //$NON-NLS-1$
- externalSchemaLoaded = true;
- break;
- }
- }
- }
- }
- }
- return externalSchemaLoaded;
- }
-
- public boolean handleGrammar(String publicId, String systemId, String type)
- {
- boolean result = false;
-
- int status = cmDocumentManager.getCMDocumentStatus(publicId);
- if (status == CMDocumentCache.STATUS_NOT_LOADED)
- {
- cmDocumentManager.addCMDocumentReference(publicId, systemId, type);
- }
- else if (status == CMDocumentCache.STATUS_ERROR)
- {
- result = true;
- }
- return result;
- }
-
-
- public void handleElement(Element element)
- {
- visitChildNodes(element);
- }
-
-
- public void handleElementNS(Element element)
- {
- namespaceTable.addElement(element);
- visitChildNodes(element);
- }
-
-
- public void visitNode(Node node)
- {
- int nodeType = node.getNodeType();
- if (nodeType == Node.ELEMENT_NODE)
- {
- count++;
-
- Element element = (Element)node;
- if (namespaceTable == null)
- {
- handleElement(element);
- }
- else
- {
- handleElementNS(element);
- }
- }
- else if (nodeType == Node.DOCUMENT_NODE)
- {
- visitChildNodes(node);
- }
- }
-
-
- protected void visitChildNodes(Node node)
- {
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling())
- {
- visitNode(child);
- }
- }
-
-
- protected class CMDocumentLoadingNamespaceTable extends NamespaceTable
- {
- protected List newNamespaceList;
-
- public CMDocumentLoadingNamespaceTable(Document document)
- {
- super(document);
- }
-
-
- public void addElement(Element element)
- {
- newNamespaceList = null;
- super.addElement(element);
- if (newNamespaceList != null)
- {
- for (Iterator i = newNamespaceList.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- handleGrammar(info.uri, info.locationHint, "XSD"); //$NON-NLS-1$
- }
- }
- }
-
-
- protected void internalAddNamespaceInfo(String key, NamespaceInfo info)
- {
- super.internalAddNamespaceInfo(key, info);
- if (newNamespaceList == null)
- {
- newNamespaceList = new ArrayList();
- }
- newNamespaceList.add(info);
- }
- }
-
-
- protected Element getRootElement(Document document)
- {
- Element result = null;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0 ; i < nodeListLength; i++)
- {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- result = (Element)node;
- break;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java
deleted file mode 100644
index 3e4af8cf2b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.modelqueryimpl;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.annotation.AnnotationUtility;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentReferenceProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.GlobalCMDocumentCache.GlobalCacheQueryResponse;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-
-import com.ibm.icu.text.MessageFormat;
-
-/**
- *
- */
-public class CMDocumentManagerImpl implements CMDocumentManager
-{
- protected CMDocumentCache cmDocumentCache;
- protected CMDocumentReferenceProvider cmDocumentReferenceProvider;
- protected List listenerList = new Vector();
- protected Hashtable propertyTable = new Hashtable();
- protected Hashtable publicIdTable = new Hashtable();
- private boolean globalCMDocumentCacheEnabled ;
-
-
- public CMDocumentManagerImpl(CMDocumentCache cmDocumentCache, CMDocumentReferenceProvider cmDocumentReferenceProvider)
- {
- this.cmDocumentCache = cmDocumentCache;
- this.cmDocumentReferenceProvider = cmDocumentReferenceProvider;
- setPropertyEnabled(PROPERTY_AUTO_LOAD, true);
- setPropertyEnabled(PROPERTY_USE_CACHED_RESOLVED_URI, false);
- setPropertyEnabled(PROPERTY_PERFORM_URI_RESOLUTION, true);
- initializeGlobalCMDocumentCacheSettings();
- }
-
-
- public CMDocumentCache getCMDocumentCache()
- {
- return cmDocumentCache;
- }
-
-
- public void setPropertyEnabled(String propertyName, boolean value)
- {
- propertyTable.put(propertyName, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- for (Iterator i = listenerList.iterator(); i.hasNext(); )
- {
- CMDocumentManagerListener listener = (CMDocumentManagerListener)i.next();
- listener.propertyChanged(this, propertyName);
- }
- }
-
-
- public boolean getPropertyEnabled(String propertyName)
- {
- Object object = propertyTable.get(propertyName);
- return object != null && object.equals("true"); //$NON-NLS-1$
- }
-
-
- public void addListener(CMDocumentManagerListener listener)
- {
- listenerList.add(listener);
- cmDocumentCache.addListener(listener);
- }
-
-
- public void removeListener(CMDocumentManagerListener listener)
- {
- listenerList.remove(listener);
- cmDocumentCache.removeListener(listener);
- }
-
-
- protected String lookupResolvedURI(String publicId)
- {
- String key = publicId != null ? publicId : ""; //$NON-NLS-1$
- return (String)publicIdTable.get(key);
- }
-
-
- protected String lookupOrCreateResolvedURI(String publicId, String systemId)
- {
- String resolvedURI = null;
-
- String key = publicId != null ? publicId : ""; //$NON-NLS-1$
-
- if (getPropertyEnabled(PROPERTY_USE_CACHED_RESOLVED_URI))
- {
- resolvedURI = (String)publicIdTable.get(key);
- }
-
- if (resolvedURI == null)
- {
- resolvedURI = cmDocumentReferenceProvider.resolveGrammarURI(publicId, systemId);
- if (resolvedURI == null)
- {
- resolvedURI = ""; //$NON-NLS-1$
- }
- publicIdTable.put(key, resolvedURI);
- }
-
- return resolvedURI;
- }
-
-
- public int getCMDocumentStatus(String publicId)
- {
- int status = CMDocumentCache.STATUS_NOT_LOADED;
- String resolvedURI = lookupResolvedURI(publicId);
- if (resolvedURI != null)
- {
- status = cmDocumentCache.getStatus(resolvedURI);
- }
- return status;
- }
-
-
- public CMDocument getCMDocument(String publicId)
- {
- CMDocument result = null;
- String resolvedURI = lookupResolvedURI(publicId);
- if (resolvedURI != null)
- {
- result = cmDocumentCache.getCMDocument(resolvedURI);
- }
- return result;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager#getCMDocument(java.lang.String, java.lang.String, java.lang.String)
- */
-public CMDocument getCMDocument(String publicId, String systemId, String type)
- {
- CMDocument cmDocument = null;
- String resolvedURI = null;
-
- if (getPropertyEnabled(PROPERTY_AUTO_LOAD))
- {
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=136399
-
- if (getPropertyEnabled(PROPERTY_PERFORM_URI_RESOLUTION))
- {
- resolvedURI = lookupOrCreateResolvedURI(publicId, systemId);
- }
- else
- {
- resolvedURI = systemId;
- }
- }
- else
- {
- resolvedURI = lookupResolvedURI(publicId);
- }
-
- if (resolvedURI != null)
- {
- int status = cmDocumentCache.getStatus(resolvedURI);
- if (status == CMDocumentCache.STATUS_LOADED)
- {
- cmDocument = cmDocumentCache.getCMDocument(resolvedURI);
- }
- else if (status == CMDocumentCache.STATUS_NOT_LOADED)
- {
- if (getPropertyEnabled(PROPERTY_AUTO_LOAD))
- {
- cmDocument = loadCMDocument(publicId, resolvedURI, type, getPropertyEnabled(PROPERTY_ASYNC_LOAD));
- }
- }
- }
- return cmDocument;
- }
-
- public void addCMDocumentReference(String publicId, String systemId, String type)
- {
- String resolvedURI = lookupOrCreateResolvedURI(publicId, systemId);
- if (resolvedURI != null && resolvedURI.length() > 0)
- {
- int status = cmDocumentCache.getStatus(resolvedURI);
- if (status == CMDocumentCache.STATUS_NOT_LOADED)
- {
- loadCMDocument(publicId, resolvedURI, type, getPropertyEnabled(PROPERTY_ASYNC_LOAD));
- }
- }
- }
-
-
- public void addCMDocument(String publicId, String systemId, String resolvedURI, String type, CMDocument cmDocument)
- {
- String key = publicId != null ? publicId : ""; //$NON-NLS-1$
- publicIdTable.put(key, resolvedURI);
- cmDocumentCache.putCMDocument(resolvedURI, cmDocument);
- }
-
-
- protected CMDocument loadCMDocument(final String publicId, final String resolvedURI, final String type, boolean async)
- {
- CMDocument result = null;
-
- //System.out.println("about to build CMDocument(" + publicId + ", " + unresolvedURI + " = " + resolvedURI + ")");
- if (async)
- {
- cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_LOADING);
- //Thread thread = new Thread(new AsyncBuildOperation(publicId, resolvedURI, type));
- //thread.start();
- Job job = new Job(XMLCoreMessages.loading + resolvedURI)
- {
- public boolean belongsTo(Object family)
- {
- boolean result = (family == CMDocumentManager.class);
- return result;
- }
-
- protected IStatus run(IProgressMonitor monitor)
- {
- try
- {
- buildCMDocument(publicId, resolvedURI, type);
- }
- catch (Exception e)
- {
- Logger.logException(MessageFormat.format(XMLCoreMessages.CMDocument_load_exception, new Object[]{resolvedURI, publicId}), e);
- }
- return Status.OK_STATUS;
- }
- };
- job.schedule();
- }
- else
- {
- result = buildCMDocument(publicId, resolvedURI, type);
- }
- return result;
- }
-
-
-
- public synchronized CMDocument buildCMDocument(String publicId, String resolvedURI, String type)
- {
- cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_LOADING);
- boolean documentCacheable = false;
- if(globalCMDocumentCacheEnabled) {
- GlobalCacheQueryResponse response = GlobalCMDocumentCache.getInstance().getCMDocument(resolvedURI);
- CMDocument cachedCMDocument = response.getCachedCMDocument();
- documentCacheable = response.isDocumentCacheable();
- if(cachedCMDocument != null) {
- cmDocumentCache.putCMDocument(resolvedURI, cachedCMDocument);
- return cachedCMDocument;
- }
- }
-
- CMDocument result = null;
- if (resolvedURI != null && resolvedURI.length() > 0)
- {
- // TODO... pass the TYPE thru to the CMDocumentBuilder
- result = ContentModelManager.getInstance().createCMDocument(resolvedURI, type);
- }
- if (result != null)
- {
- // load the annotation files for the document
- if (publicId != null)
- {
- AnnotationUtility.loadAnnotationsForGrammar(publicId, result);
- }
- if(globalCMDocumentCacheEnabled && documentCacheable) {
- GlobalCMDocumentCache.getInstance().putCMDocument(resolvedURI, result);
- }
- cmDocumentCache.putCMDocument(resolvedURI, result);
- }
- else
- {
- cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_ERROR);
- }
- return result;
- }
-
- public void removeAllReferences()
- {
- // TODO... initiate a timed release of the entries in the CMDocumentCache
- publicIdTable = new Hashtable();
- }
-
- private void initializeGlobalCMDocumentCacheSettings() {
- Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
- if(preferences != null) {
- globalCMDocumentCacheEnabled = preferences.getBoolean(XMLCorePreferenceNames.CMDOCUMENT_GLOBAL_CACHE_ENABLED);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentReferenceImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentReferenceImpl.java
deleted file mode 100644
index f4edabdb32..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentReferenceImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentReference;
-
-public class CMDocumentReferenceImpl implements CMDocumentReference
-{
- protected String systemId;
- protected String publicId;
-
- public CMDocumentReferenceImpl(String publicId, String systemId)
- {
- this.publicId = publicId;
- this.systemId = systemId;
- }
-
- public String getPublicId()
- {
- return publicId;
- }
-
- public String getSystemId()
- {
- return systemId;
- }
-
- public String toString()
- {
- return "[" + publicId + ", " + systemId + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ExternalSchemaLocationProviderRegistry.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ExternalSchemaLocationProviderRegistry.java
deleted file mode 100644
index 594c5d826e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ExternalSchemaLocationProviderRegistry.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.IExternalSchemaLocationProvider;
-
-/**
- * A registry for all external schema location providers.
- *
- */
-public class ExternalSchemaLocationProviderRegistry {
-
- private static ExternalSchemaLocationProviderRegistry fRegistry;
- private IExternalSchemaLocationProvider[] fProviders;
-
- private ExternalSchemaLocationProviderRegistry() {
- fProviders = new IExternalSchemaLocationProvider[0];
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.wst.xml.core", "externalSchemaLocations"); //$NON-NLS-1$ //$NON-NLS-2$
- List providers = new ArrayList(elements.length);
- try {
- for (int i = 0; i < elements.length; i++) {
- providers.add(elements[i].createExecutableExtension("class"));
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- fProviders = new IExternalSchemaLocationProvider[elements.length];
- providers.toArray(fProviders);
- }
-
- public IExternalSchemaLocationProvider[] getProviders() {
- return fProviders;
- }
-
- public static synchronized ExternalSchemaLocationProviderRegistry getInstance() {
- if (fRegistry == null)
- fRegistry = new ExternalSchemaLocationProviderRegistry();
- return fRegistry;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/GlobalCMDocumentCache.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/GlobalCMDocumentCache.java
deleted file mode 100644
index ca981f15dd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/GlobalCMDocumentCache.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl;
-
-import java.lang.ref.SoftReference;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.sse.core.internal.util.AbstractMemoryListener;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventConstants;
-
-public class GlobalCMDocumentCache {
-
- private static GlobalCMDocumentCache globalDocumentCache = new GlobalCMDocumentCache();
- private Map systemCatalogEntries = getSystemCatalogEntries();
- private MemoryListener memoryListener;
- private final static String CATEGORY = "CMDocumentGlobalCache"; //$NON-NLS-1$
-
- protected GlobalCMDocumentCache() {
- Logger.trace(CATEGORY, "Cache initialized"); //$NON-NLS-1$
- memoryListener = new MemoryListener();
- memoryListener.connect();
- }
-
- public static GlobalCMDocumentCache getInstance() {
- return globalDocumentCache;
- }
-
- public synchronized GlobalCacheQueryResponse getCMDocument(String grammarURI) {
- //Logger.trace(CATEGORY, "Query for: " + grammarURI); //$NON-NLS-1$
- Object systemCatalogEntry = systemCatalogEntries.get(grammarURI);
- if(systemCatalogEntry != null) {
- //Logger.trace(CATEGORY, "Document " + grammarURI + " is in system catalog"); //$NON-NLS-1$ //$NON-NLS-2$
- Object object = ((SoftReference)systemCatalogEntry).get();
- if(object != null) {
- //Logger.trace(CATEGORY, "Document " + grammarURI + "is in cache, returning cached version"); //$NON-NLS-1$ //$NON-NLS-2$
- return new GlobalCacheQueryResponse((CMDocument)object, true);
- } else {
- //Logger.trace(CATEGORY, "Document " + grammarURI + " is not in cache"); //$NON-NLS-1$ //$NON-NLS-2$
- return new GlobalCacheQueryResponse(null, true);
- }
- }
- //Logger.trace(CATEGORY, "Document " + grammarURI + " is not in system catalog, not cached"); //$NON-NLS-1$ //$NON-NLS-2$
- return new GlobalCacheQueryResponse(null, false);
- }
-
- public synchronized void putCMDocument(String grammarURI, CMDocument cmDocument) {
- //Logger.trace(CATEGORY, "Document: " + grammarURI + " added to global cache"); //$NON-NLS-1$ //$NON-NLS-2$
- systemCatalogEntries.put(grammarURI, new SoftReference(cmDocument));
- }
-
- private synchronized static HashMap getSystemCatalogEntries(){
- HashMap systemCatalogURIs = new HashMap();
- ICatalog systemCatalog = null;
- ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++) {
- INextCatalog catalog = nextCatalogs[i];
- ICatalog referencedCatalog = catalog.getReferencedCatalog();
- if (referencedCatalog != null) {
- if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
- systemCatalog = referencedCatalog;
- }
- }
- }
- if(systemCatalog != null) {
- ICatalogEntry[] catalogEntries = systemCatalog.getCatalogEntries();
- for (int i = 0; i < catalogEntries.length; i++) {
- systemCatalogURIs.put(catalogEntries[i].getURI(), new SoftReference(null));
- }
- }
- return systemCatalogURIs;
- }
-
- public class GlobalCacheQueryResponse {
-
- private CMDocument cachedDocument;
- private boolean documentCacheable;
-
- public GlobalCacheQueryResponse(CMDocument cachedCMDocument, boolean documentCacheable) {
- this.cachedDocument = cachedCMDocument;
- this.documentCacheable = documentCacheable;
- }
-
- public CMDocument getCachedCMDocument() {
- return cachedDocument;
- }
-
- public boolean isDocumentCacheable() {
- return documentCacheable;
- }
-
- }
-
- private class MemoryListener extends AbstractMemoryListener {
- protected void handleMemoryEvent(Event event) {
- Object topic = event.getProperty(EventConstants.EVENT_TOPIC);
- if(SEV_SERIOUS.equals(topic) || SEV_CRITICAL.equals(topic)) {
- Logger.trace(CATEGORY, "Serious severity low memory event received, flushing global CMDocument cache."); //$NON-NLS-1$
- systemCatalogEntries = getSystemCatalogEntries();
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/InferredGrammarBuildingCMDocumentLoader.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/InferredGrammarBuildingCMDocumentLoader.java
deleted file mode 100644
index c91e72cf45..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/InferredGrammarBuildingCMDocumentLoader.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import java.util.Hashtable;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.modelqueryimpl.InferredGrammarFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- *
- */
-public class InferredGrammarBuildingCMDocumentLoader extends CMDocumentLoader
-{
- protected CMElementDeclaration inferredCMElementDeclaration;
- protected CMDocument inferredCMDocument;
- protected InferredGrammarFactory inferredGrammarFactory;
- protected Hashtable createdCMDocumentTable;
-
- public InferredGrammarBuildingCMDocumentLoader(Document document, ModelQuery modelQuery)
- {
- this(document, modelQuery.getCMDocumentManager());
- }
-
- public InferredGrammarBuildingCMDocumentLoader(Document document, CMDocumentManager cmDocumentManager)
- {
- super(document, cmDocumentManager);
- createdCMDocumentTable = new Hashtable();
- inferredGrammarFactory = new InferredGrammarFactory();
- }
-
-
- public void loadCMDocuments()
- {
- //System.out.println("----------loadCMDocuments ------------");
- if (inferredGrammarFactory != null)
- {
- //long time = System.currentTimeMillis();
- super.loadCMDocuments();
- //System.out.println("--- elapsed time (" + count + ") = " + (System.currentTimeMillis() - time));
- //inferredGrammarFactory.debugPrint(createdCMDocumentTable.values());
- }
-
- }
-
- public void handleElement(Element element)
- {
- CMElementDeclaration parentInferredCMElementDeclaration = inferredCMElementDeclaration;
-
- if (inferredCMDocument == null)
- {
- String cacheKey = "inferred-document"; //$NON-NLS-1$
- inferredCMDocument = inferredGrammarFactory.createCMDocument(""); //$NON-NLS-1$
- cmDocumentManager.addCMDocument("", "", cacheKey, "DTD", inferredCMDocument); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- createdCMDocumentTable.put(cacheKey, inferredCMDocument);
- }
-
- inferredCMElementDeclaration = inferredGrammarFactory.createCMElementDeclaration(inferredCMDocument, element, false);
-
- if (parentInferredCMElementDeclaration != null)
- {
- inferredGrammarFactory.createCMContent(inferredCMDocument, parentInferredCMElementDeclaration, inferredCMDocument, inferredCMElementDeclaration, false, null);
- }
-
-
- visitChildNodes(element);
-
- // reset the 'current' state to inital values
- inferredCMElementDeclaration = parentInferredCMElementDeclaration;
- }
-
-
- public void handleElementNS(Element element)
- {
- CMDocument parentInferredCMDocument = inferredCMDocument;
- CMElementDeclaration parentInferredCMElementDeclaration = inferredCMElementDeclaration;
-
- inferredCMDocument = null;
- inferredCMElementDeclaration = null;
-
- // by adding the element to the namespaceTable, handleGrammar() will get called for any schema references
- if (element.getParentNode() != document)
- {
- namespaceTable.addElement(element);
- }
-
- String prefix = element.getPrefix();
- String uri = namespaceTable.getURIForPrefix(prefix);
-
- if (uri == null && element.getParentNode() == document)
- {
- // when this is the root element
- // we need to add an implied "no namespace schema location"
- uri = "ommitted-namespace"; //$NON-NLS-1$
- namespaceTable.addNamespaceInfo(prefix, uri, ""); //$NON-NLS-1$
- }
-
- // here's where we update the inferred grammar if required
- //
- boolean createCMElementDeclaration = true;
-
- boolean isLocal = (uri == null && prefix == null);
- if (isLocal)
- {
- if (parentInferredCMDocument == null)
- {
- // this is a local element... and the parent is not inferred (e.g) it has a known grammar
- // so we don't need to create an element declaration for this element
- createCMElementDeclaration = false;
- }
- else
- {
- if (uri == null)
- {
- uri = "ommitted-namespace"; //$NON-NLS-1$
- }
- }
- }
-
- if (createCMElementDeclaration)
- {
- if (isLocal)
- {
- inferredCMDocument = parentInferredCMDocument;
- inferredCMElementDeclaration = inferredGrammarFactory.createCMElementDeclaration(inferredCMDocument, element, true);
- }
- else
- {
- boolean createCMDocument = false;
-
- String cacheKey = "inferred-document" + uri; //$NON-NLS-1$
- inferredCMDocument = (CMDocument)createdCMDocumentTable.get(cacheKey);
-
- if (inferredCMDocument == null)
- {
- // we don't have an inferred document for this uri yet... let's see of we need one
- int status = cmDocumentManager.getCMDocumentStatus(uri);
- if (status == CMDocumentCache.STATUS_NOT_LOADED || status == CMDocumentCache.STATUS_ERROR)
- {
- // the cache does not contain a 'proper' CMDocument for this uri
- // so we need to create an inferred one
- createCMDocument = true;
- }
- }
-
- if (createCMDocument)
- {
- //System.out.println("encountered element {" + element.getNodeName() + "} ... creating inferred CMDocument for " + uri);
- inferredCMDocument = inferredGrammarFactory.createCMDocument(uri);
- cmDocumentManager.addCMDocument(uri, "", cacheKey, "XSD", inferredCMDocument); //$NON-NLS-1$ //$NON-NLS-2$
- createdCMDocumentTable.put(cacheKey, inferredCMDocument);
- }
-
- if (inferredCMDocument != null)
- {
- inferredCMElementDeclaration = inferredGrammarFactory.createCMElementDeclaration(inferredCMDocument, element, false);
- }
- }
-
- if (parentInferredCMElementDeclaration != null)
- {
- inferredGrammarFactory.createCMContent(parentInferredCMDocument, parentInferredCMElementDeclaration, inferredCMDocument, inferredCMElementDeclaration, isLocal, uri);
- }
- }
-
- visitChildNodes(element);
-
- // reset the 'current' state to inital values
- inferredCMElementDeclaration = parentInferredCMElementDeclaration;
- inferredCMDocument = parentInferredCMDocument;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryActionHelper.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryActionHelper.java
deleted file mode 100644
index b66a0d6ce9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryActionHelper.java
+++ /dev/null
@@ -1,574 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMValidator;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- *
- */
-public class ModelQueryActionHelper
-{
- protected ModelQueryImpl modelQuery;
-
- protected static class Action implements ModelQueryAction
- {
- public int kind;
- public int startIndex;
- public int endIndex;
- public Node parent;
- public CMNode cmNode;
- public Object userData;
-
- public Action(int kind, Node parent, CMNode cmNode)
- {
- this.kind = kind;
- this.parent = parent;
- this.cmNode = cmNode;
- }
-
- public Action(int kind, Node parent, CMNode cmNode, int startIndex, int endIndex)
- {
- this.kind = kind;
- this.parent = parent;
- this.cmNode = cmNode;
- this.startIndex = startIndex;
- this.endIndex = endIndex;
- }
-
- public int getKind()
- {
- return kind;
- }
-
- public int getStartIndex()
- {
- return startIndex;
- }
-
- public int getEndIndex()
- {
- return endIndex;
- }
-
- public Node getParent()
- {
- return parent;
- }
-
- public CMNode getCMNode()
- {
- return cmNode;
- }
-
- public Object getUserData()
- {
- return userData;
- }
-
- public void setUserData(Object object)
- {
- userData = object;
- }
-
- public void performAction()
- {
- }
- }
-
-
- public ModelQueryActionHelper(ModelQueryImpl modelQuery)
- {
- this.modelQuery = modelQuery;
- }
-
-
- public void getAllActions(Element parent, CMElementDeclaration ed, int validityChecking, List actionList)
- {
- }
-
-
- // insert actions
- //
- public void getInsertActions(Element parent, CMElementDeclaration ed, int index, int includeOptions, int validityChecking, List actionList)
- {
- if ((includeOptions & ModelQuery.INCLUDE_ATTRIBUTES) != 0)
- {
- getInsertAttributeActions(parent, ed, validityChecking, actionList);
- }
- includeOptions &= ~ModelQuery.INCLUDE_ATTRIBUTES;
- if ((includeOptions & ModelQuery.INCLUDE_CHILD_NODES) != 0)
- {
- if (index != -1)
- {
- getInsertChildNodeActionsAtIndex(parent, ed, index, includeOptions, validityChecking, actionList);
- }
- else
- {
- getInsertChildNodeActions(parent, ed, includeOptions, validityChecking, actionList);
- }
- }
- }
-
-
-
- protected void getInsertAttributeActions(Element parent, CMElementDeclaration ed, int validityChecking, List actionList)
- {
- // get actions for each insertable attribute
- //
- List availableAttributeList = modelQuery.getAvailableContent(parent, ed, ModelQuery.INCLUDE_ATTRIBUTES);
-
- for (Iterator i = availableAttributeList.iterator(); i.hasNext(); )
- {
- CMAttributeDeclaration ad = (CMAttributeDeclaration)i.next();
- if (modelQuery.canInsert(parent, ed, ad, 0, validityChecking))
- {
- Action action = new Action(ModelQueryAction.INSERT, parent, ad);
- actionList.add(action);
- }
- }
- }
-
-
- protected void getInsertChildNodeActionsAtIndex(Element parent, CMElementDeclaration ed, int index, int includeOptions, int validityChecking, List actionList)
- {
- // get actions for each insertable attribute
- //
- int size = parent.getChildNodes().getLength();
- if (index <= size)
- {
- List contentSpecificationList = modelQuery.getValidator().createContentSpecificationList(parent, ed);
- List availableChildNodeList = modelQuery.getAvailableContent(parent, ed, includeOptions);
-
- boolean isSimpleChoice = isSimpleChoiceGroupContentModel(ed);
-
- for (Iterator i = availableChildNodeList.iterator(); i.hasNext(); )
- {
- CMNode cmNode = (CMNode)i.next();
- if (isSimpleChoice || modelQuery.canInsert(parent, ed, cmNode, index, validityChecking, contentSpecificationList))
- {
- Action action = new Action(ModelQueryAction.INSERT, parent, cmNode, index, index);
- actionList.add(action);
- }
- }
- }
- }
-
-
- protected boolean isSimpleChoiceGroupContentModel(CMElementDeclaration ed)
- {
- boolean result = false;
- CMNode cmNode = ed.getContent();
- if (cmNode != null && cmNode.getNodeType() == CMNode.GROUP)
- {
- CMGroup cmGroup = (CMGroup)cmNode;
- if (cmGroup.getOperator() == CMGroup.CHOICE && cmGroup.getMaxOccur() == -1)
- {
- result = true;
- CMNodeList list = cmGroup.getChildNodes();
- for (int i = list.getLength() - 1; i >= 0; i--)
- {
- if (list.item(i).getNodeType() != CMNode.ELEMENT_DECLARATION)
- {
- result = false;
- break;
- }
- }
- }
- }
- return result;
- }
-
-
- protected void getInsertChildNodeActions(Element parent, CMElementDeclaration ed, int includeOptions, int validityChecking, List actionList)
- {
- int size = parent.getChildNodes().getLength();
- List contentSpecificationList = modelQuery.getValidator().createContentSpecificationList(parent, ed);
- List availableChildNodeList = modelQuery.getAvailableContent(parent, ed, includeOptions);
-
- boolean isSimpleChoice = isSimpleChoiceGroupContentModel(ed);
-
- for (Iterator iterator = availableChildNodeList.iterator(); iterator.hasNext(); )
- {
- CMNode cmNode = (CMNode)iterator.next();
- for (int i = size; i >= 0; i--)
- {
- if (isSimpleChoice || modelQuery.canInsert(parent, ed, cmNode, i, validityChecking, contentSpecificationList))
- {
- Action action = new Action(ModelQueryAction.INSERT, parent, cmNode, i, i);
- actionList.add(action);
- break;
- }
- }
- }
- }
-
- public void getInsertActions(Document parent, CMDocument cmDocument, int index, int includeOptions, int validityChecking, List actionList)
- {
- // get the root element and doctype index (if any)
- //
- int doctypeIndex = -1;
- DocumentType doctype = null;
- Element rootElement = null;
- NodeList nodeList = parent.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++)
- {
- Node childNode = nodeList.item(i);
- if (childNode.getNodeType() == Node.ELEMENT_NODE)
- {
- rootElement = (Element)childNode;
- break;
- }
- else if (childNode.getNodeType() == Node.DOCUMENT_TYPE_NODE)
- {
- doctype = (DocumentType)childNode;
- doctypeIndex = i;
- }
- }
-
- // make sure that root elements are only added after the doctype (if any)
- if (rootElement == null && index > doctypeIndex)
- {
- CMNamedNodeMap map = cmDocument.getElements();
- int mapLength = map.getLength();
- for (int i = 0; i < mapLength; i++)
- {
- CMNode cmNode = map.item(i);
-
- boolean canAdd = true;
- if (validityChecking == ModelQuery.VALIDITY_STRICT)
- {
- canAdd = doctype == null || doctype.getName().equals(cmNode.getNodeName());
- }
-
- if (canAdd)
- {
- Action action = new Action(ModelQueryAction.INSERT, parent, cmNode, index, index);
- actionList.add(action);
- }
- }
- }
- }
-
-
-
- public void getInsertChildNodeActionTable(Element parent, CMElementDeclaration ed, int validityChecking, Hashtable actionTable)
- {
- }
-
-
- public void getReplaceActions(Element parent, CMElementDeclaration ed, int includeOptions, int validityChecking, List actionList)
- {
- CMValidator.MatchModelNode matchModelNode = modelQuery.getValidator().getMatchModel(ed, parent);
- if (matchModelNode != null)
- {
- MatchModelVisitor visitor = new MatchModelVisitor(parent, actionList);
- visitor.visitMatchModelNode(matchModelNode);
- }
- }
-
- public void getReplaceActions(Element parent, CMElementDeclaration ed, List selectedChildren, int includeOptions, int validityChecking, List actionList)
- {
- int[] range = getRange(parent, selectedChildren);
- if (range != null)
- {
- if (isContiguous(parent, range, selectedChildren))
- {
- List tempList = new Vector();
- getReplaceActions(parent, ed, includeOptions, validityChecking, tempList);
- if ((includeOptions & ModelQuery.INCLUDE_ENCLOSING_REPLACE_ACTIONS) != 0)
- {
- removeActionsNotContainingRange(tempList, range[0], range[1]);
- }
- else
- {
- removeActionsNotMatchingRange(tempList, range[0], range[1]);
- }
- actionList.addAll(tempList);
- }
- }
-
- if (selectedChildren.size() == 1)
- {
- Node node = (Node)selectedChildren.get(0);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element childElement = (Element)node;
- CMNode childEd = modelQuery.getCMElementDeclaration(childElement);
- if (childEd != null)
- {
-
- CMNode childOrigin= modelQuery.getOrigin(childElement);
-
- CMNodeList cmNodeList = childOrigin != null ?
- (CMNodeList)childOrigin.getProperty("SubstitutionGroup") : //$NON-NLS-1$
- (CMNodeList)childEd.getProperty("SubstitutionGroup"); //$NON-NLS-1$
-
- if (cmNodeList != null && cmNodeList.getLength() > 1)
- {
- int replaceIndex = getIndex(parent, childElement);
- String childEdName = childEd.getNodeName();
- for (int i = 0; i < cmNodeList.getLength(); i++)
- {
- CMNode substitution = cmNodeList.item(i);
- if (!substitution.getNodeName().equals(childEdName) && !Boolean.TRUE.equals(substitution.getProperty("Abstract"))) //$NON-NLS-1$
- {
- Action action = new Action(ModelQueryAction.REPLACE, parent, cmNodeList.item(i), replaceIndex, replaceIndex);
- actionList.add(action);
- }
- }
- }
- }
- }
- }
- }
-
-
- // returns true if the selected nodes are contiguous
- //
- protected boolean isContiguous(Element parent, int[] range, List selectedNodeList)
- {
- boolean result = true;
- NodeList nodeList = parent.getChildNodes();
- // issue: nodeListLength was never read, but in theory,
- // nodelList.getLength() might cause some clearing of cached
- // data, or something, so leaving in a potential meaningless call, for now.
- //int nodeListLength = nodeList.getLength();
- nodeList.getLength();
- for (int i = range[0]; i < range[1]; i++)
- {
- Node node = nodeList.item(i);
- if (!isWhitespaceNode(node) && !selectedNodeList.contains(node))
- {
- result = false;
- break;
- }
- }
- return result;
- }
-
-
- protected int[] getRange(Element parent, List list)
- {
- int[] result = null;
- int first = -1;
- int last = -1;
-
- NodeList nodeList = parent.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++)
- {
- Node node = nodeList.item(i);
- if (list.contains(node))
- {
- first = (first == -1) ? i : Math.min(first, i);
- last = Math.max(last, i);
- }
- }
-
- if (first != -1 && last!= -1)
- {
- result = new int[2];
- result[0] = first;
- result[1] = last;
- }
- return result;
- }
-
-
- protected boolean isWhitespaceNode(Node node)
- {
- return node.getNodeType() == Node.TEXT_NODE &&
- node.getNodeValue().trim().length() == 0;
- }
-
-
- protected int getIndex(Node parentNode, Node child)
- {
- NodeList nodeList = parentNode.getChildNodes();
- int index = -1;
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++)
- {
- if (nodeList.item(i) == child)
- {
- index = i;
- break;
- }
- }
- return index;
- }
-
-
- protected boolean isActionContainingRange(ModelQueryAction action, int startIndex, int endIndex)
- {
- int actionStartIndex = action.getStartIndex();
- int actionEndIndex = action.getEndIndex();
-
- return (actionStartIndex <= startIndex &&
- actionEndIndex >= endIndex);
- }
-
-
- protected boolean isActionMatchingRange(ModelQueryAction action, int startIndex, int endIndex)
- {
- int actionStartIndex = action.getStartIndex();
- int actionEndIndex = action.getEndIndex();
- return (actionStartIndex == startIndex &&
- actionEndIndex == endIndex);
- }
-
-
- protected void removeActionsNotContainingRange(List actionList, int startIndex, int endIndex)
- {
- for (int i = actionList.size() - 1; i >= 0; i--)
- {
- ModelQueryAction action = (ModelQueryAction)actionList.get(i);
- if (!isActionContainingRange(action, startIndex, endIndex))
- {
- actionList.remove(i);
- }
- }
- }
-
-
- protected void removeActionsNotMatchingRange(List actionList, int startIndex, int endIndex)
- {
- for (int i = actionList.size() - 1; i >= 0; i--)
- {
- ModelQueryAction action = (ModelQueryAction)actionList.get(i);
- if (!isActionMatchingRange(action, startIndex, endIndex))
- {
- actionList.remove(i);
- }
- }
- }
-
-
- public static class MatchModelVisitor
- {
- int indent;
- int elementIndex;
- Node parent;
- List actionList;
-
- public MatchModelVisitor(Node parent, List actionList)
- {
- this.parent = parent;
- this.actionList = actionList;
- }
-
- public int indexOfNextElement(int start)
- {
- NodeList nodeList = parent.getChildNodes();
- int length = nodeList.getLength();
- int result = length;
- for (int i = start; i < length; i++)
- {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- result = i;
- break;
- }
- }
- return result;
- }
-
- public void visitMatchModelNode(CMValidator.MatchModelNode matchModelNode)
- {
- int startIndex = indexOfNextElement(elementIndex);
-
- //String cmNodeName = matchModelNode.cmNode != null ? matchModelNode.cmNode.getNodeName() : "null";
- //printIndented(indent, "+MatchModelNode : " + cmNodeName + " " + startIndex);
-
- indent += 2;
- for (Iterator iterator = matchModelNode.children.iterator(); iterator.hasNext(); )
- {
- CMValidator.MatchModelNode child = (CMValidator.MatchModelNode)iterator.next();
- visitMatchModelNode(child);
- }
- indent -= 2;
-
- if (matchModelNode.cmNode != null)
- {
- int nodeType = matchModelNode.cmNode.getNodeType();
- if (nodeType == CMNode.GROUP)
- {
- CMGroup group = (CMGroup)matchModelNode.cmNode;
- if (group.getOperator() == CMGroup.CHOICE)
- {
- addReplaceActions(matchModelNode, group, startIndex, elementIndex - 1);
- }
- }
- else if (nodeType == CMNode.ELEMENT_DECLARATION)
- {
- elementIndex = startIndex + 1;
- }
- //printIndented(indent, "-MatchModelNode : " + cmNodeName + " " + (elementIndex - 1));
- }
- }
-
- public void addReplaceActions(CMValidator.MatchModelNode matchModelNode, CMGroup group, int startIndex, int endIndex)
- {
- CMNode excludeCMNode = null;
- if (matchModelNode.children.size() > 0)
- {
- CMValidator.MatchModelNode child = (CMValidator.MatchModelNode)matchModelNode.children.get(0);
- excludeCMNode = child.cmNode;
- }
-
- CMNodeList nodeList = group.getChildNodes();
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++)
- {
- CMNode alternative = nodeList.item(i);
- if (alternative != excludeCMNode)
- {
- Action action = new Action(ModelQueryAction.REPLACE, parent, alternative, startIndex, endIndex);
- actionList.add(action);
- }
- }
- }
- }
-
- //public static void printIndented(int indent, String string)
- //{
- // for (int i = 0; i < indent; i++)
- // {
- // System.out.print(" ");
- // }
- // System.out.println(string);
- //}
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java
deleted file mode 100644
index e426ee2058..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java
+++ /dev/null
@@ -1,846 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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.modelqueryimpl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.modelqueryimpl.ModelQueryExtensionManagerImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMDataTypeValueHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.DOMValidator;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAssociationProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtensionManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-
-/**
- * This class implements a large portion of the ModelQuery interfaces.
- * Some work is delegated to the DOMHelper, CMDocumentManager, and DOMValidator.
- */
-public class ModelQueryImpl implements ModelQuery
-{
- protected ModelQueryAssociationProvider modelQueryAssociationProvider;
- protected ModelQueryActionHelper modelQueryActionHelper;
- protected DOMValidator validator;
- protected ModelQueryExtensionManagerImpl extensionManager;
- protected CMDataTypeValueHelper valueHelper;
- protected int editMode = EDIT_MODE_CONSTRAINED_STRICT;
-
- public ModelQueryImpl(ModelQueryAssociationProvider modelQueryAssociationProvider)
- {
- this.modelQueryAssociationProvider = modelQueryAssociationProvider;
- modelQueryActionHelper = createModelQueryActionHelper();
- validator = new DOMValidator();
- extensionManager = new ModelQueryExtensionManagerImpl();
- valueHelper = new CMDataTypeValueHelper();
- }
-
- public int getEditMode()
- {
- return editMode;
- }
-
- public void setEditMode(int editMode)
- {
- this.editMode =editMode;
- }
-
-
- // factory methods
- public ModelQueryActionHelper createModelQueryActionHelper()
- {
- return new ModelQueryActionHelper(this);
- }
-
- public DOMValidator getValidator()
- {
- return validator;
- }
-
- public CMDocument getCorrespondingCMDocument(Node node)
- {
- return modelQueryAssociationProvider.getCorrespondingCMDocument(node);
- }
-
- public CMNode getCMNode(Node node)
- {
- return modelQueryAssociationProvider.getCMNode(node);
- }
-
- public CMDataType getCMDataType(Text text)
- {
- return modelQueryAssociationProvider.getCMDataType(text);
- }
-
- public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr)
- {
- return modelQueryAssociationProvider.getCMAttributeDeclaration(attr);
- }
-
- public CMElementDeclaration getCMElementDeclaration(Element element)
- {
- return modelQueryAssociationProvider.getCMElementDeclaration(element);
- }
-
- public CMDocumentManager getCMDocumentManager()
- {
- CMDocumentManager result = null;
- if (modelQueryAssociationProvider instanceof XMLAssociationProvider)
- {
- XMLAssociationProvider xmlAssociationProvider = (XMLAssociationProvider)modelQueryAssociationProvider;
- result = xmlAssociationProvider.getCMDocumentManager();
- }
- return result;
- }
-
-
- /**
- * @deprected - use 3 arg version below
- */
- public List getCMDocumentList(Element element, String uri)
- {
- return Collections.EMPTY_LIST;
- }
-
- public List getCMDocumentList(Element element, CMElementDeclaration ed, String uri)
- {
- List result = new ArrayList();
- if (modelQueryAssociationProvider instanceof XMLAssociationProvider)
- {
- XMLAssociationProvider xmlAssociationProvider = (XMLAssociationProvider)modelQueryAssociationProvider;
-
- // todo... revist... handle each ##thing explicitly
- //
- if (uri == null)
- {
- uri = "##any"; //$NON-NLS-1$
- }
-
- if (uri.equals("##targetNamespace")) //$NON-NLS-1$
- {
- CMDocument cmDocument = (CMDocument)ed.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- result.add(cmDocument);
- }
- }
- else if (uri.equals("##any") || uri.equals("##other")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- String excludedURI = null;
- if (uri.equals("##other")) //$NON-NLS-1$
- {
- CMDocument cmDocument = (CMDocument)ed.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- excludedURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- }
- }
-
- // in this case we should consider all of the schema related to this document
- //
- NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
- namespaceTable.addElementLineage(element);
- List list = namespaceTable.getNamespaceInfoList();
- for (Iterator i = list.iterator(); i.hasNext();)
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- if (info.uri != null && !info.uri.equals(excludedURI))
- {
- CMDocument document = xmlAssociationProvider.getCMDocument(info.uri, info.locationHint, "XSD"); //$NON-NLS-1$
- if (document != null)
- {
- result.add(document);
- }
- }
- }
- }
- else
- {
- CMDocument document = xmlAssociationProvider.getCMDocument(element, uri);
- if (document != null)
- {
- result.add(document);
- }
- }
- }
- return result;
- }
-
-
- public CMDocument getCMDocument(Element element, String uri)
- {
-
- CMDocument result = null;
- if (modelQueryAssociationProvider instanceof XMLAssociationProvider)
- {
- XMLAssociationProvider xmlAssociationProvider = (XMLAssociationProvider)modelQueryAssociationProvider;
- result = xmlAssociationProvider.getCMDocument(element, uri);
- }
- //ContentModelManager.println("ModelQueryImpl.getCMDocument(" + element.getNodeName() + ", " + uri + ") = " + result);
- return result;
- }
-
- public boolean isContentValid(Element element)
- {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- return isContentValid(ed, element);
- }
-
- public boolean isContentValid(CMElementDeclaration ed, Element element)
- {
- boolean result = true;
- if (ed != null)
- {
- // first check to see if all the required attributes are present
- //
- CMNamedNodeMap map = ed.getAttributes();
- int mapLength = map.getLength();
- for (int i = 0; i < mapLength; i++)
- {
- CMAttributeDeclaration ad = (CMAttributeDeclaration)map.item(i);
- String attributeName = DOMNamespaceHelper.computeName(ad, element, null);
- if (ad.getUsage() == CMAttributeDeclaration.REQUIRED)
- {
- Attr attr = element.getAttributeNode(attributeName);
- if (attr == null)
- {
- result = false;
- break;
- }
- }
- }
-
- // now check to see of the children validate properly
- //
- if (result)
- {
- CMNode[] originArray = getOriginArray(element);
- result = originArray != null && originArray.length == element.getChildNodes().getLength();
- }
- }
- return result;
- }
-
-
- public CMNode getOrigin(Node node)
- {
- CMNode result = null;
- // todo... make sure parent is right
- //
- Node parentNode = getParentOrOwnerNode(node);
- if (parentNode != null && parentNode.getNodeType() == Node.ELEMENT_NODE)
- {
- Element parentElement = (Element)parentNode;
- CMNode[] array = getOriginArray(parentElement);
- if (array != null)
- {
- int index = getIndexOfNode(parentElement.getChildNodes(), node);
- if (index < array.length)
- {
- result = array[index];
- }
- }
- }
- return result;
- }
-
- public CMNode[] getOriginArray(Element element)
- {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- return (ed != null) ? getValidator().getOriginArray(ed, element) : null;
- }
-
- public int getIndexOfNode(NodeList nodeList, Node node)
- {
- int result = -1;
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++)
- {
- if (nodeList.item(i) == node)
- {
- result = i;
- break;
- }
- }
- return result;
- }
-
-
- /**
- * Returns a list of all CMNode 'meta data' that may be potentially added to the element.
- */
- public List getAvailableContent(Element element, CMElementDeclaration ed, int includeOptions)
- {
- AvailableContentCMVisitor visitor = new AvailableContentCMVisitor(element, ed);
- List list = visitor.computeAvailableContent(includeOptions);
- if (extensionManager != null)
- {
- extensionManager.filterAvailableElementContent(list, element, ed, includeOptions);
- }
- return list;
- }
-
-
- public boolean canInsert(Element parent, CMNode cmNode, int index, int validityChecking)
- {
- boolean result = true;
- CMElementDeclaration ed = getCMElementDeclaration(parent);
- if (ed != null)
- {
- result = canInsert(parent, ed, cmNode, index, validityChecking);
- }
- return result;
- }
-
-
- public boolean canInsert(Element parent, CMElementDeclaration ed, CMNode cmNode, int index, int validityChecking)
- {
- return canInsert(parent, ed, cmNode, index, validityChecking, null);
- }
-
- protected boolean canInsert(Element parent, CMElementDeclaration ed, CMNode cmNode, int index, int validityChecking, Object reuseableData)
- {
- boolean result = true;
- switch (cmNode.getNodeType())
- {
- case CMNode.ATTRIBUTE_DECLARATION :
- {
- String attributeName = DOMNamespaceHelper.computeName(cmNode, parent, null);
- result = parent.getAttributeNode(attributeName) == null;
- break;
- }
- case CMNode.ELEMENT_DECLARATION :
- case CMNode.GROUP :
- {
- if (validityChecking == VALIDITY_STRICT)
- {
- // create list
- List contentSpecificationList = null;
- if (reuseableData != null)
- {
- contentSpecificationList = (List)reuseableData;
- }
- else
- {
- contentSpecificationList = getValidator().createContentSpecificationList(parent, ed);
- }
- result = getValidator().canInsert(ed, contentSpecificationList, index, cmNode);
- }
- break;
- }
- case CMNode.DATA_TYPE :
- {
- int contentType = ed.getContentType();
- result = (contentType == CMElementDeclaration.MIXED ||
- contentType == CMElementDeclaration.PCDATA ||
- contentType == CMElementDeclaration.ANY);
- break;
- }
- default :
- {
- result = false;
- break;
- }
- }
- return result;
- }
-
- public boolean canInsert(Element parent, List cmNodeList, int index, int validityChecking)
- {
- // todo
- return true;
- }
-
-
- public boolean canRemove(Node node, int validityChecking)
- {
- boolean result = true;
- if (validityChecking == VALIDITY_STRICT)
- {
- int nodeType = node.getNodeType();
- switch (nodeType)
- {
- case Node.ATTRIBUTE_NODE:
- {
- CMAttributeDeclaration ad = getCMAttributeDeclaration((Attr)node);
- if (ad != null)
- {
- result = (ad.getUsage() == CMAttributeDeclaration.OPTIONAL);
- }
- break;
- }
- case Node.ELEMENT_NODE:
- {
- Node parentNode = node.getParentNode();
- if (parentNode.getNodeType() == Node.ELEMENT_NODE)
- {
- Element parentElement = (Element)parentNode;
- CMElementDeclaration ed = getCMElementDeclaration(parentElement);
- if (ed != null)
- {
- List contentSpecificationList = getValidator().createContentSpecificationList(parentElement, ed);
- int index = getIndexOfNode(parentElement.getChildNodes(), node);
- result = getValidator().canRemove(ed, contentSpecificationList, index);
- }
- }
- break;
- }
- }
- }
- return result;
- }
-
-
- public boolean canRemove(List nodeList, int validityChecking)
- {
- boolean result = true;
-
- if (validityChecking == VALIDITY_STRICT)
- {
- Element parentElement = null;
- List childList = null;
-
- for (Iterator i = nodeList.iterator(); i.hasNext(); )
- {
- Node node = (Node)i.next();
-
- if (parentElement == null)
- {
- parentElement = getParentOrOwnerElement(node);
- }
- else if (parentElement != getParentOrOwnerElement(node))
- {
- // make sure the parent are the same
- result = false;
- break;
- }
-
- if (parentElement == null)
- {
- result = true;
- break;
- }
-
- int nodeType = node.getNodeType();
- if (nodeType == Node.ATTRIBUTE_NODE)
- {
- if (!canRemove(node, validityChecking))
- {
- result = false;
- break;
- }
- }
- else
- {
- if (childList == null)
- {
- childList = nodeListToList(parentElement.getChildNodes());
- }
- childList.remove(node);
- }
- }
-
- if (result && childList != null)
- {
- CMElementDeclaration ed = getCMElementDeclaration(parentElement);
- if (ed != null)
- {
- List contentSpecificationList = getValidator().createContentSpecificationList(childList, ed);
- result = getValidator().isValid(ed, contentSpecificationList);
- }
- }
- }
-
- return result;
- }
-
- public boolean canReplace(Element parent, int startIndex, int endIndex, CMNode cmNode, int validityChecking)
- {
- return true;
- }
-
- public boolean canReplace(Element parent, int startIndex, int endIndex, List cmNodeList, int validityChecking)
- {
- return true;
- }
-
- /**
- * This method is experimental... use at your own risk
- */
- public boolean canWrap(Element childElement, CMElementDeclaration wrapElement, int validityChecking)
- {
- boolean result = true;
- Node parentNode = childElement.getParentNode();
- if (parentNode.getNodeType() == Node.ELEMENT_NODE)
- {
- Element parentElement = (Element)parentNode;
- CMElementDeclaration parentEd = getCMElementDeclaration(parentElement);
- if (parentEd != null)
- {
- if (validityChecking == VALIDITY_STRICT)
- {
- int index = getIndexOfNode(parentElement.getChildNodes(), childElement);
-
- List contentSpecificationList = getValidator().createContentSpecificationList(parentElement, parentEd);
- List subList = contentSpecificationList.subList(index, index + 1);
- result = getValidator().canReplace(parentEd, contentSpecificationList, index, index, wrapElement);
- if (result)
- {
- result = getValidator().isValid(wrapElement, subList);
- }
- }
- }
- }
- else
- {
- result = false;
- }
- return result;
- }
-
- public void getInsertActions(Element parent, CMElementDeclaration ed, int index, int includeOptions, int validityChecking, List actionList)
- {
- modelQueryActionHelper.getInsertActions(parent, ed, index, includeOptions, validityChecking, actionList);
- }
-
- public void getInsertActions(Document parent, CMDocument cmDocument, int index, int includeOptions, int validityChecking, List actionList)
- {
- modelQueryActionHelper.getInsertActions(parent, cmDocument, index, includeOptions, validityChecking, actionList);
- }
-
- public void getReplaceActions(Element parent, CMElementDeclaration ed, int includeOptions, int validityChecking, List actionList)
- {
- modelQueryActionHelper.getReplaceActions(parent, ed, includeOptions, validityChecking, actionList);
- }
-
- public void getReplaceActions(Element parent, CMElementDeclaration ed, List selectedChildren, int includeOptions, int validityChecking, List actionList)
- {
- modelQueryActionHelper.getReplaceActions(parent, ed, selectedChildren, includeOptions, validityChecking, actionList);
- }
-
- public void getInsertChildNodeActionTable(Element parent, CMElementDeclaration ed, int validityChecking, Hashtable actionTable)
- {
- modelQueryActionHelper.getInsertChildNodeActionTable(parent, ed, validityChecking, actionTable);
- }
-
- public void getActionTable(Element parent, CMElementDeclaration ed, int index, int validityChecking, Hashtable actionTable)
- {
- //modelQueryActionHelper.getAllActions(parent, ed, validityChecking, actionList);
- }
-
-
- // some helper methods
- //
- protected Node getParentOrOwnerNode(Node node)
- {
- return (node.getNodeType() == Node.ATTRIBUTE_NODE) ?
- ((Attr)node).getOwnerElement() :
- node.getParentNode();
- }
-
- protected Element getParentOrOwnerElement(Node node)
- {
- Node parent = getParentOrOwnerNode(node);
- return (parent.getNodeType() == Node.ELEMENT_NODE) ? (Element)parent : null;
- }
-
-
- protected List nodeListToList(NodeList nodeList)
- {
- int size = nodeList.getLength();
- List v = new ArrayList(size);
- for (int i = 0; i < size; i++)
- {
- v.add(nodeList.item(i));
- }
- return v;
- }
-
- /**
- protected List getCMNodeList(NodeList nodeList)
- {
- int size = nodeList.getLength();
- Vector v = new Vector(size);
- for (int i = 0; i < size; i++)
- {
- v.add(getCMNode(nodeList.item(i));
- }
- return v;
- }
- */
-
- public class AvailableContentCMVisitor extends CMVisitor
- {
- public Hashtable childNodeTable = new Hashtable();
- public Hashtable attributeTable = new Hashtable();
- public Element rootElement;
- public CMElementDeclaration rootElementDeclaration;
- public boolean isRootVisited;
- protected boolean includeSequenceGroups;
-
- public AvailableContentCMVisitor(Element rootElement, CMElementDeclaration rootElementDeclaration)
- {
- this.rootElement = rootElement;
- this.rootElementDeclaration = rootElementDeclaration;
- }
-
- protected String getKey(CMNode cmNode)
- {
- String key = cmNode.getNodeName();
- CMDocument cmDocument = (CMDocument)cmNode.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- String namespaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- if (namespaceURI != null)
- {
- key = "[" + namespaceURI + "]" + key; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return key;
- }
-
- protected void addToTable(Hashtable table, CMNode cmNode)
- {
- String nodeName = cmNode.getNodeName();
- if (nodeName != null && nodeName.length() > 0)
- {
- table.put(getKey(cmNode), cmNode);
- }
- }
-
- public List computeAvailableContent(int includeOptions)
- {
- List v = new ArrayList();
-
- int contentType = rootElementDeclaration.getContentType();
- includeSequenceGroups = ((includeOptions & INCLUDE_SEQUENCE_GROUPS) != 0);
- visitCMNode(rootElementDeclaration);
-
- if ((includeOptions & INCLUDE_ATTRIBUTES) != 0)
- {
- v.addAll(attributeTable.values());
- CMAttributeDeclaration nillableAttribute = (CMAttributeDeclaration)rootElementDeclaration.getProperty("http://org.eclipse.wst/cm/properties/nillable"); //$NON-NLS-1$
- if (nillableAttribute != null)
- {
- v.add(nillableAttribute);
- }
- }
-
- if ((includeOptions & INCLUDE_CHILD_NODES) != 0)
- {
- if (contentType == CMElementDeclaration.MIXED ||
- contentType == CMElementDeclaration.ELEMENT)
- {
- v.addAll(childNodeTable.values());
- }
- else if (contentType == CMElementDeclaration.ANY)
- {
- CMDocument cmDocument = (CMDocument)rootElementDeclaration.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- CMNamedNodeMap elements = cmDocument.getElements();
- for (Iterator i = elements.iterator(); i.hasNext(); )
- {
- v.add(i.next());
- }
- }
- }
- }
- return v;
- }
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- String uri = anyElement.getNamespaceURI();
- List list = getCMDocumentList(rootElement, rootElementDeclaration, uri);
- for (Iterator iterator = list.iterator(); iterator.hasNext(); )
- {
- CMDocument cmdocument = (CMDocument)iterator.next();
- if (cmdocument != null)
- {
- CMNamedNodeMap map = cmdocument.getElements();
- int size = map.getLength();
- for (int i = 0; i < size; i++)
- {
- CMNode ed = map.item(i);
- addToTable(childNodeTable,ed);
- }
- }
- }
- }
-
- public void visitCMAttributeDeclaration(CMAttributeDeclaration ad)
- {
- super.visitCMAttributeDeclaration(ad);
- attributeTable.put(ad.getNodeName(), ad);
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- if (ed == rootElementDeclaration && !isRootVisited)
- {
- isRootVisited = true;
- super.visitCMElementDeclaration(ed);
- }
- else
- {
- if (!Boolean.TRUE.equals(ed.getProperty("Abstract"))) //$NON-NLS-1$
- {
- addToTable(childNodeTable,ed);
- }
-
- CMNodeList substitutionGroup = (CMNodeList)ed.getProperty("SubstitutionGroup"); //$NON-NLS-1$
- if (substitutionGroup != null)
- {
- handleSubstitutionGroup(substitutionGroup);
- }
- }
- }
-
- protected void handleSubstitutionGroup(CMNodeList substitutionGroup)
- {
- int substitutionGroupLength = substitutionGroup.getLength();
- for (int i = 0; i < substitutionGroupLength; i++)
- {
- CMNode ed = substitutionGroup.item(i);
- if (!Boolean.TRUE.equals(ed.getProperty("Abstract"))) //$NON-NLS-1$
- {
- addToTable(childNodeTable,ed);
- }
- }
- }
-
- public void visitCMGroup(CMGroup group)
- {
- if (includeSequenceGroups)
- {
- if (group.getOperator() == CMGroup.SEQUENCE &&
- group.getChildNodes().getLength() > 1 &&
- includesRequiredContent(group))
- {
- childNodeTable.put(group, group);
- }
- }
- super.visitCMGroup(group);
- }
-
- public boolean includesRequiredContent(CMGroup group)
- {
- List list = getValidator().createContentSpecificationList(group);
- return list.size() > 1;
- }
- }
-
-
- /**
- * @deprected - use getPossibleDataTypeValues()
- */
- public List getDataTypeValues(Element element, CMNode cmNode)
- {
- return Arrays.asList(getPossibleDataTypeValues(element, cmNode));
- }
-
- /**
- * This methods return an array of possible values corresponding to the datatype of the CMNode (either an CMAttributeDeclaration or a CMElementDeclaration)
- */
- public String[] getPossibleDataTypeValues(Element element, CMNode cmNode)
- {
- List list = new ArrayList();
-
- if (cmNode != null)
- {
- CMDataType dataType = null;
- if (cmNode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION)
- {
- dataType = ((CMAttributeDeclaration)cmNode).getAttrType();
- }
- else if (cmNode.getNodeType() == CMNode.ELEMENT_DECLARATION)
- {
- dataType = ((CMElementDeclaration)cmNode).getDataType();
- }
-
- String[] enumeratedValues = dataType != null ? dataType.getEnumeratedValues() : null;
- if (enumeratedValues != null)
- {
- for (int i = 0; i < enumeratedValues.length; i++)
- {
- list.add(enumeratedValues[i]);
- }
- }
- }
-
- addValuesForXSIType(element, cmNode, list);
-
- if (extensionManager != null)
- {
- list.addAll(extensionManager.getDataTypeValues(element, cmNode));
- }
-
- // Remove duplicates
- List duplicateFreeList = new ArrayList();
- Iterator iterator = list.iterator();
- while(iterator.hasNext()) {
- Object next = iterator.next();
- if(duplicateFreeList.indexOf(next) == -1) {
- duplicateFreeList.add(next);
- }
- }
-
- return (String[]) duplicateFreeList.toArray(new String[duplicateFreeList.size()]);
- }
-
-
- protected void addValuesForXSIType(Element element, CMNode cmNode, List list)
- {
- if (cmNode != null && cmNode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION)
- {
- CMAttributeDeclaration ad = (CMAttributeDeclaration)cmNode;
- if (valueHelper.isXSIType(ad))
- {
- NamespaceTable table = new NamespaceTable(element.getOwnerDocument());
- table.addElementLineage(element);
- list.addAll(valueHelper.getQualifiedXSITypes(ad, table));
- }
- }
- }
-
-
- public ModelQueryExtensionManager getExtensionManager()
- {
- return extensionManager;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/SimpleAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/SimpleAssociationProvider.java
deleted file mode 100644
index de5242f176..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/SimpleAssociationProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * 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.modelqueryimpl;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryCMProvider;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- *
- */
-public class SimpleAssociationProvider extends BaseAssociationProvider
-{
- protected ModelQueryCMProvider modelQueryCMProvider;
-
- public SimpleAssociationProvider(ModelQueryCMProvider modelQueryCMProvider)
- {
- this.modelQueryCMProvider = modelQueryCMProvider;
- }
-
- public CMDocument getCorrespondingCMDocument(Node node)
- {
- return modelQueryCMProvider.getCorrespondingCMDocument(node);
- }
-
- public CMElementDeclaration getCMElementDeclaration(Element element)
- {
- CMElementDeclaration result = null;
- CMDocument cmDocument = getCorrespondingCMDocument(element);
- if (cmDocument != null)
- {
- result = (CMElementDeclaration)cmDocument.getElements().getNamedItem(element.getNodeName());
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/XMLAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/XMLAssociationProvider.java
deleted file mode 100644
index 454fe8ad9a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/XMLAssociationProvider.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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.modelqueryimpl;
-
-import java.io.File;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentReferenceProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.IExternalSchemaLocationProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public abstract class XMLAssociationProvider extends BaseAssociationProvider implements CMDocumentReferenceProvider
-{
- protected CMDocumentCache cmDocumentCache;
- protected CMDocumentManagerImpl documentManager;
-
- private final static boolean _trace = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.xml.core/externalSchemaLocation")).booleanValue(); //$NON-NLS-1$
-
- public XMLAssociationProvider(CMDocumentCache cmDocumentCache)
- {
- this.cmDocumentCache = cmDocumentCache;
- documentManager = new CMDocumentManagerImpl(cmDocumentCache, this);
- }
-
- public CMDocumentManager getCMDocumentManager()
- {
- return documentManager;
- }
-
-
- public static String[] getDoctypeInfo(Document document)
- {
- String[] result = null;
- DocumentType doctype = document.getDoctype();
-
- // defect 206833 ... here we test for DTDs that are declared inline
- // since we currently have no way of making use of inline DTDs we ignore them
- // so that the implict DTD (if any) can be used
- if (doctype != null && (doctype.getPublicId() != null || doctype.getSystemId() != null))
- {
- result = new String[2];
- result[0] = doctype.getPublicId();
- result[1] = doctype.getSystemId();
- }
- else if (getImplictDoctype(document) != null)
- {
- result = getImplictDoctype(document);
- }
- return result;
- }
-
-
- protected static String[] getImplictDoctype(Document document)
- {
- String[] result = null;
- /*
- DOMExtension domExtension = DOMExtensionProviderRegistry.getInstance().getDOMExtension(document);
- if (domExtension != null)
- {
- result = domExtension.getImplicitDoctype();
- }*/
- return result;
- }
-
- public CMDocument getCorrespondingCMDocument(Node node)
- {
- return getCorrespondingCMDocument(node, true);
- }
-
- protected CMDocument getCorrespondingCMDocument(Node node, boolean getDocumentFromCMNode)
- {
- CMDocument result = null;
- try
- {
- Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document)node : node.getOwnerDocument();
-
- String[] doctypeInfo = getDoctypeInfo(document);
-
- if (doctypeInfo != null)
- {
- result = getCMDocument(doctypeInfo[0], doctypeInfo[1], "DTD"); //$NON-NLS-1$
- }
- // defect 211236 ... in some cases calling this method can result in a cycle
- // we use the getDocumentFromCMNode as a flag to avoid this
- // TODO... see if there is a way to re-organize to avoid the need for this flag
- else if (getDocumentFromCMNode)
- {
- CMNode cmNode = getCMNode(node);
- if (cmNode != null)
- {
- // todo... add a getCMDocument() methods to CMNode
- // for now use the getProperty interface
- result = (CMDocument)cmNode.getProperty("CMDocument"); //$NON-NLS-1$
- }
- }
- }
- catch (Exception e)
- {
- Logger.logException("exception locating CMDocument for " + node, e); //$NON-NLS-1$
- }
- return result;
- }
-
-
- public CMDocument getCMDocument(Element element, String uri)
- {
- CMDocument result = null;
- NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
- namespaceTable.addElementLineage(element);
- NamespaceInfo namespaceInfo = namespaceTable.getNamespaceInfoForURI(uri);
- if (namespaceInfo != null)
- {
- result = getCMDocument(namespaceInfo.uri, namespaceInfo.locationHint, "XSD"); //$NON-NLS-1$
- }
- return result;
- }
-
-
- public CMDocument getCMDocument(String publicId, String systemId, String type)
- {
- //String resolvedGrammarURI = resolveGrammarURI(document, publicId, systemId);
- return documentManager.getCMDocument(publicId, systemId, type);
- }
-
- //public CMDocument getCMDocument(Document document, String publicId, String systemId)
- //{
- // //String resolvedGrammarURI = resolveGrammarURI(document, publicId, systemId);
- // return documentManager.getCMDocument(publicId, systemId);
- //}
-
- public String resolveGrammarURI(String publicId, String systemId)
- {
- return resolveGrammarURI(null, publicId, systemId);
- }
-
-
- /**
- * This method should be specialized in order to implement specialized uri resolution
- */
- protected String resolveGrammarURI(Document document, String publicId, String systemId)
- {
- return systemId;
- }
-
-
- public CMElementDeclaration getCMElementDeclaration(Element element)
- {
- CMElementDeclaration result = null;
- Document document = element.getOwnerDocument();
- String[] doctypeInfo = getDoctypeInfo(document);
- if (doctypeInfo != null)
- {
- // we have detected doctype information so we assume that we can locate the CMElementDeclaration
- // in the CMDocument's table of global elements
- CMDocument cmDocument = getCorrespondingCMDocument(element, false);
-
- // TODO... consider replacing above with
- // CMDocument cmDocument = getCMDocument(document, doctypeInfo[0], doctypeInfo[1]);
-
- if (cmDocument != null)
- {
- result = (CMElementDeclaration)cmDocument.getElements().getNamedItem(element.getNodeName());
-
- // this is a hack to get our xsl code assist working... we might want to handle similar
- // grammar behaviour via some established model query setting
- if (result == null && getImplictDoctype(document) != null)
- {
- Node parent = element.getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE)
- {
- result = getCMElementDeclaration((Element)parent);
- }
- }
- }
- }
- else
- {
- // here we use a namespaceTable to consider if the root element has any namespace information
- //
- NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
- List list = NamespaceTable.getElementLineage(element);
- Element rootElement = (Element)list.get(0);
- namespaceTable.addElement(rootElement);
-
- if (namespaceTable.isNamespaceEncountered())
- {
- // we assume that this is an XMLSchema style namespace aware document
- result = getCMElementDeclaration(element, list, namespaceTable);
- }
- else
- {
- result = checkExternalSchema(element);
- if (result == null) {
- // we assume that this is an inferred CMDocument for a DTD style 'namespaceless' document
- CMDocument cmDocument = getCMDocument("", "", "DTD"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (cmDocument != null) {
- result = (CMElementDeclaration)cmDocument.getElements().getNamedItem(element.getNodeName());
- }
- }
- }
- }
- return result;
- }
-
- protected CMElementDeclaration checkExternalSchema(Element element) {
- final Document document = element.getOwnerDocument();
- if (document instanceof IDOMDocument) {
- final String baseLocation = ((IDOMDocument) document).getModel().getBaseLocation();
- if (baseLocation != null) {
- final IPath basePath = new Path(baseLocation);
- IFile file = null;
- if (basePath.segmentCount() > 1) {
- file = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
- }
- final URI uri = (file == null || !file.isAccessible()) ? new File(baseLocation).toURI() : file.getLocationURI();
- if (uri != null) {
- IExternalSchemaLocationProvider[] providers = ExternalSchemaLocationProviderRegistry.getInstance().getProviders();
- for (int i = 0; i < providers.length; i++) {
- long time = _trace ? System.currentTimeMillis(): 0;
- final Map locations = providers[i].getExternalSchemaLocation(uri);
- if (_trace) {
- long diff = System.currentTimeMillis() - time;
- if (diff > 250)
- Logger.log(Logger.INFO, "Schema location provider took [" + diff + "ms] for URI [" + uri + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- if (locations != null && !locations.isEmpty()) {
- Object location = locations.get(IExternalSchemaLocationProvider.NO_NAMESPACE_SCHEMA_LOCATION);
- if (location != null)
- return getCMElementDeclaration(element, NamespaceTable.getElementLineage(element), uri.toString(), location.toString());
- }
- }
- }
- }
- }
- return null;
- }
-
- protected CMElementDeclaration getCMElementDeclaration(Element targetElement, List list, String publicId, String systemId)
- {
- CMElementDeclaration currentED = null;
- try
- {
- int listSize = list.size();
- for (int i = 0; i < listSize; i++)
- {
- Element element = (Element)list.get(i);
-
- final String nodeName = element.getNodeName();
-
- CMElementDeclaration ed = null;
-
- // see if the element is a local of the currentED
- //
- if (currentED != null)
- {
- ed = (CMElementDeclaration)currentED.getLocalElements().getNamedItem(nodeName);
- }
-
- if (ed == null)
- {
- CMDocument cmDocument = getCMDocument(publicId, systemId, "XSD"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- ed = (CMElementDeclaration)cmDocument.getElements().getNamedItem(nodeName);
- }
- }
- currentED = ed;
- }
- }
- catch (Exception e)
- {
- Logger.logException("exception locating element declaration for " + targetElement, e); //$NON-NLS-1$
- }
-
- return currentED;
- }
-
- protected CMElementDeclaration getCMElementDeclaration(Element targetElement, List list, NamespaceTable namespaceTable)
- {
- CMElementDeclaration currentED = null;
- try
- {
- int listSize = list.size();
- for (int i = 0; i < listSize; i++)
- {
- Element element = (Element)list.get(i);
-
- if (i != 0)
- {
- namespaceTable.addElement(element);
- }
-
- String nodeName = element.getNodeName();
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(nodeName);
- String prefix = DOMNamespaceHelper.getPrefix(nodeName);
-
- CMElementDeclaration ed = null;
-
- // see if the element is a local of the currentED
- //
- if (currentED != null)
- {
- ed = (CMElementDeclaration)currentED.getLocalElements().getNamedItem(unprefixedName);
- }
-
- if (ed == null)
- {
- NamespaceInfo namespaceInfo = namespaceTable.getNamespaceInfoForPrefix(prefix);
- if (namespaceInfo != null)
- {
- CMDocument cmDocument = getCMDocument(namespaceInfo.uri, namespaceInfo.locationHint, "XSD"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- ed = (CMElementDeclaration)cmDocument.getElements().getNamedItem(unprefixedName);
- }
- }
- }
- currentED = ed;
-
- // handle XSIType
- if (currentED != null)
- {
- CMElementDeclaration derivedED = getDerivedCMElementDeclaration(element, currentED, namespaceTable);
- if (derivedED != null)
- {
- currentED = derivedED;
- }
- }
- }
- }
- catch (Exception e)
- {
- Logger.logException("exception locating element declaration for " + targetElement, e); //$NON-NLS-1$
- }
-
- return currentED;
- }
-
-
- protected CMElementDeclaration getDerivedCMElementDeclaration(Element element, CMElementDeclaration ed, NamespaceTable namespaceTable)
- {
- CMElementDeclaration result = null;
- String xsiPrefix = namespaceTable.getPrefixForURI("http://www.w3.org/2001/XMLSchema-instance"); //$NON-NLS-1$
- if (xsiPrefix != null)
- {
- String xsiTypeValue = element.getAttribute(xsiPrefix + ":type"); //$NON-NLS-1$
- if (xsiTypeValue != null && xsiTypeValue.length() > 0)
- {
- String typePrefix = DOMNamespaceHelper.getPrefix(xsiTypeValue);
- String typeName = DOMNamespaceHelper.getUnprefixedName(xsiTypeValue);
- String typeURI = namespaceTable.getURIForPrefix(typePrefix);
- String uriQualifiedTypeName = typeName;
- if (typeURI != null && typeURI.length() > 0)
- {
- uriQualifiedTypeName = "[" + typeURI + "]" + typeName; //$NON-NLS-1$ //$NON-NLS-2$
- }
- result = (CMElementDeclaration)ed.getProperty("DerivedElementDeclaration=" + uriQualifiedTypeName); //$NON-NLS-1$
- }
- }
- return result;
- }
-
-
- public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr)
- {
- CMAttributeDeclaration result = null;
- Element element = attr.getOwnerElement();
- if (element != null)
- {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- if (ed != null)
- {
- result = (CMAttributeDeclaration)ed.getAttributes().getNamedItem(attr.getName());
- if (result == null)
- {
- // try to get the unprefixed name
- String name = DOMNamespaceHelper.getUnprefixedName(attr.getName());
- result = (CMAttributeDeclaration)ed.getAttributes().getNamedItem(name);
- }
- if (result == null)
- {
- // todo... perhaps this is a globally defined attribute...
- }
- }
- }
- return result;
- }
-
- /**
- * This method returns a list of CMDocumentReferences associated with a particular node or subtree
- */
- public List getCMDocumentReferences(Node node, boolean deep)
- {
- List result = new ArrayList();
- Document document = (node.getNodeType() == Node.DOCUMENT_NODE) ? (Document)node : node.getOwnerDocument();
- DocumentType doctype = document.getDoctype();
- // defect 206833 ... here we test for DTDs that are declared inline
- // since we currently have no way of making use of inline DTDs we ingore them
- // so that the implict DTD (if any) can be used
- if (doctype != null && (doctype.getPublicId() != null || doctype.getSystemId() != null))
- {
- String uri = resolveGrammarURI(document, doctype.getPublicId(), doctype.getSystemId());
- result.add(new CMDocumentReferenceImpl(doctype.getPublicId(), uri));
- }
- else if (getImplictDoctype(document) != null)
- {
- String[] implicitDoctype = getImplictDoctype(document);
- String uri = resolveGrammarURI(document, implicitDoctype[0], implicitDoctype[1]);
- result.add(new CMDocumentReferenceImpl(implicitDoctype[0], uri));
- }
- else
- {
- NamespaceTable namespaceTable = new NamespaceTable(document);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- namespaceTable.addElement((Element)node);
- }
- if (deep)
- {
- addChildElementsToNamespaceTable(node, namespaceTable);
- }
- List list = namespaceTable.getNamespaceInfoList();
- for (Iterator i = list.iterator(); i.hasNext();)
- {
- NamespaceInfo info = (NamespaceInfo) i.next();
- String uri = resolveGrammarURI(document, info.uri, info.locationHint);
- result.add(new CMDocumentReferenceImpl(info.uri, uri));
- }
- }
- return result;
- }
-
- protected void addChildElementsToNamespaceTable(Node node, NamespaceTable namespaceTable)
- {
- NodeList nodeList = node.getChildNodes();
- if (nodeList != null)
- {
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++)
- {
- Node childNode = nodeList.item(i);
- if (childNode.getNodeType() == Node.ELEMENT_NODE)
- {
- namespaceTable.addElement((Element)childNode);
- addChildElementsToNamespaceTable(childNode, namespaceTable);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java
deleted file mode 100644
index a82ab1c9be..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDescriptionBuilder.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.util;
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-
-public class CMDescriptionBuilder extends CMVisitor
-{
- protected StringBuffer sb;
- protected CMNode root;
- protected boolean isRootVisited;
- public String buildDescription(CMNode node)
- {
- sb = new StringBuffer();
- root = node;
- isRootVisited = false;
- visitCMNode(node);
- return sb.toString();
- }
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- sb.append("namespace:uri=\"" + anyElement.getNamespaceURI() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void visitCMDataType(CMDataType dataType)
- {
- sb.append("#PCDATA"); //$NON-NLS-1$
- }
-
- public void visitCMDocument(CMDocument document)
- {
- CMNamedNodeMap map = document.getElements();
- int size = map.getLength();
- for (int i = 0; i < size; i++)
- {
- visitCMNode(map.item(i));
- }
- }
-
- public void visitCMGroup(CMGroup group)
- {
- int op = group.getOperator();
- if (op == CMGroup.ALL)
- {
- sb.append("all"); //$NON-NLS-1$
- }
-
- sb.append("("); //$NON-NLS-1$
-
- String separator = ", "; //$NON-NLS-1$
-
- if (op == CMGroup.CHOICE)
- {
- separator = " | "; //$NON-NLS-1$
- }
-
-
- CMNodeList nodeList = group.getChildNodes();
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++)
- {
- visitCMNode(nodeList.item(i));
- if (i < size - 1)
- {
- sb.append(separator);
- }
- }
-
- sb.append(")"); //$NON-NLS-1$
- addOccurenceSymbol(group);
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- if (ed == root && !isRootVisited)
- {
- isRootVisited = true;
- CMContent content = ed.getContent();
- if (content != null)
- {
- if (content.getNodeType() != CMNode.GROUP)
- {
- sb.append("("); //$NON-NLS-1$
- visitCMNode(content);
- sb.append(")"); //$NON-NLS-1$
- }
- else
- {
- visitCMNode(content);
- }
- }
- }
- else
- {
- sb.append(ed.getElementName());
- addOccurenceSymbol(ed);
- }
- }
-
- public void addOccurenceSymbol(CMContent content)
- {
- int min = content.getMinOccur();
- int max = content.getMaxOccur();
- if (min == 0)
- {
- if (max > 1 || max == -1)
- {
- sb.append("*"); //$NON-NLS-1$
- }
- else
- {
- sb.append("?"); //$NON-NLS-1$
- }
- }
- else if (max > 1 || max == -1)
- {
- sb.append("+"); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java
deleted file mode 100644
index 670ff531b4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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.util;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-
-
-
-/**
- *
- */
-public class CMDocumentCache
-{
- public static final int STATUS_NOT_LOADED = 0;
- public static final int STATUS_LOADING = 2;
- public static final int STATUS_LOADED = 3;
- public static final int STATUS_ERROR = 4;
-
- protected class Entry
- {
- public String uri;
- public int status = STATUS_NOT_LOADED;
- public float progress;
- public CMDocument cmDocument;
-
- public Entry(String uri)
- {
- this.uri = uri;
- }
-
- public Entry(String uri, int status, CMDocument cmDocument)
- {
- this.uri = uri;
- this.status = status;
- this.cmDocument = cmDocument;
- }
- }
-
- protected Hashtable hashtable;
- protected List listenerList = new Vector();
-
-
- /**
- * temporarily public until caching problem is solved
- */
- public CMDocumentCache()
- {
- hashtable = new Hashtable();
- }
-
- public void addListener(CMDocumentCacheListener listener)
- {
- listenerList.add(listener);
- }
-
- public void removeListener(CMDocumentCacheListener listener)
- {
- listenerList.remove(listener);
- }
-
- /**
- *
- */
- public CMDocument getCMDocument(String grammarURI)
- {
- CMDocument result = null;
- if (grammarURI != null)
- {
- Entry entry = (Entry)hashtable.get(grammarURI);
- if (entry != null)
- {
- result = entry.cmDocument;
- }
- }
- return result;
- }
-
- /**
- *
- */
- public int getStatus(String grammarURI)
- {
- int result = STATUS_NOT_LOADED;
- if (grammarURI != null)
- {
- Entry entry = (Entry)hashtable.get(grammarURI);
- if (entry != null)
- {
- result = entry.status;
- }
-
- }
- return result;
- }
-
- /**
- *
- */
- protected Entry lookupOrCreate(String grammarURI)
- {
- Entry entry = (Entry)hashtable.get(grammarURI);
- if (entry == null)
- {
- entry = new Entry(grammarURI);
- hashtable.put(grammarURI, entry);
- }
- return entry;
- }
-
-
- /**
- *
- */
- public void putCMDocument(String grammarURI, CMDocument cmDocument)
- {
- if (grammarURI != null && cmDocument != null)
- {
- Entry entry = lookupOrCreate(grammarURI);
- int oldStatus = entry.status;
- entry.status = STATUS_LOADED;
- entry.cmDocument = cmDocument;
- notifyCacheUpdated(grammarURI, oldStatus, entry.status, entry.cmDocument);
- }
- }
-
- /**
- *
- */
- public void setStatus(String grammarURI, int status)
- {
- if (grammarURI != null)
- {
- Entry entry = lookupOrCreate(grammarURI);
- int oldStatus = entry.status;
- entry.status = status;
- notifyCacheUpdated(grammarURI, oldStatus, entry.status, entry.cmDocument);
- }
- }
-
- /**
- *
- */
- public void clear()
- {
- hashtable.clear();
- notifyCacheCleared();
- }
-
- /**
- *
- */
- protected void notifyCacheUpdated(String uri, int oldStatus, int newStatus, CMDocument cmDocument)
- {
- List list = new Vector();
- list.addAll(listenerList);
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- CMDocumentCacheListener listener = (CMDocumentCacheListener)i.next();
- listener.cacheUpdated(this, uri, oldStatus, newStatus, cmDocument);
- }
- }
-
- /**
- *
- */
- protected void notifyCacheCleared()
- {
- List list = new Vector();
- list.addAll(listenerList);
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- CMDocumentCacheListener listener = (CMDocumentCacheListener)i.next();
- listener.cacheCleared(this);
- }
- }
-
- public List getCMDocuments()
- {
- List list = new ArrayList();
- for (Iterator i = hashtable.values().iterator(); i.hasNext(); )
- {
- Entry entry = (Entry)i.next();
- list.add(entry.cmDocument);
- }
- return list;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCacheListener.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCacheListener.java
deleted file mode 100644
index d9f6dcdece..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCacheListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-
-
-/**
- * todo... add more interface methods
- */
-public interface CMDocumentCacheListener
-{
- /** Tells the client that the cache has been cleared.
- * This gives clients an opportunity to flush any state that depends on the CMDocument
- * since this CMDocument will be recomputed on a subsequent 'lookup' request
- */
- public void cacheCleared(CMDocumentCache cache);
-
- /**
- * Tells the client that the cache has been updated.
- */
- public void cacheUpdated(CMDocumentCache cache, String uri, int oldStatus, int newStatus, CMDocument cmDocument);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMVisitor.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMVisitor.java
deleted file mode 100644
index 89bb9d6a9a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMVisitor.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.util;
-
-import java.util.Stack;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-
-public class CMVisitor
-{
- protected int indent = 0;
- protected Stack visitedCMGroupStack = new Stack();
-
- public void visitCMNode(CMNode node)
- {
- if (node != null)
- {
- //ContentModelManager.printlnIndented("visitCMNode : " + node.getNodeName() + " " + node);
- indent += 2;
- int nodeType = node.getNodeType();
- switch (nodeType)
- {
- case CMNode.ANY_ELEMENT :
- {
- visitCMAnyElement((CMAnyElement)node);
- break;
- }
- case CMNode.ATTRIBUTE_DECLARATION :
- {
- visitCMAttributeDeclaration((CMAttributeDeclaration)node);
- break;
- }
- case CMNode.DATA_TYPE :
- {
- visitCMDataType((CMDataType)node);
- break;
- }
- case CMNode.DOCUMENT :
- {
- visitCMDocument((CMDocument)node);
- break;
- }
- case CMNode.ELEMENT_DECLARATION :
- {
- visitCMElementDeclaration((CMElementDeclaration)node);
- break;
- }
- case CMNode.GROUP :
- {
- CMGroup group = (CMGroup)node;
-
- // This is to prevent recursion.
- if (visitedCMGroupStack.contains(group))
- {
- break;
- }
-
- // Push the current group to check later to avoid potential recursion
- visitedCMGroupStack.push(group);
-
- visitCMGroup(group);
-
- // Pop the current group
- visitedCMGroupStack.pop();
- break;
- }
- }
- indent -= 2;
- }
- }
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- }
-
- public void visitCMAttributeDeclaration(CMAttributeDeclaration ad)
- {
- }
-
- public void visitCMDataType(CMDataType dataType)
- {
- }
-
- public void visitCMDocument(CMDocument document)
- {
- CMNamedNodeMap map = document.getElements();
- int size = map.getLength();
- for (int i = 0; i < size; i++)
- {
- visitCMNode(map.item(i));
- }
- }
-
- public void visitCMGroup(CMGroup group)
- {
- CMNodeList nodeList = group.getChildNodes();
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++)
- {
- visitCMNode(nodeList.item(i));
- }
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- CMNamedNodeMap nodeMap = ed.getAttributes();
- int size = nodeMap.getLength();
- for (int i = 0; i < size; i++)
- {
- visitCMNode(nodeMap.item(i));
- }
-
- visitCMNode(ed.getContent());
-
- visitCMDataType(ed.getDataType());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/ContentBuilder.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/ContentBuilder.java
deleted file mode 100644
index 14d02b1879..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/ContentBuilder.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-
-
-/**
- * This class lets you traverse a 'CM' model providing callbacks to build content.
- */
-public class ContentBuilder extends CMVisitor
-{
- public static final int BUILD_ALL_CONTENT = 1;
- public static final int BUILD_ONLY_REQUIRED_CONTENT = 2;
- protected int buildPolicy = BUILD_ALL_CONTENT;
-
- protected boolean alwaysVisit;
- protected Vector visitedCMElementDeclarationList = new Vector();
-
- public ContentBuilder()
- {
- }
-
- public void setBuildPolicy(int buildPolicy)
- {
- this.buildPolicy = buildPolicy;
- }
-
- public int getBuildPolicy()
- {
- return buildPolicy;
- }
-
- protected void createAnyElementNode(CMAnyElement anyElement)
- {
- }
-
- protected void createElementNodeStart(CMElementDeclaration ed)
- {
- }
-
- protected void createElementNodeEnd(CMElementDeclaration ed)
- {
- }
-
- protected void createTextNode(CMDataType dataType)
- {
- }
-
- protected void createAttributeNode(CMAttributeDeclaration attribute)
- {
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed)
- {
- int forcedMin = (buildPolicy == BUILD_ALL_CONTENT || alwaysVisit) ? 1 : 0;
- int min = Math.max(ed.getMinOccur(), forcedMin);
- alwaysVisit = false;
-
- if (min > 0 && !visitedCMElementDeclarationList.contains(ed))
- {
- visitedCMElementDeclarationList.add(ed);
- for (int i = 1; i <= min; i++)
- {
- createElementNodeStart(ed);
-
- // instead of calling super.visitCMElementDeclaration()
- // we duplicate the code with some minor modifications
- CMNamedNodeMap nodeMap = ed.getAttributes();
- int size = nodeMap.getLength();
- for (int j = 0; j < size; j++)
- {
- visitCMNode(nodeMap.item(j));
- }
-
- CMContent content = ed.getContent();
- if (content != null)
- {
- visitCMNode(content);
- }
-
- if (ed.getContentType() == CMElementDeclaration.PCDATA)
- {
- CMDataType dataType = ed.getDataType();
- if (dataType != null)
- {
- visitCMDataType(dataType);
- }
- }
- // end duplication
- createElementNodeEnd(ed);
- }
- int size = visitedCMElementDeclarationList.size();
- visitedCMElementDeclarationList.remove(size - 1);
- }
- }
-
-
- public void visitCMDataType(CMDataType dataType)
- {
- createTextNode(dataType);
- }
-
-
- public void visitCMGroup(CMGroup e)
- {
- int forcedMin = (buildPolicy == BUILD_ALL_CONTENT || alwaysVisit) ? 1 : 0;
- int min = Math.max(e.getMinOccur(), forcedMin);
- alwaysVisit = false;
-
- for (int i = 1; i <= min; i++)
- {
- if (e.getOperator() == CMGroup.CHOICE)
- {
- // add only 1 element from the group
- // todo... perhaps add something other than the first one
- CMNodeList nodeList = e.getChildNodes();
- if (nodeList.getLength() > 0)
- {
- visitCMNode(nodeList.item(0));
- }
- }
- else // SEQUENCE, ALL
- {
- // visit all of the content
- super.visitCMGroup(e);
- }
- }
- }
-
- public void visitCMAttributeDeclaration(CMAttributeDeclaration ad)
- {
- if (alwaysVisit ||
- buildPolicy == BUILD_ALL_CONTENT ||
- ad.getUsage() == CMAttributeDeclaration.REQUIRED)
- {
- createAttributeNode(ad);
- }
- }
-
-
- public void visitCMAnyElement(CMAnyElement anyElement)
- {
- int forcedMin = (buildPolicy == BUILD_ALL_CONTENT || alwaysVisit) ? 1 : 0;
- alwaysVisit = false;
- int min = Math.max(anyElement.getMinOccur(), forcedMin);
- for (int i = 1; i <= min; i++)
- {
- createAnyElementNode(anyElement);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilder.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilder.java
deleted file mode 100644
index 9d23576155..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Node;
-
-
-public interface DOMContentBuilder
-{
- public static final int BUILD_OPTIONAL_ATTRIBUTES = 1;
- public static final int BUILD_OPTIONAL_ELEMENTS = 1<<1;
- public static final int BUILD_FIRST_CHOICE = 1<<2;
- public static final int BUILD_TEXT_NODES = 1<<3;
- public static final int BUILD_FIRST_SUBSTITUTION = 1<<4;
-
- public static final int
- BUILD_ONLY_REQUIRED_CONTENT =
- BUILD_FIRST_CHOICE
- | BUILD_TEXT_NODES;
- public static final int
- BUILD_ALL_CONTENT =
- BUILD_OPTIONAL_ATTRIBUTES
- | BUILD_OPTIONAL_ELEMENTS
- | BUILD_FIRST_CHOICE
- | BUILD_TEXT_NODES;
-
- public static final String PROPERTY_BUILD_BLANK_TEXT_NODES = "buildBlankTextNodes"; //$NON-NLS-1$
-
- public void setBuildPolicy(int buildPolicy);
- public int getBuildPolicy();
- public void setProperty(String propertyName, Object value);
- public Object getProperty(String propertyName);
- public List getResult();
- public void build(Node parent, CMNode child);
- public void createDefaultRootContent(CMDocument cmDocument, CMElementDeclaration rootCMElementDeclaration) throws Exception;
- public void createDefaultRootContent(CMDocument cmDocument, CMElementDeclaration rootCMElementDeclaration, List namespaceInfoList) throws Exception;
- public void createDefaultContent(Node parent, CMElementDeclaration ed) throws Exception;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilderImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilderImpl.java
deleted file mode 100644
index 290f6f5866..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMContentBuilderImpl.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.util;
-
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Stack;
-import java.util.Vector;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMDataTypeValueHelper;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-/**
- * todo... common up this code with 'ContentBuilder'
- */
-public class DOMContentBuilderImpl extends CMVisitor implements DOMContentBuilder {
- protected int buildPolicy = BUILD_ALL_CONTENT;
- protected Hashtable propertyTable = new Hashtable();
-
- protected boolean alwaysVisit = false;
- protected List resultList;
- protected Document document;
- protected Node currentParent;
- protected Node topParent;
- protected Vector visitedCMElementDeclarationList = new Vector();
- protected boolean attachNodesToParent = true;
- protected NamespaceTable namespaceTable;
-
- protected List namespaceInfoList;
- protected Element rootElement; // this is used only teporarily via
- // createDefaultRootContent
- protected ExternalCMDocumentSupport externalCMDocumentSupport;
-
- public boolean supressCreationOfDoctypeAndXMLDeclaration;
-
- protected CMDataTypeValueHelper valueHelper = new CMDataTypeValueHelper();
-
- protected int numOfRepeatableElements = 1;
- protected Stack cmGroupStack = new Stack();
- protected int depthLimit = -1;
-
- protected int domLevel;
- private int originalBuildPolicy;
-
- public interface ExternalCMDocumentSupport {
- public CMDocument getCMDocument(Element element, String uri);
- }
-
- public void setExternalCMDocumentSupport(ExternalCMDocumentSupport externalCMDocumentSupport) {
- this.externalCMDocumentSupport = externalCMDocumentSupport;
- }
-
- public DOMContentBuilderImpl(Document document) {
- this.document = document;
- namespaceTable = new NamespaceTable(document);
- }
-
- public void setBuildPolicy(int buildPolicy) {
- this.buildPolicy = buildPolicy;
- }
-
- public int getBuildPolicy() {
- return buildPolicy;
- }
-
- protected boolean buildAllContent(int policy) {
- return (policy & BUILD_ALL_CONTENT) == BUILD_ALL_CONTENT;
- }
-
- protected boolean buildOptionalElements(int policy) {
- return (policy & BUILD_OPTIONAL_ELEMENTS) == BUILD_OPTIONAL_ELEMENTS;
- }
-
- protected boolean buildOptionalAttributes(int policy) {
- return (policy & BUILD_OPTIONAL_ATTRIBUTES) == BUILD_OPTIONAL_ATTRIBUTES;
- }
-
- protected boolean buildFirstChoice(int policy) {
- return (policy & BUILD_FIRST_CHOICE) == BUILD_FIRST_CHOICE;
- }
-
- protected boolean buildTextNodes(int policy) {
- return (policy & BUILD_TEXT_NODES) == BUILD_TEXT_NODES;
- }
-
- protected boolean buildFirstSubstitution(int policy) {
- return (policy & BUILD_FIRST_SUBSTITUTION) == BUILD_FIRST_SUBSTITUTION;
- }
-
- public List getResult() {
- return resultList;
- }
-
- public void setProperty(String propertyName, Object value) {
- propertyTable.put(propertyName, value);
- }
-
- public Object getProperty(String propertyName) {
- return propertyTable.get(propertyName);
- }
-
- public void build(Node parent, CMNode child) {
- resultList = new Vector();
- topParent = parent;
- currentParent = parent;
- if (parent instanceof Element) {
- namespaceTable.addElementLineage((Element) parent);
- }
- attachNodesToParent = false;
- alwaysVisit = true;
- visitCMNode(child);
- }
-
- public void createDefaultRootContent(CMDocument cmDocument, CMElementDeclaration rootCMElementDeclaration, List namespaceInfoList) throws Exception {
- this.namespaceInfoList = namespaceInfoList;
- createDefaultRootContent(cmDocument, rootCMElementDeclaration);
- }
-
- public void createDefaultRootContent(CMDocument cmDocument, CMElementDeclaration rootCMElementDeclaration) throws Exception {
- String grammarFileName = cmDocument.getNodeName();
- if (!supressCreationOfDoctypeAndXMLDeclaration) {
- // TODO cs... investigate to see if this code path is ever used,
- // doesn't seem to be
- // for now I'm setting the encoding to UTF-8 just incase this code
- // path is used somewhere
- //
- String piValue = "version=\"1.0\""; //$NON-NLS-1$
- String encoding = "UTF-8"; //$NON-NLS-1$
- piValue += " encoding=\"" + encoding + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- ProcessingInstruction pi = document.createProcessingInstruction("xml", piValue); //$NON-NLS-1$
- document.appendChild(pi);
-
- // if we have a 'dtd' then add a DOCTYPE tag
- //
- if (grammarFileName != null && grammarFileName.endsWith("dtd")) //$NON-NLS-1$
- {
- DOMImplementation domImpl = document.getImplementation();
- DocumentType documentType = domImpl.createDocumentType(rootCMElementDeclaration.getElementName(), grammarFileName, grammarFileName);
- document.appendChild(documentType);
- }
- }
-
- // if we have a schema add an xsi:schemaLocation attribute
- //
- if (grammarFileName != null && grammarFileName.endsWith("xsd") && namespaceInfoList != null) //$NON-NLS-1$
- {
- DOMNamespaceInfoManager manager = new DOMNamespaceInfoManager();
- String name = rootCMElementDeclaration.getNodeName();
- if (namespaceInfoList.size() > 0) {
- NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0);
- if (info.prefix != null && info.prefix.length() > 0) {
- name = info.prefix + ":" + name; //$NON-NLS-1$
- }
- }
- rootElement = createElement(rootCMElementDeclaration, name, document);
- manager.addNamespaceInfo(rootElement, namespaceInfoList, true);
- }
- createDefaultContent(document, rootCMElementDeclaration);
- }
-
- public void createDefaultContent(Node parent, CMElementDeclaration ed) {
- currentParent = parent;
- alwaysVisit = true;
- originalBuildPolicy = buildPolicy;
- visitCMElementDeclaration(ed);
- }
-
- public String computeName(CMNode cmNode, Node parent) {
- String prefix = null;
- return DOMNamespaceHelper.computeName(cmNode, parent, prefix, namespaceTable);
- }
-
- // overide the following 'create' methods to control how nodes are created
- //
- protected Element createElement(CMElementDeclaration ed, String name, Node parent) {
- return document.createElement(name);
- }
-
- protected Attr createAttribute(CMAttributeDeclaration ad, String name, Node parent) {
- return document.createAttribute(name);
- }
-
- protected Text createTextNode(CMDataType dataType, String value, Node parent) {
- return document.createTextNode(value);
- }
-
- protected void handlePushParent(Element parent, CMElementDeclaration ed) {
- domLevel++;
- }
-
- protected void handlePopParent(Element element, CMElementDeclaration ed) {
- domLevel--;
- }
-
- // The range must be between 1 and 99.
- public void setNumOfRepeatableElements(int i) {
- numOfRepeatableElements = i;
- }
-
- protected int getNumOfRepeatableElements() {
- return numOfRepeatableElements;
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed) {
- int forcedMin = (buildOptionalElements(buildPolicy) || alwaysVisit) ? 1 : 0;
- int min = Math.max(ed.getMinOccur(), forcedMin);
-
- // Correct the min value if the element is contained in
- // a group.
- if (!cmGroupStack.isEmpty()) {
- CMGroup group = (CMGroup) cmGroupStack.peek();
- int gmin = group.getMinOccur();
- if (gmin == 0)
- if (buildOptionalElements(buildPolicy)) {
- /* do nothing: min = min */
- }
- else {
- min = min * gmin; // min = 0
- }
- else {
- min = min * gmin;
- }
- }
-
- int max = Math.min(ed.getMaxOccur(), getNumOfRepeatableElements());
- if (max < min)
- max = min;
-
- alwaysVisit = false;
-
- // Note - ed may not be abstract but has substitutionGroups
- // involved.
- if (buildFirstSubstitution(buildPolicy) || isAbstract(ed)) // leave
- // this
- // for
- // backward
- // compatibility
- // for now
- {
- // Note - To change so that if ed is optional, we do not
- // generate anything here.
- ed = getSubstitution(ed);
-
- // Note - the returned ed may be an abstract element in
- // which case the xml will be invalid.
- }
-
- if (min > 0 && !visitedCMElementDeclarationList.contains(ed)) {
- visitedCMElementDeclarationList.add(ed);
- for (int i = 1; i <= max; i++) {
- // create an Element for each
- Element element = null;
- if (rootElement != null) {
- element = rootElement;
- rootElement = null;
- }
- else {
- element = createElement(ed, computeName(ed, currentParent), currentParent);
- }
-
- // visit the children of the GrammarElement
- Node oldParent = currentParent;
- currentParent = element;
- handlePushParent(element, ed);
-
- namespaceTable.addElement(element);
-
- boolean oldAttachNodesToParent = attachNodesToParent;
- attachNodesToParent = true;
-
- // instead of calling super.visitCMElementDeclaration()
- // we duplicate the code with some minor modifications
- CMNamedNodeMap nodeMap = ed.getAttributes();
- int size = nodeMap.getLength();
- for (int j = 0; j < size; j++) {
- visitCMNode(nodeMap.item(j));
- }
-
- CMContent content = ed.getContent();
- if (content != null) {
- visitCMNode(content);
- }
-
- if (ed.getContentType() == CMElementDeclaration.PCDATA) {
- CMDataType dataType = ed.getDataType();
- if (dataType != null) {
- visitCMDataType(dataType);
- }
- }
- // end duplication
- attachNodesToParent = oldAttachNodesToParent;
- handlePopParent(element, ed);
- currentParent = oldParent;
- linkNode(element);
- }
- int size = visitedCMElementDeclarationList.size();
- visitedCMElementDeclarationList.remove(size - 1);
- }
- }
-
-
- public void visitCMDataType(CMDataType dataType) {
- Text text = null;
- String value = null;
-
- // For backward compatibility:
- // Previous code uses a property value but new one uses
- // buildPolicy.
- if (getProperty(PROPERTY_BUILD_BLANK_TEXT_NODES) != null && getProperty(PROPERTY_BUILD_BLANK_TEXT_NODES).equals("true")) //$NON-NLS-1$
- buildPolicy = buildPolicy ^ BUILD_TEXT_NODES;
-
- if (buildTextNodes(buildPolicy)) {
- value = valueHelper.getValue(dataType);
- if (value == null) {
- if (currentParent != null && currentParent.getNodeType() == Node.ELEMENT_NODE) {
- value = currentParent.getNodeName();
- }
- else {
- value = "pcdata"; //$NON-NLS-1$
- }
- }
- }
- else {
- value = ""; //$NON-NLS-1$
- }
- text = createTextNode(dataType, value, currentParent);
- linkNode(text);
- }
-
- public void visitCMNode(CMNode node) {
- if (depthLimit != -1) {
- if (domLevel > depthLimit) {
- buildPolicy = buildPolicy &= ~BUILD_OPTIONAL_ELEMENTS;
- } else {
- buildPolicy = originalBuildPolicy;
- }
- }
- super.visitCMNode(node);
- }
-
- public void visitCMGroup(CMGroup e) {
- cmGroupStack.push(e);
-
- int forcedMin = (buildOptionalElements(buildPolicy) || alwaysVisit) ? 1 : 0;
- int min = Math.max(e.getMinOccur(), forcedMin);
-
- int max = 0;
- if (e.getMaxOccur() == -1) // unbounded
- max = getNumOfRepeatableElements();
- else
- max = Math.min(e.getMaxOccur(), getNumOfRepeatableElements());
-
- if (max < min)
- max = min;
-
- alwaysVisit = false;
-
- for (int i = 1; i <= max; i++) {
- if (e.getOperator() == CMGroup.CHOICE && buildFirstChoice(buildPolicy)) {
- CMNode hintNode = null;
-
- // todo... the CMGroup should specify the hint... but it seems
- // as though
- // the Yamato guys are making the CMElement specify the hint.
- // I do it that way for now until... we should fix this post
- // GA
- //
- int listSize = visitedCMElementDeclarationList.size();
- if (listSize > 0) {
- CMElementDeclaration ed = (CMElementDeclaration) visitedCMElementDeclarationList.get(listSize - 1);
- Object contentHint = ed.getProperty("contentHint"); //$NON-NLS-1$
- if (contentHint instanceof CMNode) {
- hintNode = (CMNode) contentHint;
- }
- }
-
- // see if this hint corresponds to a valid choice
- //
- CMNode cmNode = null;
-
- if (hintNode != null) {
- CMNodeList nodeList = e.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int j = 0; j < nodeListLength; j++) {
- if (hintNode == nodeList.item(j)) {
- cmNode = hintNode;
- }
- }
- }
-
- // if no cmNode has been determined from the hint, just use
- // the first choice
- //
- if (cmNode == null) {
- CMNodeList nodeList = e.getChildNodes();
- if (nodeList.getLength() > 0) {
- cmNode = nodeList.item(0);
- }
- }
-
- if (cmNode != null) {
- // Bug 330260
- // Problem - Add child element also adds optional grand-child elements
- // This assumes 'e' is a model group choice, case 1. However 'e' could be a model group definition, case 2, where the
- // first child is a model group. In the first case (choice), the first child is an
- // element. Upon visiting the element (visitCMElementDeclaration), the minOccurs of the
- // choice is ALSO considered. If its minOccurs is 0, then the first element is not added as a child.
- // However, in the second case (model group definition), the first child is a choice, but the multiplicity is [1,1],
- // meaning, it is required. So the first element is then added as child, even though
- // the model group definition reference is optional. (minOccurs is not checked in this method, visitCMGroup)
- // Visit the node only if it is not a GROUP (model group). If it is an element, then visit it.
- if (!(cmNode.getNodeType() == CMNode.GROUP && min > 0)) {
- visitCMNode(cmNode);
- }
- }
- }
- else if (e.getOperator() == CMGroup.ALL // ALL
- || e.getOperator() == CMGroup.SEQUENCE) // SEQUENCE
- {
- // visit all of the content
- super.visitCMGroup(e);
- }
- }
-
- cmGroupStack.pop();
- }
-
- static int count = 0;
-
- public void visitCMAttributeDeclaration(CMAttributeDeclaration ad) {
- if (alwaysVisit || buildOptionalAttributes(buildPolicy) || ad.getUsage() == CMAttributeDeclaration.REQUIRED) {
- alwaysVisit = false;
- String name = computeName(ad, currentParent);
- String value = valueHelper.getValue(ad, namespaceTable);
- Attr attr = createAttribute(ad, name, currentParent);
- attr.setValue(value != null ? value : ""); //$NON-NLS-1$
- linkNode(attr);
- }
- }
-
- protected boolean isAbstract(CMNode ed) {
- boolean result = false;
- if (ed != null) {
- Object value = ed.getProperty("Abstract"); //$NON-NLS-1$
- result = (value == Boolean.TRUE);
- }
- return result;
- }
-
- protected CMElementDeclaration getSubstitution(CMElementDeclaration ed) {
- CMElementDeclaration result = ed;
- CMNodeList l = (CMNodeList) ed.getProperty("SubstitutionGroup"); //$NON-NLS-1$
- if (l != null) {
- for (int i = 0; i < l.getLength(); i++) {
- CMNode candidate = l.item(i);
- if (!isAbstract(candidate) && (candidate instanceof CMElementDeclaration)) {
- result = (CMElementDeclaration) candidate;
- break;
- }
- }
- }
- return result;
- }
-
- protected CMElementDeclaration getParentCMElementDeclaration() {
- CMElementDeclaration ed = null;
- int listSize = visitedCMElementDeclarationList.size();
- if (listSize > 0) {
- ed = (CMElementDeclaration) visitedCMElementDeclarationList.get(listSize - 1);
- }
- return ed;
- }
-
- public void visitCMAnyElement(CMAnyElement anyElement) {
- // ingnore buildPolicy for ANY elements... only create elements if
- // absolutely needed
- //
- int forcedMin = alwaysVisit ? 1 : 0;
- int min = Math.max(anyElement.getMinOccur(), forcedMin);
- alwaysVisit = false;
-
- String uri = anyElement.getNamespaceURI();
- String targetNSProperty = "http://org.eclipse.wst/cm/properties/targetNamespaceURI"; //$NON-NLS-1$
- CMDocument parentCMDocument = (CMDocument) anyElement.getProperty("CMDocument"); //$NON-NLS-1$
- CMElementDeclaration ed = null;
-
- // System.out.println("parentCMDocument = " + parentCMDocument);
- // //$NON-NLS-1$
- if (parentCMDocument != null) {
- if (uri == null || uri.startsWith("##") || uri.equals(parentCMDocument.getProperty(targetNSProperty))) //$NON-NLS-1$
- {
- ed = getSuitableElement(getParentCMElementDeclaration(), parentCMDocument);
- }
- }
-
-
- if (ed == null && externalCMDocumentSupport != null && uri != null && !uri.startsWith("##") && currentParent instanceof Element) //$NON-NLS-1$
- {
- CMDocument externalCMDocument = externalCMDocumentSupport.getCMDocument((Element) currentParent, uri);
- if (externalCMDocument != null) {
- ed = getSuitableElement(null, externalCMDocument);
- }
- }
-
- for (int i = 1; i <= min; i++) {
- if (ed != null) {
- visitCMElementDeclaration(ed);
- }
- else {
- Element element = document.createElement("ANY-ELEMENT"); //$NON-NLS-1$
- linkNode(element);
- }
- }
- }
-
- protected CMElementDeclaration getSuitableElement(CMNamedNodeMap nameNodeMap) {
- CMElementDeclaration result = null;
- int size = nameNodeMap.getLength();
- for (int i = 0; i < size; i++) {
- CMElementDeclaration candidate = (CMElementDeclaration) nameNodeMap.item(i);
- if (!visitedCMElementDeclarationList.contains(candidate)) {
- result = candidate;
- break;
- }
- }
- return result;
- }
-
- protected CMElementDeclaration getSuitableElement(CMElementDeclaration ed, CMDocument cmDocument) {
- CMElementDeclaration result = null;
-
- if (ed != null) {
- result = getSuitableElement(ed.getLocalElements());
- }
-
- if (result == null && cmDocument != null) {
- result = getSuitableElement(cmDocument.getElements());
- }
-
- return result;
- }
-
-
- public void linkNode(Node node) {
- if (attachNodesToParent && currentParent != null) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- ((Element) currentParent).setAttributeNode((Attr) node);
- }
- else {
- currentParent.appendChild(node);
- }
- }
- else if (resultList != null) {
- resultList.add(node);
- }
- }
-
- public static void testPopulateDocumentFromGrammarFile(Document document, String grammarFileName, String rootElementName, boolean hack) {
- try {
- CMDocument cmDocument = ContentModelManager.getInstance().createCMDocument(grammarFileName, null);
- CMNamedNodeMap elementMap = cmDocument.getElements();
- CMElementDeclaration element = (CMElementDeclaration) elementMap.getNamedItem(rootElementName);
-
- DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(document);
- contentBuilder.supressCreationOfDoctypeAndXMLDeclaration = hack;
- contentBuilder.createDefaultRootContent(cmDocument, element);
-
- System.out.println();
- System.out.println("-----------------------------"); //$NON-NLS-1$
- DOMWriter writer = new DOMWriter();
- if (hack) {
- writer.print(document, grammarFileName);
- }
- else {
- writer.print(document);
- }
- System.out.println("-----------------------------"); //$NON-NLS-1$
- }
- catch (Exception e) {
- System.out.println("Error: " + e); //$NON-NLS-1$
- e.printStackTrace();
- }
- }
-
- public void setOptionalElementDepthLimit(int depth) {
- depthLimit = depth;
- }
-
-
- // test
- //
- /*
- * public static void main(String arg[]) { if (arg.length >= 2) { try {
- * CMDocumentFactoryRegistry.getInstance().registerCMDocumentBuilderWithClassName("org.eclipse.wst.xml.core.internal.contentmodel.mofimpl.CMDocumentBuilderImpl");
- *
- * String grammarFileName = arg[0]; String rootElementName = arg[1];
- *
- * Document document =
- * (Document)Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance();
- * testPopulateDocumentFromGrammarFile(document, grammarFileName,
- * rootElementName, true); } catch (Exception e) {
- * System.out.println("DOMContentBuilderImpl error"); e.printStackTrace(); } }
- * else { System.out.println("Usage : java
- * org.eclipse.wst.xml.util.DOMContentBuildingCMVisitor grammarFileName
- * rootElementName"); } }
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceHelper.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceHelper.java
deleted file mode 100644
index 049d44585c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceHelper.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class DOMNamespaceHelper
-{
- protected static String getURIForPrefix(Element element, String prefix)
- {
- String result = null;
- String nsAttrName = null;
- if (prefix != null && prefix.length() > 0)
- {
- nsAttrName = "xmlns:" + prefix; //$NON-NLS-1$
- }
- else
- {
- nsAttrName = "xmlns"; //$NON-NLS-1$
- }
-
- // assume the node is qualified... look up the URI base on the prefix
- //
- for (Node node = element; node != null; node = node.getParentNode())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element theElement = (Element)node;
- Attr attr = theElement.getAttributeNode(nsAttrName);
- if (attr != null)
- {
- result = attr.getValue();
- }
- }
- else
- {
- break;
- }
- }
-
- // see if we can find some info from an 'implicit' namespace
- //
- if (result == null)
- {
- NamespaceTable table = new NamespaceTable(element.getOwnerDocument());
- result = table.getURIForPrefix(prefix);
- }
- return result;
- }
-
- public static String getNamespaceURI(Node node)
- {
- String result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element element = (Element)node;
- String prefix = element.getPrefix();
- result = getURIForPrefix(element, prefix);
- }
- else if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- {
- Attr attr = (Attr)node;
- String prefix = attr.getPrefix();
- result = getURIForPrefix(attr.getOwnerElement(), prefix);
- }
- return result;
- }
-
- // todo... this is an ugly hack... needs to be fixed
- //
- public static String computePrefix(CMNode cmNode, Node parentNode)
- {
- String result = null;
- for (Node node = parentNode; node != null; node = node.getParentNode())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- result = getPrefix(node.getNodeName());
- if (result != null)
- {
- break;
- }
- }
- }
- return result;
- }
-
-
- public static String getPrefix(String name)
- {
- String prefix = null;
- int index = name.indexOf(":"); //$NON-NLS-1$
- if (index != -1)
- {
- prefix = name.substring(0, index);
- }
- return prefix;
- }
-
-
- public static String getUnprefixedName(String name)
- {
- int index = name.indexOf(":"); //$NON-NLS-1$
- if (index != -1)
- {
- name = name.substring(index + 1);
- }
- return name;
- }
-
-
- public static String computeName(CMNode cmNode, Node parent, String prefix)
- {
- return computeName(cmNode, parent, prefix, null);
- }
-
-
- public static String computeName(CMNode cmNode, Node parent, String prefix, NamespaceTable namespaceTable)
- {
- String result = cmNode.getNodeName();
-
- // if the cmNode has a hard coded prefix then we don't need to do anything
- //
- if (getPrefix(result) == null)
- {
- String qualification = (String)cmNode.getProperty("http://org.eclipse.wst/cm/properties/nsPrefixQualification"); //$NON-NLS-1$
- // see if we need a namespace prefix
- //
- if (qualification != null && qualification.equals("qualified")) //$NON-NLS-1$
- {
- if (prefix == null)
- {
- // todo... add getCMDocument() method to CMNode
- // for now use this getProperty() hack
- CMDocument cmDocument = (CMDocument)cmNode.getProperty("CMDocument"); //$NON-NLS-1$
- if (cmDocument != null)
- {
- String namespaceURI = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$
- if (namespaceURI != null)
- {
- // use the NamespaceTable to figure out the correct prefix for this namespace uri
- //
- if (namespaceTable == null)
- {
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document)parent : parent.getOwnerDocument();
- namespaceTable = new NamespaceTable(document);
- if (parent instanceof Element)
- {
- namespaceTable.addElementLineage((Element)parent);
- }
- }
- prefix = namespaceTable.getPrefixForURI(namespaceURI);
- }
- }
- }
- if (prefix != null && prefix.length() > 0)
- {
- result = prefix + ":" + result; //$NON-NLS-1$
- }
- }
- }
- return result;
- }
-
-
- public static String[] getURIQualifiedNameComponents(String uriQualifiedName)
- {
- String[] result = new String[2];
- int firstIndex = uriQualifiedName.indexOf("["); //$NON-NLS-1$
- int lastIndex = uriQualifiedName.indexOf("]"); //$NON-NLS-1$
- if (firstIndex != -1 && lastIndex > firstIndex)
- {
- result[0] = uriQualifiedName.substring(firstIndex + 1, lastIndex);
- result[1] = uriQualifiedName.substring(lastIndex + 1);
- }
- else
- {
- result[1] = uriQualifiedName;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceInfoManager.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceInfoManager.java
deleted file mode 100644
index 747efbc2af..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMNamespaceInfoManager.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- * DOMNamespaceInfoManager
- *
- *
- */
-public class DOMNamespaceInfoManager
-{
- public static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
-
- public DOMNamespaceInfoManager()
- {
- }
-
- public List getNamespaceInfoList(Element element)
- {
- NamespaceInfoReader reader = new NamespaceInfoReader();
- return reader.getNamespaceInfoList(element);
- }
-
- public void removeNamespaceInfo(Element element)
- {
- NamespaceInfoRemover remover = new NamespaceInfoRemover();
- remover.removeNamespaceInfo(element);
- }
-
- public void addNamespaceInfo(Element element, List namespaceInfoList, boolean needsXSI)
- {
- // first we create an xmlns attribute for each namespace
- //
- Document document = element.getOwnerDocument();
-
- String schemaLocationValue = ""; //$NON-NLS-1$
-
- for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext(); )
- {
- NamespaceInfo nsInfo = (NamespaceInfo)iterator.next();
- nsInfo.normalize();
-
- if (nsInfo.uri != null)
- {
- String attrName = nsInfo.prefix != null ? "xmlns:" + nsInfo.prefix : "xmlns"; //$NON-NLS-1$ //$NON-NLS-2$
- Attr namespaceAttr = document.createAttribute(attrName);
- namespaceAttr.setValue(nsInfo.uri);
- element.setAttributeNode(namespaceAttr);
-
- // in this case we use the attribute "xsi:schemaLocation"
- // here we build up its value
- //
- if (nsInfo.locationHint != null)
- {
- schemaLocationValue += nsInfo.uri;
- schemaLocationValue += " "; //$NON-NLS-1$
- schemaLocationValue += nsInfo.locationHint;
- schemaLocationValue += " "; //$NON-NLS-1$
- }
-
- if (nsInfo.uri.equals(XSI_URI))
- {
- needsXSI = false;
- }
- }
- else if (nsInfo.locationHint != null)
- {
- // in this case we use the attribute "xsi:noNamespaceSchemaLocation"
- //
- Attr attr = document.createAttribute("xsi:noNamespaceSchemaLocation"); //$NON-NLS-1$
- attr.setValue(nsInfo.locationHint);
- element.setAttributeNode(attr);
- }
- }
-
- if (needsXSI)
- {
- // we add an xmlns:xsi attribute to define 'xsi:schemaLocation' attribute
- //
- Attr attr = document.createAttribute("xmlns:xsi"); //$NON-NLS-1$
- attr.setValue(XSI_URI);
- element.setAttributeNode(attr);
- }
-
- if (schemaLocationValue.length() > 0)
- {
- // create the "xsi:schemaLocation" attribute
- //
- Attr attr = document.createAttribute("xsi:schemaLocation"); //$NON-NLS-1$
- attr.setValue(schemaLocationValue);
- element.setAttributeNode(attr);
- }
- }
-
- /**
- *
- */
- protected static class NamespaceInfoReader extends NamespaceAttributeVisitor
- {
- protected List namespaceInfoList = new Vector();
-
- public List getNamespaceInfoList(Element element)
- {
- visitElement(element);
- return namespaceInfoList;
- }
-
-
- public void visitXSINoNamespaceSchemaLocationAttribute(Attr attr, String value)
- {
- NamespaceInfo info = createNamespaceInfo();
- info.locationHint = value;
- }
-
- public void visitXMLNamespaceAttribute(Attr attr, String prefix, String uri)
- {
- NamespaceInfo info = createNamespaceInfo();
- info.uri = uri;
- info.prefix = prefix;
- super.visitXMLNamespaceAttribute(attr, prefix, uri);
- }
-
- public void visitXSISchemaLocationValuePair(String uri, String locationHint)
- {
- NamespaceInfo info = getNamespaceInfoForURI(uri);
- if (info != null)
- {
- info.locationHint = locationHint;
- }
- else
- {
- info = createNamespaceInfo();
- info.uri = uri;
- info.locationHint = locationHint;
- }
- }
-
- protected NamespaceInfo getNamespaceInfoForURI(String uri)
- {
- NamespaceInfo result = null;
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- if (info.uri != null && info.uri.equals(uri))
- {
- result = info;
- break;
- }
- }
- return result;
- }
-
- protected NamespaceInfo createNamespaceInfo()
- {
- NamespaceInfo info = new NamespaceInfo();
- namespaceInfoList.add(info);
- return info;
- }
- }
-
-
- /**
- *
- */
- protected static class NamespaceInfoRemover extends NamespaceAttributeVisitor
- {
- protected List attributesToRemove = new Vector();
-
- public void removeNamespaceInfo(Element element)
- {
- visitElement(element);
- removeAttributes();
- }
-
- public void visitXSINoNamespaceSchemaLocationAttribute(Attr attr, String value)
- {
- attributesToRemove.add(attr);
- }
-
- public void visitXMLNamespaceAttribute(Attr attr, String namespacePrefix, String namespaceURI)
- {
- attributesToRemove.add(attr);
- super.visitXMLNamespaceAttribute(attr, namespacePrefix, namespaceURI);
- }
-
- public void visitXSISchemaLocationAttribute(Attr attr, String value)
- {
- attributesToRemove.add(attr);
- }
-
- public void removeAttributes()
- {
- for (Iterator i = attributesToRemove.iterator(); i.hasNext(); )
- {
- Attr attr = (Attr)i.next();
- Element element = attr.getOwnerElement();
- if (element != null)
- {
- element.removeAttributeNode(attr);
- }
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMVisitor.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMVisitor.java
deleted file mode 100644
index 0742f7bd8a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMVisitor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-// todo.. move this class to another package (perhaps xmlutility)
-//
-public class DOMVisitor
-{
- public void visitNode(Node node)
- {
- switch (node.getNodeType())
- {
- case Node.ATTRIBUTE_NODE :
- {
- visitAttr((Attr)node);
- break;
- }
- case Node.CDATA_SECTION_NODE :
- {
- visitCDATASection((CDATASection)node);
- break;
- }
- case Node.COMMENT_NODE :
- {
- visitComment((Comment)node);
- break;
- }
- case Node.DOCUMENT_NODE :
- {
- visitDocument((Document)node);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE :
- {
- visitDocumentType((DocumentType)node);
- break;
- }
- case Node.ELEMENT_NODE :
- {
- visitElement((Element)node);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- visitProcessingInstruction((ProcessingInstruction)node);
- break;
- }
- case Node.TEXT_NODE :
- {
- visitText((Text)node);
- break;
- }
- }
- }
-
- protected void visitDocument(Document document)
- {
- visitChildNodesHelper(document);
- }
-
- protected void visitDocumentType(DocumentType doctype)
- {
-
- }
-
- protected void visitElement(Element element)
- {
- visitAttributesHelper(element);
- visitChildNodesHelper(element);
- }
-
-
- public void visitAttr(Attr attr)
- {
- }
-
- protected void visitText(Text text)
- {
- }
-
- protected void visitCDATASection(CDATASection cdataSection)
- {
- }
-
- protected void visitComment(Comment comment)
- {
- }
-
- protected void visitProcessingInstruction(ProcessingInstruction pi)
- {
- }
-
-
- protected void visitChildNodesHelper(Node node)
- {
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- visitNode(children.item(i));
- }
- }
-
- protected void visitAttributesHelper(Node node)
- {
- NamedNodeMap map = node.getAttributes();
- for (int i = 0; i < map.getLength(); i++ )
- {
- visitNode(map.item(i));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMWriter.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMWriter.java
deleted file mode 100644
index 2d10d5209d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/DOMWriter.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.util;
-
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-
-import org.eclipse.osgi.util.TextProcessor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-/**
- * This is a hacked up dom writer stolen from a Xerces sample.
- * I'd like to use an exisitng 'generic DOM' writer
- * If anyone can find such a thing then please go ahead and junk this.
- *
- * @version
- */
-public class DOMWriter
-{
- protected boolean formattingEnabled = true;
- protected boolean outputDoctypeEnabled = true;
- protected PrintWriter out;
- protected int indent = 0;
-
- public DOMWriter() throws UnsupportedEncodingException
- {
- this(System.out);
- }
-
- public DOMWriter(OutputStream outputSteam)
- {
- out = new PrintWriter(outputSteam);
- }
-
- public DOMWriter(Writer writer)
- {
- out = new PrintWriter(writer);
- }
-
- public void setFormattingEnabled(boolean enabled)
- {
- formattingEnabled = enabled;
- }
-
- public boolean getFormattingEnabled()
- {
- return formattingEnabled;
- }
-
- public void setOutputDoctypeEnabled(boolean enabled)
- {
- outputDoctypeEnabled = enabled;
- }
-
- public class XMLVisitor
- {
- protected boolean currentElementHasChildElements = false;
-
- public void visitNode(Node node)
- {
- switch (node.getNodeType())
- {
- case Node.ATTRIBUTE_NODE :
- {
- visitAttr((Attr)node);
- break;
- }
- case Node.CDATA_SECTION_NODE :
- {
- visitCDATASection((CDATASection)node);
- break;
- }
- case Node.COMMENT_NODE :
- {
- visitComment((Comment)node);
- break;
- }
- case Node.DOCUMENT_NODE :
- {
- visitDocument((Document)node);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE :
- {
- visitDocumentType((DocumentType)node);
- break;
- }
- case Node.ELEMENT_NODE :
- {
- visitElement((Element)node);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- visitProcessingInstruction((ProcessingInstruction)node);
- break;
- }
- case Node.TEXT_NODE :
- {
- visitText((Text)node);
- break;
- }
- }
- }
-
- public void visitDocument(Document document)
- {
- visitChildNodesHelper(document);
- }
-
- public void visitDocumentType(DocumentType doctype)
- {
- if (outputDoctypeEnabled)
- {
- String data = getDocumentTypeData(doctype);
- print("<!DOCTYPE " + data + ">"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void visitElement(Element element)
- {
- if (!doShow(element))
- return;
-
- boolean parentElementHasChildNodes = currentElementHasChildElements;
- currentElementHasChildElements = hasChildElements(element);
-
- printIndent();
- print("<"); //$NON-NLS-1$
- print(element.getNodeName());
- visitAttributesHelper(element);
-
- boolean hasChildNodes = element.getChildNodes().getLength() > 0;
- boolean isRootElement = element.getParentNode().getNodeType() == Node.DOCUMENT_NODE;
- if (hasChildNodes || isRootElement)
- {
- if (currentElementHasChildElements)
- {
- println(">"); //$NON-NLS-1$
- }
- else
- {
- print(">"); //$NON-NLS-1$
- }
- indent += 2;
- visitChildNodesHelper(element);
- indent -= 2;
-
- if (currentElementHasChildElements || isRootElement)
- {
- printIndent();
- }
- print("</"); //$NON-NLS-1$
- print(element.getNodeName());
- println(">"); //$NON-NLS-1$
- }
- else
- {
- println("/>"); //$NON-NLS-1$
- }
-
- currentElementHasChildElements = parentElementHasChildNodes;
- }
-
- public void visitAttr(Attr attr)
- {
- print(" "); //$NON-NLS-1$
- print(attr.getNodeName());
- print("=\""); //$NON-NLS-1$
- print(createPrintableCharacterData(attr.getValue()));
- print("\""); //$NON-NLS-1$
- }
-
- public void visitText(Text text)
- {
- if (currentElementHasChildElements)
- {
- printIndent();
- print(createPrintableCharacterData(text.getNodeValue()));
- println();
- }
- else
- {
- print(createPrintableCharacterData(text.getNodeValue()));
- }
- }
-
- public void visitCDATASection(CDATASection cdataSection)
- {
- }
-
- public void visitComment(Comment comment)
- {
- printIndent();
- print("<!--"); //$NON-NLS-1$
- print(comment.getNodeValue());
- println("-->"); //$NON-NLS-1$
- }
-
- public void visitProcessingInstruction(ProcessingInstruction pi)
- {
- printIndent();
- print("<?"); //$NON-NLS-1$
- print(pi.getNodeName());
- print(" "); //$NON-NLS-1$
- print(pi.getNodeValue());
- println("?>"); //$NON-NLS-1$
- }
-
-
- public boolean hasChildElements(Node node)
- {
- boolean result = false;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
- {
- result = true;
- break;
- }
- }
- return result;
- }
-
- public void visitChildNodesHelper(Node node)
- {
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- visitNode(children.item(i));
- }
- }
-
- public void visitAttributesHelper(Node node)
- {
- NamedNodeMap map = node.getAttributes();
- for (int i = 0; i < map.getLength(); i++ )
- {
- visitNode(map.item(i));
- }
- }
- }
-
- /** an ugly hack until I restruct this code a little
- *
- */
- protected boolean doShow(Element element)
- {
- return true;
- }
-
- /** converts DOM text values to 'printable' values
- * - converts '&' to '&amp;'
- */
- protected String createPrintableCharacterData(String string)
- {
- String result = ""; //$NON-NLS-1$
- int index = 0;
- while (true)
- {
- int ampersandIndex = string.indexOf("&", index); //$NON-NLS-1$
- if (ampersandIndex != -1)
- {
- result += string.substring(index, ampersandIndex);
- result += "&amp;"; //$NON-NLS-1$
- index = ampersandIndex + 1;
- }
- else
- {
- break;
- }
- }
- result += string.substring(index);
- return result;
- }
-
-
- /** Prints the specified node, recursively. */
- public void print(Node node)
- {
- // is there anything to do?
- if (node != null)
- {
- XMLVisitor visitor = new XMLVisitor();
- visitor.visitNode(node);
- }
- out.flush();
- }
-
- /** a temporary hack to workaround our inability to create a DocumentType tag*/
- public void print(Document document, String grammarURL)
- {
- String systemId = null;
- if (grammarURL.endsWith("dtd")) //$NON-NLS-1$
- {
- int lastSlashIndex = Math.max(grammarURL.lastIndexOf("/"), grammarURL.lastIndexOf("\\")); //$NON-NLS-1$ //$NON-NLS-2$
- if (lastSlashIndex != -1)
- {
- systemId = grammarURL.substring(lastSlashIndex + 1);
- }
- }
- print(document, "UTF-8", grammarURL, null, systemId); //$NON-NLS-1$
-
- }
-
- /** a temporary hack to workaround our inability to create a DocumentType tag*/
- public void print(Document document, String encoding, String grammarFileName, String publicId, String systemId)
- {
- publicId = TextProcessor.process(publicId);
- systemId = TextProcessor.process(systemId);
- out.println("<?xml version=\"1.0\"" + " encoding=\"" + encoding + "\"?>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (grammarFileName.endsWith(".dtd")) //$NON-NLS-1$
- {
- String docTypeLine = "<!DOCTYPE " + document.getDocumentElement().getNodeName() + " "; //$NON-NLS-1$ //$NON-NLS-2$
- if (publicId != null)
- {
- docTypeLine += "PUBLIC \"" + publicId + "\" "; //$NON-NLS-1$ //$NON-NLS-2$
- if (systemId != null)
- {
- docTypeLine += "\"" + systemId + "\" "; //$NON-NLS-1$ //$NON-NLS-2$
- }
- docTypeLine += ">"; //$NON-NLS-1$
- out.println(docTypeLine);
- }
- else if (systemId != null)
- {
- docTypeLine += "SYSTEM \"" + systemId + "\" >"; //$NON-NLS-1$ //$NON-NLS-2$
- out.println(docTypeLine);
- }
- }
- print(document);
- }
-
- public static String getDocumentTypeData(DocumentType doctype)
- {
- String data = doctype.getName();
- if (doctype.getPublicId() != null)
- {
- data += " PUBLIC \"" + doctype.getPublicId() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- String systemId = doctype.getSystemId();
- if (systemId == null)
- {
- systemId = ""; //$NON-NLS-1$
- }
- data += " \"" + systemId + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- {
- data += " SYSTEM \"" + doctype.getSystemId() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return data;
- }
-
- public void println()
- {
- if (formattingEnabled)
- {
- out.println();
- }
- }
-
- public void println(String string)
- {
- if (formattingEnabled)
- {
- out.println(string);
- }
- else
- {
- out.print(string);
- }
- }
-
- public void printIndent()
- {
- if (formattingEnabled)
- {
- for (int i = 0; i < indent; i++)
- {
- out.print(" "); //$NON-NLS-1$
- }
- }
- }
-
- public void print(String string)
- {
- out.print(string);
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/InferredGrammarFactory.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/InferredGrammarFactory.java
deleted file mode 100644
index d4a3c40384..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/InferredGrammarFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import java.util.Collection;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.w3c.dom.Element;
-
-
-// this interface is used to build a grammar document given a local file name
-//
-public interface InferredGrammarFactory
-{
- public CMDocument createCMDocument(String uri);
- public CMElementDeclaration createCMElementDeclaration(CMDocument cmDocument, Element element, boolean isLocal);
- public void createCMContent(CMDocument parentCMDocument, CMElementDeclaration parentEd, CMDocument childCMDocument, CMElementDeclaration childEd, boolean isLocal, String uri);
- public void debugPrint(Collection collection);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceAttributeVisitor.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceAttributeVisitor.java
deleted file mode 100644
index 58d193d3d9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceAttributeVisitor.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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
- * David Carver - STAR - bug 198807 - attribute order dependancy.
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contentmodel.util;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-import com.ibm.icu.util.StringTokenizer;
-
-
-public class NamespaceAttributeVisitor
-{
- public static final String XML_SCHEMA_INSTANCE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
- public String xsiPrefix = "xsi"; //$NON-NLS-1$
-
- public void visitXMLNamespaceAttribute(Attr attr, String namespacePrefix, String namespaceURI)
- {
- if (namespaceURI.equals(XML_SCHEMA_INSTANCE_URI))
- {
- xsiPrefix = namespacePrefix;
- }
- }
-
- public void visitXSINoNamespaceSchemaLocationAttribute(Attr attr, String value)
- {
- }
-
- public void visitXSISchemaLocationAttribute(Attr attr, String value)
- {
- StringTokenizer st = new StringTokenizer(value);
- while (true)
- {
- String nsURI = st.hasMoreTokens() ? st.nextToken() : null;
- String locationHint = st.hasMoreTokens() ? st.nextToken() : null;
- if (nsURI != null && locationHint != null)
- {
- visitXSISchemaLocationValuePair(nsURI, locationHint);
- }
- else
- {
- break;
- }
- }
- }
-
- public void visitXSISchemaLocationValuePair(String uri, String locationHint)
- {
- }
-
- public void visitElement(Element element)
- {
- NamedNodeMap map = element.getAttributes();
- int mapLength = map.getLength();
-
- // First retrieve all the namespaces so that they are loaded before
- // doing any special prefix handling. This allows the attributes to be
- // defined in any order, but the namespaces have to be retrieved first.
-
- for (int i = 0; i < mapLength; i++)
- {
- Attr attr = (Attr)map.item(i);
- String prefix = DOMNamespaceHelper.getPrefix(attr.getName());
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attr.getName());
- if (prefix != null && unprefixedName != null)
- {
- if (prefix.equals("xmlns")) //$NON-NLS-1$
- {
- visitXMLNamespaceAttribute(attr, unprefixedName, attr.getValue());
- }
- }
- else if (unprefixedName != null)
- {
- if (unprefixedName.equals("xmlns")) //$NON-NLS-1$
- {
- visitXMLNamespaceAttribute(attr, "", attr.getValue()); //$NON-NLS-1$
- }
- }
-
- }
-
- for (int i = 0; i < mapLength; i++)
- {
- Attr attr = (Attr)map.item(i);
- String prefix = DOMNamespaceHelper.getPrefix(attr.getName());
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attr.getName());
- if (prefix != null && unprefixedName != null)
- {
- if (prefix.equals(xsiPrefix) && unprefixedName.equals("schemaLocation")) //$NON-NLS-1$
- {
- visitXSISchemaLocationAttribute(attr, attr.getValue());
- }
- else if (prefix.equals(xsiPrefix) && unprefixedName.equals("noNamespaceSchemaLocation")) //$NON-NLS-1$
- {
- visitXSINoNamespaceSchemaLocationAttribute(attr, attr.getValue());
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceInfo.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceInfo.java
deleted file mode 100644
index 56af91b55a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceInfo.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-public class NamespaceInfo
-{
- public String uri;
- public String prefix;
- public String locationHint;
- public boolean isPrefixRequired;
- protected Hashtable hashtable;
-
- public NamespaceInfo()
- {
- }
-
- public NamespaceInfo(String uri, String prefix, String locationHint)
- {
- this.uri = uri;
- this.prefix = prefix;
- this.locationHint = locationHint;
- }
-
- public NamespaceInfo(NamespaceInfo that)
- {
- this.uri = that.uri;
- this.prefix = that.prefix;
- this.locationHint = that.locationHint;
- // todo... see if we need to clone the hastable
- }
-
- public void normalize()
- {
- uri = getNormalizedValue(uri);
- prefix = getNormalizedValue(prefix);
- locationHint= getNormalizedValue(locationHint);
- }
-
- protected String getNormalizedValue(String string)
- {
- return (string != null && string.trim().length() == 0) ? null : string;
- }
-
- public void setProperty(String property, Object value)
- {
- if (hashtable == null)
- {
- hashtable = new Hashtable();
- }
- hashtable.put(property, value);
- }
-
- public Object getProperty(String property)
- {
- return (hashtable != null) ? hashtable.get(property) : null;
- }
-
- public static List cloneNamespaceInfoList(List oldList)
- {
- List newList = new Vector(oldList.size());
- for (Iterator i = oldList.iterator(); i.hasNext(); )
- {
- NamespaceInfo oldInfo = (NamespaceInfo)i.next();
- newList.add(new NamespaceInfo(oldInfo));
- }
- return newList;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceTable.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceTable.java
deleted file mode 100644
index 71d115da76..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/NamespaceTable.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class NamespaceTable extends NamespaceAttributeVisitor
-{
- public Hashtable hashtable = new Hashtable();
-
-/**
- * @deprecated
- * @param document - no longer used
- */
-public NamespaceTable(Document document)
- {
- this();
- //DOMExtension domExtension = DOMExtensionProviderRegistry.getInstance().getDOMExtension(document);
- //if (domExtension != null)
- //{
- // addNamespaceInfoList(domExtension.getImplictNamespaceInfoList(), true);
- // }
- }
-
- private NamespaceTable()
- {
- super();
- }
-
- public boolean isNamespaceEncountered()
- {
- return hashtable.values().size() > 0;
- }
-
- public String getPrefixForURI(String uri)
- {
- String result = null;
- NamespaceInfo entry = getNamespaceInfoForURI(uri, true);
- if (entry != null)
- {
- result = entry.prefix;
- }
- return result;
- }
-
-
- public String getURIForPrefix(String prefix)
- {
- String result = null;
- NamespaceInfo info = getNamespaceInfoForPrefix(prefix);
- if (info != null)
- {
- result = info.uri;
- }
- return result;
- }
-
-
- protected boolean isMatchingString(String a, String b)
- {
- return ((a == null && b == null) || (a != null && b != null && a.equals(b)));
- }
-
-
- public NamespaceInfo getNamespaceInfoForURI(String uri)
- {
- return getNamespaceInfoForURI(uri, false);
- }
-
-
- public NamespaceInfo getNamespaceInfoForURI(String uri, boolean testImplied)
- {
- NamespaceInfo result = null;
- for (Iterator i = hashtable.values().iterator(); i.hasNext(); )
- {
- NamespaceInfo nsInfo = (NamespaceInfo)i.next();
- if (isMatchingString(nsInfo.uri, uri))
- {
- result = nsInfo;
- if (testImplied && nsInfo.getProperty("isImplied") != null) //$NON-NLS-1$
- {
- // continue
- }
- else
- {
- break;
- }
- }
- }
- return result;
- }
-
-
- public void setLocationHintForURI(String uri, String locationHint)
- {
- // List list = new Vector();
- for (Iterator i = hashtable.values().iterator(); i.hasNext(); )
- {
- NamespaceInfo nsInfo = (NamespaceInfo)i.next();
- if (isMatchingString(nsInfo.uri, uri))
- {
- nsInfo.locationHint = locationHint;
- }
- }
- }
-
-
- public NamespaceInfo getNamespaceInfoForPrefix(String prefix)
- {
- prefix = prefix != null ? prefix : ""; //$NON-NLS-1$
- return (NamespaceInfo)hashtable.get(prefix);
- }
-
-
- public void visitXMLNamespaceAttribute(Attr attr, String namespacePrefix, String namespaceURI)
- {
- NamespaceInfo nsInfo = new NamespaceInfo();
- nsInfo.prefix = namespacePrefix;
- nsInfo.uri = namespaceURI;
-
- NamespaceInfo matchingNamespaceInfo = getNamespaceInfoForURI(namespaceURI);
- if (matchingNamespaceInfo != null)
- {
- nsInfo.locationHint = matchingNamespaceInfo.locationHint;
- }
-
- internalAddNamespaceInfo(namespacePrefix, nsInfo);
-
- super.visitXMLNamespaceAttribute(attr, namespacePrefix, namespaceURI);
- }
-
- public void visitXSISchemaLocationValuePair(String uri, String locationHint)
- {
- setLocationHintForURI(uri, locationHint);
- }
-
- public void addNamespaceInfo(NamespaceInfo info)
- {
- String key = (info.prefix != null) ? info.prefix : ""; //$NON-NLS-1$
- internalAddNamespaceInfo(key, info);
- }
-
- protected void internalAddNamespaceInfo(String key, NamespaceInfo info)
- {
- hashtable.put(key, info);
- }
-
- protected void addNamespaceInfoList(List list, boolean isImplied)
- {
- if (list != null)
- {
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- NamespaceInfo clone = new NamespaceInfo(info);
- if (isImplied)
- {
- clone.setProperty("isImplied", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- addNamespaceInfo(clone);
- }
- }
- }
-
- public void addNamespaceInfoList(List list)
- {
- addNamespaceInfoList(list, false);
- }
-
- public void visitXSINoNamespaceSchemaLocationAttribute(Attr attr, String locationHint)
- {
- addNoNamespaceSchemaLocation(locationHint);
- }
-
- public void addNoNamespaceSchemaLocation(String locationHint)
- {
- NamespaceInfo nsInfo = new NamespaceInfo();
- nsInfo.prefix = null;
- nsInfo.uri = ""; //$NON-NLS-1$
- nsInfo.locationHint = locationHint;
- internalAddNamespaceInfo("", nsInfo); //$NON-NLS-1$
- }
-
- public void addNamespaceInfo(String prefix, String uri, String locationHint)
- {
- NamespaceInfo nsInfo = new NamespaceInfo();
- nsInfo.prefix = prefix;
- nsInfo.uri = uri;
- nsInfo.locationHint = locationHint;
- internalAddNamespaceInfo(prefix != null ? prefix : "", nsInfo); //$NON-NLS-1$
- }
-
- public void addElement(Element element)
- {
- visitElement(element);
- }
-
- public void addElementLineage(Element targetElement)
- {
- List list = NamespaceTable.getElementLineage(targetElement);
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- Element element = (Element)i.next();
- addElement(element);
- }
- }
-
- public static List getElementLineage(Element element)
- {
- List result = new ArrayList();
- for (Node node = element; node != null; node = node.getParentNode())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- result.add(0, node);
- }
- else
- {
- break;
- }
- }
- return result;
- }
-
- public Collection getNamespaceInfoCollection()
- {
- return hashtable.values();
- }
-
- public List getNamespaceInfoList()
- {
- List list = new Vector();
- list.addAll(hashtable.values());
- return list;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSEAdapter.java b/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSEAdapter.java
deleted file mode 100644
index 5fd1041daf..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSEAdapter.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.emf2xml;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapter;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-import org.eclipse.wst.common.internal.emf.resource.TranslatorResource;
-import org.eclipse.wst.common.internal.emf.utilities.Assert;
-import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities;
-import org.eclipse.wst.common.internal.emf.utilities.FeatureValueConversionException;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-public class EMF2DOMSSEAdapter extends EMF2DOMAdapterImpl implements INodeAdapter {
-
- private Class resourceClass;
- public EMF2DOMSSEAdapter(Node node, EMF2DOMRenderer renderer, Translator translator) {
- super(node, renderer, translator);
- }
-
- public EMF2DOMSSEAdapter(Notifier object, Node node, EMF2DOMRenderer renderer, Translator translator) {
- super(object, node, renderer, translator);
- }
-
- public EMF2DOMSSEAdapter(TranslatorResource resource, Document document, EMF2DOMRenderer renderer, Translator translator) {
- super(resource, document, renderer, translator);
- }
-
- protected String calcIndentString(Node node) {
- Assert.isNotNull(node);
- Assert.isNotNull(node.getParentNode(), "Node must be connected into the tree"); //$NON-NLS-1$
-
- Node parent = node.getParentNode();
-
- String indentString = getNewlineString(node);
-
- // Find indentation string for this node based on its sibling or
- // parent
- Node previousSibling = DOMUtilities.getPreviousNodeSibling(node);
- if (previousSibling != null) {
- indentString = primGetIndentString(previousSibling);
- }
- else {
- String parentIndentString = primGetIndentString(parent);
- indentString = parentIndentString + DOMUtilities.INDENT_STRING;
- }
- return indentString;
- }
-
- /*
- * Prints out a DOM notification for debugging.
- */
- protected void debugDOMNotify(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue) {
- if (fDebug) {
- String notifType = ""; //$NON-NLS-1$
- switch (eventType) {
- case INodeNotifier.ADD :
- notifType = "ADD"; //$NON-NLS-1$
- break;
- case INodeNotifier.REMOVE :
- notifType = "REMOVE"; //$NON-NLS-1$
- break;
- case INodeNotifier.CHANGE :
- notifType = "CHANGE"; //$NON-NLS-1$
- break;
- case INodeNotifier.CONTENT_CHANGED :
- notifType = "CONTENT_CHANGED"; //$NON-NLS-1$
- break;
- case INodeNotifier.STRUCTURE_CHANGED :
- notifType = "STRUCTURE_CHANGE"; //$NON-NLS-1$
- break;
- }
- Logger.log(Logger.INFO_DEBUG, "DOM Change: " + notifType); //$NON-NLS-1$
- Logger.log(Logger.INFO_DEBUG, "\tnotifier : " + notifier); //$NON-NLS-1$
- Logger.log(Logger.INFO_DEBUG, "\tchangedFeature: " + changedFeature); //$NON-NLS-1$
- Logger.log(Logger.INFO_DEBUG, "\toldValue : " + oldValue); //$NON-NLS-1$
- Logger.log(Logger.INFO_DEBUG, "\tnewValue : " + newValue); //$NON-NLS-1$
- }
- }
-
- protected void disableUndoManagementIfNecessary() {
- IDOMModel model = getXMLModel();
- if (model != null && model.getUndoManager() != null)
- model.disableUndoManagement();
- }
-
- protected void enableUndoManagement() {
- IDOMModel model = getXMLModel();
- if (model != null && model.getUndoManager() != null)
- model.enableUndoManagement();
- }
-
- protected String getNewlineString(Node node) {
- /*
- * We should always have IDOMNode, and IStructuredDocument, and
- * consquently a valid "preferred" line delimiter, but just to be
- * safe, we'll assign something by default.
- */
- if (node instanceof IDOMNode) {
- IDOMNode xmlNode = (IDOMNode) node;
- IStructuredDocument document = xmlNode.getStructuredDocument();
- if (document != null) {
- return document.getLineDelimiter();
- }
- }
- return DOMUtilities.NEWLINE_STRING;
- }
-
- protected IDOMModel getXMLModel() {
- if (getNode() != null)
- return ((IDOMNode) getNode()).getModel();
- return null;
- }
-
- protected IDOMNode getXMLNode() {
- return (IDOMNode) getNode();
- }
-
- /*
- * Do nothing for SSE, we will tolerate anything they add
- */
- protected void handleFeatureValueConversionException(FeatureValueConversionException ex) {
- // Do nothing
- }
-
- /*
- * Do nothing for SSE, we will tolerate anything they add
- */
- protected void handleInvalidMultiNodes(String nodeName) {
- // Do nothing
- }
-
- protected void indent(Node node, Translator map) {
- Assert.isNotNull(node.getParentNode(), "Node must be connected into the tree"); //$NON-NLS-1$
- Assert.isNotNull(node);
-
- String indentString = calcIndentString(node);
-
- // Indent before the start tag
- indentStartTag(indentString, node, map);
-
- // Indent before the end tag
- indentEndTag(indentString, node, map);
- }
-
- /**
- * Indent before the end tag of the <node>passed in.
- */
- protected void indentEndTag(String indentString, Node node, Translator map) {
- if (!map.shouldIndentEndTag(node))
- return;
- String domPath = map.getDOMPath();
-
- if ((!map.isManagedByParent() && !map.isDOMTextValue()) || (map.isManagedByParent() && domPath.length() != 0) && node.getNodeName().equals(domPath)) {
- Text newWS = node.getOwnerDocument().createTextNode(getNewlineString(node) + indentString); //$NON-NLS-1$
- DOMUtilities.insertBeforeNode(node, newWS, null);
- }
- }
-
- /**
- * Indent before the start tag of the <node>passed in.
- */
- protected void indentStartTag(String indentString, Node node, Translator map) {
- Node parent = node.getParentNode();
- Text newWS = node.getOwnerDocument().createTextNode(getNewlineString(node) + indentString); //$NON-NLS-1$
- DOMUtilities.insertAfterNode(parent, newWS, DOMUtilities.getPreviousNodeSibling(node));
- }
-
- protected boolean isEmptyTag(Element parent) {
- return ((IDOMElement) parent).isEmptyTag();
- }
-
- /*
- * This method is called when the DOM node changes. It attempts to update
- * MOF object based on the changes.
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
-
- if (!isNotificationEnabled())
- return;
-
- debugDOMNotify(notifier, eventType, changedFeature, oldValue, newValue);
-
- if (notifier != getNode() && eventType != INodeNotifier.CHANGE) {
- // This is the case where the notification was sent from a
- // sub node. Use the notifiers name to determine which
- // MOF feature to update. Note that is is assumed that if
- // the eventType is CHANGE then it attribute on a path node
- // changing. This was put in for the EGL group.
- if (notifier instanceof Element) {
- if (eventType == INodeNotifier.STRUCTURE_CHANGED || eventType == INodeNotifier.CONTENT_CHANGED || eventType == INodeNotifier.CHANGE) {
- Element notifyingNode = (Element) notifier;
- Translator map = findTranslator(notifyingNode.getNodeName(), false);
- if (map != null)
- updateMOFFeature(map, getNode(), getEObject());
- }
- }
- }
- else {
- // Update everything on STRUCTURE_CHANGE or CONTENT_CHANGE.
- // Other event types occur too often.
- if (eventType == INodeNotifier.STRUCTURE_CHANGED || eventType == INodeNotifier.CONTENT_CHANGED) {
- updateMOF();
- }
- // Update just the attribute that changed.
- else if (eventType == INodeNotifier.CHANGE) {
- Translator map = findTranslator(changedFeature.toString(), true);
- if (map != null)
- updateMOFFeature(map, getNode(), getEObject());
- }
- }
- }
-
- protected void postUpdateDOMFeature(Translator map, Node node, EObject mofObject) {
- enableUndoManagement();
- }
-
- protected void preUpdateDOMFeature(Translator map, Node node, EObject mofObject) {
- super.preUpdateDOMFeature(map, node, mofObject);
- disableUndoManagementIfNecessary();
- }
-
- protected void primAddDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- ((IDOMNode) aNode).addAdapter((EMF2DOMSSEAdapter) anAdapter);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(EObject mofObject, Translator childMap) {
- Element newNode = createNewNode(mofObject, childMap);
- return new EMF2DOMSSEAdapter(mofObject, newNode, fRenderer, childMap);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(Node node, Translator childMap) {
- return new EMF2DOMSSEAdapter(node, fRenderer, childMap);
- }
- protected EMF2DOMAdapter createAdapter(Node node, Translator childMap) {
-
- //Assert.isNotNull(childMap.getChildAdapterClass());
- Assert.isNotNull(node);
-
- EMF2DOMAdapter adapter = primGetExistingAdapter(node,childMap);
-
- if (adapter != null) {
- if (adapter.isMOFProxy() || adapter.getTarget() == null) {
- removeDOMAdapter(node, adapter);
- if (adapter.getTarget() != null) {
- adapter.getTarget().eAdapters().remove(adapter);
- }
- adapter = null;
- }
- }
- if (adapter == null) {
- adapter = primCreateAdapter(node, childMap);
- }
- return adapter;
- }
- protected void addDOMAdapter(Node childNode) {
-
- // Only add the adapter if this is an child node that will not be
- // adapted. For instance a subtree that maps to a MOF attribute
- // setting.
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- EMF2DOMAdapter attrAdapter = primGetExistingAdapter(childNode);
-
- if (attrAdapter == null || attrAdapter.getNode() != getNode()) {
- // If the node is adapted, but not by this adapter then remove
- // it. This happens to non-object children when the parent tag
- // name is changed.
- removeDOMAdapter(childNode, attrAdapter);
-
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tCHILD: Adding DOM adapter: " + this); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\t\tto: " + childNode); //$NON-NLS-1$
- }
- primAddDOMAdapter(childNode, this);
- }
- }
- }
-
- protected EMF2DOMAdapter primGetExistingAdapter(Node aNode, Translator childMap) {
- INodeNotifier sseNode = (INodeNotifier) aNode;
- Collection adapters = sseNode.getAdapters();
- for (Iterator iterator = adapters.iterator(); iterator.hasNext();) {
- INodeAdapter adapter = (INodeAdapter) iterator.next();
- // First Check if it's an EMF2DOMAdapter
- if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
- // Cast to EMF2DOMAdapter
- EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
- Object adapterTarget = e2DAdapter.getTarget();
- //Translator adapterTranslator = e2DAdapter.fTranslator;
-
- //Handle the cases where either adapter's target is null
- if ((getTarget() == null) || (adapterTarget == null))
- if (resourceClass != null && resourceClass.equals(e2DAdapter.getResourceClass()))
- return e2DAdapter;
- else
- continue;
-
-
- // Check if target is an EMF resource
- if (getTarget() instanceof Resource) {
- /*
- * Now check if it's the right one (Multiple resources
- * could be attached)
- */
- if (adapterTarget != null && adapterTarget == getTarget()) {
- return e2DAdapter;
- }
- }
- else {
- // Check if targets are EObjects with the same resources
- EObject myTarget = (EObject) getTarget();
- /*
- * Now check if it's the right one (Multiple resources could
- * be attached)
- */
- if (adapterTarget != null && ((EObject)adapterTarget).eResource() == myTarget.eResource()) {
- return e2DAdapter;
- }
- }
-
- if (adapterTarget instanceof EObject) {
- if (((EObject) e2DAdapter.getTarget()).eResource() == null && e2DAdapter.fTranslator == childMap) {
- return e2DAdapter;
- }
- }
- }
- }
- return null;
- }
-
- protected EMF2DOMAdapter primGetExistingAdapter(Node aNode) {
- INodeNotifier sseNode = (INodeNotifier) aNode;
- Collection adapters = sseNode.getAdapters();
- for (Iterator iterator = adapters.iterator(); iterator.hasNext();) {
- INodeAdapter adapter = (INodeAdapter) iterator.next();
- // First Check if it's an EMF2DOMAdapter
- if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
- // Cast to EMF2DOMAdapter
- EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
- Object adapterTarget = e2DAdapter.getTarget();
-
- //Handle the cases where either adapter's target is null
- if ((getTarget() == null) || (adapterTarget == null))
- if (resourceClass != null && resourceClass.equals(e2DAdapter.getResourceClass()))
- return e2DAdapter;
- else
- continue;
-
-
- // Check if target is an EMF resource
- if (getTarget() instanceof Resource) {
- /*
- * Now check if it's the right one (Multiple resources
- * could be attached)
- */
- if (adapterTarget != null && adapterTarget == getTarget()) {
- return e2DAdapter;
- }
- }
- else {
- // Check if targets are EObjects with the same resources
- EObject myTarget = (EObject) getTarget();
- /*
- * Now check if it's the right one (Multiple resources could
- * be attached)
- */
- if (adapterTarget != null && ((EObject)adapterTarget).eResource() == myTarget.eResource()) {
- return e2DAdapter;
- }
- }
-
- if (adapterTarget instanceof EObject) {
- if (((EObject) e2DAdapter.getTarget()).eResource() == null) {
- return e2DAdapter;
- }
- }
- }
- }
- return null;
- }
-
- protected String primGetIndentString(Node node) {
- IStructuredDocument flatModel = ((IDOMNode) node).getStructuredDocument();
- int nodeStartOff = ((IDOMNode) node).getStartOffset();
-
- int startOff = Math.max(0, nodeStartOff - 100);
- int endOff = nodeStartOff;
-
- if(flatModel != null) {
- try {
- String text = flatModel.get(startOff, endOff - startOff);
-
- int inx = text.length() - 1;
- if (inx >= 0) {
- for (; inx >= 0; inx--) {
- char ch = text.charAt(inx);
- if (Character.isWhitespace(ch) && ch != '\n' && ch != '\r') {
- continue;
- }
- inx++;
- break;
- }
-
- return text.substring(inx);
- }
- }
- catch (BadLocationException ex) {
- Logger.logException(ex);
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- protected void removeDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- ((IDOMNode) aNode).removeAdapter((INodeAdapter) anAdapter);
- }
-
-
- protected void reorderDOMChild(Node parentNode, Node childNode, Node insertBeforeNode, Translator map) {
- super.reorderDOMChild(parentNode, childNode, insertBeforeNode, map);
- // Since reordering deletes all the whitespace before the node, we
- // must indent .
- if (insertBeforeNode != null && insertBeforeNode.getNodeType() == Node.ELEMENT_NODE)
- indentStartTag(calcIndentString(insertBeforeNode), insertBeforeNode, map);
- else
- indentStartTag(calcIndentString(childNode), childNode, map);
- }
-
- protected void setEmptyTag(Element element) {
- ((IDOMElement) element).setEmptyTag(true);
- }
-
- public void updateDOM() {
- if (!isNotificationEnabled())
- return;
- try {
- disableUndoManagementIfNecessary();
- primUpdateDOM();
- }
- finally {
- enableUndoManagement();
- }
- }
-
- public Class getResourceClass() {
- return resourceClass;
- }
-
- protected void initChildTranslators() {
- if (fRenderer != null && fRenderer.getResource() != null)
- resourceClass = fRenderer.getResource().getClass();
- super.initChildTranslators();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERenderer.java b/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERenderer.java
deleted file mode 100644
index 40289d717e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERenderer.java
+++ /dev/null
@@ -1,656 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.emf2xml;
-
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapter;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer;
-import org.eclipse.wst.common.internal.emf.resource.TranslatorResource;
-import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities;
-import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
-import org.eclipse.wst.common.internal.emfworkbench.integration.ResourceSetWorkbenchEditSynchronizer;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent;
-import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelStateListener;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-
-
-public class EMF2DOMSSERenderer extends EMF2DOMRenderer implements IModelStateListener, IModelLifecycleListener {
-
- protected Object aboutToChangeNode = null;
-
- protected boolean isBatchChanges = false;
-
- private boolean isSaving = false;
-
- private IModelManager modelManager;
-
- private Class resourceClass;
-
- private boolean reverting = false;
-
- /** The XML DOM model */
- protected IDOMModel xmlModel;
-
- /** Used internally; the unique id for the xml model */
- protected String xmlModelId;
-
- protected boolean xmlModelReverted = false;
-
- public EMF2DOMSSERenderer() {
- super();
- }
-
- public void accessForRead() {
- if (!resource.isNew()) {
- String id = getModelManagerId();
- getModelManager().getExistingModelForRead(id);
- }
- }
-
- public void accessForWrite() {
- modelAccessForWrite();
- }
-
- /**
- * see batchModelEnd
- *
- */
-
- public void batchModeEnd() {
- getXMLModel().changedModel();
- setRootNodeAdapterNotificationEnabled(true);
- isBatchChanges = false;
- }
-
- /**
- * batchModeStart and batchModeEnd is a pair that controls notifications,
- * and tread access. They should always be called in a try/finally block.
- *
- * setBatchModel begins the processing where notifications are not sent
- * out on each change, but saved up until the endBatchMode called.
- *
- * This pair of calls can also, indirectly, "lock" the DOM Model to access
- * from only one thread, so it should not be locked for long periods of
- * time. That's also why it is important to have the endBatchMode in a
- * finally block to be sure it is always called, or the DOM will be left
- * in a locked, unusable, state and only shortly away from severere
- * program error.
- *
- * <pre><code>
- * Example
- * </code>
- *
- * try {
- * batchModelStart();
- * ...do a some work ...
- * }
- * finally {
- * endBatchMode();
- * }
- *
- *
- * </pre>
- */
- public void batchModeStart() {
- isBatchChanges = true;
- getXMLModel().aboutToChangeModel();
- setRootNodeAdapterNotificationEnabled(false);
- }
-
- private void cacheSynchronizationStamp() {
- IFile file = WorkbenchResourceHelper.getFile(resource);
- if (file != null) {
- if (xmlModel != null)
- xmlModel.resetSynchronizationStamp(file);
- }
- }
-
- /**
- * Create a new Document given
- *
- * @aResource.
- */
- protected void createDocument() {
- TranslatorResource res = getResource();
- res.setDefaults();
- IFile file = WorkbenchResourceHelper.getFile(resource);
- InputStream is = DOMUtilities.createHeaderInputStream(res.getDoctype(), res.getPublicId(), res.getSystemId());
- if (is == null)
- return;
- try {
- try {
- List folders = new ArrayList();
- IContainer container = file.getParent();
- while (null != container && !container.exists() && container instanceof IFolder) {
- folders.add(container);
- container = container.getParent();
- }
- IFolder folder = null;
- for (int i = 0; i < folders.size(); i++) {
- folder = (IFolder) folders.get(i);
- folder.create(true, true, null);
- }
- file.create(is, true, null);
- file.setLocal(true, 1, null);
- }
- catch (CoreException e1) {
- Logger.logException(e1);
- }
- finally {
- if (null != is) {
- is.close();
- }
- }
- initializeXMLModel(file, resource.getWriteCount() != 0);
- }
- catch (IOException ex) {
- Logger.log(Logger.ERROR, "IWAE0017E Unexpected IO exception occurred creating xml document");//$NON-NLS-1$
- }
- }
-
- protected void createDOMTreeIfNecessary() {
- if (needsToCreateDOM)
- createDOMTree();
- }
-
- protected EMF2DOMAdapter createRootDOMAdapter() {
- return new EMF2DOMSSEAdapter(getResource(), document, this, getResource().getRootTranslator());
- }
-
- public void deRegisterAsModelLifecycleListener() {
- if (xmlModel != null)
- xmlModel.removeModelLifecycleListener(this);
- }
-
- public void deRegisterAsModelStateListener() {
- if (xmlModel != null)
- xmlModel.removeModelStateListener(this);
- }
-
- private void deregisterFromXMLModel() {
-
- deRegisterAsModelStateListener();
- deRegisterAsModelLifecycleListener();
- // This try/catch block is a hack to fix defect 204114. This occurs
- // because
- // the model manager plugin is shut down and unloaded before the j2ee
- // plugin.
- // Calling getModelManager() can result in a class cast exception that
- // should
- // be ignored.
- // ModelManager mgr = null;
- try {
- getModelManager();
- }
- catch (ClassCastException exc) {
- return;
- }
- if (xmlModel != null) {
- int writeCount = resource.getWriteCount();
- int readCount = resource.getReadCount();
- for (int i = 0; i < writeCount; i++)
- xmlModel.releaseFromEdit();
- for (int ii = 0; ii < readCount; ii++)
- xmlModel.releaseFromRead();
- }
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getAdapter(resource.eAdapters(), EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null) {
- adapter.removeAdapters(adapter.getNode());
- }
- xmlModel = null;
- xmlModelId = null;
- }
-
- public void doSave(OutputStream outputStream, Map options) throws IOException {
-
- try {
- isSaving = true;
- if (null != outputStream) {
- throw new RuntimeException(this.getClass().getName() + " should not use an OutputStream for saving");} //$NON-NLS-1$
- createDOMTreeIfNecessary();
- ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) resource.getResourceSet()).getSynchronizer();
- IFile aFile = WorkbenchResourceHelper.getFile(resource);
- try {
- synchronizer.preSave(aFile, resource);
- xmlModel.save(aFile);
- }
- catch (CoreException ex) {
- synchronizer.removeFromRecentlySavedList(aFile);
- Logger.logException(ex);
- }
- cacheSynchronizationStamp();
- }
- finally {
- isSaving = false;
- }
- }
-
- public EMF2DOMAdapter getExistingDOMAdapter(Node node) {
- //IDOMNode xNode = (IDOMNode) node;
- //return (EMF2DOMSSEAdapter) xNode.getAdapterFor(EMF2DOMAdapter.ADAPTER_CLASS);
-
- INodeNotifier sseNode = (INodeNotifier) node;
- Collection adapters = sseNode.getAdapters();
- for (Iterator iterator = adapters.iterator(); iterator.hasNext();) {
- INodeAdapter adapter = (INodeAdapter) iterator.next();
- // First Check if it's an EMF2DOMAdapter
- if (adapter != null && adapter.isAdapterForType(EMF2DOMAdapter.ADAPTER_CLASS)) {
- // Cast to EMF2DOMSSEAdapter
- EMF2DOMSSEAdapter e2DAdapter = (EMF2DOMSSEAdapter) adapter;
- //Handle the cases where either adapter's target is null
- //Use the resourceClass to make sure the resource type is identical
- if (getResource() == null || e2DAdapter.getTarget() == null)
- if(resourceClass.equals(e2DAdapter.getResourceClass()))
- return e2DAdapter;
- else
- continue;
-
- // First check if targets are resources
- if (e2DAdapter.getTarget() instanceof Resource) {
- /*
- * Now check if it's the right one (Multiple resources
- * could be attached)
- */
- if (e2DAdapter.getTarget() == getResource()) {
- return e2DAdapter;
- }
- } else {
- // Check if targets are EObjects with the same resources
- TranslatorResource myTarget = getResource();
- EObject adapterTarget = (EObject) e2DAdapter.getTarget();
- /*
- * Now check if it's the right one (Multiple resources could
- * be attached)
- */
- if (adapterTarget.eResource() == myTarget || adapterTarget.eResource() == null) {
- return e2DAdapter;
- }
- }
- }
- }
- return null;
-
- }
-
- protected IModelManager getModelManager() {
- if (modelManager == null)
- modelManager = StructuredModelManager.getModelManager();
- return modelManager;
- }
-
- /**
- * Return id used to key the XML resource in the XML ModelManager.
- */
- protected String getModelManagerId() {
- if (xmlModelId == null) {
- IFile file = WorkbenchResourceHelper.getFile(getResource());
- if (file != null) {
- xmlModelId = getModelManager().calculateId(file);
- }
- else {
- xmlModelId = resource.getURI() + Long.toString(System.currentTimeMillis());
- }
- }
- return xmlModelId;
- }
-
- protected ResourceSet getResourceSet() {
- return resource == null ? null : resource.getResourceSet();
- }
-
- /**
- * Return the DOM model for this resource.
- */
- public IDOMModel getXMLModel() {
- return xmlModel;
- }
-
- public String getXMLModelId() {
- return xmlModelId;
- }
-
- private IDOMModel initializeXMLModel(IFile file, boolean forWrite) throws UnsupportedEncodingException, IOException {
- if (file == null || !file.exists())
- throw new FileNotFoundException((file == null) ? "null" : file.getFullPath().toOSString()); //$NON-NLS-1$
- try {
- IModelManager manager = getModelManager();
- String id = manager.calculateId(file);
- if (forWrite) {
- IDOMModel mod = (IDOMModel)manager.getExistingModelForEdit(id);
- if (mod == null)
- setXMLModel((IDOMModel) manager.getModelForEdit(file));
- else {
- setXMLModel(mod);
- }
- }
- else {
- IDOMModel mod = (IDOMModel)manager.getExistingModelForRead(id);
- if (mod == null)
- setXMLModel((IDOMModel) manager.getModelForRead(file));
- else {
- setXMLModel(mod);
- }
- }
- setXMLModelId(getXMLModel().getId());
- needsToCreateDOM = false;
- }
- catch (CoreException e) {
- Logger.logException(e);
- return null;
- }
- String id = getXMLModel().getId();
- syncReferenceCounts(id, forWrite);
- if (xmlModel != null)
- document = xmlModel.getDocument();
- return xmlModel;
- }
-
- public boolean isBatchMode() {
- return isBatchChanges;
- }
-
- public boolean isModified() {
- return (getXMLModel() != null && getXMLModel().isDirty());
- }
-
- public boolean isShared() {
-
- if( xmlModel == null) { //resource could be in process of being unloaded - check with model manager
- String id = getModelManagerId();
- return getModelManager().isShared(id);
- }
- if (getResourceSet() == null)
- return false;
- return xmlModel.isShared();
- }
-
- public boolean isSharedForWrite() {
- if (getResourceSet() == null || xmlModel == null)
- return false;
- return xmlModel.isSharedForEdit();
- }
-
- protected void loadDocument(InputStream in, Map options) throws IOException {
- if (null != in) {
- throw new RuntimeException(this.getClass().getName() + " should not use an InputStream for loading");} //$NON-NLS-1$
- IFile file = WorkbenchResourceHelper.getFile(resource);
- initializeXMLModel(file, (resource.getWriteCount() != 0));
- cacheSynchronizationStamp();
- }
-
- protected boolean managesDOMAdapters() {
- return false;
- }
-
- public void modelAboutToBeChanged(IStructuredModel model) {
- if (model.getStructuredDocument() != null)
- aboutToChangeNode = model.getStructuredDocument().getFirstStructuredDocumentRegion();
- }
-
- public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
- // TODO Auto-generated method stub
-
- }
-
- private void modelAccessForWrite() {
- String id = getModelManagerId();
- getModelManager().getExistingModelForEdit(id);
- }
-
- public void modelChanged(IStructuredModel model) {
- if (isBatchChanges)
- return;
- try {
- if (reverting && aboutToChangeNode != null && model.getStructuredDocument() != null
- && model.getStructuredDocument().getFirstStructuredDocumentRegion() != aboutToChangeNode) {
- String id = getModelManagerId();
- IStructuredModel tempModel = null;
- try {
- tempModel = getModelManager().getExistingModelForEdit(id);
- xmlModelReverted = true;
- resource.unload();
- } finally {
- if (tempModel != null && (tempModel.getReferenceCountForEdit() > 0)) {
- tempModel.releaseFromEdit();
- }
- reverting = false;
- }
- }
- } finally {
- aboutToChangeNode = null;
- }
- }
-
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- if (!isDirty && resource.isModified()) { // The XMLModel was saved
- resource.setModified(false);
- long stamp = WorkbenchResourceHelper.computeModificationStamp(resource);
- WorkbenchResourceHelper.setSynhronizationStamp(resource, stamp);
- IProject proj = WorkbenchResourceHelper.getProject(resource);
- ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) WorkbenchResourceHelperBase.getResourceSet(proj)).getSynchronizer();
- IFile aFile = WorkbenchResourceHelper.getFile(resource);
- synchronizer.preSave(aFile, resource);
- }
- if (isDirty)
- resource.setModified(true);
- }
-
- public void modelReinitialized(IStructuredModel structuredModel) {
- // TODO Auto-generated method stub
-
- }
-
- public void modelResourceDeleted(IStructuredModel model) {
- // Do nothing
- }
-
- public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
- // Do nothing
- }
-
- /**
- * This method is called just prior to being removed from the ResourceSet.
- * Ensure that all reference counts to the XMLModel are removed.
- */
- public void preDelete() {
- if (resource.isLoaded())
- deregisterFromXMLModel();
- }
-
- public void preUnload() {
- deregisterFromXMLModel();
- }
-
- public void processPostModelEvent(ModelLifecycleEvent event) {
- if (event.getType() == ModelLifecycleEvent.MODEL_REVERT)
- reverting = false;
-
- }
-
- public void processPreModelEvent(ModelLifecycleEvent event) {
- if (event.getType() == ModelLifecycleEvent.MODEL_REVERT)
- reverting = true;
-
- if (!isSaving) {
- if (event.getType() == ModelLifecycleEvent.MODEL_SAVED) {
- ResourceSetWorkbenchEditSynchronizer synchronizer = (ResourceSetWorkbenchEditSynchronizer) ((ProjectResourceSet) resource.getResourceSet()).getSynchronizer();
- IFile aFile = WorkbenchResourceHelper.getFile(resource);
- synchronizer.preSave(aFile, resource);
- }
- }
-
- }
-
-
- public void registerAsModelLifecycleListener() {
- this.xmlModel.addModelLifecycleListener(this);
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 10:49:53
- * AM)
- */
- public void registerAsModelStateListener() {
- this.xmlModel.addModelStateListener(this);
- }
-
- public void releaseFromRead() {
- if (xmlModel != null)
- xmlModel.releaseFromRead();
- }
-
- public void releaseFromWrite() {
- if (xmlModel != null)
- xmlModel.releaseFromEdit();
- }
-
- public void removeDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- ((IDOMNode) aNode).removeAdapter((EMF2DOMSSEAdapter) anAdapter);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.internal.util.emf.xml.EMF2DOMRenderer#replaceDocumentType(java.lang.String,
- * java.lang.String, java.lang.String)
- */
- public void replaceDocumentType(String docTypeName, String publicId, String systemId) {
- if (document == null)
- return;
- DocumentTypeImpl docType = (DocumentTypeImpl) document.getDoctype();
- if (docType == null)
- return;
- if (publicId == null && systemId == null)
- document.removeChild(docType);
- else {
- docType.setPublicId(publicId);
- docType.setSystemId(systemId);
- }
- }
-
- /**
- * @deprecated use batchModeStart and BatchModeEnd instead even if you do
- * not use batchModelStart/End, you still need to use the
- * try/finally pattern documented there.
- */
-
- public void setBatchMode(boolean isBatch) {
-
- // This is some extra processing for clients to know they may be using
- // incorrectly
- if (isBatch) {
- if (isBatchChanges) {
- Logger.log(Logger.INFO_DEBUG, "setBatch was set to true when it was already true. This can be an indication of invalid calling order"); //$NON-NLS-1$
- }
- }
-
-
- if (isBatch) {
- batchModeStart();
- }
- else {
- batchModeEnd();
- }
- }
-
- private void setRootNodeAdapterNotificationEnabled(boolean b) {
- EObject root = resource.getRootObject();
- if (root != null) {
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(root, EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null) {
- adapter.setNotificationEnabled(b);
- if (b)
- adapter.updateDOM();
- }
- }
- }
-
- /**
- * Return the DOM model for this resource.
- */
- public void setXMLModel(IDOMModel xmlModel) {
- deRegisterAsModelStateListener();
- deRegisterAsModelLifecycleListener();
- this.xmlModel = xmlModel;
- registerAsModelStateListener();
- registerAsModelLifecycleListener();
- }
-
- public void setXMLModelId(String id) {
- xmlModelId = id;
- }
-
- private void syncReferenceCounts(String id, boolean forWrite) {
- int editIndex = 0, readIndex = 0;
- if (forWrite)
- editIndex++;
- else
- readIndex++;
- int writeCount = resource.getWriteCount();
- int readCount = resource.getReadCount();
- for (int i = writeCount; i > editIndex; i--)
- modelManager.getExistingModelForEdit(id);
- for (int i = readCount; i > readIndex; i--)
- modelManager.getExistingModelForRead(id);
- }
-
- public boolean useStreamsForIO() {
- return false;
- }
-
- public boolean wasReverted() {
- return xmlModelReverted;
- }
-
- public void setResource(TranslatorResource resource) {
- super.setResource(resource);
- if (resource != null)
- resourceClass = resource.getClass();
- }
- public boolean isReverting() {
- return this.reverting;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERendererFactory.java b/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERendererFactory.java
deleted file mode 100644
index 9b7912321d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-emfModelSynch/org/eclipse/wst/xml/core/internal/emf2xml/EMF2DOMSSERendererFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.emf2xml;
-
-import org.eclipse.wst.common.internal.emf.resource.Renderer;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-/**
- * @author schacher
- */
-public class EMF2DOMSSERendererFactory extends RendererFactory {
-
- public static final EMF2DOMSSERendererFactory INSTANCE = new EMF2DOMSSERendererFactory();
-
- public EMF2DOMSSERendererFactory() {
- // Default constructor
- }
-
-
- public Renderer createRenderer() {
- return new EMF2DOMSSERenderer();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/ComponentSearchContributor.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/ComponentSearchContributor.java
deleted file mode 100644
index 6c1dcdeeef..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/ComponentSearchContributor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-
-public abstract class ComponentSearchContributor {
-
- protected HashMap declarations;
-
- protected HashMap references;
-
- protected String[] namespaces;
-
- public ComponentSearchContributor() {
- super();
- }
-
- public XMLSearchPattern getDeclarationPattern(QualifiedName componentName) {
- return (XMLSearchPattern) getDeclarations().get(componentName);
- }
-
- protected Map getDeclarations() {
- if (declarations == null) {
- initializeDeclarations();
- }
- return declarations;
- }
-
- protected Map getReferences() {
- if (references == null) {
- initializeReferences();
- }
- return references;
- }
-
- public XMLSearchPattern[] getReferencesPatterns(QualifiedName componentName) {
- List references = (List) getReferences().get(componentName);
- if (references != null) {
- return (XMLSearchPattern[]) references
- .toArray(new XMLSearchPattern[references.size()]);
- }
- return new XMLSearchPattern[0];
- }
-
-
- public boolean supports(QualifiedName componentName){
- return getReferencesPatterns(componentName).length > 0 ||
- getDeclarationPattern(componentName) != null;
- }
-
- public String[] getSupportedNamespaces() {
- return namespaces;
- }
-
- protected abstract void initializeDeclarations();
-
- protected abstract void initializeReferences();
-
- protected abstract void initializeSupportedNamespaces();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/TargetNamespaceReferencePattern.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/TargetNamespaceReferencePattern.java
deleted file mode 100644
index 6321b7c3b1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/TargetNamespaceReferencePattern.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-
-public class TargetNamespaceReferencePattern extends SearchPattern {
-
- String namespaceURI;
-
- public TargetNamespaceReferencePattern(int matchRule, String namespaceuri) {
- super(matchRule);
- namespaceURI = namespaceuri;
- }
-
- public TargetNamespaceReferencePattern(String namespaceuri) {
- super();
- namespaceURI = namespaceuri;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentDeclarationPattern.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentDeclarationPattern.java
deleted file mode 100644
index 19f475beb1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentDeclarationPattern.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-
-public class XMLComponentDeclarationPattern extends XMLComponentSearchPattern {
-
- public XMLComponentDeclarationPattern(QualifiedName elementQName, QualifiedName typeQName, int matchRule) {
- super(null, elementQName, typeQName, matchRule);
-
- }
-
- public XMLComponentDeclarationPattern(IFile file, QualifiedName elementQName, QualifiedName typeQName) {
- super(file, elementQName, typeQName);
- }
-
- public XMLComponentDeclarationPattern(QualifiedName elementQName, QualifiedName typeQName) {
- super(null, elementQName, typeQName);
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentReferencePattern.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentReferencePattern.java
deleted file mode 100644
index e68a8a422a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentReferencePattern.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-
-public class XMLComponentReferencePattern extends XMLComponentSearchPattern{
-
- public XMLComponentReferencePattern(IFile file, QualifiedName elementQName, QualifiedName typeQName, int matchRule) {
- super(file, elementQName, typeQName, matchRule);
-
- }
-
- public XMLComponentReferencePattern(IFile file, QualifiedName elementQName, QualifiedName typeQName) {
- super(file, elementQName, typeQName);
-
- }
-
- public XMLComponentReferencePattern(QualifiedName elementQName, QualifiedName typeQName) {
- super(null, elementQName, typeQName);
-
- }
-
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentSearchPattern.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentSearchPattern.java
deleted file mode 100644
index dff3048c6a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLComponentSearchPattern.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.common.core.search.SearchParticipant;
-import org.eclipse.wst.common.core.search.pattern.ComponentSearchPattern;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-
-/**
- * XML component search pattern is a composite pattern that combines XML element pattern.
- *
- */
-public class XMLComponentSearchPattern extends ComponentSearchPattern {
-
- /**
- * Containing element patterns
- * @deprecated
- */
- XMLSearchPattern[] children = new XMLSearchPattern[0];
-
- /**
- * A map of XMLSearchPattern[] by {@link SearchParticipant search participant}.
- */
- protected Map childPatternsByParticipant = new HashMap();
-
- public XMLComponentSearchPattern(IFile file, QualifiedName elementQName, QualifiedName typeQName, int matchRule) {
- super(file, elementQName, typeQName, matchRule);
-
- }
-
-
- public XMLComponentSearchPattern(IFile file, QualifiedName elementQName, QualifiedName typeQName) {
- super(file, elementQName, typeQName);
-
- }
-
- /**
- * @deprecated Use {@link #getChildren(SearchParticipant)} instead.
- */
- public XMLSearchPattern[] getChildren(){
- return children;
- }
-
- /**
- * @deprecated Use {@link #addChildren(SearchParticipant, XMLSearchPattern[])} instead.
- */
- public void setChildren(XMLSearchPattern[] patterns){
- children = patterns;
-
- }
-
- /**
- * Provides the child patterns contributed by the given search participant.
- * @param searchParticipant the {@link SearchParticipant search participant} that contributed the patterns.
- * @see XMLComponentSearchPattern#addChildren(SearchParticipant, XMLSearchPattern[]) addChildren
- * @return an array with the {@link XMLSearchPattern patterns} contributed by the {@link SearchParticipant search participant}.
- */
- public XMLSearchPattern[] getChildren(SearchParticipant searchParticipant){
- XMLSearchPattern[] childPatterns = getChildren();
- if (searchParticipant != null){
- childPatterns = (XMLSearchPattern[])childPatternsByParticipant.get(searchParticipant);
- if (childPatterns == null){
- childPatterns = getChildren();
- }
- }
- return childPatterns;
- }
-
- /**
- * Saves the child patterns contributed by the given search participant.
- * @param searchParticipant the {@link SearchParticipant search participant} that is contributing the child search patterns.
- * @param childPatterns the child patterns contributed by the {@link SearchParticipant searchParticipant search participant}.
- * @see XMLComponentSearchPattern#getChildren(SearchParticipant) getChildren
- */
- public void addChildren(SearchParticipant searchParticipant, XMLSearchPattern[] childPatterns){
- if (searchParticipant != null && childPatterns != null) {
- childPatternsByParticipant.put(searchParticipant, childPatterns);
- }
- else {
- children = childPatterns;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchParticipant.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchParticipant.java
deleted file mode 100644
index b709f58b74..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchParticipant.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.SearchParticipant;
-import org.eclipse.wst.common.core.search.SearchRequestor;
-import org.eclipse.wst.common.core.search.document.ComponentDeclarationEntry;
-import org.eclipse.wst.common.core.search.document.Entry;
-import org.eclipse.wst.common.core.search.document.FileReferenceEntry;
-import org.eclipse.wst.common.core.search.document.SearchDocument;
-import org.eclipse.wst.common.core.search.document.SearchDocumentSet;
-import org.eclipse.wst.common.core.search.pattern.ComponentSearchPattern;
-import org.eclipse.wst.common.core.search.pattern.FileReferencePattern;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.common.core.search.scope.ContentTypeSearchScope;
-import org.eclipse.wst.common.core.search.scope.SearchScope;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.search.impl.IXMLSearchConstants;
-import org.eclipse.wst.xml.core.internal.search.impl.XMLSearchDocument;
-import org.eclipse.wst.xml.core.internal.search.matching.PatternMatcher;
-import org.eclipse.wst.xml.core.internal.search.matching.XMLSearchPatternMatcher;
-import org.eclipse.wst.xml.core.internal.search.quickscan.XMLQuickScan;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- *
- */
-public abstract class XMLSearchParticipant extends SearchParticipant {
-
- protected static final boolean debugPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.xml.core.internal.search/perf")); //$NON-NLS-1$ //$NON-NLS-2$
-
- public XMLSearchParticipant() {
- super();
- }
-
-
- /*
- public boolean initialize(SearchPattern pattern, String[] contentTypes){
-
- super.initialize(pattern, contentTypes);
- this.supportedContentTypes = contentTypes;
-
- if(pattern instanceof XMLComponentSearchPattern){
- return true;
- }
- return false;
- }*/
-
-
-
- public SearchDocument createSearchDocument(String documentPath) {
-
- return new XMLSearchDocument(documentPath, this);
-
- }
-
- public String getDescription() {
- return "XML search participant"; //$NON-NLS-1$
- }
-
-
-
- private void locateMatches(SearchPattern pattern, SearchDocument document,
- SearchRequestor requestor, Map searchOptions, IProgressMonitor monitor) {
-
- // TODO... utilize search options (that should get passed down via the SearchEngine)
- // to specify if accurate source coordinates are req'd if not, simply use the SAX results
- //
- if (pattern.getMatchRule() == SearchPattern.R_PATTERN_MATCH)
- {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(document.getPath()));
- // TODO.. don't assume the category is COMPONENT_DECL... handle any arbitarty category
- Entry[] entries = document.getEntries(IXMLSearchConstants.COMPONENT_DECL, null, 0);
- for (int i = 0; i < entries.length; i++)
- {
- // TODO.. don't assume this is just a component declaration entry
- ComponentDeclarationEntry entry = (ComponentDeclarationEntry)entries[i];
- SearchMatch searchMatch = new SearchMatch(null, 0, 0, file);
- searchMatch.map.put("name", entry.getName()); //$NON-NLS-1$
- searchMatch.map.put("metaName", entry.getMetaName()); //$NON-NLS-1$
- try
- {
- requestor.acceptSearchMatch(searchMatch);
- }
- catch (Exception e)
- {
- }
- }
- }
- else
- { if (document.getModel() instanceof IDOMModel) {
- IDOMModel domModel = (IDOMModel) document.getModel();
- IDOMElement contextNode = (IDOMElement) domModel.getDocument()
- .getDocumentElement();
- DOMVisitor visitor = new DOMVisitor(document.getPath(), pattern,
- requestor);
- visitor.visit(contextNode);
- }
- }
- }
-
- private PatternMatcher getAdapter(Object adaptableObject, Class adapterType) {
- if (PatternMatcher.class.equals(adapterType) &&
- (adaptableObject instanceof XMLSearchPattern ||
- adaptableObject instanceof XMLComponentSearchPattern) ) {
- return new XMLSearchPatternMatcher(this);
- }
- return null;
- }
-
- private class DOMVisitor {
-
- String path;
- SearchPattern pattern;
- SearchRequestor requestor;
- PatternMatcher matcher;
-
-
- protected DOMVisitor(String path, SearchPattern pattern,
- SearchRequestor requestor) {
- super();
- this.path = path;
- this.pattern = pattern;
-
- matcher = (PatternMatcher)pattern.getAdapter(PatternMatcher.class);
- if(matcher == null){
- matcher = getAdapter(pattern, PatternMatcher.class);
- }
- this.requestor = requestor;
- }
-
- private void visit(Node node) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- match((Element)node);
- NodeList nodeList = node.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node aNode = nodeList.item(i);
- visit(aNode);
- }
- }
- }
-
- private void match(Element node) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
- new Path(path));
- if(matcher != null){
- matcher.locateMatches(pattern, file, node, requestor);
- }
-
-
- }
-
- }
-
- public SearchScope selectDocumentLocations(SearchPattern pattern, SearchScope scope, Map searchOptions, IProgressMonitor monitor) {
- /*
- * gate #1: reduce the scope to the files with the content type that
- * could be searched using this participant
- */
- String[] contentTypes = getSupportedContentTypes();
- if(contentTypes != null && contentTypes.length > 0){
- scope = new ContentTypeSearchScope(scope, contentTypes);
- }
- return super.selectDocumentLocations(pattern, scope, searchOptions, monitor);
- }
-
- public abstract ComponentSearchContributor getSearchContributor();
-
-
- public void beginSearching(SearchPattern pattern, Map searchOptions) {
-
- super.beginSearching(pattern, searchOptions);
- if(pattern instanceof XMLComponentDeclarationPattern){
- XMLComponentDeclarationPattern componentPattern = (XMLComponentDeclarationPattern)pattern;
- XMLSearchPattern childPattern = getSearchContributor().getDeclarationPattern(componentPattern.getMetaName());
- if(childPattern != null){
- childPattern.setSearchName(componentPattern.getName().getLocalName());
- childPattern.setSearchNamespace(componentPattern.getName().getNamespace());
- componentPattern.addChildren(this, new XMLSearchPattern[]{childPattern});
- }
-
- }
- else if(pattern instanceof XMLComponentReferencePattern){
- XMLComponentReferencePattern componentPattern = (XMLComponentReferencePattern)pattern;
- XMLSearchPattern[] childPatterns = getSearchContributor().getReferencesPatterns(componentPattern.getMetaName());
- for (int i = 0; i < childPatterns.length; i++) {
- XMLSearchPattern childPattern = childPatterns[i];
- childPattern.setSearchName(componentPattern.getName().getLocalName());
- childPattern.setSearchNamespace(componentPattern.getName().getNamespace());
- }
- componentPattern.addChildren(this, childPatterns);
-
- }
- }
-
-
- /**
- * The intend of this method is to limit the search to the files that have content
- * which can be searched for the given pattern. It is called from
- * {@link #selectDocumentLocations(SearchPattern, SearchScope, IProgressMonitor)}
- *
- * @param pattern the search pattern that is searched for
- * @return content type's unique identifiers that could be searched for the given pattern.
- */
- public abstract String[] getSupportedContentTypes();
-
- public void populateSearchDocument(SearchDocument document, SearchPattern pattern)
- {
- PatternMatcher matcher = (PatternMatcher)pattern.getAdapter(PatternMatcher.class);
- if(matcher == null){
- matcher = getAdapter(pattern, PatternMatcher.class);
- }
- XMLQuickScan.populateSearchDocument(document, matcher, pattern);
- }
-
- public void locateMatches(SearchDocumentSet documentSet, SearchPattern pattern, SearchScope scope, SearchRequestor requestor, Map searchOptions, IProgressMonitor monitor) throws CoreException
- {
- long time = System.currentTimeMillis();
-
- // TODO: use the file reference entries in the documents to reduce the scope to the referenced files only
- // SearchDocument[] documents = documentSet.getSearchDocuments(id);
-
- // check to see if the search pattern is qualified by a file location
- // if this is the case then we can use file scoping rules to prune the matches
- IFile targetFile = null;
- if (pattern instanceof ComponentSearchPattern)
- {
- ComponentSearchPattern componentSearchPattern = (ComponentSearchPattern)pattern;
- targetFile = componentSearchPattern.getFile();
- }
-
- // here we should have in scope only referenced files
- IFile[] files = scope.enclosingFiles();
- for (int i = 0; i < files.length; i++)
- {
- IFile file = files[i];
- String path = file.getLocation().toString();
- SearchDocument document = documentSet.getSearchDocument(path, id);
- if (document != null)
- {
- Entry[] entries = document.getEntries(getSearchEntryCategory(pattern), null, 0);
- if ((entries != null && entries.length > 0) || (searchOptions != null && searchOptions.get("searchDirtyContent") != null))
- {
- //for (int j = 0; j < entries.length; j++)
- //{
- // Entry entry = entries[j];
- //System.out.println("entry " + entry.getCategory() + " " + entry.getKey() + " " + entry.getClass().getName());
- //}
-
- boolean isInScope = true;
- if (targetFile != null)
- {
- try
- {
- isInScope = isLinked(documentSet, "file:///" + path, "file:///" + targetFile.getLocation().toString()); //$NON-NLS-1$ //$NON-NLS-2$
- //if (path.endsWith("CancelSelection.wsdl") && path.indexOf("clone1") != -1)
- //{
- // fileReferenceTable.debug(qualifiedPath, 0, 5);
- //}
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- if (isInScope)
- {
- this.locateMatches(pattern, document, requestor, searchOptions, monitor);
- }
- }
- }
- }
-
-
- if (debugPerf)
- {
- System.out
- .println("" //$NON-NLS-1$
- + getDescription()
- + ": " + (System.currentTimeMillis() - time) + "ms for locateMatches"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- }
-
- private boolean isLinked(SearchDocumentSet set, String source, String target)
- {
- return isLinked(set, source, target, new HashMap());
- }
-
- private boolean isLinked(SearchDocumentSet set, String source, String target, HashMap visited)
- {
- if (source.equals(target))
- return true;
-
- String fileProtocol = "file:///"; //$NON-NLS-1$
-
- // Fix for bug 204174 - Begin
- if(target.charAt(fileProtocol.length()) == '/') //$NON-NLS-1$
- {
- target = fileProtocol + target.substring(fileProtocol.length() + 1);
- }
- // Fix for bug 204174 - End
-
- if (source.startsWith(fileProtocol))
- {
-
- SearchDocument document = set._tempGetSearchDocumetn(source.substring(fileProtocol.length()));
- if (document != null)
- {
- URIResolver uriResolver = URIResolverPlugin.createResolver();
- Entry[] entries = document.getEntries(IXMLSearchConstants.REF, null, 0);
- String[] resolveEntry = new String[entries.length];
- for (int j = 0; j < entries.length; j++)
- {
- Entry entry = entries[j];
- if (entry instanceof FileReferenceEntry)
- {
- FileReferenceEntry fileReferenceEntry = (FileReferenceEntry)entry;
- // TODO.. record an utilize the public id from the fileReferenceEntry
- //
- if (fileReferenceEntry.getRelativeFilePath() != null)
- {
- String resolvedURI = uriResolver.resolve(source, null, fileReferenceEntry.getRelativeFilePath());
- resolveEntry[j] = resolvedURI;
- if (resolvedURI.equals(target))
- {
- return true;
- }
- }
- }
- }
- // now see if there's an indirect link from the source to the target
- // we keep track of the nodes we've already visited to avoid cycles
- if (visited.get(source) == null)
- {
- visited.put(source, Boolean.TRUE);
- for (int j = 0; j < entries.length; j++)
- {
- String resolvedURI = resolveEntry[j];
- if (resolvedURI != null && isLinked(set, resolveEntry[j], target, visited))
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
-
- public static String getSearchEntryCategory(SearchPattern pattern){
- if(pattern instanceof XMLComponentDeclarationPattern){
- return IXMLSearchConstants.COMPONENT_DECL;
- }
- else if(pattern instanceof XMLComponentReferencePattern){
- return IXMLSearchConstants.COMPONENT_REF;
- }
- else if(pattern instanceof FileReferencePattern){
- return IXMLSearchConstants.COMPONENT_REF;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchPattern.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchPattern.java
deleted file mode 100644
index 7bc2a6aae4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/XMLSearchPattern.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search;
-
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.xml.core.internal.search.matching.SAXSearchElement;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import com.ibm.icu.util.StringTokenizer;
-
-public class XMLSearchPattern extends SearchPattern{
-
- private String elementNamespace = null;
- private String elementName = null;
- private String attributeName = null;
- private String searchName = null;
- private String searchNamespace = null;
- private String parentName = null;
- private int depth = -1;
- private SAXSearchElement element = null;
- private Element domElement = null;
-
- public XMLSearchPattern(String elementNamespace, String parentElementName,String elementName, String attributeName) {
- this(elementNamespace, parentElementName, elementName, attributeName, -1);
- }
-
- public XMLSearchPattern(String elementNamespace, String elementName, String attributeName) {
- this(elementNamespace, null, elementName, attributeName, -1);
- }
-
- public XMLSearchPattern(String elementNamespace, String elementName, String attributeName, int depth) {
- this(elementNamespace, null, elementName, attributeName, depth);
- }
-
- private XMLSearchPattern(String elementNamespace, String parentElementName, String elementName, String attributeName, int depth) {
- super();
- this.attributeName = attributeName;
- this.elementName = elementName;
- this.parentName = parentElementName;
- this.elementNamespace = elementNamespace;
- this.depth = depth;
- }
-
- public XMLSearchPattern(){
-
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
- public String getElementName() {
- return elementName;
- }
-
- public String getElementNamespace() {
- return elementNamespace;
- }
-
- public String getSearchName() {
- return searchName;
- }
-
- public String getSearchNamespace() {
- return searchNamespace;
- }
-
- public void setSearchName(String searchName) {
- this.searchName = searchName;
- }
-
- public void setSearchNamespace(String searchNamespace) {
- this.searchNamespace = searchNamespace;
- }
-
- public void setAttributeName(String attributeName) {
- this.attributeName = attributeName;
- }
-
- public void setElementName(String elementName) {
- this.elementName = elementName;
- }
-
- public void setElementNamespace(String elementNamespace) {
- this.elementNamespace = elementNamespace;
- }
-
- public void setSearchElement(SAXSearchElement element) {
- this.element = element;
- }
-
- public void setSearchElement(Element element) {
- domElement = element;
- }
-
- public boolean matches(XMLSearchPattern pattern) {
- if (pattern.searchName == null)
- return false;
- if ("*".equals(searchName) && "*".equals(searchNamespace)) { //$NON-NLS-1$ //$NON-NLS-2$
- return true;
- }
-
- final StringTokenizer tokenizer = new StringTokenizer(pattern.searchName);
- while (tokenizer.hasMoreTokens()) {
- final String token = tokenizer.nextToken();
- int n = token.indexOf(":"); //$NON-NLS-1$
- String name = token;
- String namespace = pattern.searchNamespace; // accept the default
- if(n > 0) {
- final String prefix = token.substring(0, n);
- name = token.substring(n+1);
- namespace = pattern.element != null ? (String)pattern.element.getNamespaceMap().get(prefix) : computeNamespaceForPrefix(pattern.domElement, prefix);
- }
-
- if (namespace == null) {
- if (name.equals(searchName) || "*".equals(searchName))
- return true;
- }
- else {
- if ((namespace.equals(searchNamespace) || "*".equals(searchNamespace)) && name.equals(searchName))
- return true;
- }
- }
- return false;
- }
-
- protected String computeNamespaceForPrefix(Element element, String prefix)
- {
- String result = null;
- for (Node node = element; node != null; node = node.getParentNode())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element e = (Element)node;
- String attributeName = (prefix != null && prefix.length() > 0) ? ("xmlns:" + prefix) : "xmlns"; //$NON-NLS-1$ //$NON-NLS-2$
- result = e.hasAttribute(attributeName) ? e.getAttribute(attributeName) : null;
- if (result != null && result.length() > 0)
- {
- break;
- }
- }
- }
- return result;
- }
-
- public int getDepth()
- {
- return depth;
- }
-
- public void setDepth(int depth)
- {
- this.depth = depth;
- }
-
-public String getParentName() {
- return parentName;
-}
-
-public void setParentName(String parentName) {
- this.parentName = parentName;
-}
-
-
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/IXMLSearchConstants.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/IXMLSearchConstants.java
deleted file mode 100644
index d160d819ea..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/IXMLSearchConstants.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.impl;
-
-public interface IXMLSearchConstants
-{
- String REF= "outLink"; //$NON-NLS-1$
- String COMPONENT_DECL = "componentDecl"; //$NON-NLS-1$
- String COMPONENT_REF = "componentDecl"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/Messages.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/Messages.java
deleted file mode 100644
index d7ae22f5c2..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/Messages.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.impl;
-
-import java.text.MessageFormat;
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.core.internal.search.messages";//$NON-NLS-1$
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
- private Messages() {
- // Do not instantiate
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @return the manipulated String
- */
- public static String bind(String message) {
- return bind(message, null);
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @param binding the object to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object binding) {
- return bind(message, new Object[] {binding});
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @param binding1 An object to be inserted into the message
- * @param binding2 A second object to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object binding1, Object binding2) {
- return bind(message, new Object[] {binding1, binding2});
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @param bindings An array of objects to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object[] bindings) {
- return MessageFormat.format(message, bindings);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/XMLSearchDocument.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/XMLSearchDocument.java
deleted file mode 100644
index 7908adfac8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/XMLSearchDocument.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.impl;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.common.core.search.document.Entry;
-import org.eclipse.wst.common.core.search.document.SearchDocument;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.search.XMLSearchParticipant;
-
-public class XMLSearchDocument extends SearchDocument {
-
- IDOMModel model;
- Map entries = new HashMap(); // category -> set (entry)
-
- public XMLSearchDocument(String documentPath, XMLSearchParticipant participant) {
- super(documentPath, participant);
- }
-
- public Object getModel() {
- if(model == null){
- //System.out.println("creating DOM for " + getPath());
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(getPath()));
- if(file != null){
- try {
- model = (IDOMModel)StructuredModelManager.getModelManager().getModelForEdit(file);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- }
- }
- return model;
- }
-
- public Entry[] getEntries(String category, String key, int matchRule)
- {
- // TODO use matchRule
- Set results = new HashSet();
- if(category != null){
- Set values = (Set)entries.get(category);
- if(values == null){
- return new Entry[0];
- }
- if(key == null || "".equals(key) || "*".equals(key)){ //$NON-NLS-1$ //$NON-NLS-2$
- // entries with any key in the given category
- results.addAll(values);
- }
- else{
- // entries with the specified key in the given category
- for (Iterator iter = values.iterator(); iter.hasNext();)
- {
- Entry entry = (Entry) iter.next();
- if(key.equals(entry.getKey())){
- results.add(entry);
- }
- }
- }
-
- }
- return (Entry[]) results.toArray(new Entry[results.size()]);
- }
-
- public void putEntry(Entry entry)
- {
- if(entry.getCategory() != null){
- Set values = (Set)entries.get(entry.getCategory());
- if(values == null){
- entries.put(entry.getCategory(), values=new HashSet());
- }
- values.add(entry);
- }
-
- }
-
- public void dispose()
- {
- if (model != null)
- {
- model.releaseFromEdit();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/messages.properties b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/messages.properties
deleted file mode 100644
index 43aea953b7..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/impl/messages.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 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
-###############################################################################
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java
deleted file mode 100644
index fa518e83f5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.matching;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.SearchRequestor;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-/**
- * This class contains matching implementation.
- * <p>
- * Subclasses of the PatternMatches should provide an implementation of the specific pattern matching.
- * </p>
- * <p>
- * Subclasses of the PatternMatches should be set as adapters for the patterns that they match.
- * </p>
- * An implementation of {@link org.eclipse.wst.common.core.search.SearchParticipant#selectDocumentLocations()} will call
- * { @link PatternMatcher#matches() } on the adapter on pattern matcher.
- *
- * An implementation of {@link org.eclipse.wst.common.core.search.SearchParticipant#locateMatches()} will call
- * { @link PatternMatcher#locateMatches() } on the adapter on pattern matcher.
- *
- */
-public abstract class PatternMatcher {
-
-
- /**
- * This method does dive actual match location to the requestor if there are matches
- */
- public abstract void locateMatches(SearchPattern pattern, IFile file, Element element, SearchRequestor requestor);
-
- /**
- * This method only answers if the pattern matches element, it does not give actual match location
- */
- public abstract boolean matches(SearchPattern pattern, Object element);
-
- protected SearchMatch createSearchMatch(IFile file, Attr attributeNode)
- {
- int start = 0;
- int length = 0;
- if(attributeNode instanceof IDOMAttr){
- IDOMAttr domAttr = (IDOMAttr)attributeNode;
- start = domAttr.getValueRegionStartOffset();
- length = domAttr.getValueRegionText().length();
- }
- SearchMatch match = new SearchMatch(attributeNode, start, length, file);
- return match;
- }
-
- protected void addMatch(SearchPattern pattern, IFile file, Attr attributeNode, SearchRequestor requestor) {
- //System.out.println("addMatch " + pattern + " " + attributeNode.getName() + "=" + attributeNode.getValue());
- if (attributeNode != null) {
- SearchMatch match = createSearchMatch(file, attributeNode);
- if(requestor != null){
- try {
- requestor.acceptSearchMatch(match);
- } catch (CoreException e) {
- //do nothing
- }
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/SAXSearchElement.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/SAXSearchElement.java
deleted file mode 100644
index a9ec4a10a6..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/SAXSearchElement.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.matching;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.xml.sax.Attributes;
-
-public class SAXSearchElement{
- Attributes attributes;
- String elementName;
- String elementNamespace;
- Map namespaceMap = new HashMap(); // Map of string prefix keys and namespace
- String targetNamespace = ""; //$NON-NLS-1$
- String parentName;
- int depth = -1;
-
- public SAXSearchElement() {
- super();
- }
- public Attributes getAttributes() {
- return attributes;
- }
- public String getElementName() {
- return elementName;
- }
- public String getElementNamespace() {
- return elementNamespace;
- }
- public Map getNamespaceMap() {
- return namespaceMap;
- }
- public String getTargetNamespace() {
- return targetNamespace;
- }
- public void setAttributes(Attributes attributes) {
- this.attributes = attributes;
- }
- public void setElementName(String elementName) {
- this.elementName = elementName;
- }
- public void setElementNamespace(String elementNamespace) {
- this.elementNamespace = elementNamespace;
- }
- public void setNamespaceMap(Map namespaceMap) {
- this.namespaceMap = namespaceMap;
- }
- public void setTargetNamespace(String targetNamespace) {
- this.targetNamespace = targetNamespace;
- }
- public int getDepth()
- {
- return depth;
- }
- public void setDepth(int depth)
- {
- this.depth = depth;
- }
-public String getParentName() {
- return parentName;
-}
-public void setParentName(String parentName) {
- this.parentName = parentName;
-}
-
-
-
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/XMLSearchPatternMatcher.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/XMLSearchPatternMatcher.java
deleted file mode 100644
index 3364898649..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/XMLSearchPatternMatcher.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.matching;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.SearchParticipant;
-import org.eclipse.wst.common.core.search.SearchRequestor;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentSearchPattern;
-import org.eclipse.wst.xml.core.internal.search.XMLSearchPattern;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class XMLSearchPatternMatcher extends PatternMatcher{
-
- /**
- * The active search participant.
- */
- private SearchParticipant searchParticipant;
-
- /**
- * Constructs a pattern matcher given a search participant.
- * @param searchParticipant the active {@link SearchParticipant search participant}.
- */
- public XMLSearchPatternMatcher(SearchParticipant searchParticipant)
- {
- this.searchParticipant = searchParticipant;
- }
-
- protected String computeNamespaceForPrefix(Element element, String prefix)
- {
- String result = null;
- for (Node node = element; node != null; node = node.getParentNode())
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element e = (Element)node;
- String attributeName = (prefix != null && prefix.length() > 0) ? ("xmlns:" + prefix) : "xmlns"; //$NON-NLS-1$ //$NON-NLS-2$
- result = e.hasAttribute(attributeName) ? e.getAttribute(attributeName) : null;
- if (result != null && result.length() > 0)
- {
- break;
- }
- }
- }
- return result;
- }
-
-
- protected void initialize(XMLSearchPattern pattern, Element domElement) {
-
- pattern.setElementName(domElement.getLocalName());
- pattern.setElementNamespace(domElement.getNamespaceURI());
- // TODO (cs) set the depth attribute on the pattern
- //
- String actualValue = domElement.hasAttribute(pattern.getAttributeName()) ? domElement.getAttribute(pattern.getAttributeName()) : null;
- if(actualValue != null && actualValue.length() > 0){
- pattern.setSearchElement(domElement);
- pattern.setSearchName(actualValue);
- pattern.setSearchNamespace(domElement.getOwnerDocument().getDocumentElement().getAttribute("targetNamespace")); // set a default
- }
-
- }
-
- protected void initialize(XMLSearchPattern pattern, SAXSearchElement saxElement) {
-
- pattern.setElementName(saxElement.getElementName());
- pattern.setElementNamespace(saxElement.getElementNamespace());
- pattern.setDepth(saxElement.getDepth());
- pattern.setParentName(saxElement.getParentName());
- String actualValue = saxElement.getAttributes().getValue(pattern.getAttributeName());
- if(actualValue != null){
- pattern.setSearchElement(saxElement);
- pattern.setSearchName(actualValue);
- pattern.setSearchNamespace(saxElement.getTargetNamespace()); // set a default
- }
-
- }
-
- XMLSearchPattern searchPattern;
-
- public XMLSearchPatternMatcher() {
- super();
-
- }
-
-
-
-
- /**
- * This method does dive actual match location to the requestor if there are matches
- */
-
- public void locateMatches(SearchPattern pattern, IFile file, Element element, SearchRequestor requestor) {
- if(pattern instanceof XMLComponentSearchPattern){
- XMLSearchPattern[] childPatterns = ((XMLComponentSearchPattern)pattern).getChildren(searchParticipant);
- if (childPatterns == null){
- return;
- }
- for (int i = 0; i < childPatterns.length; i++) {
- PatternMatcher matcher = (PatternMatcher)childPatterns[i].getAdapter(PatternMatcher.class);
- if(matcher == null){
- matcher = this;
- }
- if(matcher != null){
- matcher.locateMatches(childPatterns[i], file, element, requestor);
- }
- }
- }
- else if(pattern instanceof XMLSearchPattern){
- if(matches(pattern, element)){
- Attr attribute = element.getAttributeNode(((XMLSearchPattern)pattern).getAttributeName());
- addMatch(pattern, file, attribute, requestor);
- }
-
- }
- }
-
- /**
- * This method only answers if the pattern matches element, it does not give actual match location
- */
- public boolean matches(SearchPattern pattern, Object element){
- if(pattern instanceof XMLComponentSearchPattern){
- XMLSearchPattern[] childPatterns = ((XMLComponentSearchPattern)pattern).getChildren(searchParticipant);
- if (childPatterns == null){
- return false;
- }
- for (int i = 0; i < childPatterns.length; i++) {
- PatternMatcher matcher = (PatternMatcher)childPatterns[i].getAdapter(PatternMatcher.class);
- if(matcher == null){
- matcher = this;
- }
- if(matcher != null){
- if(matcher.matches(childPatterns[i], element)){
- return true;
- }
- }
-
- }
- }
- else if(pattern instanceof XMLSearchPattern){
-
- XMLSearchPattern possibleMatch = new XMLSearchPattern();
- possibleMatch.setAttributeName(((XMLSearchPattern)pattern).getAttributeName());
- if(element instanceof Element){
- initialize(possibleMatch, (Element)element);
- }
- else if(element instanceof SAXSearchElement){
- initialize(possibleMatch, (SAXSearchElement)element);
- }
- searchPattern = (XMLSearchPattern)pattern;
- return matchesPattern(possibleMatch);
- }
- return false;
- }
-
- protected boolean matchesPattern(SearchPattern pattern) {
- if(searchPattern != null && pattern instanceof XMLSearchPattern){
- XMLSearchPattern decodedPattern = (XMLSearchPattern)pattern;
- if(searchPattern.getElementName().equals(decodedPattern.getElementName()) &&
- searchPattern.getElementNamespace().equals(decodedPattern.getElementNamespace())){
- if(searchPattern.getParentName() != null &&
- decodedPattern.getParentName() != null &&
- !searchPattern.getParentName().equals(decodedPattern.getParentName()))
- {
- return false;
- }
- return searchPattern.matches(decodedPattern);
- }
- }
-
- return false;
- }
-
-
- protected SearchMatch createSearchMatch(IFile file, Attr attributeNode)
- {
- SearchMatch match = super.createSearchMatch(file, attributeNode);
- // todo... remove this ugly hack!!
- if ("name".equals(attributeNode.getName())) //$NON-NLS-1$
- {
- QualifiedName qualifiedName = new QualifiedName("todo-compute-targetNamespace", attributeNode.getValue()); //$NON-NLS-1$
- match.map.put("name", qualifiedName); //$NON-NLS-1$
- }
- //Element element = attributeNode.getOwnerDocument().getDocumentElement();
- //if (element.getAttribute("targetNamespace"))
- //{
- //}
- return match;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScan.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScan.java
deleted file mode 100644
index bf8a14cd89..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScan.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.search.quickscan;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import org.eclipse.wst.common.core.search.document.SearchDocument;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.xml.core.internal.search.matching.PatternMatcher;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-
-/**
- *
- */
-public class XMLQuickScan
-{
- /*
- public static String getTargetNamespace(String fullFilePath)
- {
- XMLQuickScanContentHandler handler = new XMLQuickScanContentHandler();
- parseFile(fullFilePath, handler);
- return handler.getTargetNamespace();
- }*/
-
- /*
- * Returns information about matches encountered based on the criteria
- * provided.
- *
- public static boolean hasMatch(String fullFilePath, PatternMatcher matcher, SearchPattern pattern)
- {
- XMLQuickScanContentHandler handler = new XMLQuickScanContentHandler(matcher, pattern);
- parseFile(fullFilePath, handler);
- return handler.hasMatch();
- }*/
-
- public static boolean populateSearchDocument(SearchDocument document, PatternMatcher matcher, SearchPattern pattern)
- {
- XMLQuickScanContentHandler handler = new XMLQuickScanContentHandler(document, matcher, pattern);
- parseFile(document.getPath(), handler);
- return handler.hasMatch();
- }
-
- private static XMLReader reader;
- private static XMLReader getOrCreateReader()
- {
- if (reader == null)
- {
- try
- {
- SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
- reader = parser.getXMLReader();
- reader.setFeature("http://xml.org/sax/features/namespaces", true); //$NON-NLS-1$
- reader.setErrorHandler(new InternalErrorHandler());
- }
- catch (Exception e)
- {
- }
- }
- return reader;
- }
-
- static class InternalErrorHandler implements ErrorHandler
- {
- public void error(SAXParseException exception) throws SAXException
- {
- }
-
- public void fatalError(SAXParseException exception) throws SAXException
- {
- }
- public void warning(SAXParseException exception) throws SAXException
- {
- }
- }
-
- private synchronized static void parseFile(String fullFilePath,
- XMLQuickScanContentHandler handler)
- {
- FileInputStream inputStream = null;
- try
- {
- inputStream = new FileInputStream(new File(fullFilePath));
- XMLReader reader = getOrCreateReader();
- reader.setContentHandler(handler);
- //System.out.println("parseFile" + reader + " (" + fullFilePath + ")");
- reader.parse(new InputSource(inputStream));
- } catch (Exception e)
- {
- // skip the file
- }
- finally{
- if(inputStream != null){
- try {
- inputStream.close();
- } catch (IOException e) {
- // can not do much
- }
- }
-
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScanContentHandler.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScanContentHandler.java
deleted file mode 100644
index 65d87cdc76..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/quickscan/XMLQuickScanContentHandler.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.search.quickscan;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-import org.eclipse.wst.common.core.search.document.ComponentDeclarationEntry;
-import org.eclipse.wst.common.core.search.document.ComponentReferenceEntry;
-import org.eclipse.wst.common.core.search.document.FileReferenceEntry;
-import org.eclipse.wst.common.core.search.document.SearchDocument;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentReferencePattern;
-import org.eclipse.wst.xml.core.internal.search.impl.IXMLSearchConstants;
-import org.eclipse.wst.xml.core.internal.search.matching.PatternMatcher;
-import org.eclipse.wst.xml.core.internal.search.matching.SAXSearchElement;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * This class is a SAX content handler, it should be recycled before scanning a file for the new SearchPattern.
- *
- */
-public class XMLQuickScanContentHandler extends DefaultHandler
-{
- private Map namespaceMap = new HashMap(); // Map of string prefix keys and namespace
- private String targetNamespace = ""; //$NON-NLS-1$
-
- private SearchPattern pattern;
- private SearchDocument document; // we'll add useful entries in the search document as we parsing
- private SAXSearchElement searchElement = new SAXSearchElement();
-
- private boolean hasMatch = false;
- private Stack currentPath = new Stack();
- private PatternMatcher matcher;
-
- public static final String XMLSCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
- public static final String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/"; //$NON-NLS-1$
-
-
- public XMLQuickScanContentHandler(PatternMatcher matcher, SearchPattern pattern) {
- super();
- this.pattern = pattern;
- this.matcher = matcher;
- }
-
- public XMLQuickScanContentHandler(SearchDocument document, PatternMatcher matcher, SearchPattern pattern) {
- super();
- this.pattern = pattern;
- this.matcher = matcher;
- this.document = document;
- }
-
- public XMLQuickScanContentHandler() {
- super();
- }
-
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException
- {
- // Search for targetNamespace if we haven't encountered it yet.
- if (targetNamespace.equals("")) //$NON-NLS-1$
- {
- int nAttributes = attributes.getLength();
- for (int i = 0; i < nAttributes; i++)
- {
- if ("targetNamespace".equals(attributes.getQName(i))) //$NON-NLS-1$
- {
- targetNamespace = attributes.getValue(i);
- break;
- }
- }
- }
-
- // collect link info
-
- // TODO This code should be refactored to delegate the responsibility to
- // detect links between files to the search providers/contributors.
- // The current code only handles the XSD and WSDL cases.
-
- if("import".equals(localName) && namespaceMatches(uri)){ //$NON-NLS-1$
- FileReferenceEntry documentEntry = new FileReferenceEntry();
- documentEntry.setCategory(IXMLSearchConstants.REF);
- documentEntry.setKey("import"); //$NON-NLS-1$
- String namespace = attributes.getValue("namespace"); //$NON-NLS-1$
- String location = attributes.getValue(getLocationAttributeName(uri)); //$NON-NLS-1$
- documentEntry.setPublicIdentifier(namespace);
- documentEntry.setRelativeFilePath(location);
- document.putEntry(documentEntry);
- }
- if(("redefine".equals(localName)|| "include".equals(localName)) && //$NON-NLS-1$ //$NON-NLS-2$
- namespaceMatches(uri)){
- FileReferenceEntry documentEntry = new FileReferenceEntry();
- documentEntry.setCategory(IXMLSearchConstants.REF);
- documentEntry.setKey("include"); //$NON-NLS-1$
- String location = attributes.getValue(getLocationAttributeName(uri)); //$NON-NLS-1$
- documentEntry.setPublicIdentifier(uri);
- documentEntry.setRelativeFilePath(location);
- document.putEntry(documentEntry);
- }
-
-
- // issue (cs) you may want to try perf measurements to compate reusing the same
- // instance of a SAXSearchElement instead of newing one each time
- //XMLSearchPattern.SAXSearchElement searchElement = new XMLSearchPattern.SAXSearchElement();
- searchElement.setElementName(localName);
- searchElement.setElementNamespace(uri);
- searchElement.setAttributes(attributes);
- searchElement.setNamespaceMap(namespaceMap);
- searchElement.setTargetNamespace(targetNamespace);
- if (currentPath.size() > 0)
- {
- String parentName = (String)currentPath.peek();
- searchElement.setParentName(parentName);
- }
-
-
- if(matcher != null){
- if(matcher.matches(pattern, searchElement)){
- hasMatch = true;
- if(pattern instanceof XMLComponentReferencePattern){
- ComponentReferenceEntry documentEntry = new ComponentReferenceEntry();
- documentEntry.setCategory(IXMLSearchConstants.COMPONENT_REF);
- QualifiedName name = new QualifiedName(uri, localName);
- documentEntry.setKey(name.toString());
- documentEntry.setName(name);
- document.putEntry(documentEntry);
- }
- else if(pattern instanceof XMLComponentDeclarationPattern){
- ComponentDeclarationEntry documentEntry = new ComponentDeclarationEntry();
- documentEntry.setCategory(IXMLSearchConstants.COMPONENT_DECL);
- QualifiedName name = new QualifiedName(targetNamespace, attributes.getValue("name")); //$NON-NLS-1$
- QualifiedName metaName = new QualifiedName(uri, localName);
- documentEntry.setKey(name.toString());
- documentEntry.setName(name);
- documentEntry.setMetaName(metaName);
- document.putEntry(documentEntry);
- }
- }
- }
- currentPath.push(localName); //$NON-NLS-1$
- }
-
- private String getLocationAttributeName(String uri)
- {
- if (XMLSCHEMA_NAMESPACE.equals(uri))
- {
- return "schemaLocation";
- }
-
- else if (WSDL_NAMESPACE.equals(uri))
- {
- return "location";
- }
-
- return "";
- }
-
- private boolean namespaceMatches(String uri)
- {
- return XMLSCHEMA_NAMESPACE.equals(uri) ||
- WSDL_NAMESPACE.equals(uri);
- }
-
- public void endElement(String uri, String localName, String qName)
- throws SAXException
- {
- currentPath.pop();
- }
-
- /**
- * Callback for SAX parser
- *
- * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
- * java.lang.String)
- */
- public void startPrefixMapping(String arg0, String arg1)
- throws SAXException
- {
- if (arg0 != null && arg0.length() > 0)
- {
- this.namespaceMap.put(arg0, arg1);
- }
- }
-
- public String getTargetNamespace() {
- return targetNamespace;
- }
-
- public void setTargetNamespace(String targetNamespace) {
- this.targetNamespace = targetNamespace;
- }
-
- public boolean hasMatch() {
- return hasMatch;
- }
-
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/AnnotationMsg.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/AnnotationMsg.java
deleted file mode 100644
index 5ba65d9705..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/AnnotationMsg.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- ********************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation;
-
-public class AnnotationMsg {
- public static String PROBMLEM_ID = "ProblemId"; //$NON-NLS-1$
- public static String LENGTH = "Length"; //$NON-NLS-1$
- public static String ATTRVALUETEXT = "AttributeValueText"; //$NON-NLS-1$
- public static String ATTRVALUENO = "AttributeValueNo"; //$NON-NLS-1$
- public static String ATTRNO = "AttrNo"; //$NON-NLS-1$
- private int problemId;
- private Object attributeValueText;
- private int length;
-
- public AnnotationMsg(int problemId, Object attributeValueText, int length) {
- super();
- this.problemId = problemId;
- this.attributeValueText = attributeValueText;
- this.length = length;
- }
- public int getProblemId() {
- return problemId;
- }
-
- public Object getAttributeValueText() {
- return attributeValueText;
- }
-
- public int getLength(){
- return length;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/MarkupValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/MarkupValidator.java
deleted file mode 100644
index a6d19bf645..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/MarkupValidator.java
+++ /dev/null
@@ -1,929 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.validation;
-
-import java.util.Locale;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Node;
-
-/**
- * Basic XML syntax checking step.
- */
-public class MarkupValidator extends AbstractValidator implements IValidator {
- public static final int ELEMENT_ERROR_LIMIT = 25;
- public static final int PARTIAL = 1;
- public static final int TOTAL = 0;
- private String DQUOTE = "\""; //$NON-NLS-1$
- private String SQUOTE = "'"; //$NON-NLS-1$
-
-
- private IDocument fDocument;
-
- private IContentType fRootContentType = null;
-
- private IReporter fReporter = null;
-
- private static final String ANNOTATIONMSG = AnnotationMsg.class.getName();
-
- public void getAnnotationMsg(IReporter reporter, int problemId, LocalizedMessage message, Object attributeValueText, int len){
- AnnotationMsg annotation = new AnnotationMsg(problemId, attributeValueText,len);
- message.setAttribute(ANNOTATIONMSG, annotation);
- reporter.addMessage(this, message);
- }
-
-
- private void addAttributeError(String messageText, String attributeValueText, int start, int length, int problemId, IStructuredDocumentRegion sdRegion, IReporter reporter, int messageSeverity) {
-
- if (sdRegion.isDeleted()) {
- return;
- }
-
- int lineNo = getLineNumber(start);
- LocalizedMessage message = new LocalizedMessage(messageSeverity, messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
-
-
- getAnnotationMsg(reporter, problemId, message, attributeValueText,length);
-
- }
-
- private void checkAttributesInEndTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- ITextRegionList textRegions = structuredDocumentRegion.getRegions();
- int errorCount = 0;
- int start = structuredDocumentRegion.getEndOffset();
- int end = structuredDocumentRegion.getEndOffset();
- for (int i = 0; (i < textRegions.size()) && (errorCount < ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
- ITextRegion textRegion = textRegions.get(i);
- if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- if (start > structuredDocumentRegion.getStartOffset(textRegion)) {
- start = structuredDocumentRegion.getStartOffset(textRegion);
- }
- end = structuredDocumentRegion.getEndOffset(textRegion);
- errorCount++;
- }
- }
- // create one error for all attributes in the end tag
- if (errorCount > 0) {
- // Position p = new Position(start, end - start);
- String messageText = XMLCoreMessages.End_tag_has_attributes;
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES), messageText);
- message.setOffset(start);
- message.setLength(end - start);
- message.setLineNo(getLineNumber(start));
-
- getAnnotationMsg(reporter, ProblemIDsXML.AttrsInEndTag, message, null,end-start);
-
- }
- }
-
-
- private void checkClosingBracket(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- boolean closed = false;
- for (int i = 0; (i < regions.size()) && !structuredDocumentRegion.isDeleted(); i++) {
- r = regions.get(i);
- if ((r.getType() == DOMRegionContext.XML_TAG_CLOSE) || (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) {
- closed = true;
- }
- }
- if (!closed) {
-
- String messageText = XMLCoreMessages.ReconcileStepForMarkup_6;
-
- int start = structuredDocumentRegion.getStartOffset();
- int length = structuredDocumentRegion.getText().trim().length();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
- getAnnotationMsg(reporter, ProblemIDsXML.MissingClosingBracket, message, null,length);
-
-
- }
- }
-
- private void checkEmptyTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // navigate to name
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- if (regions.size() == 2) {
- // missing name region
- if ((regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN) && (regions.get(1).getType() == DOMRegionContext.XML_TAG_CLOSE)) {
- String messageText = XMLCoreMessages.ReconcileStepForMarkup_3;
- int start = structuredDocumentRegion.getStartOffset();
- int length = structuredDocumentRegion.getLength();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_TAG_NAME) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
-
- getAnnotationMsg(reporter, ProblemIDsXML.EmptyTag, message, null,length);
- }
- }
- }
-
- private int getLineNumber(int start) {
- int lineNo = -1;
- try {
- lineNo = getDocument().getLineOfOffset(start) + 1;
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- return lineNo;
- }
-
- private void checkForAttributeValue(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // check for attributes without a value
- // track the attribute/equals/value sequence using a state of 0, 1 ,2
- // representing the name, =, and value, respectively
- int attrState = 0;
- ITextRegionList textRegions = structuredDocumentRegion.getRegions();
- // ReconcileAnnotationKey key = createKey(structuredDocumentRegion,
- // getScope());
-
- int errorCount = 0;
- for (int i = 0; (i < textRegions.size()) && (errorCount < ELEMENT_ERROR_LIMIT); i++) {
- ITextRegion textRegion = textRegions.get(i);
- if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || isTagCloseTextRegion(textRegion)) {
- // dangling name and '='
- if ((attrState == 2) && (i >= 2)) {
- // create annotation
- ITextRegion nameRegion = textRegions.get(i - 2);
- if (!(nameRegion instanceof ITextRegionContainer)) {
- Object[] args = {structuredDocumentRegion.getText(nameRegion)};
- String messageText = NLS.bind(XMLCoreMessages.Attribute__is_missing_a_value, args);
-
- int start = structuredDocumentRegion.getStartOffset(nameRegion);
- int end = structuredDocumentRegion.getEndOffset();
- int lineNo = getLineNumber(start);
- int textLength = structuredDocumentRegion.getText(nameRegion).trim().length();
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE) , messageText);
- message.setOffset(start);
- message.setLength(textLength);
- message.setLineNo(lineNo);
-
- // quick fix info
- ITextRegion equalsRegion = textRegions.get(i - 2 + 1);
- int insertOffset = structuredDocumentRegion.getTextEndOffset(equalsRegion) - end;
- Object[] additionalFixInfo = {structuredDocumentRegion.getText(nameRegion), new Integer(insertOffset)};
-
- getAnnotationMsg(reporter, ProblemIDsXML.MissingAttrValue, message, additionalFixInfo,textLength);
- errorCount++;
- }
- }
- // name but no '=' (XML only)
- else if ((attrState == 1) && (i >= 1)) {
- // create annotation
- ITextRegion previousRegion = textRegions.get(i - 1);
- if (!(previousRegion instanceof ITextRegionContainer)) {
- Object[] args = {structuredDocumentRegion.getText(previousRegion)};
- String messageText = NLS.bind(XMLCoreMessages.Attribute__has_no_value, args);
- int start = structuredDocumentRegion.getStartOffset(previousRegion);
- int textLength = structuredDocumentRegion.getText(previousRegion).trim().length();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE), messageText);
- message.setOffset(start);
- message.setLength(textLength);
- message.setLineNo(lineNo);
-
- getAnnotationMsg(reporter, ProblemIDsXML.NoAttrValue, message, structuredDocumentRegion.getText(previousRegion),textLength);
-
-
- errorCount++;
- }
- }
- attrState = 1;
- }
- else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- attrState = 2;
- }
- else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- attrState = 0;
- }
- }
-
- }
-
- private void checkForSpaceBeforeName(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- String sdRegionText = structuredDocumentRegion.getFullText();
- if (sdRegionText.startsWith(" ")) { //$NON-NLS-1$
- IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious();
- if (prev != null) {
- // this is possibly the case of "< tag"
- if ((prev.getRegions().size() == 1) && isStartTag(prev)) {
- // add the error for preceding space in tag name
- String messageText = XMLCoreMessages.ReconcileStepForMarkup_2;
- int start = structuredDocumentRegion.getStartOffset();
- // find length of whitespace
- int length = sdRegionText.trim().equals("") ? sdRegionText.length() : sdRegionText.indexOf(sdRegionText.trim()); //$NON-NLS-1$
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
- getAnnotationMsg(reporter, ProblemIDsXML.SpacesBeforeTagName, message, null,length);
- }
- }
- }
- }
-
- private void checkNoNamespaceInPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // navigate to name
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- int errorCount = 0;
- for (int i = 0; (i < regions.size()) && (errorCount < ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- String piText = structuredDocumentRegion.getText(r);
- int index = piText.indexOf(":"); //$NON-NLS-1$
- if (index != -1) {
- String messageText = XMLCoreMessages.ReconcileStepForMarkup_4;
- int start = structuredDocumentRegion.getStartOffset(r) + index;
- int length = piText.trim().length() - index;
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
-
-
- getAnnotationMsg(reporter, ProblemIDsXML.NamespaceInPI, message, null,length);
-
- errorCount++;
- }
- }
- }
- }
-
- private void checkQuotesForAttributeValues(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- String attrValueText = ""; //$NON-NLS-1$
- int errorCount = 0;
- for (int i = 0; (i < regions.size()) && (errorCount < ELEMENT_ERROR_LIMIT); i++) {
- r = regions.get(i);
- if (r.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- continue;
- }
-
- attrValueText = structuredDocumentRegion.getText(r);
- // attribute value includes quotes in the string
- // split up attribute value on quotes
- /*
- * WORKAROUND till
- * http://dev.icu-project.org/cgi-bin/icu-bugs/incoming?findid=5207
- * is fixed. (Also see BUG143628)
- */
-
- java.util.StringTokenizer st = new java.util.StringTokenizer(attrValueText, "\"'", true); //$NON-NLS-1$
- int size = st.countTokens();
- // get the pieces of the attribute value
- String one = "", two = ""; //$NON-NLS-1$ //$NON-NLS-2$
- if (size > 0) {
- one = st.nextToken();
- }
- if (size > 1) {
- two = st.nextToken();
- }
- if (size > 2) {
- // should be handled by parsing...
- // as in we can't have an attribute value like: <element
- // attr="a"b"c"/>
- // and <element attr='a"b"c' /> is legal
- continue;
- }
-
-
- if (size == 1) {
- if (one.equals(DQUOTE) || one.equals(SQUOTE)) {
- // missing closing quote
- String message = XMLCoreMessages.ReconcileStepForMarkup_0;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter, getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE));
- errorCount++;
- }
- else {
- // missing both
- String message = XMLCoreMessages.ReconcileStepForMarkup_1;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.AttrValueNotQuoted, structuredDocumentRegion, reporter, getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE));
- errorCount++;
- }
- }
- else if (size == 2) {
- if ((one.equals(SQUOTE) && !two.equals(SQUOTE)) || (one.equals(DQUOTE) && !two.equals(DQUOTE))) {
- // missing closing quote
- String message = XMLCoreMessages.ReconcileStepForMarkup_0;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter, getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE));
- errorCount++;
- }
- }
- }
- // end of region for loop
- }
-
- private void checkStartEndTagPairs(IStructuredDocumentRegion sdRegion, IReporter reporter) {
-
- if (sdRegion.isDeleted()) {
- return;
- }
-
- // check start/end tag pairs
- IDOMNode xmlNode = getXMLNode(sdRegion);
-
- if (xmlNode == null) {
- return;
- }
-
- boolean selfClosed = false;
- String tagName = null;
-
- /**
- * For tags that aren't meant to be EMPTY, make sure it's empty or has an end tag
- */
- if (xmlNode.isContainer()) {
- IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
- if (endRegion == null) {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion != null && !startRegion.isDeleted() && DOMRegionContext.XML_TAG_OPEN.equals(startRegion.getFirstRegion().getType())) {
- // analyze the tag (check self closing)
- ITextRegionList regions = startRegion.getRegions();
- ITextRegion r = null;
- int start = sdRegion.getStart();
- int length = sdRegion.getTextLength();
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- start = sdRegion.getStartOffset(r);
- length = r.getTextLength();
- }
- else if (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- selfClosed = true;
- }
- }
-
-
- if (!selfClosed && (tagName != null)) {
- Object[] args = {tagName};
- String messageText = NLS.bind(XMLCoreMessages.Missing_end_tag_, args);
-
- int lineNumber = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_END_TAG) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNumber);
- Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
-
- getAnnotationMsg(reporter, ProblemIDsXML.MissingEndTag, message, additionalFixInfo,length);
- }
- }
- }
- else {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion == null || startRegion.isDeleted()) {
- // analyze the tag (check self closing)
- ITextRegionList regions = endRegion.getRegions();
- ITextRegion r = null;
- int start = sdRegion.getStart();
- int length = sdRegion.getTextLength();
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- start = sdRegion.getStartOffset(r);
- length = r.getTextLength();
- }
- }
-
- if (tagName != null) {
- Object[] args = {tagName};
- String messageText = NLS.bind(XMLCoreMessages.Missing_start_tag_, args);
-
- int lineNumber = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_START_TAG), messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNumber);
- Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
-
- getAnnotationMsg(reporter, ProblemIDsXML.MissingStartTag, message, additionalFixInfo,length);
-
- }
- }
- }
-
- }
- /*
- * Check for an end tag that has no start tag
- */
- else {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion == null) {
- IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
- if (!endRegion.isDeleted()) {
- // get name
- ITextRegionList regions = endRegion.getRegions();
- ITextRegion r = null;
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- }
- }
-
- if (!selfClosed && (tagName != null)) {
- String messageText = XMLCoreMessages.Indicate_no_grammar_specified_severities_error;
-
- int start = sdRegion.getStart();
- int lineNumber = getLineNumber(start);
-
- // SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY
- IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText);
- message.setOffset(start);
- message.setLength(sdRegion.getTextLength());
- message.setLineNo(lineNumber);
-
- reporter.addMessage(this, message);
- }
- }
- }
- }
- }
-
- private Object[] getStartEndFixInfo(IDOMNode xmlNode, String tagName, ITextRegion r) {
- // quick fix info
- String tagClose = "/>"; //$NON-NLS-1$
- int tagCloseOffset = xmlNode.getFirstStructuredDocumentRegion().getEndOffset();
- if ((r != null) && (r.getType() == DOMRegionContext.XML_TAG_CLOSE)) {
- tagClose = "/"; //$NON-NLS-1$
- tagCloseOffset--;
- }
- IDOMNode firstChild = (IDOMNode) xmlNode.getFirstChild();
- while ((firstChild != null) && (firstChild.getNodeType() == Node.TEXT_NODE)) {
- firstChild = (IDOMNode) firstChild.getNextSibling();
- }
- int endOffset = xmlNode.getEndOffset();
- int firstChildStartOffset = firstChild == null ? endOffset : firstChild.getStartOffset();
- Object[] additionalFixInfo = {tagName, tagClose, new Integer(tagCloseOffset), new Integer(xmlNode.getFirstStructuredDocumentRegion().getEndOffset()), // startTagEndOffset
- new Integer(firstChildStartOffset), // firstChildStartOffset
- new Integer(endOffset)}; // endOffset
- return additionalFixInfo;
- }
-
- private void checkStartingSpaceForPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious();
- if ((prev != null) && prev.getStartOffset() == 0) {
- if (prev.getType() == DOMRegionContext.XML_CONTENT) {
- String messageText = XMLCoreMessages.ReconcileStepForMarkup_5;
- int start = prev.getStartOffset();
- int length = prev.getLength();
-
- LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.WHITESPACE_AT_START) , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
-
-
- getAnnotationMsg(reporter, ProblemIDsXML.SpacesBeforePI, message, null,length);
-
- // Position p = new Position(start, length);
- //
- // ReconcileAnnotationKey key =
- // createKey(structuredDocumentRegion, getScope());
- // TemporaryAnnotation annotation = new TemporaryAnnotation(p,
- // SEVERITY_SYNTAX_ERROR, message, key,
- // ProblemIDsXML.SpacesBeforePI);
- // results.add(annotation);
- }
- }
- }
-
- public int getScope() {
- return PARTIAL;
- }
-
- private IDOMNode getXMLNode(IStructuredDocumentRegion sdRegion) {
-
- if (sdRegion == null) {
- return null;
- }
-
- IStructuredModel xModel = null;
- IDOMNode xmlNode = null;
- // get/release models should always be in a try/finally block
- try {
- xModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- // xModel is sometime null, when closing editor, for example
- if (xModel != null) {
- xmlNode = (IDOMNode) xModel.getIndexedRegion(sdRegion.getStart());
- }
- }
- finally {
- if (xModel != null) {
- xModel.releaseFromRead();
- }
- }
- return xmlNode;
- }
-
- /**
- * Determines whether the IStructuredDocumentRegion is a XML "end tag"
- * since they're not allowed to have attribute ITextRegions
- *
- * @param structuredDocumentRegion
- */
- private boolean isEndTag(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN;
- }
-
- /**
- * Determines if the IStructuredDocumentRegion is an XML Processing
- * Instruction
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isPI(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_PI_OPEN;
- }
-
- /**
- * Determines whether the IStructuredDocumentRegion is a XML "start tag"
- * since they need to be checked for proper XML attribute region sequences
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isStartTag(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN;
- }
-
- // Because we check the "proper" closing separately from attribute
- // sequencing, we need to know what's
- // an appropriate close.
- private boolean isTagCloseTextRegion(ITextRegion textRegion) {
- return (textRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) || (textRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE);
- }
-
- /**
- * Determines if the IStructuredDocumentRegion is XML Content
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isXMLContent(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_CONTENT;
- }
-
- private IDocument getDocument() {
- return fDocument;
- }
-
- public void connect(IDocument document) {
- fDocument = document;
- }
-
- public void disconnect(IDocument document) {
- fDocument = null;
- }
-
- public void validate(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion == null) {
- return;
- }
-
- if (isStartTag(structuredDocumentRegion)) {
- // check for attributes without a value
- checkForAttributeValue(structuredDocumentRegion, reporter);
- // check if started tag is ended
- checkStartEndTagPairs(structuredDocumentRegion, reporter);
- // check empty tag <>
- checkEmptyTag(structuredDocumentRegion, reporter);
- // check that each attribute has quotes
- checkQuotesForAttributeValues(structuredDocumentRegion, reporter);
- // check that the closing '>' is there
- checkClosingBracket(structuredDocumentRegion, reporter);
- }
- else if (isEndTag(structuredDocumentRegion)) {
- // check if ending tag was started
- checkStartEndTagPairs(structuredDocumentRegion, reporter);
- // check for attributes in an end tag
- checkAttributesInEndTag(structuredDocumentRegion, reporter);
- // check that the closing '>' is there
- checkClosingBracket(structuredDocumentRegion, reporter);
- }
- else if (isPI(structuredDocumentRegion)) {
- // check validity of processing instruction
- checkStartingSpaceForPI(structuredDocumentRegion, reporter);
- checkNoNamespaceInPI(structuredDocumentRegion, reporter);
- }
- else if (isXMLContent(structuredDocumentRegion)) {
- checkForSpaceBeforeName(structuredDocumentRegion, reporter);
- }
- else if (isXMLDoctypeDeclaration(structuredDocumentRegion)) {
- checkDocumentTypeReferences(structuredDocumentRegion, reporter);
- }
- }
-
- /**
- * @param structuredDocumentRegion
- * @param reporter
- */
- private void checkDocumentTypeReferences(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- }
-
- /**
- * @param structuredDocumentRegion
- * @return
- */
- private boolean isXMLDoctypeDeclaration(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_DECLARATION_OPEN && structuredDocumentRegion.getType().equals(DOMRegionContext.XML_DOCTYPE_DECLARATION);
- }
-
- public void cleanup(IReporter reporter) {
- fDocument = null;
- }
-
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- String[] uris = helper.getURIs();
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- if (uris.length > 0) {
- IFile currentFile = null;
-
- for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
- // might be called with just project path?
- IPath path = new Path(uris[i]);
- if (path.segmentCount() > 1) {
- currentFile = wsRoot.getFile(path);
- if (shouldValidate(currentFile, true)) {
- validateV1File(currentFile, reporter);
- }
- }
- else if (uris.length == 1) {
- validateV1Project(helper, reporter);
- }
- }
- }
- else
- validateV1Project(helper, reporter);
- }
-
- private boolean shouldValidate(IResourceProxy proxy) {
- if(proxy.getType() == IResource.FILE) {
- String name = proxy.getName();
- if(name.toLowerCase(Locale.US).endsWith(".xml")) { //$NON-NLS-1$
- return true;
- }
- }
- return shouldValidate(proxy.requestResource(), false);
- }
-
- private boolean shouldValidate(IResource file, boolean checkExtension) {
- if (file == null || !file.exists() || file.getType() != IResource.FILE)
- return false;
- if (checkExtension) {
- String extension = file.getFileExtension();
- if (extension != null && "xml".endsWith(extension.toLowerCase(Locale.US))) //$NON-NLS-1$
- return true;
- }
-
- IContentDescription contentDescription = null;
- try {
- contentDescription = ((IFile) file).getContentDescription();
- if (contentDescription != null) {
- IContentType contentType = contentDescription.getContentType();
- return contentDescription != null && contentType.isKindOf(getXMLContentType());
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- return false;
- }
-
- /**
- * @param helper
- * @param reporter
- */
- private void validateV1Project(IValidationContext helper, final IReporter reporter) {
- // if uris[] length 0 -> validate() gets called for each project
- if (helper instanceof IWorkbenchContext) {
- IProject project = ((IWorkbenchContext) helper).getProject();
- IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (shouldValidate(proxy)) {
- validateV1File((IFile) proxy.requestResource(), reporter);
- }
- return true;
- }
- };
- try {
- // collect all jsp files for the project
- project.accept(visitor, IResource.DEPTH_INFINITE);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
-
- /**
- * @param currentFile
- * @param reporter
- */
- private void validateV1File(IFile currentFile, IReporter reporter) {
- Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, currentFile.getFullPath().toString().substring(1));
- reporter.displaySubtask(MarkupValidator.this, message);
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getModelForRead(currentFile);
- IStructuredDocument document = null;
- if (model != null) {
- document = model.getStructuredDocument();
- connect(document);
- IStructuredDocumentRegion validationRegion = document.getFirstStructuredDocumentRegion();
- while (validationRegion != null) {
- validate(validationRegion, reporter);
- validationRegion = validationRegion.getNext();
- }
- disconnect(document);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
- }
-
- /**
- * @return
- */
- private IContentType getXMLContentType() {
- if (fRootContentType == null) {
- fRootContentType = Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
- }
- return fRootContentType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.AbstractValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
- */
- public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
- if (resource.getType() != IResource.FILE)
- return null;
- ValidationResult result = new ValidationResult();
- fReporter = result.getReporter(monitor);
-
- validateV1File((IFile) resource, fReporter);
-
- return result;
- }
-
- public IReporter validate(IResource resource, int kind, ValidationState state) {
- validate(resource,kind,state,new NullProgressMonitor());
- return fReporter;
- }
- private Preferences getPluginPreference(){
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) {
- if (getDocument() == null) {
- return;
- }
- if (!(getDocument() instanceof IStructuredDocument)) {
- return;
- }
-
- // remove old messages
- reporter.removeAllMessages(this);
-
- IStructuredDocumentRegion[] regions = ((IStructuredDocument) fDocument).getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength());
- for (int i = 0; i < regions.length; i++) {
- validate(regions[i], reporter);
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ProblemIDsXML.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ProblemIDsXML.java
deleted file mode 100644
index cf34e74f0b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ProblemIDsXML.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 20010 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation;
-
-public interface ProblemIDsXML {
- int AttrsInEndTag = 3;
- int AttrValueNotQuoted = 13;
- int EmptyTag = 1;
- int InvalidAttrValue = 11;
- int MissingAttrValue = 4;
- int MissingClosingBracket = 14;
- int MissingEndTag = 2;
- int MissingRequiredAttr = 12;
- int MissingStartTag = 15;
- int NamespaceInPI = 8;
- int NoAttrValue = 5;
- int SpacesBeforePI = 7;
- int SpacesBeforeTagName = 6;
- int Unclassified = 0;
- int UnknownAttr = 10;
- int UnknownElement = 9;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java
deleted file mode 100644
index cd4631d5c8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.LexicalHandler;
-
-import com.ibm.icu.util.StringTokenizer;
-
-/**
- * A helper class for the XML validator.
- *
- * @author Craig Salter, IBM
- * @author Lawrence Mandel, IBM
- */
-public class ValidatorHelper
-{
- public List namespaceURIList = new Vector();
- public boolean isGrammarEncountered = false;
- public boolean isDTDEncountered = false;
- public boolean isNamespaceEncountered = false;
- public String schemaLocationString = ""; //$NON-NLS-1$
- public int numDTDElements = 0;
- public boolean isDocumentElementEncountered = false;
-
- private static final boolean _trace = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.xml.core/debug/validation")).booleanValue(); //$NON-NLS-1$
- /**
- * Constructor.
- */
- public ValidatorHelper()
- {
- }
-
- /**
- * Create an XML Reader.
- *
- * @return An XML Reader if one can be created or null.
- * @throws SAXNotSupportedException
- * @throws SAXNotRecognizedException
- */
- protected XMLReader createXMLReader(String uri) throws SAXNotRecognizedException, SAXNotSupportedException {
- XMLReader reader = null;
-
- reader = new org.apache.xerces.parsers.SAXParser();
- reader.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false); //$NON-NLS-1$
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); //$NON-NLS-1$
- reader.setFeature("http://xml.org/sax/features/namespaces", false); //$NON-NLS-1$
- reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$
- reader.setContentHandler(new MyContentHandler(uri));
- reader.setErrorHandler(new InternalErrorHandler());
-
- LexicalHandler lexicalHandler = new LexicalHandler()
- {
- public void startDTD (String name, String publicId, String systemId)
- {
- isGrammarEncountered = true;
- isDTDEncountered = true;
- }
-
- public void endDTD() throws SAXException
- {
- }
-
- public void startEntity(String name) throws SAXException
- {
- }
-
- public void endEntity(String name) throws SAXException
- {
- }
-
- public void startCDATA() throws SAXException
- {
- }
-
- public void endCDATA() throws SAXException
- {
- }
-
- public void comment (char ch[], int start, int length) throws SAXException
- {
- }
- };
- reader.setProperty("http://xml.org/sax/properties/lexical-handler", lexicalHandler); //$NON-NLS-1$
-
- return reader;
- }
-
- /**
- * An error handler to suppress error and warning information.
- */
- private class InternalErrorHandler implements org.xml.sax.ErrorHandler
- {
- public InternalErrorHandler()
- {
- super();
- }
-
- public void error(SAXParseException exception) throws SAXException
- {
- }
-
- public void fatalError(SAXParseException exception) throws SAXException
- {
- }
-
- public void warning(SAXParseException exception) throws SAXException
- {
- }
- }
-
-
- /**
- * Figures out the information needed for validation.
- *
- * @param uri The uri of the file to validate.
- * @param uriResolver A helper to resolve locations.
- */
- public void computeValidationInformation(String uri, Reader characterStream, URIResolver uriResolver)
- {
- try {
- XMLReader reader = createXMLReader(uri);
- InputSource inputSource = new InputSource(uri);
- inputSource.setCharacterStream(characterStream);
- reader.parse(inputSource);
- }
- catch (SAXException e) {
- if (_trace)
- Logger.logException(e);
- }
- catch (IOException e) {
- if (_trace)
- Logger.logException(e);
- }
- }
-
-
-
- /**
- * Handle the content while parsing the file.
- */
- class MyContentHandler extends org.xml.sax.helpers.DefaultHandler
- {
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
- */
- boolean isRootElement = true;
- String baseURI;
-
- MyContentHandler(String uri)
- {
- this.baseURI = uri;
- }
-
- public void error(SAXParseException e) throws SAXException
- {
- }
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
- */
- public void fatalError(SAXParseException e) throws SAXException
- {
- }
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
- */
- public void warning(SAXParseException e) throws SAXException
- {
- }
- public String getPrefix(String name)
- {
- String prefix = null;
- int index = name.indexOf(":"); //$NON-NLS-1$
- if (index != -1)
- {
- prefix = name.substring(0, index);
- }
- return prefix;
- }
-
- public String getUnprefixedName(String name)
- {
- int index = name.indexOf(":"); //$NON-NLS-1$
- if (index != -1)
- {
- name = name.substring(index + 1);
- }
- return name;
- }
-
- public String getPrefixedName(String prefix, String localName)
- {
- return prefix != null && prefix.length() > 0 ? prefix + ":" + localName : localName; //$NON-NLS-1$
- }
-
- public void startElement(String namespaceURI, String localName, String rawName, Attributes atts)
- {
- //String explicitLocation = null;
- if (isRootElement)
- {
- isDocumentElementEncountered = true;
- isRootElement = false;
- int nAtts = atts.getLength();
- String schemaInstancePrefix = null;
- for (int i =0; i < nAtts; i++)
- {
- String attributeName = atts.getQName(i);
- if (attributeName.equals("xmlns") || attributeName.startsWith("xmlns:")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- isNamespaceEncountered = true;
- String value = atts.getValue(i);
- if (value.startsWith("http://www.w3.org/") && value.endsWith("/XMLSchema-instance")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- schemaInstancePrefix = attributeName.equals("xmlns") ? "" : getUnprefixedName(attributeName); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- String prefix = getPrefix(rawName);
- String rootElementNamespaceDeclarationName = (prefix != null && prefix.length() > 0) ? "xmlns:" + prefix : "xmlns"; //$NON-NLS-1$ //$NON-NLS-2$
- String rootElementNamespace = rootElementNamespaceDeclarationName != null ? atts.getValue(rootElementNamespaceDeclarationName) : null;
-
- String location = null;
-
- // first we use any 'xsi:schemaLocation' or 'xsi:noNamespaceSchemaLocation' attribute
- // to determine a location
- if (schemaInstancePrefix != null)
- {
- location = atts.getValue(getPrefixedName(schemaInstancePrefix, "noNamespaceSchemaLocation")); //$NON-NLS-1$
- if (location == null)
- {
- String schemaLoc = atts.getValue(getPrefixedName(schemaInstancePrefix, "schemaLocation")); //$NON-NLS-1$
- location = getSchemaLocationForNamespace(schemaLoc, rootElementNamespace);
- }
- }
- if (rootElementNamespace == null)
- {
- rootElementNamespace = "";
- }
-
- location = URIResolverPlugin.createResolver().resolve(baseURI, rootElementNamespace, location);
- location = URIResolverPlugin.createResolver().resolvePhysicalLocation(baseURI, rootElementNamespace, location);
- if (location != null)
- {
- location = URIHelper.addImpliedFileProtocol(location);
- }
-
- schemaLocationString = location;
-
- if (location != null)
- {
- InputStream is = null;
- try
- {
- URL url = new URL(location);
- is = url.openStream();
- isGrammarEncountered = true;
- }
- catch(Exception e)
- {
- // Do nothing.
- }
- finally
- {
- if(is != null)
- {
- try
- {
- is.close();
- }
- catch(Exception e)
- {
- // Do nothing.
- }
- }
- }
- }
- }
- }
- /* (non-Javadoc)
- * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
- */
- public void elementDecl(String name, String model)
- {
- numDTDElements++;
- }
-
- // The xsiSchemaLocationValue is a list of namespace/location pairs that are separated by whitespace
- // this method walks the list of pairs looking for the specified namespace and returns the associated
- // location.
- //
- protected String getSchemaLocationForNamespace(String xsiSchemaLocationValue, String namespace)
- {
- String result = null;
- if (xsiSchemaLocationValue != null && namespace != null)
- {
-
- StringTokenizer st = new StringTokenizer(xsiSchemaLocationValue);
- while(st.hasMoreTokens())
- {
- if(st.nextToken().equals(namespace))
- {
- if(st.hasMoreTokens())
- {
- result = st.nextToken();
- }
- }
- else
- {
- if(st.hasMoreTokens())
- {
- st.nextToken();
- }
- }
- }
- }
- return result;
- }
- }
-
-
- /**
- * Replace all instances in the string of the old pattern with the new pattern.
- *
- * @param string The string to replace the patterns in.
- * @param oldPattern The old pattern to replace.
- * @param newPattern The pattern used for replacement.
- * @return The modified string with all occurrances of oldPattern replaced by new Pattern.
- */
- protected static String replace(String string, String oldPattern, String newPattern)
- {
- int index = 0;
- while (index != -1)
- {
- index = string.indexOf(oldPattern, index);
- if (index != -1)
- {
- string = string.substring(0, index) + newPattern + string.substring(index + oldPattern.length());
- index = index + oldPattern.length();
- }
- }
- return string;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLNestedValidatorContext.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLNestedValidatorContext.java
deleted file mode 100644
index 29c5e7e3f9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLNestedValidatorContext.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation;
-
-
-import java.util.HashSet;
-
-import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
-
-
-/**
- * XMLNestedValidatorContext is used to store state data needed during an XML
- * validation session.
- */
-public class XMLNestedValidatorContext extends NestedValidatorContext
-{
- /**
- * A set of inaccessible locations URIs (String).
- */
- private HashSet inaccessibleLocationURIs = new HashSet();
-
- /**
- * Determines if a location URI was marked as inaccessible.
- *
- * @param locationURI
- * the location URI to test. Must not be null.
- * @return true if a location URI was marked as inaccessible, false otherwise.
- */
- public boolean isURIMarkedInaccessible(String locationURI)
- {
- return locationURI != null && inaccessibleLocationURIs.contains(locationURI);
- }
-
- /**
- * Marks the given location URI as inaccessible.
- *
- * @param locationURI
- * the location URI to mark as inaccessible. Must not be null.
- */
- public void markURIInaccessible(String locationURI)
- {
- if (locationURI != null)
- {
- inaccessibleLocationURIs.add(locationURI);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationConfiguration.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationConfiguration.java
deleted file mode 100644
index 1649104002..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationConfiguration.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 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
- * David Carver (STAR) - bug 297005 - Some static constants not made final.
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation;
-
-/**
- * An XML validation configuration allows setting specific configuration
- * information for a WTP XML validation run. Any features and properties
- * set on this configuration should not be confused with those from
- * parsers such as Xerces. (This object does not by default wrap features
- * and properties from specific parsers.)
- */
-public class XMLValidationConfiguration
-{
- /**
- * @deprecated
- */
- public static final String WARN_NO_GRAMMAR = "WARN_NO_GRAMMAR"; //$NON-NLS-1$
- public static final String INDICATE_NO_GRAMMAR = "INDICATE_NO_GRAMMAR"; //$NON-NLS-1$
- public static final String INDICATE_NO_DOCUMENT_ELEMENT = "INDICATE_NO_DOCUMENT_ELEMENT"; //$NON-NLS-1$
- public static final String USE_XINCLUDE = "USE_XINCLUDE"; //$NON-NLS-1$
- public static final String HONOUR_ALL_SCHEMA_LOCATIONS = "HONOUR_ALL_SCHEMA_LOCATIONS"; //$NON-NLS-1$
-
- private boolean warn_no_grammar_value = false;
- private int indicate_no_grammar_value = 1;
- private boolean use_xinclude = false;
- private boolean honour_all_schema_locations_value = false;
- private int indicate_no_document_value = 0;
-
- /**
- * Set a feature of this configuration.
- *
- * @param feature
- * The feature to set.
- * @param value
- * The value to set for the feature.
- * @throws
- * An exception is thrown if the feature is not recognized.
- */
- public void setFeature(String feature, boolean value) throws Exception
- {
- if(WARN_NO_GRAMMAR.equals(feature))
- warn_no_grammar_value = value;
- else if(USE_XINCLUDE.equals(feature))
- use_xinclude = value;
- else if(HONOUR_ALL_SCHEMA_LOCATIONS.equals(feature))
- honour_all_schema_locations_value = value;
- else
- throw new Exception("Feature not recognized."); //$NON-NLS-1$
-
- }
-
- /**
- * Set a feature of this configuration.
- *
- * @param feature
- * The feature to set.
- * @param value
- * The value to set for the feature.
- * @throws
- * An exception is thrown if the feature is not recognized.
- */
- public void setFeature(String feature, int value) throws Exception
- {
- if(INDICATE_NO_GRAMMAR.equals(feature))
- indicate_no_grammar_value = value;
- else if (INDICATE_NO_DOCUMENT_ELEMENT.equals(feature))
- indicate_no_document_value = value;
- else
- throw new IllegalArgumentException("Feature not recognized."); //$NON-NLS-1$
-
- }
-
-
- /**
- * Get the value for a given feature. If the feature is not defined
- * this method will throw an exception.
- *
- * @param feature
- * The feature for which to retrieve the value.
- * @return
- * The feature's value, true or false.
- * @throws
- * An exception is thrown if the feature is not recognized.
- */
- public boolean getFeature(String feature) throws Exception
- {
- if(WARN_NO_GRAMMAR.equals(feature))
- return warn_no_grammar_value;
- else if(USE_XINCLUDE.equals(feature))
- return use_xinclude;
- if(HONOUR_ALL_SCHEMA_LOCATIONS.equals(feature))
- return honour_all_schema_locations_value;
-
- throw new Exception("Feature not recognized."); //$NON-NLS-1$
- }
-
- /**
- * Get the value for a given feature. If the feature is not defined
- * this method will throw an exception.
- *
- * @param feature
- * The feature for which to retrieve the value.
- * @return
- * The feature's value, true or false.
- * @throws
- * An exception is thrown if the feature is not recognized.
- */
- public int getIntFeature(String feature) throws Exception
- {
- if(INDICATE_NO_GRAMMAR.equals(feature))
- return indicate_no_grammar_value;
- else if (INDICATE_NO_DOCUMENT_ELEMENT.equals(feature))
- return indicate_no_document_value;
-
- throw new IllegalArgumentException("Feature not recognized."); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationInfo.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationInfo.java
deleted file mode 100644
index 1113eb9e1d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationInfo.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation;
-
-import java.util.Stack;
-
-import org.apache.xerces.xni.XMLLocator;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationInfo;
-import org.eclipse.wst.xml.core.internal.validation.errorcustomization.ErrorCustomizationManager;
-
-
-/**
- * A validation information object specific to XML validators.
- */
-public class XMLValidationInfo extends ValidationInfo implements XMLValidationReport
-{
- protected boolean grammarEncountered = false;
- protected boolean dtdEncountered = false;
- protected boolean namespaceEncountered = false;
- protected int elementDeclCount = 0;
- protected String currentErrorKey;
- protected Object messageArguments[] = null;
- protected XMLLocator locator = null;
- protected ErrorCustomizationManager errorCustomizationManager = null;
-
- /**
- * A stack of start tag locations, used to move errors
- * reported at the close tag to be reported at the start tag.
- */
- protected Stack startElementLocations = new Stack();
-
- /**
- * Constructor.
- *
- * @param uri The URI of the file this report describes.
- */
- public XMLValidationInfo(String uri)
- {
- super(uri);
- }
-
- public boolean isGrammarEncountered()
- {
- return grammarEncountered;
- }
-
- /**
- * Set whether a grammar has been encountered or not.
- *
- * @param grammarEncountered Set true if a grammar has been encountered, false otherwise.
- */
- public void setGrammarEncountered(boolean grammarEncountered)
- {
- this.grammarEncountered = grammarEncountered;
- }
-
- public boolean isDTDWithoutElementDeclarationEncountered()
- {
- return dtdEncountered && elementDeclCount == 0;
- }
-
- /**
- * Set whether a DTD without an element declaration was encountered.
- *
- * @param dtdWithoutElementDeclarationEncountered Set true if a DTD without an
- * element declaration was encountered, false otherwise.
- */
- public void setDTDEncountered(boolean dtdEncountered)
- {
- this.dtdEncountered = dtdEncountered;
- }
-
- public boolean isNamespaceEncountered()
- {
- return namespaceEncountered;
- }
-
- /**
- * Set whether a namespace was encountered.
- *
- * @param namespaceEncountered Set true if a namespace was encountered, false otherwise.
- */
- public void setNamespaceEncountered(boolean namespaceEncountered)
- {
- this.namespaceEncountered = namespaceEncountered;
- }
-
- /**
- * Increase the element declaration count for DTD elements by one.
- */
- public void increaseElementDeclarationCount()
- {
- this.elementDeclCount++;
- }
-
- /**
- * Set the number of DTD elements encountered.
- *
- * @param count The number of DTD elements encountered.
- */
- public void setElementDeclarationCount(int count)
- {
- elementDeclCount = count;
- }
-
- /**
- * Get the XML locator if one has been specified.
- *
- * @return The XML locator if one has been specified or null.
- */
- public XMLLocator getXMLLocator()
- {
- return locator;
- }
-
- /**
- * Set the XMLLocator.
- *
- * @param locator The XMLLocator to set.
- */
- public void setXMLLocator(XMLLocator locator)
- {
- this.locator = locator;
- }
-
- /**
- * Get the current error key.
- *
- * @return Returns the currentErrorKey.
- */
- public String getCurrentErrorKey()
- {
- return currentErrorKey;
- }
-
- /**
- * Set the current error key.
- *
- * @param currentErrorKey The currentErrorKey to set.
- */
- public void setCurrentErrorKey(String currentErrorKey)
- {
- this.currentErrorKey = currentErrorKey;
- }
-
-public Object[] getMessageArguments() {
- return messageArguments;
-}
-
-
-public void setMessageArguments(Object[] messageArguments) {
- this.messageArguments = messageArguments;
-}
-
- /**
- * Get the start elements locations.
- *
- * @return
- * A stack containing the start element locations.
- */
- protected Stack getStartElementLocations()
- {
- return startElementLocations;
- }
-
- /**
- * Get the error customization manager for this validation run.
- *
- * @return
- * The error customization manager for this validation run.
- */
- protected ErrorCustomizationManager getErrorCustomizationManager()
- {
- if(errorCustomizationManager == null)
- {
- errorCustomizationManager = new ErrorCustomizationManager();
- }
- return errorCustomizationManager;
- }
-
- /**
- * @deprecated Use {@link XMLValidationConfiguration} instead.
- */
- public boolean isUseXInclude() {
- return XMLCorePlugin.getDefault().getPluginPreferences().getBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationMessages.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationMessages.java
deleted file mode 100644
index bf6887460c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationMessages.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML Validation
- */
-public class XMLValidationMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.core.internal.validation.xmlvalidation";//$NON-NLS-1$
-
- public static String _UI_PROBLEMS_VALIDATING_UNKNOWN_HOST;
- public static String _UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND;
- public static String _UI_PROBLEMS_CONNECTION_REFUSED;
- public static String _UI_REF_FILE_ERROR_MESSAGE;
- public static String _WARN_NO_GRAMMAR;
- public static String _NO_DOCUMENT_ELEMENT;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLValidationMessages.class);
- }
-
- private XMLValidationMessages() {
- // cannot create new instance
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationReport.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationReport.java
deleted file mode 100644
index 5a4f1f641c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidationReport.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation;
-
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
-
-/**
- * An interface represention a validation report for XML validation.
- *
- * @author Lawrence Mandel, IBM
- */
-public interface XMLValidationReport extends ValidationReport
-{
-
- /**
- * Returns whether a grammar was encountered during the validation.
- *
- * @return True if a grammar was encountered, false otherwise.
- */
- public boolean isGrammarEncountered();
-
- /**
- * Returns whether a namespace was encountered.
- *
- * @return True if a namespace was encountered, false otherwise.
- */
- public boolean isNamespaceEncountered();
-
- /**
- * Returns whether a DTD without element declarations was encountered.
- *
- * @return True if a DTD without element declarations was encountered.
- */
- public boolean isDTDWithoutElementDeclarationEncountered();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java
deleted file mode 100644
index 4277255285..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/XMLValidator.java
+++ /dev/null
@@ -1,930 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.net.ConnectException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.xerces.impl.XMLErrorReporter;
-import org.apache.xerces.impl.msg.XMLMessageFormatter;
-import org.apache.xerces.parsers.XIncludeAwareParserConfiguration;
-import org.apache.xerces.xni.Augmentations;
-import org.apache.xerces.xni.NamespaceContext;
-import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLLocator;
-import org.apache.xerces.xni.XMLResourceIdentifier;
-import org.apache.xerces.xni.XNIException;
-import org.apache.xerces.xni.parser.XMLEntityResolver;
-import org.apache.xerces.xni.parser.XMLInputSource;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.internal.ValOperation;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.IExternalSchemaLocationProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ExternalSchemaLocationProviderRegistry;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream;
-import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.DeclHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * This class performs validation using a xerces sax parser.
- * Here's a quick overview of the details :
- * - an ErrorHandler is used to collect errors into a list (so they may be displayed by the UI)
- * - an EntityResolver is used along with the xerces "external-schemaLocation" property to implement XML Catalog support
- */
-public class XMLValidator
-{
- protected URIResolver uriResolver = null;
- protected Hashtable ingoredErrorKeyTable = new Hashtable();
- protected Set adjustLocationErrorKeySet = new TreeSet();
-
- protected static final String IGNORE_ALWAYS = "IGNORE_ALWAYS"; //$NON-NLS-1$
- protected static final String IGNORE_IF_DTD_WITHOUT_ELEMENT_DECL = "IGNORE_IF_DTD_WITHOUT_ELEMENT_DECL"; //$NON-NLS-1$
- protected static final String PREMATURE_EOF = "PrematureEOF"; //$NON-NLS-1$
- protected static final String ROOT_ELEMENT_TYPE_MUST_MATCH_DOCTYPEDECL = "RootElementTypeMustMatchDoctypedecl"; //$NON-NLS-1$
- protected static final String MSG_ELEMENT_NOT_DECLARED = "MSG_ELEMENT_NOT_DECLARED"; //$NON-NLS-1$
-
- // WTP XML validator specific key.
- protected static final String NO_GRAMMAR_FOUND = "NO_GRAMMAR_FOUND"; //$NON-NLS-1$
- protected static final String NO_DOCUMENT_ELEMENT_FOUND = "NO_DOCUMENT_ELEMENT_FOUND"; //$NON-NLS-1$
-
- private static final String FILE_NOT_FOUND_KEY = "FILE_NOT_FOUND"; //$NON-NLS-1$
-
- private MarkupValidator val = new MarkupValidator();
-
- private final String ANNOTATIONMSG = AnnotationMsg.class.getName();
-
- private final static boolean _trace = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.xml.core/externalSchemaLocation")).booleanValue(); //$NON-NLS-1$
- /**
- * Constructor.
- */
- public XMLValidator()
- {
- // Here we add some error keys that we need to filter out when we're validation
- // against a DTD without any element declarations.
- ingoredErrorKeyTable.put(PREMATURE_EOF, IGNORE_ALWAYS);
- ingoredErrorKeyTable.put(ROOT_ELEMENT_TYPE_MUST_MATCH_DOCTYPEDECL, IGNORE_IF_DTD_WITHOUT_ELEMENT_DECL);
- ingoredErrorKeyTable.put(MSG_ELEMENT_NOT_DECLARED, IGNORE_IF_DTD_WITHOUT_ELEMENT_DECL);
-
- // Here we add some error keys that we need to adjust the location information for.
- // The location information will be adjusted to place the message on the line of the starting
- // element instead of on the line of the closing element.
- adjustLocationErrorKeySet.add("MSG_CONTENT_INVALID"); //$NON-NLS-1$
- adjustLocationErrorKeySet.add("MSG_CONTENT_INCOMPLETE"); //$NON-NLS-1$
- adjustLocationErrorKeySet.add("cvc-complex-type.2.4.b"); //$NON-NLS-1$
- adjustLocationErrorKeySet.add("cvc-complex-type.2.3"); //$NON-NLS-1$
- }
-
- /**
- * Set the URI Resolver to use.
- *
- * @param uriResolver The URI Resolver to use.
- */
- public void setURIResolver(URIResolver uriResolver)
- {
- this.uriResolver = uriResolver;
- //entityResolver = new MyEntityResolver(uriResolver);
- }
-
-
- /**
- * Create an XML Reader.
- *
- * @return The newly created XML reader or null if unsuccessful.
- * @throws Exception
- */
- protected XMLReader createXMLReader(final XMLValidationInfo valinfo, XMLEntityResolver entityResolver) throws Exception
- {
- XMLReader reader = null;
- // move to Xerces-2... add the contextClassLoader stuff
- ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- MyStandardParserConfiguration configuration = new MyStandardParserConfiguration(valinfo);
- reader = new org.apache.xerces.parsers.SAXParser(configuration)
- {
- private XMLLocator locator = null;
-
- /* (non-Javadoc)
- * @see org.apache.xerces.parsers.AbstractSAXParser#startDocument(org.apache.xerces.xni.XMLLocator, java.lang.String, org.apache.xerces.xni.NamespaceContext, org.apache.xerces.xni.Augmentations)
- */
- public void startDocument(org.apache.xerces.xni.XMLLocator theLocator, java.lang.String encoding, NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs)
- {
- locator = theLocator;
- valinfo.setXMLLocator(theLocator);
- super.startDocument(theLocator, encoding, nscontext, augs);
- }
-
- /* (non-Javadoc)
- * @see org.apache.xerces.parsers.AbstractSAXParser#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
- */
- public void startElement(QName arg0, XMLAttributes arg1, Augmentations arg2) throws XNIException
- {
- valinfo.getStartElementLocations().push(new LocationCoordinate(locator.getLineNumber(), locator.getColumnNumber()));
- super.startElement(arg0, arg1, arg2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.xerces.parsers.AbstractSAXParser#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
- */
- public void endElement(QName arg0, Augmentations arg1) throws XNIException {
- super.endElement(arg0, arg1);
- valinfo.getStartElementLocations().pop();
- }
- };
-
- reader.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false); //$NON-NLS-1$
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes", valinfo.isNamespaceEncountered()); //$NON-NLS-1$
- reader.setFeature("http://xml.org/sax/features/namespaces", valinfo.isNamespaceEncountered()); //$NON-NLS-1$
-
- reader.setContentHandler(new DefaultHandler()
- {
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- valinfo.getErrorCustomizationManager().startElement(uri, localName);
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- valinfo.getErrorCustomizationManager().endElement(uri, localName);
- }
- });
-
- // MH make sure validation works even when a customer entityResolver is note set (i.e. via setURIResolver())
- if (entityResolver != null)
- {
- reader.setProperty("http://apache.org/xml/properties/internal/entity-resolver", entityResolver); //$NON-NLS-1$
- }
- reader.setProperty("http://xml.org/sax/properties/declaration-handler", new MyDeclHandler()); //$NON-NLS-1$
- }
- catch(Exception e)
- {
- Logger.logException(e);
- //e.printStackTrace();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(prevClassLoader);
- }
- return reader;
- }
-
- /**
- * Validate the file located at the given URI.
- *
- * @param uri The URI of the file to validate.
- * @return Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri)
- {
- return validate(uri, null, new XMLValidationConfiguration());
- }
-
- final String createStringForInputStream(InputStream inputStream)
- {
- // Here we are reading the file and storing to a stringbuffer.
- StringBuffer fileString = new StringBuffer();
- try
- {
- InputStreamReader inputReader = new InputStreamReader(inputStream, "UTF-8"); //$NON-NLS-1$
- BufferedReader reader = new BufferedReader(inputReader);
- char[] chars = new char[1024];
- int numberRead = reader.read(chars);
- while (numberRead != -1)
- {
- fileString.append(chars, 0, numberRead);
- numberRead = reader.read(chars);
- }
- }
- catch (Exception e)
- {
- //TODO: log error message
- //e.printStackTrace();
- }
- return fileString.toString();
- }
- /**
- * Validate the inputStream
- *
- * @param uri The URI of the file to validate.
- * @param the inputStream of the file to validate
- * @return Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream)
- {
- return validate(uri, inputStream, new XMLValidationConfiguration());
- }
- /**
- * Validate the inputStream
- *
- * @param uri
- * The URI of the file to validate.
- * @param inputstream
- * The inputStream of the file to validate
- * @param configuration
- * A configuration for this validation session.
- * @return
- * Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream, XMLValidationConfiguration configuration)
- {
- return validate(uri, inputStream, configuration, null);
- }
-
- /**
- * Validate the inputStream
- *
- * @param uri
- * The URI of the file to validate.
- * @param inputstream
- * The inputStream of the file to validate
- * @param configuration
- * A configuration for this validation session.
- * @param result
- * The validation result
- * @return
- * Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream, XMLValidationConfiguration configuration, ValidationResult result)
- {
- return validate(uri, inputStream, configuration, null, null);
- }
-
- /**
- * Validate the inputStream
- *
- * @param uri
- * The URI of the file to validate.
- * @param inputstream
- * The inputStream of the file to validate
- * @param configuration
- * A configuration for this validation session.
- * @param result
- * The validation result
- * @param context
- * The validation context
- * @return
- * Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream, XMLValidationConfiguration configuration, ValidationResult result, NestedValidatorContext context)
- {
- String grammarFile = ""; //$NON-NLS-1$
- Reader reader1 = null; // Used for the preparse.
- Reader reader2 = null; // Used for validation parse.
-
- if (inputStream != null)
- {
- String string = createStringForInputStream(inputStream);
- reader1 = new StringReader(string);
- reader2 = new StringReader(string);
- }
-
- XMLValidationInfo valinfo = new XMLValidationInfo(uri);
- MyEntityResolver entityResolver = new MyEntityResolver(uriResolver, context);
- ValidatorHelper helper = new ValidatorHelper();
- try
- {
- helper.computeValidationInformation(uri, reader1, uriResolver);
- valinfo.setDTDEncountered(helper.isDTDEncountered);
- valinfo.setElementDeclarationCount(helper.numDTDElements);
- valinfo.setNamespaceEncountered(helper.isNamespaceEncountered);
- valinfo.setGrammarEncountered(helper.isGrammarEncountered);
- XMLReader reader = createXMLReader(valinfo, entityResolver);
- // Set the configuration option
- if (configuration.getFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS))
- {
- reader.setFeature("http://apache.org/xml/features/honour-all-schemaLocations", true); //$NON-NLS-1$
- }
- if (configuration.getFeature(XMLValidationConfiguration.USE_XINCLUDE))
- {
- reader.setFeature("http://apache.org/xml/features/xinclude", true); //$NON-NLS-1$
- }
-
- // Support external schema locations
- boolean isGrammarEncountered = helper.isGrammarEncountered;
- if (!isGrammarEncountered) {
- isGrammarEncountered = checkExternalSchemas(reader, valinfo.getFileURI());
- }
- reader.setFeature("http://xml.org/sax/features/validation", isGrammarEncountered); //$NON-NLS-1$
- reader.setFeature("http://apache.org/xml/features/validation/schema", isGrammarEncountered); //$NON-NLS-1$
-
- XMLErrorHandler errorhandler = new XMLErrorHandler(valinfo);
- reader.setErrorHandler(errorhandler);
-
- InputSource inputSource = new InputSource(uri);
- inputSource.setCharacterStream(reader2);
- reader.parse(inputSource);
- if(configuration.getIntFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR) > 0 &&
- valinfo.isValid() && !isGrammarEncountered)
- {
- if(configuration.getIntFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR) == 1)
- valinfo.addWarning(XMLValidationMessages._WARN_NO_GRAMMAR, 1, 0, uri, NO_GRAMMAR_FOUND, null);
- else // 2
- valinfo.addError(XMLValidationMessages._WARN_NO_GRAMMAR, 1, 0, uri, NO_GRAMMAR_FOUND, null);
- }
- if(configuration.getIntFeature(XMLValidationConfiguration.INDICATE_NO_DOCUMENT_ELEMENT) > 0 && valinfo.isValid() && !helper.isDocumentElementEncountered) {
- if(configuration.getIntFeature(XMLValidationConfiguration.INDICATE_NO_DOCUMENT_ELEMENT) == 1)
- valinfo.addWarning(XMLValidationMessages._NO_DOCUMENT_ELEMENT, 1, 0, uri, NO_DOCUMENT_ELEMENT_FOUND, null);
- else // 2
- valinfo.addError(XMLValidationMessages._NO_DOCUMENT_ELEMENT, 1, 0, uri, NO_DOCUMENT_ELEMENT_FOUND, null);
- }
- if (helper.isDTDEncountered)
- grammarFile = entityResolver.getLocation();
- else
- grammarFile = helper.schemaLocationString;
- }
- catch (SAXParseException saxParseException)
- {
- // These errors are caught by the error handler.
- //addValidationMessage(valinfo, saxParseException);
- }
- catch (IOException ioException)
- {
- addValidationMessage(valinfo, ioException);
- }
- catch (Exception exception)
- {
- Logger.logException(exception.getLocalizedMessage(), exception);
- }
-
- // Now set up the dependencies
- // Wrap with try catch so that if something wrong happens, validation can
- // still proceed as before
- if (result != null)
- {
- try
- {
- IResource resource = getWorkspaceFileFromLocation(grammarFile);
- ArrayList resources = new ArrayList();
- if (resource != null)
- resources.add(resource);
- result.setDependsOn((IResource [])resources.toArray(new IResource [0]));
- }
- catch (Exception e)
- {
- Logger.logException(e.getLocalizedMessage(), e);
- }
- }
-
- if ( XMLCorePlugin.getDefault().getPluginPreferences().getBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION)){
- IReporter reporter = executeMarkupValidator(uri);
- if (reporter != null){
- List msgList = reporter.getMessages();
- for (int i = 0;i < msgList.size();i++){
- LocalizedMessage msg = (LocalizedMessage)msgList.get(i);
- if (msg.getSeverity() == 2)
- valinfo.addError(msg.getLocalizedMessage(), msg.getLineNumber(), msg.getOffset(),valinfo.getFileURI(),"null",getMsgArguments(msg) ); //$NON-NLS-1$
- else if (msg.getSeverity() == 1)
- valinfo.addWarning(msg.getLocalizedMessage(), msg.getLineNumber(), msg.getOffset(),valinfo.getFileURI(),"null", getMsgArguments(msg)); //$NON-NLS-1$
- }
- }
- }
-
- return valinfo;
-
- }
-
- private boolean checkExternalSchemas(XMLReader reader, String fileURI) throws Exception {
- boolean isGrammarEncountered = false;
- final StringBuffer schemaLocation = new StringBuffer();
- String noNamespaceSchemaLocation = null;
- // Check the schema provider extension point
- IExternalSchemaLocationProvider[] providers = ExternalSchemaLocationProviderRegistry.getInstance().getProviders();
- for (int i = 0; i < providers.length; i++) {
- URI uri = null;
- try {
- uri = URIUtil.fromString(fileURI);
- }
- catch (URISyntaxException e) {
- Logger.logException(e.getLocalizedMessage(), e);
- }
- if (uri != null) {
- long time = _trace ? System.currentTimeMillis(): 0;
- final Map locations = providers[i].getExternalSchemaLocation(uri);
- if (_trace) {
- long diff = System.currentTimeMillis() - time;
- if (diff > 250)
- Logger.log(Logger.INFO, "Schema location provider took [" + diff + "ms] for URI [" + fileURI + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- if (locations != null && !locations.isEmpty()) {
- Object path = locations.get(IExternalSchemaLocationProvider.SCHEMA_LOCATION);
- if (path instanceof String) {
- if (schemaLocation.length() > 0) {
- schemaLocation.append(' ');
- }
- schemaLocation.append(path);
- }
- path = locations.get(IExternalSchemaLocationProvider.NO_NAMESPACE_SCHEMA_LOCATION);
- if (path instanceof String) {
- noNamespaceSchemaLocation = (String)path;
- }
- }
- }
- }
-
- if (schemaLocation.length() > 0) {
- reader.setProperty(IExternalSchemaLocationProvider.SCHEMA_LOCATION, schemaLocation.toString());
- isGrammarEncountered = true;
- }
- if (noNamespaceSchemaLocation != null) {
- reader.setProperty(IExternalSchemaLocationProvider.NO_NAMESPACE_SCHEMA_LOCATION, noNamespaceSchemaLocation);
- isGrammarEncountered = true;
- }
- return isGrammarEncountered;
- }
-
- private Object[] getMsgArguments(LocalizedMessage msg){
- Object obj = msg.getAttribute(ANNOTATIONMSG);
- return new Object[]{obj};
- }
-
-
- private IReporter executeMarkupValidator(String uri){
- Path path = new Path(uri);
- String fileProtocol = "file://"; //$NON-NLS-1$
- int index = uri.indexOf(fileProtocol);
-
- IFile resource = null;
- if (index == 0){
- String transformedUri = uri.substring(fileProtocol.length());
- Path transformedPath = new Path(transformedUri);
- resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(transformedPath);
- }
- else {
- resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
-
- }
- IReporter reporter = null;
- if (resource != null){
- reporter = val.validate(resource, 0, new ValOperation().getState()) ;
- }
- return reporter;
- }
-
- /**
- * Add a validation message to the specified list.
- *
- * @param valinfo The validation info object to add the error to.
- * @param exception The exception that contains the validation information.
- */
- protected void addValidationMessage(XMLValidationInfo valinfo, IOException exception)
- {
- String validationMessageStr = exception.getMessage();
- Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
- while(validationMessageStr == null && cause != null){
- String localizedMessage = cause.getLocalizedMessage();
- cause = cause.getCause();
- if(cause == null && localizedMessage != null )
- {
- validationMessageStr = localizedMessage;
- }
- }
-
- if (validationMessageStr != null)
- {
- if (cause instanceof FileNotFoundException)
- {
- validationMessageStr = NLS.bind(XMLValidationMessages._UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND, new Object [] { validationMessageStr });
- }
- else if (cause instanceof UnknownHostException)
- {
- validationMessageStr = NLS.bind(XMLValidationMessages._UI_PROBLEMS_VALIDATING_UNKNOWN_HOST, new Object [] { validationMessageStr });
- }
- else if(cause instanceof ConnectException)
- {
- validationMessageStr = XMLValidationMessages._UI_PROBLEMS_CONNECTION_REFUSED;
- }
- }
-
- if (validationMessageStr != null)
- {
- XMLLocator locator = valinfo.getXMLLocator();
- valinfo.addWarning(validationMessageStr, locator != null ? locator.getLineNumber() : 1, locator != null ? locator.getColumnNumber() : 0, valinfo.getFileURI(), FILE_NOT_FOUND_KEY, null);
- }
- }
-
- /**
- * Add a validation message to the specified list.
- *
- * @param valinfo The validation info object to add the error to.
- * @param exception The exception that contains the validation information.
- */
- protected void addValidationMessage(XMLValidationInfo valinfo, SAXParseException exception)
- {
- if (exception.getMessage() != null)
- {
- valinfo.addError(exception.getLocalizedMessage(), exception.getLineNumber(), exception.getColumnNumber(), exception.getSystemId());
- }
- }
-
-
- /**
- * A custom entity resolver that uses the URI resolver specified to resolve entities.
- */
- protected class MyEntityResolver implements XMLEntityResolver
- {
- private URIResolver uriResolver;
- private String resolvedDTDLocation;
- private NestedValidatorContext context;
-
- /**
- * Constructor.
- *
- * @param uriResolver The URI resolver to use with this entity resolver.
- * @param context The XML validator context.
- */
- public MyEntityResolver(URIResolver uriResolver, NestedValidatorContext context)
- {
- this.uriResolver = uriResolver;
- this.context = context;
- }
-
- /* (non-Javadoc)
- * @see org.apache.xerces.xni.parser.XMLEntityResolver#resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier)
- */
- public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIException, IOException
- {
- XMLInputSource inputSource = _internalResolveEntity(uriResolver, rid, context);
- if (inputSource != null)
- {
- resolvedDTDLocation = inputSource.getSystemId();
- }
- return inputSource;
- }
-
- public String getLocation()
- {
- return resolvedDTDLocation;
- }
- }
-
- // cs : I've refactored the common SAX based resolution code into this method for use by other validators
- // (i.e. XML Schema, WSDL etc). The other approach is maintain a copy for each validator that has
- // identical code. In any case we should strive to ensure that the validators perform resolution consistently.
- public static XMLInputSource _internalResolveEntity(URIResolver uriResolver, XMLResourceIdentifier rid) throws IOException
- {
- return _internalResolveEntity(uriResolver, rid, null);
- }
-
- public static XMLInputSource _internalResolveEntity(URIResolver uriResolver, XMLResourceIdentifier rid, NestedValidatorContext context) throws IOException
- {
- XMLInputSource is = null;
-
- if (uriResolver != null)
- {
- String id = rid.getPublicId();
- if(id == null)
- {
- id = rid.getNamespace();
- }
-
- String location = null;
- if (id != null || rid.getLiteralSystemId() != null)
- {
- location = uriResolver.resolve(rid.getBaseSystemId(), id, rid.getLiteralSystemId());
- }
-
- if (location != null)
- {
- String physical = uriResolver.resolvePhysicalLocation(rid.getBaseSystemId(), id, location);
-
- // if physical is already a known bad uri, just go ahead and throw an exception
- if (context instanceof XMLNestedValidatorContext)
- {
- XMLNestedValidatorContext xmlContext = ((XMLNestedValidatorContext)context);
-
- if (xmlContext.isURIMarkedInaccessible(physical))
- {
- throw new FileNotFoundException(physical);
- }
- }
-
- is = new XMLInputSource(rid.getPublicId(), location, location);
-
- // This block checks that the file exists. If it doesn't we need to throw
- // an exception so Xerces will report an error. note: This may not be
- // necessary with all versions of Xerces but has specifically been
- // experienced with the version included in IBM's 1.4.2 JDK.
- InputStream isTemp = null;
- try
- {
- isTemp = new URL(physical).openStream();
- }
- catch (IOException e)
- {
- // physical was a bad url, so cache it so we know next time
- if (context instanceof XMLNestedValidatorContext)
- {
- XMLNestedValidatorContext xmlContext = ((XMLNestedValidatorContext)context);
- xmlContext.markURIInaccessible(physical);
- }
- throw e;
- }
- finally
- {
- if(isTemp != null)
- {
- isTemp.close();
- }
- }
- is.setByteStream(new LazyURLInputStream(physical));
- }
- }
- return is;
- }
-
- /**
- * An error handler to catch errors encountered while parsing the XML document.
- */
- protected class XMLErrorHandler implements org.xml.sax.ErrorHandler
- {
-
- private final int ERROR = 0;
- private final int WARNING = 1;
- private XMLValidationInfo valinfo;
-
- /**
- * Constructor.
- *
- * @param valinfo The XML validation info object that will hold the validation messages.
- */
- public XMLErrorHandler(XMLValidationInfo valinfo)
- {
- this.valinfo = valinfo;
- }
-
- /**
- * Add a validation message with the given severity.
- *
- * @param exception The exception that contains the message.
- * @param severity The severity of the message.
- */
-
- protected void addValidationMessage(SAXParseException exception, int severity)
- {
- if(exception.getSystemId() != null)
- {
- int lineNumber = exception.getLineNumber();
- int columnNumber = exception.getColumnNumber();
-
- // For the following three errors the line number will be modified to use that of the start
- // tag instead of the end tag. Unless its a self ending tag and in that case the startElementLocations will be empty
- String currentErrorKey = valinfo.currentErrorKey;
- if (currentErrorKey != null && adjustLocationErrorKeySet.contains(currentErrorKey) && valinfo.getStartElementLocations().size() > 0)
- {
- LocationCoordinate adjustedCoordinates = (LocationCoordinate)valinfo.getStartElementLocations().peek();
- lineNumber = adjustedCoordinates.getLineNumber();
- columnNumber = adjustedCoordinates.getColumnNumner();
- }
-
- if(severity == WARNING)
- {
- valinfo.addWarning(exception.getLocalizedMessage(), lineNumber, columnNumber, exception.getSystemId());
- }
- else
- {
- valinfo.addError(exception.getLocalizedMessage(), lineNumber, columnNumber, exception.getSystemId(), valinfo.getCurrentErrorKey(), valinfo.getMessageArguments());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
- */
- public void error(SAXParseException exception) throws SAXException
- {
- addValidationMessage(exception, ERROR);
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
- */
- public void fatalError(SAXParseException exception) throws SAXException
- {
- addValidationMessage(exception, ERROR);
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
- */
- public void warning(SAXParseException exception) throws SAXException
- {
- addValidationMessage(exception, WARNING);
- }
- }
-
- /**
- * This class is used to count the elementDecls that are encountered in a DTD.
- */
- protected class MyDeclHandler implements DeclHandler
- {
-
- /**
- * Constructor.
- *
- * @param valinfo The XMLValidationInfo object that will count the declarations.
- */
- public MyDeclHandler()
- {
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
- {
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
- */
- public void elementDecl(String name, String model)
- {
- //valinfo.increaseElementDeclarationCount();
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- public void externalEntityDecl(String name, String publicId, String systemId)
- {
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(java.lang.String, java.lang.String)
- */
- public void internalEntityDecl(String name, String value)
- {
- }
- }
-
- /**
- * A XIncludeAwareParserConfiguration that creates an error reporter which can ignore
- * DTD error messages for DTD's with no elements defined.
- */
-
- protected class MyStandardParserConfiguration extends XIncludeAwareParserConfiguration
- {
- XMLValidationInfo valinfo = null;
- List reportedExceptions = new ArrayList();
-
- /**
- * Constructor.
- *
- * @param valinfo The XMLValidationInfo object to use.
- */
- public MyStandardParserConfiguration(XMLValidationInfo valinfo)
- {
- this.valinfo = valinfo;
-
- XMLErrorReporter errorReporter = createErrorReporter();
- if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
- XMLMessageFormatter xmft = new XMLMessageFormatter();
- errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
- errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
- }
- fErrorReporter = errorReporter;
- setProperty(ERROR_REPORTER, errorReporter);
- fCommonComponents.remove(fErrorReporter);
- fCommonComponents.add(fErrorReporter);
- }
-
- /* (non-Javadoc)
- * @see org.apache.xerces.parsers.DTDConfiguration#createErrorReporter()
- */
- protected XMLErrorReporter createErrorReporter()
- {
- return new XMLErrorReporter()
- {
- /* (non-Javadoc)
- * @see org.apache.xerces.impl.XMLErrorReporter#reportError(java.lang.String, java.lang.String, java.lang.Object[], short)
- */
- public void reportError(String domain, String key, Object[] arguments, short severity) throws XNIException
- {
- boolean reportError = true;
- valinfo.setCurrentErrorKey(key);
- valinfo.setMessageArguments(arguments);
- String ignoreCondition = (String)ingoredErrorKeyTable.get(key);
- if (ignoreCondition != null)
- {
- if (ignoreCondition.equals(XMLValidator.IGNORE_IF_DTD_WITHOUT_ELEMENT_DECL))
- {
- boolean isDTDWithoutElementDeclarationEncountered = valinfo.isDTDWithoutElementDeclarationEncountered();
- reportError = !isDTDWithoutElementDeclarationEncountered;
- }
- else
- {
- reportError = false;
- }
- }
- if ("schema_reference.4".equals(key) && arguments.length > 0) //$NON-NLS-1$
- {
- Object location = arguments[0];
- if (location != null)
- {
- if(reportedExceptions.contains(location))
- {
- reportError = false;
- }
- else
- {
- reportedExceptions.add(location);
- }
- }
- }
- if (reportError)
- {
- super.reportError(domain, key, arguments, severity);
- valinfo.getErrorCustomizationManager().considerReportedError(valinfo, key, arguments);
- }
- }
- };
- }
- }
-
- /**
- * A line and column number coordinate.
- */
- protected class LocationCoordinate
- {
- private int lineNo = -1;
- private int columnNo = -1;
-
- public LocationCoordinate(int lineNumber, int columnNumber)
- {
- this.lineNo = lineNumber;
- this.columnNo = columnNumber;
- }
-
- public int getLineNumber()
- {
- return this.lineNo;
- }
-
- public int getColumnNumner()
- {
- return this.columnNo;
- }
- }
-
- protected IResource getWorkspaceFileFromLocation(String location)
- {
- if (location == null) return null;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- // To canonicalize the EMF URI
- IPath canonicalForm = new Path(location);
- // Need to convert to absolute location...
- IPath pathLocation = new Path(URIHelper.removeProtocol(canonicalForm.toString()));
- // ...to find the resource file that is in the workspace
- IResource resourceFile = workspace.getRoot().getFileForLocation(pathLocation);
- // If the resource is resolved to a file from http, or a file outside
- // the workspace, then we will just ignore it.
- return resourceFile;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
deleted file mode 100644
index f3a4da8801..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
+++ /dev/null
@@ -1,543 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
-import org.eclipse.wst.xml.core.internal.validation.AnnotationMsg;
-
-/**
- * An abstract validator that assists validators in running and contributing
- * nested messages in the validation results.
- * *note: Subclasses do not need to contribute nested messages in order to
- * benefit from the use of this class. This class takes care of iterating
- * through results for validators that use the standard context.
- */
-public abstract class AbstractNestedValidator extends AbstractValidator implements IValidatorJob
-{
- // Locally used, non-UI strings.
- private static final String REFERENCED_FILE_ERROR_OPEN = "referencedFileError("; //$NON-NLS-1$
- private static final String REFERENCED_FILE_ERROR_CLOSE = ")"; //$NON-NLS-1$
- private static final String FILE_PROTOCOL_NO_SLASH = "file:"; //$NON-NLS-1$
- private static final String FILE_PROTOCOL = "file:///"; //$NON-NLS-1$
- private final String GET_FILE = "getFile"; //$NON-NLS-1$
- private final String GET_PROJECT_FILES = "getAllFiles"; //$NON-NLS-1$
- private final String GET_INPUTSTREAM = "inputStream"; //$NON-NLS-1$
-
- // Internal strings. These strings are common addition information types.
- protected static final String COLUMN_NUMBER_ATTRIBUTE = "columnNumber"; //$NON-NLS-1$
- protected static final String SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE = "squiggleSelectionStrategy"; //$NON-NLS-1$
- protected static final String SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE = "squiggleNameOrValue"; //$NON-NLS-1$
-
- /**
- * Perform the validation using version 2 of the validation framework.
- */
- public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor){
- ValidationResult result = new ValidationResult();
- IReporter reporter = result.getReporter(monitor);
- IFile file = null;
- if (resource instanceof IFile)file = (IFile)resource;
- if (file != null)
- {
- NestedValidatorContext nestedcontext = getNestedContext(state, false);
- boolean teardownRequired = false;
- if (nestedcontext == null)
- {
- // validationstart was not called, so manually setup and tear down
- nestedcontext = getNestedContext(state, true);
- nestedcontext.setProject(file.getProject());
- setupValidation(nestedcontext);
- teardownRequired = true;
- }
- else {
- nestedcontext.setProject(file.getProject());
- }
- validate(file, null, result, reporter, nestedcontext);
-
- if (teardownRequired)
- teardownValidation(nestedcontext);
- }
- return result;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#validateInJob(org.eclipse.wst.validation.internal.provisional.core.IValidationContext, org.eclipse.wst.validation.internal.provisional.core.IReporter)
- */
- public IStatus validateInJob(IValidationContext context, IReporter reporter) throws ValidationException
- {
- NestedValidatorContext nestedcontext = new NestedValidatorContext();
- setupValidation(nestedcontext);
- String[] fileURIs = context.getURIs();
- if (fileURIs != null && fileURIs.length > 0)
- {
- int numFiles = fileURIs.length;
- for (int i = 0; i < numFiles && !reporter.isCancelled(); i++)
- {
- String fileName = fileURIs[i];
- if (fileName != null)
- {
- Object []parms = {fileName};
-
- IFile file = (IFile) context.loadModel(GET_FILE, parms);
- if (file != null && shouldValidate(file))
- {
- nestedcontext.setProject(file.getProject());
- // The helper may not have a file stored in it but may have an InputStream if being
- // called from a source other than the validation framework such as an editor.
- if (context.loadModel(GET_INPUTSTREAM) instanceof InputStream)
- {
- validate(file, (InputStream)context.loadModel(GET_INPUTSTREAM), null, reporter, nestedcontext); //do we need the fileName? what is int ruleGroup?
- }
- else
- {
- validate(file, null, null, reporter, nestedcontext);
- }
- }
- }
- }
- }
- // TODO: Is this needed? Shouldn't the framework pass the complete list?
- // Should I know that I'm validating a project as opposed to files?
- else
- {
- Object []parms = {getValidatorID()};
- Collection files = (Collection) context.loadModel(GET_PROJECT_FILES, parms);
- // files can be null if they're outside of the workspace
- if (files != null) {
- Iterator iter = files.iterator();
- while (iter.hasNext() && !reporter.isCancelled())
- {
- IFile file = (IFile) iter.next();
- if(shouldValidate(file))
- {
- validate(file, null, null, reporter, nestedcontext);
- }
- }
- }
- }
-
- teardownValidation(nestedcontext);
- if(reporter.isCancelled())
- return Status.CANCEL_STATUS;
- return Status.OK_STATUS;
- }
-
- /**
- * Provides the id of this validator. The ID is used by the validation
- * framework. It usually is the fully qualified class name of the class
- * implementing the IValidator interface.
- *
- * @return a String with the ID of this validator.
- */
- protected String getValidatorID()
- {
- return this.getClass().getName();
- }
-
- /**
- * Perform set up before validation runs. Subclasses may implement this
- * method to perform validation specific set up.
- *
- * @param context
- * The context of the current validation.
- */
- protected void setupValidation(NestedValidatorContext context)
- {
- // Default implementation does nothing.
- }
-
- /**
- * Perform tear down after validation runs. Subclasses may implement this
- * method to perform validation specific tear down.
- *
- * @param context
- * The context of the current validation.
- */
- protected void teardownValidation(NestedValidatorContext context)
- {
- // Default implementation does nothing.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#getSchedulingRule(org.eclipse.wst.validation.internal.provisional.core.IValidationContext)
- */
- public ISchedulingRule getSchedulingRule(IValidationContext arg0)
- {
- // TODO review whether returning a null rule is correct. Gary had a suggestion in the bug report.
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.provisional.core.IValidator#cleanup(org.eclipse.wst.validation.internal.provisional.core.IReporter)
- */
- public void cleanup(IReporter arg0)
- {
- // No cleanup to perform. Subclasses are free to implement this method.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.provisional.core.IValidator#validate(org.eclipse.wst.validation.internal.provisional.core.IValidationContext, org.eclipse.wst.validation.internal.provisional.core.IReporter)
- */
- public void validate(IValidationContext context, IReporter reporter) throws ValidationException
- {
- validateInJob(context, reporter);
- }
-
-
- /**
- * Determine if a given file should be validated.
- *
- * @param file The file that may be validated.
- * @return True if the file should be validated, false otherwise.
- */
- private static boolean shouldValidate(IFile file)
- {
- IResource resource = file;
- do
- {
- if (resource.isDerived() || resource.isTeamPrivateMember() ||
- !resource.isAccessible() || resource.getName().charAt(0) == '.')
- {
- return false;
- }
- resource = resource.getParent();
- }while ((resource.getType() & IResource.PROJECT) == 0);
-
- return true;
- }
-
- /**
- * Validate the given file and use the reporter for the validation messages.
- * This method does not perform the validation logic but rather delegates
- * to the validate method in subclasses to validate. This method is responsible
- * for reporting the messages that result from validation.
- *
- * @param file
- * An IFile to validate.
- * @param inputstream
- * An InputStream that represents the file. The InputStream may be null
- * in which case the files should be validated from the IFile.
- * @param result - The validation result
- * @param reporter
- * The reporter with which to report validation messages.
- * @param context
- * The context of the current validation.
- */
- private void validate(IFile file, InputStream inputstream, ValidationResult result, IReporter reporter, NestedValidatorContext context)
- {
- Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, file.getFullPath().toString());
- reporter.displaySubtask(this, message);
-
- String locationString = null;
- if (file.getLocation() != null) {
- locationString = file.getLocation().toString();
- }
- if (locationString == null && file.getLocationURI() != null) {
- locationString = file.getLocationURI().toString();
- }
- if (locationString == null) {
- locationString = file.getFullPath().toString();
- }
- String uri = createURIForFilePath(locationString);
-
- clearMarkers(file, this, reporter);
-
- ValidationReport valreport = null;
- if (result == null)
- valreport = validate(uri, inputstream, context);
- else
- valreport = validate(uri, inputstream, context, result);
-
- createMarkers(file, valreport.getValidationMessages(), reporter);
-
- try
- {
- file.setSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME, valreport.getNestedMessages());
- }
- catch(CoreException e)
- {
- System.out.println("Unable to set nested messages property."); //$NON-NLS-1$
- }
- }
-
- /**
- * Validate the given file and use the reporter for the validation messages.
- * Clients must implement this method with their specific validation logic.
- *
- * @param uri
- * The URI of the file to validate.
- * @param inputstream
- * An InputStream that represents the file. The InputStream may be null
- * in which case the files should be validated from the IFile.
- * @param context
- * The context of the current validation.
- * @return
- * A validation report summarizing the validation.
- */
- public abstract ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context);
-
- /**
- * Validate the given file and use the reporter for the validation messages.
- * Clients should override this method with their specific validation logic.
- * This method should now be used instead of the abstract version.
- * Design decision to not make this abstract.
- *
- * @param uri
- * @param inputstream
- * @param context
- * @param result
- * @return
- */
- public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context, ValidationResult result)
- {
- return validate(uri, inputstream, context);
- }
-
- /**
- * This method clears all the markers on the given IFile for a specified
- * validator.
- * This is a convenience method for subclasses.
- *
- * @param iFile
- * The IFile from which to clear the markers.
- * @param validator
- * The validator for which to remove the markers.
- * @param reporter
- * The reporter that can remove the markers.
- */
- private void clearMarkers(IFile iFile, IValidator validator, IReporter reporter)
- {
- if (fileIsAccessible(iFile))
- {
- reporter.removeAllMessages(validator, iFile);
- }
- }
-
- /**
- * Test whether the given file is accessible and may be used for validation. A file is
- * available if
- * 1. It is not null.
- * 2. It exists.
- * 3. The project containing the file is accessible.
- *
- * @param file
- * The file to check to ensure it is accessible.
- * @return
- * True if the file is accessible, false otherwise.
- */
- private boolean fileIsAccessible(IFile file)
- {
- if (file != null && file.exists() && file.getProject().isAccessible())
- {
- return true;
- }
- return false;
- }
-
- /**
- * Format a file name into a correct URI.
- * This is a convenience method for subclasses.
- *
- * @param filename
- * The file name to format.
- * @return
- *
- * The formatted URI.
- */
- private String createURIForFilePath(String filename)
- {
- if(!filename.startsWith(FILE_PROTOCOL_NO_SLASH))
- {
- while(filename.startsWith("/")) //$NON-NLS-1$
- {
- filename = filename.substring(1);
- }
- filename = FILE_PROTOCOL + filename;
- }
- return filename;
- }
-
- /**
- * Create markers for the valiation messages generated from the validation.
- *
- * @param iFile
- * The resource to create the markers on.
- * @param valmessages
- * The array of validation messages.
- */
- public void createMarkers(IFile iFile, ValidationMessage[] valmessages, IReporter reporter)
- {
- if (!fileIsAccessible(iFile))
- {
- return;
- }
- int nummessages = valmessages.length;
- for (int i = 0; i < nummessages; i++)
- {
- ValidationMessage validationMessage = valmessages[i];
- String uri = validationMessage.getUri();
-
- LocalizedMessage message;
- if (validationMessage.getSeverity() == ValidationMessage.SEV_LOW)
- {
- message = new LocalizedMessage(IMessage.NORMAL_SEVERITY,
- validationMessage.getMessage(), iFile);
- }
- else
- {
- message = new LocalizedMessage(IMessage.HIGH_SEVERITY, validationMessage.getMessage(), iFile);
- }
-
- message.setLineNo(validationMessage.getLineNumber());
- addInfoToMessage(validationMessage, message);
- Object[] objlist = validationMessage.getMessageArguments();
- if (objlist != null && objlist.length ==1 ){
- Object obj = objlist[0];
- if (obj instanceof AnnotationMsg){
- message.setAttribute(AnnotationMsg.PROBMLEM_ID, new Integer(((AnnotationMsg)obj).getProblemId()));
- message.setAttribute(AnnotationMsg.LENGTH, new Integer(((AnnotationMsg)obj).getLength()));
- Object obj1 = ((AnnotationMsg)obj).getAttributeValueText();
- if (obj1 instanceof String){
- message.setAttribute(AnnotationMsg.ATTRVALUETEXT, obj1);
- }
- else if ( obj1 instanceof Object[]){
- Object[] objArray = (Object[])obj1;
- message.setAttribute(AnnotationMsg.ATTRVALUENO, new Integer(objArray.length));
- for (int j=0; j <objArray.length;j++){
- Object obj2 = objArray[j];
- String attrName = AnnotationMsg.ATTRNO + j;
- message.setAttribute(attrName, obj2);
- }
-
- }
- }
- }
- List nestederrors = validationMessage.getNestedMessages();
- if (nestederrors != null && !nestederrors.isEmpty())
- {
- message.setGroupName(REFERENCED_FILE_ERROR_OPEN + uri + REFERENCED_FILE_ERROR_CLOSE);
- }
-
- reporter.addMessage(this, message);
-
- }
- }
-
- /**
- * This method allows the addition of information to the validation message
- * @param validationmessage
- * The ValidationMessage to retrieve the information from.
- * @param message
- * The IMessage to add the information to.
- */
- protected void addInfoToMessage (ValidationMessage validationmessage, IMessage message)
- {
- // This method may be overridden by subclasses
- }
-
- /**
- * Get the nested validation context.
- *
- * @param state
- * the validation state.
- * @param create
- * when true, a new context will be created if one is not found
- * @return the nested validation context.
- */
- protected NestedValidatorContext getNestedContext(ValidationState state, boolean create)
- {
- NestedValidatorContext context = null;
- if (create)
- {
- context = new NestedValidatorContext();
- }
- return context;
- }
-
- /**
- * A localized message is a specialized type of IMessage that allows setting
- * and using a localized message string for a message.
- */
- class LocalizedMessage extends Message
- {
- private String _message = null;
-
- public LocalizedMessage(int severity, String messageText)
- {
- this(severity, messageText, null);
- }
-
- public LocalizedMessage(int severity, String messageText, IResource targetObject)
- {
- this(severity, messageText, (Object) targetObject);
- }
-
- public LocalizedMessage(int severity, String messageText, Object targetObject)
- {
- super(null, severity, null);
- setLocalizedMessage(messageText);
- setTargetObject(targetObject);
- }
-
- public void setLocalizedMessage(String message)
- {
- _message = message;
- }
-
- public String getLocalizedMessage()
- {
- return _message;
- }
-
- public String getText()
- {
- return getLocalizedMessage();
- }
-
- public String getText(ClassLoader cl)
- {
- return getLocalizedMessage();
- }
-
- public String getText(Locale l)
- {
- return getLocalizedMessage();
- }
-
- public String getText(Locale l, ClassLoader cl)
- {
- return getLocalizedMessage();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/Helper.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/Helper.java
deleted file mode 100644
index d9497af689..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/Helper.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.validation.internal.operations.ValidatorManager;
-import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * A helper class for validation in the validation framework.
- *
- * @author Ernest Mah (ernest@ca.ibm.com)
- * @author Lawrence Mandel, IBM
- */
-public class Helper extends WorkbenchContext
-{
- public static final String GET_PROJECT_FILES = "getAllFiles"; //$NON-NLS-1$
- public static final String GET_FILE = "getFile"; //$NON-NLS-1$
- //dw private static final IContainer[] NO_CONTAINERS = new IContainer[0];
- public static final String VALIDATION_MARKER = "org.eclipse.wst.validation.problemmarker"; //$NON-NLS-1$
- public static final String VALIDATION_MARKER_OWNER = "owner"; //$NON-NLS-1$
-
- /**
- * Constructor.
- */
- public Helper()
- {
- super();
-
- // the following will register the helper's symbolic methods
- Class [] args = new Class[1] ;
- args[0] = String.class ; // a string argument denoting a specific JSP.
-
- registerModel(GET_FILE, "getFile", args);//$NON-NLS-1$
- registerModel(GET_PROJECT_FILES, "getFiles", args);//$NON-NLS-1$
- }
-
- /**
- * Get the IFile for the given filename.
- *
- * @param filename The name of the file to retrieve.
- * @return An IFile representing the file specified or null if it can't be resolved.
- */
- public IFile getFile(String filename)
- {
- // System.out.println("file name = " + filename);
- IResource res = getProject().findMember(filename, true); // true means include phantom resources
- if (res instanceof IFile)
- {
- return (IFile) res;
- }
- return null;
- }
-
- /**
- * Get the collection of files from the project that are relevant for the
- * validator with the given class name.
- *
- * @param validatorClassName The name of the validator class.
- * @return The collection of files relevant for the validator class specified.
- */
- public Collection getFiles(String validatorClassName)
- {
- IProject project = getProject();
- List files = new ArrayList();
- getFiles(files, project, validatorClassName);
- return files;
- }
-
- /**
- * Get the collection of files from the project that are relevant for the
- * validator with the given class name.
- *
- * @param files The files relevant for the class name.
- * @param resource The resource to look for files in.
- * @param validatorClassName The name of the validator class.
- */
- protected void getFiles(Collection files, IContainer resource, String validatorClassName)
- {
- try
- {
- IResource [] resourceArray = resource.members(false);
- for (int i=0; i<resourceArray.length; i++)
- {
- if (ValidatorManager.getManager().isApplicableTo(validatorClassName, resourceArray[i]))
- {
- if (resourceArray[i] instanceof IFile)
- {
- files.add(resourceArray[i]);
- }
- }
- if (resourceArray[i].getType() == IResource.FOLDER)
- getFiles(files,(IContainer)resourceArray[i], validatorClassName) ;
- }
- }
- catch (Exception e) {}
- }
-
-
-/**
- * Return the name of the resource, without the project-specific information
- * in front.
- *
- * This method is used by ValidationOperation to calculate the non-environment
- * specific names of the files. Only the IWorkbenchContext implementation knows how
- * much information to strip off of the IResource name. For example, if there is
- * an EJB Project named "MyEJBProject", and it uses the default names for the
- * source and output folders, "source" and "ejbModule", respectively, then the
- * current implementation of EJB Helper knows how much of that structure is
- * eclipse-specific.
- *
- * Since the "source" folder contains Java source files, a portable name would
- * be the fully-qualified name of the Java class, without the eclipse-specific
- * project and folder names in front of the file name. The EJBHelper knows that
- * everything up to the "source" folder, for example, can be removed, because,
- * according to the definition of the EJB Project, everything contained
- * in the source folder is java source code. So if there is an IResource in an
- * EJB Project named "/MyEJBProject/source/com/ibm/myclasses/MyJavaFile.java",
- * this method would make this name portable by stripping off the
- * "/MyEJBProject/source", and returning "com/ibm/myclasses/MyJavaFile.java".
- *
- * The output of this method is used by the ValidationOperation, when it
- * is calculating the list of added/changed/deleted file names for incremental
- * validation. If getPortableName(IResource) returns null, that means
- * that the IWorkbenchContext's implementation does not support that particular
- * type of resource, and the resource should not be included in the array of
- * IFileDelta objects in the IValidator's "validate" method.
- *
- * @param resource The resource to get the name from.
- * @return The portable name of the resource.
- */
-public String getPortableName(IResource resource)
- {
- // System.out.println("get portablename for " + resource);
- return resource.getProjectRelativePath().toString();
- }
-
-/**
- * When an IValidator associates a target object with an IMessage,
- * the WorkbenchReporter eventually resolves that target object
- * with an IResource. Sometimes more than one target object resolves
- * to the same IResource (usually the IProject, which is the default
- * IResource when an IFile cannot be found). This method is called,
- * by the WorkbenchReporter, so that the WorkbenchReporter can
- * distinguish between the IMessages which are on the same IResource,
- * but refer to different target objects. This is needed for the
- * removeAllMessages(IValidator, Object) method, so that when one
- * target object removes all of its messages, that it doesn't remove
- * another target object's messages.
- *
- * This method may return null only if object is null. Otherwise, an
- * id which can uniquely identify a particular object must be returned.
- * The id needs to be unique only within one particular IValidator.
- *
- * @param object The object from which to get the name.
- * @return The name of the object or null if the object is null.
- */
-public String getTargetObjectName(Object object)
- {
- if (object == null)
- {
- return null;
- }
-
- // System.out.println("get targetname for " + object);
- return object.toString();
- }
-
- /**
- * Delete the markers of the specified type from the specified resource.
- *
- * @param resource The resource to delete the markers from.
- * @param markerType The type of markers to delete from the resource.
- * @param attributeName The name of the attribute which the markers must have to be deleted.
- * @param attributeValue The value of the attribute corresponding to attributeName which the markers must have to be deleted.
- * @throws CoreException
- */
- public static void deleteMarkers(IResource resource, String markerType, final String attributeName, final Object attributeValue) throws CoreException
- {
- final IMarker[] v400Markers = resource.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_INFINITE);
- final IMarker[] markers = resource.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
- IWorkspaceRunnable op = new IWorkspaceRunnable()
- {
- public void run(IProgressMonitor progressMonitor) throws CoreException
- {
- // this fixes defect 193406
- // here we remove markers that may have been added by the v400 code
- // hopefully the '.markers' metadata files will be removed for the V5 install
- // and this kludge will not be needed there
- for (int i = 0; i < v400Markers.length; i++)
- {
- IMarker marker = markers[i];
- marker.delete();
- }
-
- for (int i = 0; i < markers.length; i++)
- {
- IMarker marker = markers[i];
-
- Object value = marker.getAttribute(attributeName);
- if (value != null &&
- value.equals(attributeValue))
- {
- marker.delete();
- }
- }
- }
- };
-
- try
- {
- ResourcesPlugin.getWorkspace().run(op, null);
- }
- catch (Exception e) { }
- }
-
- /**
- * Get the validation framework severity for the given severity.
- *
- * @param severity The severity to convert to validation framework severity.
- * @return The validation framework severity for the given severity.
- */
- static public int getValidationFrameworkSeverity(int severity)
- {
- switch (severity)
- {
- case IMarker.SEVERITY_ERROR:
- return IMessage.HIGH_SEVERITY;
- case IMarker.SEVERITY_WARNING:
- return IMessage.NORMAL_SEVERITY;
- case IMarker.SEVERITY_INFO:
- return IMessage.LOW_SEVERITY;
- }
- return IMessage.LOW_SEVERITY;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/LazyURLInputStream.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/LazyURLInputStream.java
deleted file mode 100644
index 78fd207fdc..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/LazyURLInputStream.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-
-/**
- * This class allows InputStreams to be created and returned to xerces without
- * actually opening file handles or network connections until it is absolutely
- * neccessary.
- */
-public class LazyURLInputStream extends InputStream
-{
-// private static int debugTotalOpenStreamCount = 0;
- protected InputStream inner;
- protected String url;
- protected boolean error;
- boolean hasMarks;
- boolean pretendFileIsStillOpen;
-
- public LazyURLInputStream(String url)
- {
- this.url = url;
- inner = null;
- pretendFileIsStillOpen = false;
- }
-
- private void createInnerStreamIfRequired() throws IOException
- {
- if (inner == null && !error)
- {
-// debugTotalOpenStreamCount++;
-
- try
- {
- inner = new URL(url).openStream();
- pretendFileIsStillOpen = false;
- hasMarks = false;
- }
- finally
- {
- if (inner == null)
- {
- error = true;
- }
- }
- }
- }
-
- protected void closeStream() throws IOException {
- if (inner != null && !pretendFileIsStillOpen) {
- inner.close();
- pretendFileIsStillOpen = true;
- }
- }
-
- public int available() throws IOException
- {
- if (pretendFileIsStillOpen) return 0;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- return inner.available();
- }
-
- public void close() throws IOException
- {
- if (pretendFileIsStillOpen) {
- // Stop behaving as if the stream were still open.
- pretendFileIsStillOpen = false;
- } else {
- if (inner != null) {
-// debugTotalOpenStreamCount--;
- inner.close();
- }
- }
- }
-
- public void mark(int readlimit)
- {
- if (pretendFileIsStillOpen) return;
- hasMarks = true;
- try {
- createInnerStreamIfRequired();
- inner.mark(readlimit);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public boolean markSupported()
- {
- if (pretendFileIsStillOpen) return false;
- try {
- createInnerStreamIfRequired();
- if (inner == null) return false;
- return inner.markSupported();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return false;
- }
-
- public int read() throws IOException
- {
- if (pretendFileIsStillOpen) return -1;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- int bytesRead = inner.read();
- if (bytesRead == -1 && !hasMarks) closeStream();
- return bytesRead;
- }
-
-
- public int read(byte[] b) throws IOException {
- if (pretendFileIsStillOpen) return -1;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- int bytesRead = inner.read(b);
- if (bytesRead == -1 && !hasMarks) closeStream();
- return bytesRead;
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (pretendFileIsStillOpen) return -1;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- int bytesRead = inner.read(b, off, len);
- if (bytesRead == -1 && !hasMarks) closeStream();
- return bytesRead;
- }
-
- public void reset() throws IOException
- {
- if (pretendFileIsStillOpen) return;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- inner.reset();
- }
-
- public long skip(long n) throws IOException
- {
- if (pretendFileIsStillOpen) return 0;
- createInnerStreamIfRequired();
- if (inner == null) throw new IOException("Stream not available"); //$NON-NLS-1$
- return inner.skip(n);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java
deleted file mode 100644
index bb96caff52..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import org.eclipse.core.resources.IProject;
-
-
-/**
- * A context class for validators to be able to determine the context of
- * given validation session. Currently this class is only used to identify
- * the unique context.
- */
-public class NestedValidatorContext
-{
- private IProject fProject;
-
- public void setProject(IProject project) {
- fProject = project;
- }
-
- public IProject getProject() {
- return fProject;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java
deleted file mode 100644
index c43ac1d48e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationInfo.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- * David Carver (STAR) - bug 297005 - Some static constants not made final.
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationMessages;
-
-/**
- * This class handles messages from a validator. This class can handle
- *
- * @author Lawrence Mandel, IBM
- */
-public class ValidationInfo implements ValidationReport
-{
- private boolean WRAPPER_ERROR_SUPPORT_ENABLED = true;
- public static final int SEV_ERROR = 0;
- public static final int SEV_WARNING = 1;
-
- private String validating_file_uri = null;
- private URL validating_file_url = null;
- private boolean valid = true;
- private List messages = new ArrayList();
- private HashMap nestedMessages = new HashMap();
-
- /**
- * Constructor.
- *
- * @param uri
- * The URI of the file for the validation.
- */
- public ValidationInfo(String uri)
- {
- if(uri != null)
- {
- this.validating_file_uri = uri;
- try
- {
- this.validating_file_url = new URL(uri);
- } catch (MalformedURLException e)
- {
- }
- }
- }
-
- public String getFileURI()
- {
- return validating_file_uri;
- }
-
- public boolean isValid()
- {
- return valid;
- }
-
- /**
- * Add an error message.
- *
- * @param message The message to add.
- * @param line The line location of the message.
- * @param column The column location of the message.
- * @param uri The URI of the file that contains the message.
- */
- public void addError(String message, int line, int column, String uri)
- {
- addError(message, line, column, uri, null, null);
- }
-
- /**
- *
- * Add an error message.
- *
- * @param message The message to add.
- * @param line The line location of the message.
- * @param column The column location of the message.
- * @param uri The URI of the file that contains the message.
- * @param key The key for the message.
- * @param messageArguments more information about the error
- */
- public void addError(String message, int line, int column, String uri, String key, Object[] messageArguments)
- {
- if(addMessage(message, line, column, uri, SEV_ERROR, key, messageArguments))
- {
- valid = false;
- }
- }
-
- /**
- * Add a warning message.
- *
- * @param message The string message of the warning.
- * @param line The line location of the warning.
- * @param column The column location of the warning.
- * @param uri The URI of the file that contains the warning.
- */
- public void addWarning(String message, int line, int column, String uri)
- {
- addWarning(message, line, column, uri, null, null);
- }
-
- /**
- *
- * Add an error message.
- *
- * @param message The message to add.
- * @param line The line location of the message.
- * @param column The column location of the message.
- * @param uri The URI of the file that contains the message.
- * @param key The key for the message.
- * @param messageArguments more information about the error
- */
- public void addWarning(String message, int line, int column, String uri, String key, Object[] messageArguments)
- {
- addMessage(message, line, column, uri, SEV_WARNING, key, messageArguments);
- }
-
- /**
- * Add a message to the list. Return true if successful, false otherwise.
- *
- * @param message The message to add to the list.
- * @param line The line location of the message.
- * @param column The column location of the message.
- * @param uri The URI of the file that contains the message.
- * @param severity The severity of the message.
- * @param key the Xerces error key for this error
- * @param messageArguments more information on the error
- * @return True if the message was successfully added, false otherwise.
- */
- private boolean addMessage(String message, int line, int column, String uri, int severity, String key, Object[] messageArguments)
- {
- boolean successfullyAdded = false;
- // If the message if null there is nothing to add.
- if(message == null)
- {
- return successfullyAdded;
- }
- String errorURI = normalize(uri);
- URL errorURL = null;
- if (errorURI != null)
- {
- try
- {
- errorURL = new URL(errorURI);
- } catch (MalformedURLException e)
- {
- }
- //errorURI = normalizeURI(errorURI);
- }
- //boolean doDialog = true;
- if (errorURL != null)
- {
- successfullyAdded = true;
- // Add to the appropriate list if nested error support is off or
- // this message is for the current file.
- if (!WRAPPER_ERROR_SUPPORT_ENABLED || (validating_file_url != null && validating_file_url.sameFile(errorURL)))
- {
-
- ValidationMessage valmes = new ValidationMessage(message, line,
- column, validating_file_uri, key, messageArguments);
- if (severity == SEV_ERROR)
- {
- valmes.setSeverity(ValidationMessage.SEV_NORMAL);
- } else if (severity == SEV_WARNING)
- {
- valmes.setSeverity(ValidationMessage.SEV_LOW);
- }
- messages.add(valmes);
- }
- // If nested error support is enabled create a nested error.
- else if (WRAPPER_ERROR_SUPPORT_ENABLED)
- {
- String nesteduri = errorURL.toExternalForm();
- ValidationMessage nestedmess = new ValidationMessage(message, line,
- column, nesteduri, key, messageArguments);
- if(severity == SEV_WARNING)
- {
- nestedmess.setSeverity(ValidationMessage.SEV_LOW);
- }
- else
- {
- nestedmess.setSeverity(ValidationMessage.SEV_NORMAL);
- }
-
- ValidationMessage container = (ValidationMessage) nestedMessages.get(nesteduri);
- if(container == null)
- {
- container = new ValidationMessage(NLS.bind(XMLValidationMessages._UI_REF_FILE_ERROR_MESSAGE, new Object [] { nesteduri }), 1, 0, nesteduri);
-
- // Initially set the nested error to a warning. This will automatically be changed
- // to an error if a nested message has a severity of error.
- container.setSeverity(ValidationMessage.SEV_LOW);
- nestedMessages.put(nesteduri, container);
- messages.add(container);
- }
- container.addNestedMessage(nestedmess);
- }
- }
- return successfullyAdded;
- }
-
-
- /**
- * Add a nested message to the validation information.
- *
- * @param message The string message of the validation message.
- * @param line The line location of the validation message.
- * @param column The column location of the validation message.
- * @param uri The URI of the validation message.
- * @param severity The severity of the validation message.
- */
-// public void addNestedMessage(String message, int line, int column, String uri, int severity)
-// {
-// ValidationMessage nestedmess = new ValidationMessage(message, line, column, uri);
-// if(severity == SEV_WARNING)
-// {
-// nestedmess.setSeverity(ValidationMessage.SEV_LOW);
-// }
-// else
-// {
-// nestedmess.setSeverity(ValidationMessage.SEV_NORMAL);
-// }
-// ValidationMessage container = (ValidationMessage)nestedMessages.get(uri);
-// if(container == null)
-// {
-// container = new ValidationMessage(XMLCoreValidationPlugin.getResourceString(_UI_REF_FILE_ERROR_MESSAGE, uri), 1, 0, validating_file_uri);
-// // Initially set the nested error to a warning. This will automatically be changed
-// // to an error if a nested message has a severity of error.
-// container.setSeverity(ValidationMessage.SEV_LOW);
-// nestedMessages.put(uri, container);
-// messages.add(container);
-// }
-// container.addNestedMessage(nestedmess);
-// }
-
- /**
- * @see org.eclipse.wsdl.validate.ValidationReport#getValidationMessages()
- */
- public ValidationMessage[] getValidationMessages()
- {
- return (ValidationMessage[])messages.toArray(new ValidationMessage[messages.size()]);
- }
-
- public HashMap getNestedMessages()
- {
- return nestedMessages;
- }
-
- /**
- * Put the URI in a standard format.
- *
- * @param uri The URI to put into a standard format.
- * @return The standard format of the URI.
- */
- private String normalize(String uri)
- {
-// if(uri.startsWith("platform:"))
-// {
-// try
-// {
-// uri = Platform.resolve(new URL(uri)).toString();
-// }
-// catch(Exception e)
-// {
-// }
-// }
- uri = uri.replaceAll("%20"," "); //$NON-NLS-1$ //$NON-NLS-2$
- uri = uri.replaceAll("%5E", "^"); //$NON-NLS-1$ //$NON-NLS-2$
- uri = uri.replace('\\','/');
-
- return uri;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationMessage.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationMessage.java
deleted file mode 100644
index e2662c0f19..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationMessage.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * David Carver (STAR) - bug 297005 - Some static constants not made final.
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * A class for holding validation message information. Holds the message and the
- * message location.
- */
-public class ValidationMessage
-{
- public static final QualifiedName ERROR_MESSAGE_MAP_QUALIFIED_NAME = new QualifiedName("org.eclipse.wst.xml.validation", "errorMessageMap"); //$NON-NLS-1$ //$NON-NLS-2$
- protected String message;
- protected int lineNumber;
- protected int columnNumber;
- protected String uri;
- protected List nestedErrors;
- protected String key;
- protected Object[] messageArguments;
- protected int startOffset;
- protected int severity = IMessage.NORMAL_SEVERITY;
- public static final int SEV_HIGH = IMessage.HIGH_SEVERITY;
- public static final int SEV_NORMAL = IMessage.NORMAL_SEVERITY;
- public static final int SEV_LOW = IMessage.LOW_SEVERITY;
-
- /**
- * Constructor.
- *
- * @param message The message for the validation message.
- * @param lineNumber The line location of the message.
- * @param columnNumber The column location of the message.
- */
- public ValidationMessage(String message, int lineNumber, int columnNumber)
- {
- this(message, lineNumber, columnNumber, null);
- }
-
- /**
- * Constructor.
- *
- * @param message The message for the validation message.
- * @param lineNumber The line location of the message.
- * @param columnNumber The column location of the message.
- * @param uri The uri of the file the message is for.
- */
- public ValidationMessage(String message, int lineNumber, int columnNumber, String uri)
- {
- this(message, lineNumber, columnNumber, uri, null, null);
- }
-
- /**
- * Constructor.
- *
- * @param message The message for the validation message.
- * @param lineNumber The line location of the message.
- * @param columnNumber The column location of the message.
- * @param uri The uri of the file the message is for.
- * @param key a unique string representing the error
- * @param messageArguments the arguments Xerces uses to create the message
- */
- public ValidationMessage(String message, int lineNumber, int columnNumber, String uri, String key, Object[] messageArguments)
- {
- this.message = message;
- this.lineNumber = lineNumber;
- this.columnNumber = columnNumber;
- this.uri = uri;
- this.key = key;
- this.messageArguments = messageArguments;
- this.startOffset = 0;
- }
-
-
- /**
- * Get the message for this valiation message.
- *
- * @return The message for this validation message.
- */
- public String getMessage()
- {
- return message;
- }
-
- /**
- * Get the column location.
- *
- * @return The column number.
- */
- public int getColumnNumber()
- {
- return columnNumber;
- }
-
- /**
- * Get the line location.
- *
- * @return The line number.
- */
- public int getLineNumber()
- {
- return lineNumber;
- }
-
- /**
- * Get the uri for the file that contains the message.
- *
- * @return The uri of the file that contains the message.
- */
- public String getUri()
- {
- return uri;
- }
-
- /**
- * Add a nested validation message to this validation message.
- *
- * @param validationMessage The validation message to add as a nested message.
- */
- public void addNestedMessage(ValidationMessage validationMessage)
- {
- if (nestedErrors == null)
- {
- nestedErrors = new ArrayList();
- }
- nestedErrors.add(validationMessage);
- int validaitonmessageSeverity = validationMessage.getSeverity();
- if(validaitonmessageSeverity == SEV_NORMAL || validaitonmessageSeverity == SEV_HIGH)
- {
- setSeverity(SEV_NORMAL);
- }
- }
-
- /**
- * Get the list of nested validation messages.
- *
- * @return The list of nested validation messages.
- */
- public List getNestedMessages()
- {
- return nestedErrors != null ? nestedErrors : Collections.EMPTY_LIST;
- }
-
- /**
- * Get the severity of the defect.
- *
- * @return The severity of the defect.
- */
- public int getSeverity()
- {
- return severity;
- }
-
- /**
- * Set the severity of the message.
- *
- * @param sev The severity to set.
- */
- public void setSeverity(int sev)
- {
- severity = sev;
- }
-
- public void setStartOffset(int offset)
- {
- this.startOffset = offset;
- }
-
- /**
- * @return Returns the key.
- */
- public String getKey()
- {
- return key;
- }
-
- public Object[] getMessageArguments()
- {
- return this.messageArguments;
- }
-
-
- public void setMessage(String message)
- {
- this.message = message;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationReport.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationReport.java
deleted file mode 100644
index dbb1570553..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/ValidationReport.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.core;
-
-import java.util.HashMap;
-
-/**
- * An interface for a validation report.
- *
- * @author Lawrence Mandel, IBM
- */
-public interface ValidationReport
-{
- /**
- * Returns the URI for the file the report refers to.
- *
- * @return The URI for the file the report refers to.
- */
- public String getFileURI();
-
- /**
- * Returns whether the file is valid. The file may have warnings associated with it.
- *
- * @return True if the file is valid, false otherwise.
- */
- public boolean isValid();
-
- /**
- * Returns an array of validation messages.
- *
- * @return An array of validation messages.
- */
- public ValidationMessage[] getValidationMessages();
-
- public HashMap getNestedMessages();
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/CommandLineLogger.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/CommandLineLogger.java
deleted file mode 100644
index 0d38f38817..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/CommandLineLogger.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core.logging;
-
-/**
- * A logger that will print log info to System.out.
- *
- * @author Lawrence Mandel, IBM
- */
-public class CommandLineLogger implements ILogger
-{
- public void logError(String error, Throwable exception)
- {
- System.out.println(error);
- System.out.println(exception.toString());
- }
-
- public void logWarning(String warning, Throwable exception)
- {
- System.out.println(warning);
- System.out.println(exception.toString());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/EclipseLogger.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/EclipseLogger.java
deleted file mode 100644
index 573cf2de9c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/EclipseLogger.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.core.logging;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-
-
-/**
- * A logger that will log to the log file in the eclipse metadata directory.
- */
-public class EclipseLogger implements ILogger
-{
-
- public void logError(String error, Throwable exception)
- {
- XMLCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, XMLCorePlugin.getDefault().getBundle().getSymbolicName(), IStatus.ERROR, error, exception));
- }
-
- public void logWarning(String warning, Throwable exception)
- {
- XMLCorePlugin.getDefault().getLog().log(new Status(IStatus.WARNING, XMLCorePlugin.getDefault().getBundle().getSymbolicName(), IStatus.WARNING, warning, exception));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/ILogger.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/ILogger.java
deleted file mode 100644
index e81a410bc8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/ILogger.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.core.logging;
-
-/**
- * The interface for a standard logger. Allows for logging errors and warnings.
- *
- * @author Lawrence Mandel, IBM
- */
-public interface ILogger
-{
- /**
- * Log an error message.
- *
- * @param error The error message to log.
- * @param exception The exception to log.
- */
- public void logError(String error, Throwable exception);
-
- /**
- * Log a warning message.
- *
- * @param warning The warning message to log.
- * @param exception The exception to log.
- */
- public void logWarning(String warning, Throwable exception);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/LoggerFactory.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/LoggerFactory.java
deleted file mode 100644
index 81549e3e9d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/logging/LoggerFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.core.logging;
-
-/**
- * The logger factory allows for simple use of whatever logging mechanism is in
- * place. The tool can specify a custom logging class and can request the
- * logger from this class.
- *
- * @author Lawrence Mandel, IBM
- *
- * @deprecated - not used in WTP or by any adopters as of 9/12/2007
- */
-public class LoggerFactory
-{
- private static ILogger logger = null;
- private static ClassLoader classloader = null;
- private static String loggerClass = null;
- private static final String commandlinelogger = "org.eclipse.wst.xml.validation.internal.core.logging.CommandLineLogger"; //$NON-NLS-1$
- private static final String eclipselogger = "org.eclipse.wst.xml.validation.internal.core.logging.EclipseLogger"; //$NON-NLS-1$
- private static String defaultlogger = commandlinelogger;
-
- /**
- * Get the one and only instance of the logger.
- *
- * @return The one and only instance of the logger.
- */
- public static ILogger getLoggerInstance()
- {
- if(logger == null)
- {
- if(loggerClass != null)
- {
- if(classloader != null)
- {
- try
- {
- Class lc = classloader.loadClass(loggerClass);
- logger = (ILogger) lc.newInstance();
- }
- catch (Exception e)
- {
- }
- }
- if(logger == null)
- {
- try
- {
- Class lc = LoggerFactory.class.getClassLoader().loadClass(loggerClass);
- logger = (ILogger) lc.newInstance();
- }
- catch (Exception e)
- {
- }
- }
- }
- if(logger == null)
- {
- try
- {
- Class lc = LoggerFactory.class.getClassLoader().loadClass(defaultlogger);
- logger = (ILogger) lc.newInstance();
- }
- catch (Exception e)
- {
- }
- }
- }
- return logger;
- }
-
- /**
- * Specify the logger implementation to be used.
- *
- * @param classname
- * The name of the logger class.
- * @param loggerclassloader
- * The classloader to use to load the logger. If null, the default
- * classloader will be used.
- */
- public static void specifyLogger(String classname, ClassLoader loggerclassloader)
- {
- loggerClass = classname;
- classloader = loggerclassloader;
- }
-
- /**
- * Set the default logger to the eclipse logger.
- */
- public static void useEclipseLogger()
- {
- defaultlogger = eclipselogger;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/ErrorCustomizationPluginRegistryReader.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/ErrorCustomizationPluginRegistryReader.java
deleted file mode 100644
index 44a6481ad2..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/ErrorCustomizationPluginRegistryReader.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.eclipse;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.validation.errorcustomization.ErrorCustomizationRegistry;
-import org.eclipse.wst.xml.core.internal.validation.errorcustomization.ErrorMessageCustomizerDelegate;
-import org.osgi.framework.Bundle;
-/**
- * This class reads the plug-in manifests and registers each extension
- * error customizer with the ErrorCustomizationRegistry.
- */
-public class ErrorCustomizationPluginRegistryReader {
-
- protected static final String PLUGIN_ID = "org.eclipse.wst.xml.core"; //$NON-NLS-1$
- protected static final String ATT_CLASS = "class"; //$NON-NLS-1$
- protected static final String ATT_NAMESPACE = "namespace"; //$NON-NLS-1$
- protected static final String EXTENSION_POINT_ID = "errorCustomizer"; //$NON-NLS-1$
- protected static final String tagName = EXTENSION_POINT_ID;
-
- /**
- * Read from plugin registry for the errorcustomizer extension.
- */
- public void readRegistry()
- {
- IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null)
- {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++)
- {
- readElement(elements[i]);
- }
- }
- }
-
- /**
- * readElement() - parse and deal with an extension like:
- *
- * <extension point="org.eclipse.wst.xml.core.errorCustomizer"
- * id="specificErrorCustomizer"
- * name="Specific Error Customizer">
- * <errorCustomizer
- * namespace="http://specificnamespace"
- * class="org.eclipse.wst.xml.core.MySpecificErrorCustomizer/>
- * </extension>
- */
- protected void readElement(IConfigurationElement element)
- {
- if (element.getName().equals(tagName))
- {
- String errorCustomizerClass = element.getAttribute(ATT_CLASS);
- String namespace = element.getAttribute(ATT_NAMESPACE);
-
- if (errorCustomizerClass != null)
- {
- try
- {
- Bundle pluginBundle = Platform.getBundle(element.getDeclaringExtension().getContributor().getName());
- ErrorMessageCustomizerDelegate delegate = new ErrorMessageCustomizerDelegate(pluginBundle, errorCustomizerClass);
- ErrorCustomizationRegistry.getInstance().addErrorMessageCustomizer(namespace, delegate);
- }
- catch (Exception e)
- {
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
deleted file mode 100644
index 31b4d087bd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.eclipse;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.validation.XMLNestedValidatorContext;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationReport;
-import org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator;
-import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
-
-public class Validator extends AbstractNestedValidator
-{
- private static final String XML_VALIDATOR_CONTEXT = "org.eclipse.wst.xml.core.validatorContext"; //$NON-NLS-1$
- protected int indicateNoGrammar = 0;
- private IScopeContext[] fPreferenceScopes = null;
- /**
- * Set any preferences for XML validation.
- *
- * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#setupValidation(org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext)
- */
- protected void setupValidation(NestedValidatorContext context)
- {
- super.setupValidation(context);
- fPreferenceScopes = createPreferenceScopes(context);
- indicateNoGrammar = Platform.getPreferencesService().getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, 0, fPreferenceScopes);
- }
-
- protected IScopeContext[] createPreferenceScopes(NestedValidatorContext context) {
- if (context != null) {
- final IProject project = context.getProject();
- if (project != null && project.isAccessible()) {
- final ProjectScope projectScope = new ProjectScope(project);
- if (projectScope.getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(XMLCorePreferenceNames.USE_PROJECT_SETTINGS, false))
- return new IScopeContext[]{projectScope, new InstanceScope(), new DefaultScope()};
- }
- }
- return new IScopeContext[]{new InstanceScope(), new DefaultScope()};
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(java.lang.String, java.io.InputStream, org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext)
- */
- public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context)
- {
- return validate(uri, inputstream, context, null);
- }
-
- public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context, ValidationResult result)
- {
- XMLValidator validator = XMLValidator.getInstance();
-
- XMLValidationConfiguration configuration = new XMLValidationConfiguration();
- try
- {
- //Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences();
- configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, indicateNoGrammar);
- final IPreferencesService preferencesService = Platform.getPreferencesService();
- configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_DOCUMENT_ELEMENT, preferencesService.getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_DOCUMENT_ELEMENT, -1, fPreferenceScopes));
- configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.USE_XINCLUDE, false, fPreferenceScopes));
- configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true, fPreferenceScopes));
- }
- catch(Exception e)
- {
- // TODO: Unable to set the preference. Log this problem.
- }
-
- XMLValidationReport valreport = validator.validate(uri, inputstream, configuration, result, context);
-
- return valreport;
- }
-
- /**
- * Store additional information in the message parameters. For XML validation there
- * are three additional pieces of information to store:
- * param[0] = the column number of the error
- * param[1] = the 'squiggle selection strategy' for which DOM part to squiggle
- * param[2] = the name or value of what is to be squiggled
- *
- * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#addInfoToMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage, org.eclipse.wst.validation.internal.provisional.core.IMessage)
- */
- protected void addInfoToMessage(ValidationMessage validationMessage, IMessage message)
- {
- String key = validationMessage.getKey();
- if(key != null)
- {
- XMLMessageInfoHelper messageInfoHelper = new XMLMessageInfoHelper();
- String[] messageInfo = messageInfoHelper.createMessageInfo(key, validationMessage.getMessageArguments());
-
- message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, new Integer(validationMessage.getColumnNumber()));
- message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, messageInfo[0]);
- message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, messageInfo[1]);
- }
- }
-
- /**
- * Get the nested validation context.
- *
- * @param state
- * the validation state.
- * @param create
- * when true, a new context will be created if one is not found
- * @return the nested validation context.
- */
- protected NestedValidatorContext getNestedContext(ValidationState state, boolean create)
- {
- NestedValidatorContext context = null;
- Object o = state.get(XML_VALIDATOR_CONTEXT);
- if (o instanceof XMLNestedValidatorContext)
- context = (XMLNestedValidatorContext)o;
- else if (create)
- {
- context = new XMLNestedValidatorContext();
- }
- return context;
- }
-
- public void validationStarting(IProject project, ValidationState state, IProgressMonitor monitor)
- {
- if (project != null)
- {
- NestedValidatorContext context = getNestedContext(state, false);
- if (context == null)
- {
- context = getNestedContext(state, true);
- if (context != null)
- context.setProject(project);
- setupValidation(context);
- state.put(XML_VALIDATOR_CONTEXT, context);
- }
- super.validationStarting(project, state, monitor);
- }
- }
-
- public void validationFinishing(IProject project, ValidationState state, IProgressMonitor monitor)
- {
- if (project != null)
- {
- super.validationFinishing(project, state, monitor);
- NestedValidatorContext context = getNestedContext(state, false);
- if (context != null)
- {
- teardownValidation(context);
- state.put(XML_VALIDATOR_CONTEXT, null);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLMessageInfoHelper.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLMessageInfoHelper.java
deleted file mode 100644
index b2a265bb27..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLMessageInfoHelper.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.eclipse;
-
-/**
- * The message info helper determines the selection strategy for elements
- * in a SSE editor.
- *
- */
-public class XMLMessageInfoHelper
-{
- public XMLMessageInfoHelper()
- {
- super();
- }
-
- /**
- * Returns an array containing information about what should be underlined with the red "squiggles"
- * using the errorKey, and the messageArguments.
- * <br>Position 0 of the array returned contains the selection Strategy, or what DOM Element to underline.
- * For example "ATTRIBUTE_NAME"
- * <br>Position 1 contains the name or value to squiggle.
- * <p>For example, if we wanted to squiggle the attribute name of an attribute name
- * foo this method would return {"ATTRIBUTE_NAME", "foo"}
- * </p>
- * @param errorKey
- * The error key given by the Xerces parser.
- * @param messageArguments
- * The arguments used by Xerces to "fill in the blanks" of their messages.
- * @return
- * An array containing the squiggle information.
- * @see org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidator
- *
- */
- public String[] createMessageInfo(String errorKey, Object[] messageArguments)
- {
- String selectionStrategy = null;
- String nameOrValue = null;
-
- if(errorKey != null)
- {
- if (errorKey.equals("cvc-complex-type.2.4.a") || errorKey.equals("cvc-complex-type.2.4.d") || errorKey.equals("cvc-complex-type.2.4.b") || errorKey.equals("MSG_CONTENT_INVALID") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- | errorKey.equals("MSG_CONTENT_INCOMPLETE") || errorKey.equals("MSG_REQUIRED_ATTRIBUTE_NOT_SPECIFIED") || errorKey.equals("cvc-complex-type.4") || errorKey.equals("ElementPrefixUnbound") ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- {
- selectionStrategy = "START_TAG"; //$NON-NLS-1$
- }
- else if (errorKey.equals("cvc-type.3.1.3")) //$NON-NLS-1$
- {
- selectionStrategy = "TEXT"; //$NON-NLS-1$
- }
- else if (errorKey.equals("cvc-complex-type.2.3")) //$NON-NLS-1$
- {
- selectionStrategy = "FIRST_NON_WHITESPACE_TEXT"; //$NON-NLS-1$
- }
- else if (errorKey.equals("cvc-type.3.1.1")) //$NON-NLS-1$
- {
- selectionStrategy = "ALL_ATTRIBUTES"; //$NON-NLS-1$
- }
- else if (errorKey.equals("cvc-complex-type.3.2.2") || errorKey.equals("MSG_ATTRIBUTE_NOT_DECLARED")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- selectionStrategy = "ATTRIBUTE_NAME"; //$NON-NLS-1$
- //in this case we need nameOrValue to be the name of the attribute to underline
- nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("cvc-attribute.3") || errorKey.equals("MSG_ATTRIBUTE_VALUE_NOT_IN_LIST") || errorKey.equals("cvc-complex-type.3.1")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- {
- selectionStrategy = "ATTRIBUTE_VALUE"; //$NON-NLS-1$
- //in this case we need nameOrValue to be the name of the Attribute
- if (errorKey.equals("cvc-attribute.3") || errorKey.equals("cvc-complex-type.3.1")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("MSG_ATTRIBUTE_VALUE_NOT_IN_LIST")) //$NON-NLS-1$
- {
- nameOrValue = (String)messageArguments[0];
- }
- }
- else if (errorKey.equals("cvc-elt.4.2")) //$NON-NLS-1$
- {
- selectionStrategy="VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE"; //$NON-NLS-1$
- //in this case we need nameOrValue to be the value of the attribute we want to unerline
- nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("EntityNotDeclared")) //$NON-NLS-1$
- {
- selectionStrategy="TEXT_ENTITY_REFERENCE"; //$NON-NLS-1$
- nameOrValue = (String)messageArguments[0];
- }
- else if (errorKey.equals("ElementUnterminated")) //$NON-NLS-1$
- {
- selectionStrategy = "ENTIRE_ELEMENT"; //$NON-NLS-1$
- }
- else if (errorKey.equals("ETagUnterminated") || errorKey.equals("ETagRequired")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- selectionStrategy = "END_TAG"; //$NON-NLS-1$
- }
- else if (errorKey.equals("AttributeNotUnique")) //$NON-NLS-N$
- {
- selectionStrategy = "ATTRIBUTE_NAME_LAST"; //$NON-NLS-1$
- //in this case we need nameOrValue to be the name of the last attribute(like in case of duplicate attributes)
- //to underline
- nameOrValue = (String)messageArguments[1];
- }
- }
- String messageInfo[] = new String[2];
- messageInfo[0] = selectionStrategy != null? selectionStrategy: ""; //$NON-NLS-1$
- messageInfo[1] = nameOrValue;
- return messageInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLValidator.java
deleted file mode 100644
index d4810581a1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/XMLValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.validation.eclipse;
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-
-/**
- * An XML validator specific to Eclipse. This validator will wrap the internal
- * XML validator and provide automatic URI resolution support. This class also
- * reads from the plug-in registry and registers all error customizers with the
- * registry.
- */
-public class XMLValidator extends org.eclipse.wst.xml.core.internal.validation.XMLValidator
-{
- private static XMLValidator instance = null;
-
- /**
- * Return the one and only instance of the XML validator. The validator
- * can be reused and cannot be customized so there should only be one instance of it.
- *
- * @return The one and only instance of the XML validator.
- */
- public static XMLValidator getInstance()
- {
- if(instance == null)
- {
- instance = new XMLValidator();
- }
- return instance;
- }
- /**
- * Constructor. Create the XML validator, set the URI resolver and
- * get the extension error customizers from the registry.
- */
- protected XMLValidator()
- {
- setURIResolver(URIResolverPlugin.createResolver());
- new ErrorCustomizationPluginRegistryReader().readRegistry();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ElementInformation.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ElementInformation.java
deleted file mode 100644
index 649c99e553..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ElementInformation.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.errorcustomization;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A simple class to store information about an XML element.
- */
-public class ElementInformation
-{
- protected String localName;
- protected String namespace;
- protected List children = new ArrayList();
-
- /**
- * Constructor.
- *
- * @param uri
- * The namespace URI of the element.
- * @param localName
- * The local name of the element.
- */
- public ElementInformation(String uri, String localName)
- {
- this.localName = localName;
- this.namespace = uri;
- }
-
- /**
- * Get the namespace of this element.
- *
- * @return
- * The namespace of this element.
- */
- public String getNamespace()
- {
- return namespace;
- }
-
- /**
- * Get the local name of this element.
- *
- * @return
- * The local name of this element.
- */
- public String getLocalname()
- {
- return localName;
- }
-
- /**
- * Get the list of children of this element. The list contains
- * ElementInformation objects representing the children of this element.
- *
- * @return
- * The list of children of this element.
- */
- public List getChildren()
- {
- return children;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationManager.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationManager.java
deleted file mode 100644
index 745acc045a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationManager.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.errorcustomization;
-
-import java.util.Stack;
-
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationInfo;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-
-/**
- * This class tracks the context of the parsed document to help identify error
- * conditions
- */
-public class ErrorCustomizationManager
-{
- protected Stack elementInformationStack = new Stack();
- protected ErrorMessageInformation messageForConsideration;
-
- /**
- * This method should be called in the start element method of the XML validator's
- * content handler.
- *
- * @param uri
- * The namespace of the element.
- * @param localName
- * The local name of the element.
- */
- public void startElement(String uri, String localName)
- {
- ElementInformation elementInformation = new ElementInformation(uri, localName);
- if (elementInformationStack.size() > 0)
- {
- ElementInformation parent = (ElementInformation) elementInformationStack.peek();
- parent.children.add(elementInformation);
- }
- elementInformationStack.push(elementInformation);
- }
-
- /**
- * This method should be called in the end element method of the XML validator's
- * content handler.
- *
- * @param uri
- * The namespace of the element.
- * @param localName
- * The local name of the element.
- */
- public void endElement(String uri, String localName)
- {
- if (elementInformationStack.size() > 0)
- {
- ElementInformation elementInformation = (ElementInformation)elementInformationStack.pop();
- if (messageForConsideration != null)
- {
- IErrorMessageCustomizer[] customizers = ErrorCustomizationRegistry.getInstance().getCustomizers(elementInformation.getNamespace());
- int numCustomizers = customizers.length;
- for(int i = 0; i < numCustomizers; i++)
- {
- String message = customizers[i].customizeMessage(elementInformation, messageForConsideration.key, messageForConsideration.arguments);
- if(message != null)
- {
- messageForConsideration.message.setMessage(message);
- break;
- }
- }
- }
- }
- }
-
- /**
- * Consider the reported error for customization.
- *
- * @param valInfo
- * The current ValidationInfo object containing validation specific information.
- * @param key
- * The key related to the message.
- * @param arguments
- * Any message arguments.
- */
- public void considerReportedError(ValidationInfo valInfo, String key, Object[] arguments)
- {
- messageForConsideration = null;
- ValidationMessage[] messages = valInfo.getValidationMessages();
- if (messages.length > 0)
- {
- messageForConsideration = new ErrorMessageInformation();
- messageForConsideration.key = key;
- messageForConsideration.arguments = arguments;
- messageForConsideration.message = messages[messages.length - 1];
- }
- }
-
- /**
- * A simple class to hold error message information.
- */
- public class ErrorMessageInformation
- {
- public String key = null;
- public Object[] arguments = null;
- public ValidationMessage message = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationRegistry.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationRegistry.java
deleted file mode 100644
index 20948794fa..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorCustomizationRegistry.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.errorcustomization;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The error customization regsitry manages all registered
- * IErrorMessageCustomizers by namespace.
- */
-public class ErrorCustomizationRegistry
-{
- protected static ErrorCustomizationRegistry registry = null;
- protected Map customizers = new HashMap();
-
- /**
- * Restricted constructor in keeping with the singleton pattern.
- */
- protected ErrorCustomizationRegistry()
- {
- }
-
- /**
- * Get the one and only instance of the registry.
- *
- * @return
- * The one and only instance of the registry.
- */
- public static ErrorCustomizationRegistry getInstance()
- {
- if(registry == null)
- {
- registry = new ErrorCustomizationRegistry();
- }
- return registry;
- }
-
- /**
- * Add a customizer to the registry.
- *
- * @param namespace
- * The namespace the customizer will act on.
- * @param customizer
- * The error customizer to register.
- */
- public void addErrorMessageCustomizer(String namespace, IErrorMessageCustomizer customizer)
- {
- // To register a customizer for the no namespace use an empty string.
- if(namespace == null)
- {
- namespace = ""; //$NON-NLS-1$
- }
- List customizersForNS = (List)customizers.get(namespace);
- if(customizersForNS == null)
- {
- customizersForNS = new ArrayList();
- customizers.put(namespace, customizersForNS);
- }
- if(customizer != null)
- {
- customizersForNS.add(customizer);
- }
- }
-
- /**
- * Get the error customizers for a given namespace.
- *
- * @param namespace
- * The namespace for which to retrieve the customizers.
- * @return
- * An array of customizers registered for this namespace.
- */
- public IErrorMessageCustomizer[] getCustomizers(String namespace)
- {
- if(namespace == null)
- {
- namespace = ""; //$NON-NLS-1$
- }
- List customizersForNS = (List)customizers.get(namespace);
- if(customizersForNS == null)
- {
- customizersForNS = new ArrayList();
- }
- return (IErrorMessageCustomizer[])customizersForNS.toArray(new IErrorMessageCustomizer[customizersForNS.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorMessageCustomizerDelegate.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorMessageCustomizerDelegate.java
deleted file mode 100644
index 07147c1455..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/ErrorMessageCustomizerDelegate.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.errorcustomization;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.osgi.framework.Bundle;
-
-/**
- * An error message customizer delegate is used to allow for
- * lazy loading of error customizers.
- *
- */
-public class ErrorMessageCustomizerDelegate implements IErrorMessageCustomizer
-{
- protected Bundle bundle = null;
- protected String classname = null;
- protected IErrorMessageCustomizer customizer = null;
-
- public ErrorMessageCustomizerDelegate(Bundle bundle, String classname)
- {
- this.bundle = bundle;
- this.classname = classname;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xml.core.internal.validation.errorcustomization.IErrorMessageCustomizer#customizeMessage(org.eclipse.wst.xml.core.internal.validation.errorcustomization.ElementInformation, java.lang.String, java.lang.Object[])
- */
- public String customizeMessage(ElementInformation elementInfo, String errorKey, Object[] arguments)
- {
- if(customizer == null)
- {
- loadCustomizer();
- }
- if(customizer == null)
- {
- return null;
- }
- return customizer.customizeMessage(elementInfo, errorKey, arguments);
- }
-
- /**
- * Load the customizer class.
- */
- protected void loadCustomizer()
- {
- try
- {
- Class customizerClass = bundle.loadClass(classname);
- customizer = (IErrorMessageCustomizer)customizerClass.newInstance();
- }
- catch(Exception e)
- {
- XMLCorePlugin.getDefault().getLog().log(
- new Status(IStatus.WARNING,
- XMLCorePlugin.getDefault().getBundle().getSymbolicName(),
- IStatus.OK,
- "The XML validator error customizer was unable to load class " + classname, e)); //$NON-NLS-1$
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/IErrorMessageCustomizer.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/IErrorMessageCustomizer.java
deleted file mode 100644
index ac6d1e0d89..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/errorcustomization/IErrorMessageCustomizer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.validation.errorcustomization;
-
-/**
- * An error message customizer will be called by the XML validator to customize
- * XML validation errors for a given namespace. The customizer can be used to
- * create clearer errors for specific application domains.
- */
-public interface IErrorMessageCustomizer
-{
- /**
- * Return a customized error message for the given element. Null should be returned
- * if the message should not be customized.
- *
- * @param elementInformation
- * The information about the element for which to customize the error.
- * @param errorKey
- * The key for the error for which to replace the message.
- * @param arguments
- * Arguments related the the error message.
- * @return
- * A customized error message or null if this customizer will not customize the message.
- */
- public String customizeMessage(ElementInformation elementInfo, String errorKey, Object[] arguments);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties
deleted file mode 100644
index a88483aa59..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/xmlvalidation.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2011 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
-###############################################################################
-!-- Constants for strings
-
-! Usage:
-! {0} replaced with the host name
-!
-_UI_PROBLEMS_VALIDATING_UNKNOWN_HOST = The file cannot be validated as the host "{0}" is currently unreachable.
-
-! Usage:
-! {0} replaced with the file name
-!
-_UI_PROBLEMS_VALIDATING_FILE_NOT_FOUND = The file cannot be validated as the XML definition "{0}" that is specified as describing the syntax of the file cannot be located.
-
-_UI_PROBLEMS_CONNECTION_REFUSED = The file cannot be validated as there was a connection problem.
-
-!
-! Referenced File Dialog Related Message
-!
-_UI_REF_FILE_ERROR_MESSAGE = Referenced file contains errors ({0}). For more information, right click on the message in the Problems View and select "Show Details..."
-
-# Warning when no grammar is located.
-_WARN_NO_GRAMMAR = No grammar constraints (DTD or XML schema) detected for the document.
-
-_NO_DOCUMENT_ELEMENT = A well-formed document requires a root element.
-
diff --git a/bundles/org.eclipse.wst.xml.core/src/.cvsignore b/bundles/org.eclipse.wst.xml.core/src/.cvsignore
deleted file mode 100644
index 101c29e19d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-notebook.jpage
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/DebugAdapterFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/DebugAdapterFactory.java
deleted file mode 100644
index 266b80a5fc..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/DebugAdapterFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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;
-
-import java.util.ArrayList;
-
-import org.eclipse.wst.sse.core.internal.PropagatingAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-
-
-public class DebugAdapterFactory extends AbstractAdapterFactory implements PropagatingAdapterFactory {
-
- /**
- * Constructor for DebugAdapterFactory.
- */
- public DebugAdapterFactory() {
- this(IDebugAdapter.class, true);
- }
-
- /**
- * Constructor for DebugAdapterFactory.
- *
- * @param fAdapterKey
- * @param registerAdapters
- */
- private DebugAdapterFactory(Object adapterKey, boolean registerAdapters) {
- super(adapterKey, registerAdapters);
- }
-
-
- public void addContributedFactories(INodeAdapterFactory factory) {
- //none expected
- }
-
- public INodeAdapterFactory copy() {
- return new DebugAdapterFactory(getAdapterKey(), isShouldRegisterAdapter());
- }
-
- protected INodeAdapter createAdapter(INodeNotifier target) {
- EveryNodeDebugAdapter result = null;
- result = EveryNodeDebugAdapter.getInstance();
- return result;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IAdapterFactory#isFactoryForType(java.lang.Object)
- */
- public boolean isFactoryForType(Object type) {
-
- return IDebugAdapter.class == type;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.PropagatingAdapterFactory#setContributedFactories(java.util.ArrayList)
- */
- public void setContributedFactories(ArrayList list) {
- // none expected
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java
deleted file mode 100644
index baa718c736..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.IModelStateListener;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.events.AboutToBeChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-
-/**
- * Purely for use in debugging
- */
-public class EveryNodeDebugAdapter implements IDebugAdapter {
-
- static class InternalDocumentListener implements IDocumentListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- Debug.println("IdocumentAboutToBeChanged: " + event); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- Debug.println("IdocumentChanged: " + event); //$NON-NLS-1$
-
- }
-
- }
-
- static class InternalModelStateListener implements IModelStateListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelStateListener#modelAboutToBeChanged(org.eclipse.wst.sse.core.IStructuredModel)
- */
- public void modelAboutToBeChanged(IStructuredModel model) {
- Debug.println("modelAboutToBeChanged: " + model); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelStateListener#modelChanged(org.eclipse.wst.sse.core.IStructuredModel)
- */
- public void modelChanged(IStructuredModel model) {
- Debug.println("modelChanged: " + model); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelStateListener#modelDirtyStateChanged(org.eclipse.wst.sse.core.IStructuredModel,
- * boolean)
- */
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- Debug.println("modelDirtyStateChanged: " + model); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelStateListener#modelResourceDeleted(org.eclipse.wst.sse.core.IStructuredModel)
- */
- public void modelResourceDeleted(IStructuredModel model) {
- Debug.println("modelResourceDeleted: " + model); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelStateListener#modelResourceMoved(org.eclipse.wst.sse.core.IStructuredModel,
- * org.eclipse.wst.sse.core.IStructuredModel)
- */
- public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
- Debug.println("modelResourceMoved: " + "oldModel: " + oldModel + "newModel: " + newModel); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
- Debug.println("modelAboutToBeReinitialized: " + "structuredModel: " + structuredModel); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- public void modelReinitialized(IStructuredModel structuredModel) {
- Debug.println("modelReinitialized: " + "structuredModel: " + structuredModel); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- }
-
- static class InternalStructuredDocumentAboutToChange implements IModelAboutToBeChangedListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener#modelAboutToBeChanged(org.eclipse.wst.sse.core.events.AboutToBeChangedEvent)
- */
- public void modelAboutToBeChanged(AboutToBeChangedEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentAboutToBeChanged: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- }
-
- static class InternalStructuredDocumentListener implements IStructuredDocumentListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#newModel(org.eclipse.wst.sse.core.events.NewDocumentContentEvent)
- */
- public void newModel(NewDocumentEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentChanged - newModel: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#noChange(org.eclipse.wst.sse.core.events.NoChangeEvent)
- */
- public void noChange(NoChangeEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentChanged - noChange: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#nodesReplaced(org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent)
- */
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentChanged - nodesReplaced: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#regionChanged(org.eclipse.wst.sse.core.events.RegionChangedEvent)
- */
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentChanged - regionChanged: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#regionsReplaced(org.eclipse.wst.sse.core.events.RegionsReplacedEvent)
- */
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
- Debug.println("structuredDocumentChanged - regionsReplaced: " + structuredDocumentEvent); //$NON-NLS-1$
-
- }
-
- }
-
- private static EveryNodeDebugAdapter singletonInstance;
-
- public static EveryNodeDebugAdapter getInstance() {
- if (singletonInstance == null) {
- singletonInstance = new EveryNodeDebugAdapter();
- }
- return singletonInstance;
- }
-
- InternalDocumentListener fInternalDocumentListener;
- InternalModelStateListener fInternalModelStateListener;
- InternalStructuredDocumentAboutToChange fInternalStructuredDocumentAboutToChange;
- InternalStructuredDocumentListener fInternalStructuredDocumentListener;
- IStructuredModel fModel;
-
- /**
- *
- */
- public EveryNodeDebugAdapter() {
- super();
- fInternalDocumentListener = new InternalDocumentListener();
- fInternalStructuredDocumentAboutToChange = new InternalStructuredDocumentAboutToChange();
- fInternalStructuredDocumentListener = new InternalStructuredDocumentListener();
- fInternalModelStateListener = new InternalModelStateListener();
- }
-
- /**
- * @param target
- */
- public EveryNodeDebugAdapter(INodeNotifier target) {
- this();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.INodeAdapter#isAdapterForType(java.lang.Object)
- */
- public boolean isAdapterForType(Object type) {
- return (type == IDebugAdapter.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.INodeAdapter#notifyChanged(org.eclipse.wst.sse.core.INodeNotifier,
- * int, java.lang.Object, java.lang.Object, java.lang.Object, int)
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (notifier instanceof IDOMNode) {
- setModel(((IDOMNode) notifier).getModel());
- }
- Debug.println("notifier: " + notifier + " " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " changedFeature: " + changedFeature + " oldValue: " + oldValue + " newValue: " + newValue + " pos: " + pos); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.internal.IDebugAdapter#setDocument(org.eclipse.wst.sse.core.text.IStructuredDocument)
- */
- private void setModel(IStructuredModel structuredModel) {
- if (fModel == structuredModel)
- return;
-
- if (fModel != null) {
- fModel.removeModelStateListener(fInternalModelStateListener);
- //
- IStructuredDocument structuredDocument = fModel.getStructuredDocument();
- if (structuredDocument != null) {
- structuredDocument.removeDocumentListener(fInternalDocumentListener);
- structuredDocument.removeDocumentAboutToChangeListener(fInternalStructuredDocumentAboutToChange);
- structuredDocument.removeDocumentChangedListener(fInternalStructuredDocumentListener);
- }
- }
- fModel = structuredModel;
- if (fModel != null) {
-
- fModel.addModelStateListener(fInternalModelStateListener);
- //
- IStructuredDocument structuredDocument = fModel.getStructuredDocument();
- if (structuredDocument != null) {
- structuredDocument.addDocumentListener(fInternalDocumentListener);
- structuredDocument.addDocumentAboutToChangeListener(fInternalStructuredDocumentAboutToChange);
- structuredDocument.addDocumentChangedListener(fInternalStructuredDocumentListener);
- }
- }
-
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/IDebugAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/IDebugAdapter.java
deleted file mode 100644
index 35c5712dae..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/IDebugAdapter.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-
-
-public interface IDebugAdapter extends INodeAdapter {
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/Logger.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/Logger.java
deleted file mode 100644
index 798c9bba70..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/Logger.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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;
-
-import com.ibm.icu.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.Bundle;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if
- * desired, the console. This class should only be used by classes in this
- * plugin. Other plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static final String PLUGIN_ID = "org.eclipse.wst.xml.core"; //$NON-NLS-1$
-
- public static final int ERROR = IStatus.ERROR; // 4
- public static final int ERROR_DEBUG = 200 + ERROR;
- public static final int INFO = IStatus.INFO; // 1
- public static final int INFO_DEBUG = 200 + INFO;
-
- public static final int OK = IStatus.OK; // 0
-
- public static final int OK_DEBUG = 200 + OK;
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int WARNING_DEBUG = 200 + WARNING;
-
- /**
- * Adds message to log.
- *
- * @param level
- * severity level of the message (OK, INFO, WARNING, ERROR,
- * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message
- * text to add to the log
- * @param exception
- * exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- *
- * @param message
- * text to print
- * @param category
- * category of the message, to be compared with
- * /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
- }
-
- /**
- * @return true if the platform is debugging
- */
- public static boolean isDebugging() {
- return Platform.inDebugMode();
- }
-
- /**
- * Determines if currently tracing a category
- *
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCoreMessages.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCoreMessages.java
deleted file mode 100644
index 831c0a274e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCoreMessages.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005, 2010 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 - Initial API and implementation
- * Jesper Steen Moeller - Added XML Catalogs 1.1 support
- **********************************************************************/
-package org.eclipse.wst.xml.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML Core
- *
- * @plannedfor 1.0
- */
-public class XMLCoreMessages {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.core.internal.XMLCorePluginResources";//$NON-NLS-1$
-
- public static String Invalid_character_lt_fo_ERROR_;
- public static String Invalid_character_gt_fo_ERROR_;
- public static String Invalid_character_amp_fo_ERROR_;
- public static String Invalid_character__f_EXC_;
- public static String loading;
- public static String Catalog_entry_key_not_set;
- public static String Catalog_entry_uri_not_set;
- public static String Catalog_rewrite_startString_not_set;
- public static String Catalog_rewrite_prefix_not_set;
- public static String Catalog_suffix_string_not_set;
- public static String Catalog_suffix_uri_not_set;
- public static String Catalog_delegate_prefix_not_set;
- public static String Catalog_delegate_catalog_not_set;
- public static String Catalog_next_catalog_location_uri_not_set;
- public static String Catalog_resolution_null_catalog;
- public static String Catalog_resolution_malformed_url;
- public static String Catalog_resolution_io_exception;
- public static String CMDocument_load_exception;
- public static String End_tag_has_attributes;
- public static String Attribute__is_missing_a_value;
- public static String Attribute__has_no_value;
- public static String Missing_end_tag_;
- public static String Missing_start_tag_;
- public static String ReconcileStepForMarkup_0;
- public static String ReconcileStepForMarkup_1;
- public static String ReconcileStepForMarkup_2;
- public static String ReconcileStepForMarkup_3;
- public static String ReconcileStepForMarkup_4;
- public static String ReconcileStepForMarkup_5;
- public static String ReconcileStepForMarkup_6;
- public static String Indicate_no_grammar_specified_severities_error;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLCoreMessages.class);
- }
-
- private XMLCoreMessages() {
- // cannot create new instance
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java
deleted file mode 100644
index b31c95aaf4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.xml.core.internal.catalog.Catalog;
-import org.eclipse.wst.xml.core.internal.catalog.CatalogSet;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class XMLCorePlugin extends Plugin {
- // The shared instance.
- private static XMLCorePlugin plugin;
- public static final String USER_CATALOG_ID = "user_catalog"; //$NON-NLS-1$
- public static final String DEFAULT_CATALOG_ID = "default_catalog"; //$NON-NLS-1$
- public static final String SYSTEM_CATALOG_ID = "system_catalog"; //$NON-NLS-1$
- private CatalogSet catalogSet = null;
- private String defaultCatalogFileStateLocation;
-
-
- /**
- * Returns the shared instance.
- */
- public static XMLCorePlugin getDefault() {
- return plugin;
- }
-
- /**
- * @deprecated use ResourcesPlugin.getWorkspace() directly
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * The constructor.
- */
- public XMLCorePlugin() {
- super();
- plugin = this;
- }
-
- private String getPluginStateLocation(String fileName) {
- String location = getStateLocation().append(fileName).toString();
- String file_protocol = "file:"; //$NON-NLS-1$
- if (location != null && !location.startsWith(file_protocol)) {
- location = file_protocol + location;
- }
- return location;
- }
-
- public ICatalog getDefaultXMLCatalog() {
- if (catalogSet == null) {
- catalogSet = new CatalogSet();
-
- defaultCatalogFileStateLocation = getPluginStateLocation(Catalog.DEFAULT_CATALOG_FILE);
-
- catalogSet.putCatalogPersistenceLocation(DEFAULT_CATALOG_ID, defaultCatalogFileStateLocation);
- catalogSet.putCatalogPersistenceLocation(SYSTEM_CATALOG_ID, getPluginStateLocation(Catalog.SYSTEM_CATALOG_FILE));
- catalogSet.putCatalogPersistenceLocation(USER_CATALOG_ID, getPluginStateLocation(Catalog.USER_CATALOG_FILE));
- }
- return catalogSet.lookupOrCreateCatalog(DEFAULT_CATALOG_ID, defaultCatalogFileStateLocation);
- }
-
- public void clearCatalogCache() {
- if (catalogSet != null) {
- catalogSet.clearResourceCache();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePluginResources.properties b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePluginResources.properties
deleted file mode 100644
index d9f1fb7099..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePluginResources.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2010 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
-# Jesper Steen Moeller - Added XML Catalogs 1.1 support
-#
-###############################################################################
-Invalid_character_lt_fo_ERROR_=Invalid character ('<') found
-Invalid_character_gt_fo_ERROR_=Invalid character ('>') found
-Invalid_character_amp_fo_ERROR_=Invalid character ('&') found
-Invalid_character__f_EXC_=Invalid character ('\"') found
-###############################################################################
-# contentmodel strings
-loading=loading
-# catalog strings
-Catalog_entry_key_not_set=Catalog entry key is not set
-Catalog_entry_uri_not_set=Catalog entry URI is not set
-Catalog_rewrite_startString_not_set=Catalog rewrite start string is not set
-Catalog_rewrite_prefix_not_set=Catalog rewrite prefix is not set
-Catalog_suffix_string_not_set=Catalog suffix string is not set
-Catalog_suffix_uri_not_set=Catalog suffix URI is not set
-Catalog_delegate_prefix_not_set=Catalog delegate prefix is not set
-Catalog_delegate_catalog_not_set=Catalog delegate URI is not set
-Catalog_next_catalog_location_uri_not_set=Next catalog location URI is not set
-Catalog_resolution_null_catalog=Catalog resolution attempted with null catalog; ignored
-Catalog_resolution_malformed_url=Malformed URL exception trying to resolve
-Catalog_resolution_io_exception=I/O exception trying to resolve
-CMDocument_load_exception=An error occurred while loading document {0} with publicId {1}
-End_tag_has_attributes=End tag has attributes
-Attribute__is_missing_a_value=Attribute \"{0}\" is missing a value
-Attribute__has_no_value=Attribute \"{0}\" has no value
-Missing_start_tag_=Missing start tag \"{0}\"
-Missing_end_tag_=Missing end tag \"{0}\"
-ReconcileStepForMarkup_0=Missing closing quote
-ReconcileStepForMarkup_1=Missing quotes for attribute value
-ReconcileStepForMarkup_2=A tagname cannot start with a space
-ReconcileStepForMarkup_3=Empty tags are not allowed
-ReconcileStepForMarkup_4=Namespaces are not allowed in a Processing Instruction target
-ReconcileStepForMarkup_5=Spaces are not allowed before a Processing Instruction
-ReconcileStepForMarkup_6=Tag missing closing bracket '>'
-Indicate_no_grammar_specified_severities_error=ErrorCMDocument_load_exception=An error occurred while loading document {0} with publicId {1}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java
deleted file mode 100644
index 05a4af4a52..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.cleanup.AbstractStructuredCleanupProcessor;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
-import org.eclipse.wst.xml.core.internal.document.TextImpl;
-import org.eclipse.wst.xml.core.internal.formatter.XMLFormatterFormatProcessor;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-
-public class CleanupProcessorXML extends AbstractStructuredCleanupProcessor {
- protected IStructuredCleanupPreferences fCleanupPreferences = null;
-
- public void cleanupModel(IStructuredModel structuredModel) {
- Preferences preferences = getModelPreferences();
- if (preferences != null && preferences.getBoolean(XMLCorePreferenceNames.FIX_XML_DECLARATION)) {
- IDOMDocument document = ((DOMModelImpl) structuredModel).getDocument();
- if (!fixExistingXmlDecl(document)) {
- String encoding = preferences.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
- Node xml = document.createProcessingInstruction("xml", "version=\"1.0\" " + "encoding=\"" + encoding +"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- document.insertBefore(xml, document.getFirstChild());
- }
- }
- super.cleanupModel(structuredModel);
- }
-
- /**
- * Is the node an XML declaration
- * @param node
- * @return true if the node is an XML declaration; otherwise, false.
- */
- private boolean isXMLDecl(IDOMNode node) {
- return node != null && node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && "xml".equalsIgnoreCase(((ProcessingInstruction) node).getTarget()); //$NON-NLS-1$
- }
-
- private boolean fixExistingXmlDecl(IDOMDocument document) {
- IDOMNode node = (IDOMNode) document.getFirstChild();
- while (node != null && node.getNodeType() == Node.TEXT_NODE && ((TextImpl) node).isWhitespace())
- node = (IDOMNode) node.getNextSibling();
- if (isXMLDecl(node)) {
- document.insertBefore(node, document.getFirstChild());
- return true;
- }
- return false;
- }
-
- protected IStructuredCleanupHandler getCleanupHandler(Node node) {
- short nodeType = node.getNodeType();
- IStructuredCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE : {
- cleanupHandler = new ElementNodeCleanupHandler();
- break;
- }
- case Node.TEXT_NODE : {
- cleanupHandler = new NodeCleanupHandler();
- break;
- }
- default : {
- cleanupHandler = new NodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
-
- return cleanupHandler;
- }
-
- public IStructuredCleanupPreferences getCleanupPreferences() {
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new StructuredCleanupPreferences();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
- }
- }
-
- return fCleanupPreferences;
- }
-
- protected String getContentType() {
- return ContentTypeIdForXML.ContentTypeID_XML;
- }
-
- protected IStructuredFormatProcessor getFormatProcessor() {
- return new XMLFormatterFormatProcessor();
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void refreshCleanupPreferences() {
- fCleanupPreferences = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/ElementNodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/ElementNodeCleanupHandler.java
deleted file mode 100644
index 10baa534a3..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/ElementNodeCleanupHandler.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- * David Carver (Intalion) - Cleanup Repeated Conditional check in isXMLType method
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.cleanup;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class ElementNodeCleanupHandler extends NodeCleanupHandler {
- protected static final char DOUBLE_QUOTE = '\"'; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTES = "\"\""; //$NON-NLS-1$
- protected static final String EMPTY_TAG_CLOSE = "/>"; //$NON-NLS-1$
- protected static final String END_TAG_OPEN = "</"; //$NON-NLS-1$
- protected static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$
- protected static final String SINGLE_QUOTES = "''"; //$NON-NLS-1$
-
- /** Non-NLS strings */
- protected static final String START_TAG_OPEN = "<"; //$NON-NLS-1$
- protected static final String TAG_CLOSE = ">"; //$NON-NLS-1$
-
- public Node cleanup(Node node) {
- Node newNode = cleanupChildren(node);
- IDOMNode renamedNode = newNode instanceof IDOMNode ? (IDOMNode) newNode : null;
-
- // call quoteAttrValue() first so it will close any unclosed attr
- // quoteAttrValue() will return the new start tag if there is a
- // structure change
- renamedNode = quoteAttrValue(renamedNode);
-
- // insert tag close if missing
- // if node is not comment tag
- // and not implicit tag
- if (!isCommentTag(renamedNode) && !isImplicitTag(renamedNode)) {
- IDOMModel structuredModel = renamedNode.getModel();
-
- // save start offset before insertTagClose()
- // or else renamedNode.getStartOffset() will be zero if
- // renamedNode replaced by insertTagClose()
- int startTagStartOffset = renamedNode.getStartOffset();
-
- // for start tag
- IStructuredDocumentRegion startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
- insertTagClose(structuredModel, startTagStructuredDocumentRegion);
-
- // update renamedNode and startTagStructuredDocumentRegion after
- // insertTagClose()
- renamedNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset);
- startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
-
- // for end tag
- IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion)
- insertTagClose(structuredModel, endTagStructuredDocumentRegion);
- }
-
- // call insertMissingTags() next, it will generate implicit tags if
- // there are any
- // insertMissingTags() will return the new missing start tag if one is
- // missing
- renamedNode = insertMissingTags(renamedNode);
-
- renamedNode = compressEmptyElementTag(renamedNode);
-
- renamedNode = insertRequiredAttrs(renamedNode);
-
- return renamedNode;
- }
-
- protected Node cleanupChildren(Node node) {
- Node parentNode = node;
-
- if (node != null) {
- Node childNode = node.getFirstChild();
- while (childNode != null) {
- // get cleanup handler
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler(childNode);
-
- // cleanup each child
- childNode = cleanupHandler.cleanup(childNode);
-
- // get new parent node
- parentNode = childNode.getParentNode();
-
- // get next child node
- childNode = childNode.getNextSibling();
- }
- }
-
- return parentNode;
- }
-
- private IDOMNode compressEmptyElementTag(IDOMNode node) {
- boolean compressEmptyElementTags = getCleanupPreferences().getCompressEmptyElementTags();
- IDOMNode newNode = node;
-
- IStructuredDocumentRegion startTagStructuredDocumentRegion = newNode.getFirstStructuredDocumentRegion();
- IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getLastStructuredDocumentRegion();
-
- if (compressEmptyElementTags && startTagStructuredDocumentRegion != endTagStructuredDocumentRegion && startTagStructuredDocumentRegion != null) {
- ITextRegionList regions = startTagStructuredDocumentRegion.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- // format children and end tag if not empty element tag
- if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- NodeList childNodes = newNode.getChildNodes();
- if (childNodes == null || childNodes.getLength() == 0 || (childNodes.getLength() == 1 && (childNodes.item(0)).getNodeType() == Node.TEXT_NODE && ((childNodes.item(0)).getNodeValue().trim().length() == 0))) {
- IDOMModel structuredModel = newNode.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- int startTagStartOffset = newNode.getStartOffset();
- int offset = endTagStructuredDocumentRegion.getStart();
- int length = endTagStructuredDocumentRegion.getLength();
- structuredDocument.replaceText(structuredDocument, offset, length, ""); //$NON-NLS-1$
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
-
- offset = startTagStructuredDocumentRegion.getStart() + lastRegion.getStart();
- structuredDocument.replaceText(structuredDocument, offset, 0, "/"); //$NON-NLS-1$
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- }
- }
- }
-
- return newNode;
- }
-
- protected IStructuredCleanupHandler getCleanupHandler(Node node) {
- short nodeType = node.getNodeType();
- IStructuredCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case org.w3c.dom.Node.ELEMENT_NODE : {
- cleanupHandler = new ElementNodeCleanupHandler();
- break;
- }
- case org.w3c.dom.Node.TEXT_NODE : {
- cleanupHandler = new NodeCleanupHandler();
- break;
- }
- default : {
- cleanupHandler = new NodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
-
- return cleanupHandler;
- }
-
-
- protected ModelQuery getModelQuery(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return ModelQueryUtil.getModelQuery((Document) node);
- } else {
- return ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- }
- }
-
- protected List getRequiredAttrs(Node node) {
- List result = new ArrayList();
-
- ModelQuery modelQuery = getModelQuery(node);
- if (modelQuery != null) {
- CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
- if (elementDecl != null) {
- CMNamedNodeMap attrMap = elementDecl.getAttributes();
- Iterator it = attrMap.iterator();
- CMAttributeDeclaration attr = null;
- while (it.hasNext()) {
- attr = (CMAttributeDeclaration) it.next();
- if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
- result.add(attr);
- }
- }
- }
- }
-
- return result;
- }
-
- private IDOMNode insertEndTag(IDOMNode node) {
- IDOMNode newNode = node;
- IDOMElement element = (IDOMElement) node;
- if (element.isCommentTag())
- return node; // do nothing
-
- int startTagStartOffset = node.getStartOffset();
- IDOMModel structuredModel = node.getModel();
-
- if (isEmptyElement(element)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- ITextRegionList regions = startStructuredDocumentRegion.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), lastRegion.getLength(), EMPTY_TAG_CLOSE);
-
- if (regions.size() > 1) {
- ITextRegion regionBeforeTagClose = regions.get(regions.size() - 1 - 1);
-
- // insert a space separator before tag close if the previous
- // region does not have extra spaces
- if (regionBeforeTagClose.getTextLength() == regionBeforeTagClose.getLength())
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$
- }
- } else {
- String tagName = node.getNodeName();
- String endTag = END_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
-
- IDOMNode lastChild = (IDOMNode) node.getLastChild();
- int endTagStartOffset = 0;
- if (lastChild != null)
- // if this node has children, insert the end tag after the
- // last child
- endTagStartOffset = lastChild.getEndOffset();
- else
- // if this node does not has children, insert the end tag
- // after the start tag
- endTagStartOffset = node.getEndOffset();
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, endTagStartOffset, 0, endTag);
- }
-
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
-
- return newNode;
- }
-
- private IDOMNode insertMissingTags(IDOMNode node) {
- boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags();
- IDOMNode newNode = node;
-
- if (insertMissingTags) {
- IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startTagStructuredDocumentRegion == null) {
- // implicit start tag; generate tag for it
- newNode = insertStartTag(node);
- startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
- }
-
- IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion();
- ITextRegionList startStructuredDocumentRegionRegions = startTagStructuredDocumentRegion.getRegions();
- if (startTagStructuredDocumentRegion != null && startStructuredDocumentRegionRegions != null && (startStructuredDocumentRegionRegions.get(startStructuredDocumentRegionRegions.size() - 1)).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
-
- } else {
- if (startTagStructuredDocumentRegion == null) {
- // start tag missing
- if (isStartTagRequired(newNode))
- newNode = insertStartTag(newNode);
- } else if (endTagStructuredDocumentRegion == null) {
- // end tag missing
- if (isEndTagRequired(newNode))
- newNode = insertEndTag(newNode);
- }
- }
- }
-
- return newNode;
- }
-
- private IDOMNode insertRequiredAttrs(IDOMNode node) {
- boolean insertRequiredAttrs = getCleanupPreferences().getInsertRequiredAttrs();
- IDOMNode newNode = node;
-
- if (insertRequiredAttrs) {
- List requiredAttrs = getRequiredAttrs(newNode);
- if (requiredAttrs.size() > 0) {
- NamedNodeMap currentAttrs = node.getAttributes();
- List insertAttrs = new ArrayList();
- if (currentAttrs.getLength() == 0)
- insertAttrs.addAll(requiredAttrs);
- else {
- for (int i = 0; i < requiredAttrs.size(); i++) {
- String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName();
- boolean found = false;
- for (int j = 0; j < currentAttrs.getLength(); j++) {
- String currentAttrName = currentAttrs.item(j).getNodeName();
- if (requiredAttrName.compareToIgnoreCase(currentAttrName) == 0) {
- found = true;
- break;
- }
- }
- if (!found)
- insertAttrs.add(requiredAttrs.get(i));
- }
- }
- if (insertAttrs.size() > 0) {
- IStructuredDocumentRegion startStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
- int index = startStructuredDocumentRegion.getEndOffset();
- ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion();
- if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) {
- index--;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- } else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- index = index - 2;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- try {
- for (int i = insertAttrs.size() - 1; i >= 0; i--) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
- String requiredAttributeName = attrDecl.getAttrName();
- String defaultValue = attrDecl.getDefaultValue();
- if (defaultValue == null)
- defaultValue = ""; //$NON-NLS-1$
- String nameAndDefaultValue = " "; //$NON-NLS-1$
- if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
- nameAndDefaultValue = ""; //$NON-NLS-1$
- nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
- // BUG3381: MultiTextEdit applies all child
- // TextEdit's basing on offsets
- // in the document before the first TextEdit, not
- // after each
- // child TextEdit. Therefore, do not need to
- // advance the index.
- //index += nameAndDefaultValue.length();
- }
- multiTextEdit.apply(newNode.getStructuredDocument());
- } catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
- }
- }
-
- return newNode;
- }
-
- private IDOMNode insertStartTag(IDOMNode node) {
- IDOMNode newNode = node;
-
- if (isCommentTag(node))
- return node; // do nothing
-
- String tagName = node.getNodeName();
- String startTag = START_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
- int startTagStartOffset = node.getStartOffset();
-
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, startTagStartOffset, 0, startTag);
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
-
- return newNode;
- }
-
- private void insertTagClose(IDOMModel structuredModel, IStructuredDocumentRegion flatNode) {
- if (flatNode != null) {
- ITextRegionList flatnodeRegions = flatNode.getRegions();
- if (flatnodeRegions != null) {
- ITextRegion lastRegion = flatnodeRegions.get(flatnodeRegions.size() - 1);
- if (lastRegion != null) {
- String regionType = lastRegion.getType();
- if ((regionType != DOMRegionContext.XML_EMPTY_TAG_CLOSE) && (regionType != DOMRegionContext.XML_TAG_CLOSE)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- // insert ">" after lastRegion of flatNode
- // as in "<a</a>" if flatNode is for start tag, or in
- // "<a></a" if flatNode is for end tag
- structuredDocument.replaceText(structuredDocument, flatNode.getTextEndOffset(lastRegion), 0, ">"); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- /**
- * @param renamedNode
- * @return
- */
- private boolean isCommentTag(Node renamedNode) {
- boolean result = false;
- if (renamedNode instanceof IDOMElement) {
- IDOMElement element = (IDOMElement) renamedNode;
- result = element.isCommentTag();
- }
- return result;
- }
-
- private boolean isEmptyElement(IDOMElement element) {
- Document document = element.getOwnerDocument();
- if (document == null)
- // undefined tag, return default
- return false;
-
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery == null)
- // undefined tag, return default
- return false;
-
- CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
- if (decl == null)
- // undefined tag, return default
- return false;
-
- return (decl.getContentType() == CMElementDeclaration.EMPTY);
- }
-
- private boolean isEndTagRequired(IDOMNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- /**
- * A tag is implicit if it has not corresponding region in document.
- *
- * @param renamedNode
- * @return
- */
- private boolean isImplicitTag(IDOMNode renamedNode) {
- return renamedNode.getStartStructuredDocumentRegion() == null;
- }
-
- /**
- * The end tags of HTML EMPTY content type, such as IMG, and HTML
- * undefined tags are parsed separately from the start tags. So inserting
- * the missing start tag is useless and even harmful.
- */
- private boolean isStartTagRequired(IDOMNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- private boolean isXMLType(IDOMModel structuredModel) {
- boolean result = false;
-
- if (structuredModel != null) {
- IDOMDocument document = structuredModel.getDocument();
-
- if (document != null)
- result = document.isXMLType();
- }
-
- return result;
- }
-
- private IDOMNode quoteAttrValue(IDOMNode node) {
- IDOMNode newNode = node;
- //XMLElement element = (XMLElement) node;
- if (isCommentTag(node))
- return node; // do nothing
-
- boolean quoteAttrValues = getCleanupPreferences().getQuoteAttrValues();
-
- if (quoteAttrValues) {
- NamedNodeMap attributes = newNode.getAttributes();
- if (attributes != null) {
- int attributesLength = attributes.getLength();
- ISourceGenerator generator = node.getModel().getGenerator();
-
- for (int i = 0; i < attributesLength; i++) {
- attributes = newNode.getAttributes();
- attributesLength = attributes.getLength();
- IDOMAttr eachAttr = (IDOMAttr) attributes.item(i);
- //ITextRegion oldAttrValueRegion =
- // eachAttr.getValueRegion();
- String oldAttrValue = eachAttr.getValueRegionText();
- if (oldAttrValue == null) {
- IDOMModel structuredModel = node.getModel();
- if (isXMLType(structuredModel)) {
- String newAttrValue = "\"" + eachAttr.getNameRegionText() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- if (eachAttr.getEqualRegion() != null)
- // equal region exists
- structuredDocument.replaceText(structuredDocument, eachAttr.getEndOffset(), 0, newAttrValue);
- else
- // no equal region
- structuredDocument.replaceText(structuredDocument, eachAttr.getNameRegionTextEndOffset(), 0, "=".concat(newAttrValue)); //$NON-NLS-1$
- newNode = (IDOMNode) structuredModel.getIndexedRegion(node.getStartOffset()); // save
- // new
- // node
- }
- } else {
- //String oldAttrValue = oldAttrValueRegion.getText();
- char quote = StringUtils.isQuoted(oldAttrValue) ? oldAttrValue.charAt(0) : DOUBLE_QUOTE;
- String newAttrValue = generator.generateAttrValue(eachAttr, quote);
-
- // There is a problem in
- // StructuredDocumentRegionUtil.getAttrValue(ITextRegion)
- // when the region is instanceof ContextRegion.
- // Workaround for now...
- if (oldAttrValue.length() == 1) {
- char firstChar = oldAttrValue.charAt(0);
- if (firstChar == SINGLE_QUOTE)
- newAttrValue = SINGLE_QUOTES;
- else if (firstChar == DOUBLE_QUOTE)
- newAttrValue = DOUBLE_QUOTES;
- }
-
- if (newAttrValue != null) {
- if (newAttrValue.compareTo(oldAttrValue) != 0) {
- int attrValueStartOffset = eachAttr.getValueRegionStartOffset();
- int attrValueLength = oldAttrValue.length();
- int startTagStartOffset = node.getStartOffset();
-
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, attrValueStartOffset, attrValueLength, newAttrValue);
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
- }
- }
- }
- }
- }
- }
-
- return newNode;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java
deleted file mode 100644
index 95c209792b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.cleanup;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.w3c.dom.Node;
-
-
-public class NodeCleanupHandler implements IStructuredCleanupHandler {
-
- protected IStructuredCleanupPreferences fCleanupPreferences = null;
- protected IProgressMonitor fProgressMonitor = null;
-
-
- public Node cleanup(Node node) {
-
- return node;
- }
-
- public IStructuredCleanupPreferences getCleanupPreferences() {
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new StructuredCleanupPreferences();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
- }
- }
-
- return fCleanupPreferences;
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- public void setCleanupPreferences(IStructuredCleanupPreferences cleanupPreferences) {
-
- fCleanupPreferences = cleanupPreferences;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java
deleted file mode 100644
index 473c4875da..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLPreferenceNames;
-
-/**
- * @deprecated renamed to StructuredCleanupPreferences
- *
- * TODO will delete in C5
- */
-public class XMLCleanupPreferencesImpl {
-
- private static XMLCleanupPreferencesImpl fInstance;
-
- public synchronized static XMLCleanupPreferencesImpl getInstance() {
-
- // added for one method in CleanupDialog ... may be better way
- if (fInstance == null) {
- fInstance = new XMLCleanupPreferencesImpl();
- }
- return fInstance;
- }
-
- private int fAttrNameCase;
- private boolean fConvertEOLCodes;
- private String fEOLCode;
- private boolean fFormatSource;
- private boolean fInsertMissingTags;
- // private IPreferenceStore fPreferenceStore = null;
- private Preferences fPreferences = null;
- private boolean fQuoteAttrValues;
- private int fTagNameCase;
-
- public int getAttrNameCase() {
-
- return fAttrNameCase;
- }
-
- public boolean getConvertEOLCodes() {
-
- return fConvertEOLCodes;
- }
-
- public String getEOLCode() {
-
- return fEOLCode;
- }
-
- public boolean getFormatSource() {
-
- return fFormatSource;
- }
-
- public boolean getInsertMissingTags() {
-
- return fInsertMissingTags;
- }
-
- public Preferences getPreferences() {
-
- if (fPreferences == null) {
- fPreferences = SSECorePlugin.getDefault().getPluginPreferences();
- }
- return fPreferences;
- }
-
- public boolean getQuoteAttrValues() {
-
- return fQuoteAttrValues;
- }
-
- public int getTagNameCase() {
-
- return fTagNameCase;
- }
-
- public void setAttrNameCase(int attrNameCase) {
-
- fAttrNameCase = attrNameCase;
- }
-
- public void setConvertEOLCodes(boolean convertEOLCodes) {
-
- fConvertEOLCodes = convertEOLCodes;
- }
-
- public void setEOLCode(String EOLCode) {
-
- fEOLCode = EOLCode;
- }
-
- public void setFormatSource(boolean formatSource) {
-
- fFormatSource = formatSource;
- }
-
- public void setInsertMissingTags(boolean insertMissingTags) {
-
- fInsertMissingTags = insertMissingTags;
- }
-
- public void setPreferences(Preferences prefs) {
-
- fPreferences = prefs;
- updateOptions();
- }
-
- public void setQuoteAttrValues(boolean quoteAttrValues) {
-
- fQuoteAttrValues = quoteAttrValues;
- }
-
- public void setTagNameCase(int tagNameCase) {
-
- fTagNameCase = tagNameCase;
- }
-
- protected void updateOptions() {
-
- Preferences p = getPreferences();
- fTagNameCase = p.getInt(IXMLPreferenceNames.CLEANUP_TAG_NAME_CASE);
- fAttrNameCase = p.getInt(IXMLPreferenceNames.CLEANUP_ATTR_NAME_CASE);
- fInsertMissingTags = p.getBoolean(IXMLPreferenceNames.INSERT_MISSING_TAGS);
- fQuoteAttrValues = p.getBoolean(IXMLPreferenceNames.QUOTE_ATTR_VALUES);
- fFormatSource = p.getBoolean(IXMLPreferenceNames.FORMAT_SOURCE);
- fConvertEOLCodes = p.getBoolean(IXMLPreferenceNames.CONVERT_EOL_CODES);
- fEOLCode = p.getString(IXMLPreferenceNames.CLEANUP_EOL_CODE);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java
deleted file mode 100644
index c06af5e212..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.commentelement;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementConfiguration;
-import org.eclipse.wst.xml.core.internal.document.TagAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-
-/**
- */
-public class CommentElementAdapter implements TagAdapter {
- private CommentElementConfiguration fConfiguration;
-
- private boolean fEndTag;
- private CommentElementHandler fHandler;
-
- public CommentElementAdapter(boolean isEndTag, CommentElementHandler handler) {
- fEndTag = isEndTag;
- fHandler = handler;
- }
-
- private String generateCommentClose(IDOMElement element) {
- return (element.isJSPTag()) ? "--%>" : "-->"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String generateCommentOpen(IDOMElement element) {
- return (element.isJSPTag()) ? "<%--" : "<!--"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private CommentElementConfiguration getConfiguration() {
- return fConfiguration;
- }
-
- public String getEndTag(IDOMElement element) {
- String content = fHandler.generateEndTagContent(element);
- if (content == null) {
- return null;
- }
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(generateCommentOpen(element));
- buffer.append(content);
- buffer.append(generateCommentClose(element));
-
- return buffer.toString();
- }
-
- public String getHandlerID() {
- return getConfiguration().getHandlerID();
- }
-
-
- public String getProperty(String name) {
- return getConfiguration().getProperty(name);
- }
-
- public String getStartTag(IDOMElement element) {
- String content = fHandler.generateStartTagContent(element);
- if (content == null) {
- return null;
- }
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(generateCommentOpen(element));
- buffer.append(content);
- buffer.append(generateCommentClose(element));
-
- return buffer.toString();
- }
-
- public boolean isAdapterForType(Object type) {
- return (type == CommentElementAdapter.class || type == TagAdapter.class);
- }
-
- public boolean isContainer() {
- return (!fHandler.isEmpty());
- }
-
- public boolean isEndTag() {
- return fEndTag;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- public void setConfiguration(CommentElementConfiguration configuration) {
- fConfiguration = configuration;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java
deleted file mode 100644
index 93e8e6eedb..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.commentelement;
-
-
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public interface CommentElementHandler {
- /**
- * This method is called when the prefix of the comment content matches
- * the string specified in &lt;startswith prefix=""/&gt; in plugin
- * extension. Comment content is parsed and new DOM element is created in
- * this method. Implementor has to do following:
- * <li>For start tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * </ul>
- * </li>
- * <li>For end tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * <li>make isEndTag flag true.</li>
- * <li>Parser framework searches mached start tag element instance after
- * this createElement call, and new instance is just thrown away.</li>
- * </ul>
- * </li>
- * <li>For empty tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * <li>make isEndTag flag true.</li>
- * </ul>
- * </li>
- *
- * @param document
- * parent DOM document
- * @param data
- * comment content. comment prefix (&lt;!-- or &lt;%--), suffix
- * (--&gt; or --%&gt;), and surrounding spaces are trimmed.
- * @param isJSPTag
- * true if the comment is JSP style comment. This information
- * may be required by handler when the handler accepts both XML
- * style and JSP style comment (namely,
- * commenttype=&quot;both&quot; in plugin.xml).
- * @return comment element instance if the comment content is rightly
- * parsed. if parse failed, returns null.
- */
- Element createElement(Document document, String data, boolean isJSPTag);
-
- /**
- * This method generates the source text of the end tag for the passed
- * element. Do not generate comment prefix (&lt;!-- or &lt;%--) and suffix
- * (--&gt; or --%&gt;). XMLGenerator uses this method to generate XML/HTML
- * source for a comment element.
- *
- * @param element
- * the comment element
- * @return generated tag string
- */
- String generateEndTagContent(IDOMElement element);
-
- /**
- * This method generates the source text of the start tag for the passed
- * element. Do not generate comment prefix (&lt;!-- or &lt;%--) and suffix
- * (--&gt; or --%&gt;). XMLGenerator uses this method to generate XML/HTML
- * source for a comment element.
- *
- * @param element
- * the comment element
- * @return generated tag string
- */
- String generateStartTagContent(IDOMElement element);
-
- /**
- *
- * @param element
- * the element
- * @return boolean whether the element is comment element or not
- */
- boolean isCommentElement(IDOMElement element);
-
- /**
- *
- * @return boolean whether this element can have children or not
- */
- boolean isEmpty();
-
- /**
- * @return String
- */
- // String getElementPrefix();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java
deleted file mode 100644
index caf62283d9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.commentelement.impl;
-
-
-
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.commentelement.util.CommentElementFactory;
-import org.eclipse.wst.xml.core.internal.commentelement.util.TagScanner;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-
-/**
- */
-class BasicCommentElementHandler implements CommentElementHandler {
-
- private String elementName;
- private boolean isEmpty;
-
- public BasicCommentElementHandler(String elementName, boolean isEmpty) {
- super();
- this.elementName = elementName;
- this.isEmpty = isEmpty;
- }
-
-
- public Element createElement(Document document, String data, boolean isJSPTag) {
- Element element = null;
- String str = data.trim();
- CommentElementFactory factory = new CommentElementFactory(document, isJSPTag, this);
- if (str.charAt(0) == '/') { // end tag
- TagScanner scanner = new TagScanner(str, 1); // skip '/'
- String name = scanner.nextName();
- if (name.equals(elementName)) {
- element = factory.create(name, CommentElementFactory.IS_END);
- }
- } else { // start tag
- TagScanner scanner = new TagScanner(str, 0);
- String name = scanner.nextName();
- if (name.equals(elementName)) {
- element = factory.create(name, (isEmpty) ? CommentElementFactory.IS_EMPTY : CommentElementFactory.IS_START);
- // set attributes
- String attrName = scanner.nextName();
- while (attrName != null) {
- String attrValue = scanner.nextValue();
- Attr attr = document.createAttribute(attrName);
- if (attr != null) {
- if (attrValue != null)
- ((IDOMAttr) attr).setValueSource(attrValue);
- element.setAttributeNode(attr);
- }
- attrName = scanner.nextName();
- }
- }
- }
- return element;
- }
-
-
- public String generateEndTagContent(IDOMElement element) {
- if (isEmpty) {
- return null;
- }
- ISourceGenerator generator = element.getModel().getGenerator();
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(" /"); //$NON-NLS-1$
- String tagName = generator.generateTagName(element);
- if (tagName != null) {
- buffer.append(tagName);
- }
- buffer.append(' ');
-
- return buffer.toString();
- }
-
- public String generateStartTagContent(IDOMElement element) {
- ISourceGenerator generator = element.getModel().getGenerator();
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(' ');
- String tagName = generator.generateTagName(element);
- if (tagName != null) {
- buffer.append(tagName);
- }
-
- NamedNodeMap attributes = element.getAttributes();
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- Attr attr = (Attr) attributes.item(i);
- if (attr == null) {
- continue;
- }
- buffer.append(' ');
- String attrName = generator.generateAttrName(attr);
- if (attrName != null) {
- buffer.append(attrName);
- }
- String attrValue = generator.generateAttrValue(attr);
- if (attrValue != null) {
- // attr name only for HTML boolean and JSP
- buffer.append('=');
- buffer.append(attrValue);
- }
- }
-
- buffer.append(' ');
-
- return buffer.toString();
- }
-
- public boolean isCommentElement(IDOMElement element) {
- return (element != null && element.getTagName().equals(elementName)) ? true : false;
- }
-
- public boolean isEmpty() {
- return isEmpty;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java
deleted file mode 100644
index 78d900d615..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.commentelement.impl;
-
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementConfiguration {
- private Map fAttributes = null;
- private boolean fCustom;
- private IConfigurationElement fElement = null;
-
- private boolean fEmpty;
- private CommentElementHandler fHandler = null;
- private String fID = null;
- private boolean fJSPComment;
- private String[] fPrefix = null;
- private boolean fXMLComment;
-
- CommentElementConfiguration(IConfigurationElement element) {
- super();
- fElement = element;
- fCustom = "handler-custom".equalsIgnoreCase(element.getName()); //$NON-NLS-1$
-
- fillAttributes(element);
-
- fXMLComment = fJSPComment = false;
- String commentType = getProperty("commenttype"); //$NON-NLS-1$
- if ("xml".equalsIgnoreCase(commentType)) { //$NON-NLS-1$
- fXMLComment = true;
- } else if ("jsp".equalsIgnoreCase(commentType)) { //$NON-NLS-1$
- fJSPComment = true;
- } else if ("both".equalsIgnoreCase(commentType)) { //$NON-NLS-1$
- fXMLComment = fJSPComment = true;
- }
- String empty = getProperty("isempty"); //$NON-NLS-1$
- fEmpty = Boolean.valueOf(empty).booleanValue(); //$NON-NLS-1$
- }
-
- public boolean acceptJSPComment() {
- return fJSPComment;
- }
-
- public boolean acceptXMLComment() {
- return fXMLComment;
- }
-
- public Element createElement(Document document, String data, boolean isJSPTag) {
- IDOMElement element = (IDOMElement) getHandler().createElement(document, data, isJSPTag);
- if (element != null) {
- CommentElementAdapter adapter = (CommentElementAdapter) element.getAdapterFor(CommentElementAdapter.class);
- if (adapter != null) {
- adapter.setConfiguration(this);
- }
- }
- return element;
- }
-
- private void fillAttributes(IConfigurationElement element) {
- if (fAttributes == null) {
- fAttributes = new HashMap();
- } else {
- fAttributes.clear();
- }
- String[] names = element.getAttributeNames();
- if (names == null) {
- return;
- }
- int length = names.length;
- for (int i = 0; i < length; i++) {
- String name = names[i];
- fAttributes.put(name.toLowerCase(), element.getAttribute(name));
- }
- }
-
- public CommentElementHandler getHandler() {
- if (fHandler == null) {
- if (fElement != null) {
- try {
- if (isCustom()) {
- fHandler = (CommentElementHandler) fElement.createExecutableExtension("class"); //$NON-NLS-1$
- } else {
- String elementName = getProperty("elementname"); //$NON-NLS-1$
- if (elementName != null) {
- fHandler = new BasicCommentElementHandler(elementName, fEmpty);
- }
- }
- // ((AbstractCommentElementHandler)fHandler).setElementPrefix(fElement.getAttribute("prefix"));
- } catch (Exception e) {
- // catch and log (and ignore) ANY exception created
- // by executable extension.
- Logger.logException(e);
- fHandler = null;
- }
- }
- if (fHandler == null) {
- fHandler = new CommentElementHandler() {
- public Element createElement(Document document, String data, boolean isJSPTag) {
- return null;
- }
-
- public String generateEndTagContent(IDOMElement element) {
- return null;
- }
-
- public String generateStartTagContent(IDOMElement element) {
- return null;
- }
-
-// removed in RC2, ro removed "unused" error/warning
-// public String getElementPrefix() {
-// return null;
-// }
-
- public boolean isCommentElement(IDOMElement element) {
- return false;
- }
-
- public boolean isEmpty() {
- return false;
- }
- };
- }
- }
- return fHandler;
- }
-
- public String getHandlerID() {
- if (fID == null) {
- fID = getProperty("id"); //$NON-NLS-1$
- if (fID == null) {
- if (isCustom()) {
- fID = getProperty("class"); //$NON-NLS-1$
- } else {
- StringBuffer buf = new StringBuffer();
- buf.append(fElement.getDeclaringExtension().getNamespace());
- buf.append('.');
- buf.append(getProperty("elementname")); //$NON-NLS-1$
- fID = buf.toString();
- }
- }
- }
- return fID;
- }
-
-
- public String[] getPrefix() {
- if (fPrefix == null) {
- if (fElement != null) {
- if (isCustom()) { // custom
- IConfigurationElement[] prefixes = fElement.getChildren("startwith"); //$NON-NLS-1$
- if (prefixes != null) {
- List prefixValues = new ArrayList(prefixes.length);
- for (int i = 0; i < prefixes.length; i++) {
- String prefix = prefixes[i].getAttribute("prefix"); //$NON-NLS-1$
- if (prefix != null) {
- prefixValues.add(prefix);
- }
- else {
- try {
- Logger.log(Logger.WARNING, "misconfigured comment element in" + fElement.getContributor().getName(), new IllegalArgumentException("startwith")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (InvalidRegistryObjectException e) {
- // stale bundle?
- }
- }
- }
- if (!prefixValues.isEmpty()) {
- fPrefix = (String[]) prefixValues.toArray(new String[prefixValues.size()]);
- }
- }
- } else { // basic
- String name = getProperty("elementname"); //$NON-NLS-1$
- if (name != null) {
- if (isEmpty()) {
- fPrefix = new String[1];
- fPrefix[0] = name;
- } else {
- fPrefix = new String[2];
- fPrefix[0] = name;
- fPrefix[1] = '/' + name;
- }
- }
- }
- }
- }
- if (fPrefix == null) {
- fPrefix = new String[0];
- }
- return fPrefix;
- }
-
- public String getProperty(String name) {
- return (fAttributes != null) ? (String) fAttributes.get(name) : null;
- }
-
- private boolean isCustom() {
- return fCustom;
- }
-
- private boolean isEmpty() {
- return fEmpty;
- }
-
- void setupCommentElement(IDOMElement element) {
- element.setCommentTag(true);
- CommentElementAdapter adapter = new CommentElementAdapter(false, fHandler);
- adapter.setConfiguration(this);
- element.addAdapter(adapter);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java
deleted file mode 100644
index 3516c9b23c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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.commentelement.impl;
-
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-
-/**
- */
-public class CommentElementRegistry {
-
- private static CommentElementRegistry fInstance = null;
-
- public synchronized static CommentElementRegistry getInstance() {
- if (fInstance == null) {
- fInstance = new CommentElementRegistry();
- }
- return fInstance;
- }
-
- private String EXTENSION_POINT_ID = "commentElementHandler"; //$NON-NLS-1$
- private CommentElementConfiguration[] fConfigurations = null;
-
- private String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- /**
- * Constructor for CommentElementRegistry.
- */
- private CommentElementRegistry() {
- super();
- }
-
- public synchronized CommentElementConfiguration[] getConfigurations() {
- if (fConfigurations == null) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- fConfigurations = new CommentElementConfiguration[elements.length];
- for (int i = 0; i < elements.length; i++) {
- fConfigurations[i] = new CommentElementConfiguration(elements[i]);
- }
- }
- if (fConfigurations == null) {
- fConfigurations = new CommentElementConfiguration[0];
- }
- }
- return fConfigurations;
- }
-
- public boolean setupCommentElement(IDOMElement element) {
- CommentElementConfiguration configurations[] = getConfigurations();
- int length = configurations.length;
- for (int i = 0; i < length; i++) {
- CommentElementConfiguration conf = configurations[i];
- boolean isJSP = element.isJSPTag();
- if (isJSP && conf.acceptJSPComment() || !isJSP && conf.acceptXMLComment()) {
- CommentElementHandler handler = conf.getHandler();
- if (handler.isCommentElement(element)) {
- conf.setupCommentElement(element);
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java
deleted file mode 100644
index 2ac27ba0b1..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.commentelement.util;
-
-
-
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementFactory {
- public static final int IS_EMPTY = 4866;
- public static final int IS_END = 1808;
-
- public static final int IS_START = 28011;
-
- private Document fDocument;
- private CommentElementHandler fHandler;
- private boolean fJSPTag;
-
- /**
- * Constructor for CommentElementFactory.
- */
- private CommentElementFactory() {
- super();
- }
-
- public CommentElementFactory(Document document, boolean isJSPTag, CommentElementHandler handler) {
- this();
- fDocument = document;
- fJSPTag = isJSPTag;
- fHandler = handler;
- }
-
- public Element create(String name, int nodeType) {
- IDOMElement element = (IDOMElement) fDocument.createElement(name);
- if (element == null)
- return null;
- element.setCommentTag(true);
- if (nodeType == IS_EMPTY) {
- element.setEmptyTag(true);
- }
- element.setJSPTag(fJSPTag);
-
- CommentElementAdapter adapter = new CommentElementAdapter((nodeType == IS_END), fHandler);
- element.addAdapter(adapter);
-
- return element;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java
deleted file mode 100644
index 1d0d404c86..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.commentelement.util;
-
-
-
-/**
- */
-public class TagScanner {
-
- /**
- */
- private static boolean isEqual(char c) {
- return (c == '=');
- }
-
- /**
- */
- private static boolean isQuote(char c) {
- return (c == '"' || c == '\'');
- }
-
- /**
- */
- private static boolean isSpace(char c) {
- return Character.isWhitespace(c);
- }
-
- private int length = 0;
- private int memOffset = 0;
- private int offset = 0;
- private boolean oneLine = false;
-
- private String tag = null;
-
- /**
- */
- public TagScanner(String tag, int offset) {
- super();
-
- this.tag = tag;
- this.offset = offset;
- this.memOffset = -1;
- if (tag != null)
- this.length = tag.length();
- }
-
- /**
- */
- public TagScanner(String tag, int offset, boolean oneLine) {
- this(tag, offset);
-
- this.oneLine = oneLine;
- }
-
- /**
- */
- public int getNextOffset() {
- int i;
- char c;
- for (i = offset; i < length; i++) {
- c = tag.charAt(i);
- if (isEnd(c))
- break;
- if (isQuote(c)) {
- i++;
- break;
- }
- if (!isSpace(c) && !isEqual(c))
- break;
- }
- return i;
- }
-
- /**
- */
- public int getOffset() {
- return this.memOffset;
- }
-
- /**
- */
- private final boolean isEnd(char c) {
- return (this.oneLine && (c == '\r' || c == '\n'));
- }
-
- /**
- */
- public boolean isNewLine() {
- if (oneLine)
- return false;
- char c;
- for (int i = memOffset - 1; 0 <= i; i--) {
- c = tag.charAt(i);
- if (c == '\r' || c == '\n')
- return true;
- if (!isSpace(c))
- return false;
- }
- return false;
- }
-
- /**
- */
- private char nextChar() {
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c))
- break;
- if (!isSpace(c))
- return c;
- }
- return 0;
- }
-
- /**
- */
- public String nextName() {
- if (this.tag == null)
- return null;
- if (this.offset >= this.length)
- return null;
-
- if (nextChar() == 0)
- return null;
-
- int nameOffset = this.offset;
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c) || isSpace(c))
- break;
- if (isEqual(c) && this.offset > nameOffset)
- break;
- }
- if (this.offset == nameOffset)
- return null;
-
- this.memOffset = nameOffset;
- return this.tag.substring(nameOffset, this.offset);
- }
-
- /**
- */
- public String nextValue() {
- if (this.tag == null)
- return null;
- if (this.offset >= this.length)
- return null;
-
- char seperator = nextChar();
- if (!isEqual(seperator))
- return null;
- this.offset++; // skip '='
- char quote = nextChar();
- if (quote == 0)
- return null;
- if (isQuote(quote))
- this.offset++;
- else
- quote = 0;
-
- int valueOffset = this.offset;
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c)) {
- quote = 0;
- break;
- }
- if (quote == 0) {
- if (isSpace(c))
- break;
- } else {
- if (c == quote)
- break;
- }
- }
- int valueEnd = this.offset;
- if (quote != 0 && this.offset < this.length)
- this.offset++;
- if (valueEnd == valueOffset)
- return null;
-
- this.memOffset = valueOffset;
- return this.tag.substring(valueOffset, valueEnd);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/AbstractResourceEncodingDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/AbstractResourceEncodingDetector.java
deleted file mode 100644
index fcbcbea17f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/AbstractResourceEncodingDetector.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.contenttype;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
-
-
-public abstract class AbstractResourceEncodingDetector implements IResourceCharsetDetector {
-
- protected EncodingMemento fEncodingMemento;
-
- protected boolean fHeaderParsed;
-
- protected Reader fReader;
-
- /**
- *
- */
- public AbstractResourceEncodingDetector() {
- super();
- }
-
- /**
- * Note: once this instance is created, trace info still needs to be
- * appended by caller, depending on the context its created.
- */
- private void createEncodingMemento(String detectedCharsetName) {
- fEncodingMemento = new EncodingMemento();
- fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName));
- fEncodingMemento.setDetectedCharsetName(detectedCharsetName);
- // TODO: if detectedCharset and spec default is
- // null, need to use "work
- // bench based" defaults.
- fEncodingMemento.setAppropriateDefault(getSpecDefaultEncoding());
- }
-
- /**
- * convience method all subclasses can use (but not override)
- *
- * @param detectedCharsetName
- * @param reason
- */
- final protected void createEncodingMemento(String detectedCharsetName, String reason) {
- createEncodingMemento(detectedCharsetName);
- }
-
- /**
- * convience method all subclasses can use (but not override)
- */
- final protected void ensureInputSet() {
- if (fReader == null) {
- throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$
- }
- }
-
- /**
- * This method can return null, if invalid charset name (in which case
- * "appropriateDefault" should be used, if a name is really need for some
- * "save anyway" cases).
- *
- * @param detectedCharsetName
- * @return
- */
- private String getAppropriateJavaCharset(String detectedCharsetName) {
- String result = null;
- // 1. Check explicit mapping overrides from
- // property file -- its here we pick up "rules" for cases
- // that are not even in Java
- result = CodedIO.checkMappingOverrides(detectedCharsetName);
- // 2. Use the "canonical" name from JRE mappings
- // Note: see Charset JavaDoc, the name you get one
- // with can be alias,
- // the name you get back is "standard" name.
- Charset javaCharset = null;
- try {
- javaCharset = Charset.forName(detectedCharsetName);
- } catch (UnsupportedCharsetException e) {
- // only set invalid, if result is same as detected -- they won't
- // be equal if
- // overridden
- if (result != null && result.equals(detectedCharsetName)) {
- fEncodingMemento.setInvalidEncoding(detectedCharsetName);
- }
- } catch (IllegalCharsetNameException e) {
- // only set invalid, if result is same as detected -- they won't
- // be equal if
- // overridden
- if (result != null && result.equals(detectedCharsetName)) {
- fEncodingMemento.setInvalidEncoding(detectedCharsetName);
- }
- }
- // give priority to java cononical name, if present
- if (javaCharset != null) {
- result = javaCharset.name();
- // but still allow overrides
- result = CodedIO.checkMappingOverrides(result);
- }
- return result;
- }
-
- public String getEncoding() throws IOException {
- return getEncodingMemento().getDetectedCharsetName();
- }
-
- // to ensure consist overall rules used, we'll mark as
- // final,
- // and require subclasses to provide certain pieces of
- // the
- // implementation
- public EncodingMemento getEncodingMemento() throws IOException {
- ensureInputSet();
- if (!fHeaderParsed) {
- parseInput();
- // we keep track of if header's already been
- // parse, so can make
- // multiple 'get' calls, without causing
- // reparsing.
- fHeaderParsed = true;
- // Note: there is a "hidden assumption" here
- // that an empty
- // string in content should be treated same as
- // not present.
- }
- if (fEncodingMemento == null) {
- handleSpecDefault();
- }
- if (fEncodingMemento == null) {
- // safty net
- fEncodingMemento = new NullMemento();
- }
- return fEncodingMemento;
- }
-
- /**
- * This is to return a default encoding -- as specified by an industry
- * content type spec -- when not present in the stream, for example, XML
- * specifies UTF-8, JSP specifies ISO-8859-1. This method should return
- * null if there is no such "spec default".
- */
- abstract public String getSpecDefaultEncoding();
-
- public EncodingMemento getSpecDefaultEncodingMemento() {
- resetAll();
- EncodingMemento result = null;
- String enc = getSpecDefaultEncoding();
- if (enc != null) {
- createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT);
- fEncodingMemento.setAppropriateDefault(enc);
- result = fEncodingMemento;
- }
- return result;
- }
-
- private void handleSpecDefault() {
- String encodingName;
- encodingName = getSpecDefaultEncoding();
- if (encodingName != null) {
- //createEncodingMemento(encodingName,
- // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
- fEncodingMemento = new EncodingMemento();
- fEncodingMemento.setJavaCharsetName(encodingName);
- fEncodingMemento.setAppropriateDefault(encodingName);
- }
- }
-
- /**
- * Every subclass must provide a way to parse the input. This method has
- * several critical responsibilities:
- * <li>set the fEncodingMemento field appropriately, according to the
- * results of the parse of fReader.</li>
- * <li>set fHarderParsed to true, to avoid wasted re-parsing.</li>
- */
- abstract protected void parseInput() throws IOException;
-
- /**
- *
- */
- protected void resetAll() {
- fReader = null;
- fHeaderParsed = false;
- fEncodingMemento = null;
- }
-
- /**
- *
- */
- public void set(InputStream inputStream) {
- resetAll();
- fReader = new ByteReader(inputStream);
- try {
- fReader.mark(CodedIO.MAX_MARK_SIZE);
- } catch (IOException e) {
- // impossible, since we know ByteReader
- // supports marking
- throw new Error(e);
- }
- }
-
- /**
- *
- */
- public void set(IStorage iStorage) throws CoreException {
- resetAll();
- InputStream inputStream = iStorage.getContents();
- InputStream resettableStream = new BufferedInputStream(inputStream, CodedIO.MAX_BUF_SIZE);
- resettableStream.mark(CodedIO.MAX_MARK_SIZE);
- set(resettableStream);
- // TODO we'll need to "remember" IFile, or
- // get its (or its project's) settings, in case
- // those are needed to handle cases when the
- // encoding is not in the file stream.
- }
-
- /**
- * Note: this is not part of interface to help avoid confusion ... it
- * expected this Reader is a well formed character reader ... that is, its
- * all ready been determined to not be a unicode marked input stream. And,
- * its assumed to be in the correct position, at position zero, ready to
- * read first character.
- */
- public void set(Reader reader) {
- resetAll();
- fReader = reader;
- if (!fReader.markSupported()) {
- fReader = new BufferedReader(fReader);
- }
- try {
- fReader.mark(CodedIO.MAX_MARK_SIZE);
- } catch (IOException e) {
- // impossble, since we just checked if markable
- throw new Error(e);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java
deleted file mode 100644
index 3d50b3f7a2..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.contenttype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
-
-/**
- * This is an "adapter" class, simply to get in input stream to act like a
- * reader. We could not use InputStreamReader directly because its internal
- * buffers are not controllable, and it sometimes pulls too much out of input
- * stream (even when it wasn't needed for our purposes).
- *
- * The use of this class is highly specialized and by not means meant to be
- * general purpose. Its use is restricted to those cases where the input
- * stream can be regarded as ascii just long enough to determine what the real
- * encoding should be.
- */
-
-public class ByteReader extends Reader {
-
- public static final int DEFAULT_BUFFER_SIZE = CodedIO.MAX_BUF_SIZE;
-
- protected byte[] fBuffer;
-
- protected InputStream fInputStream;
-
- protected ByteReader() {
- super();
- }
-
- public ByteReader(InputStream inputStream) {
- this(inputStream, DEFAULT_BUFFER_SIZE);
- if (!inputStream.markSupported()) {
- throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
- }
- }
-
- public ByteReader(InputStream inputStream, int size) {
- fInputStream = inputStream;
- if (!inputStream.markSupported()) {
- throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
- }
- fBuffer = new byte[size];
-
- }
-
- public void close() throws IOException {
- fInputStream.close();
- }
-
- public void mark(int readAheadLimit) throws IOException {
- fInputStream.mark(readAheadLimit);
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public int read() throws IOException {
- int b0 = fInputStream.read();
- return (b0 & 0x00FF);
- }
-
- public int read(char ch[], int offset, int length) throws IOException {
- if (length > fBuffer.length) {
- length = fBuffer.length;
- }
-
- int count = fInputStream.read(fBuffer, 0, length);
-
- for (int i = 0; i < count; i++) {
- int b0 = fBuffer[i];
- // the 0x00FF is to "lose" the negative bits filled in the byte to
- // int conversion
- // (and which would be there if cast directly from byte to char).
- char c0 = (char) (b0 & 0x00FF);
- ch[offset + i] = c0;
- }
- return count;
- }
-
- public boolean ready() throws IOException {
- return fInputStream.available() > 0;
- }
-
- public void reset() throws IOException {
- fInputStream.reset();
- }
-
- public long skip(long n) throws IOException {
- return fInputStream.skip(n);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ContentDescriberForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ContentDescriberForXML.java
deleted file mode 100644
index 9e56e7029e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ContentDescriberForXML.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.contenttype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentDescriber;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.ITextContentDescriber;
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended;
-import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
-
-
-public final class ContentDescriberForXML implements ITextContentDescriber {
- private final static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT};
- /**
- * <code>restrictedMode</code> is used just for testing/experiments.
- *
- * If in restrictedMode, our "custom" contentType is seen as valid only in
- * cases that the platform's standard one does not cover.
- */
- private final static boolean restrictedMode = true;
- private IResourceCharsetDetector getDetector() {
- return new XMLResourceEncodingDetector();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.content.IContentDescriber#describe(java.io.InputStream,
- * org.eclipse.core.runtime.content.IContentDescription)
- */
- public int describe(InputStream contents, IContentDescription description) throws IOException {
- // for this special case, always assume invalid, unless
- // our special circumstances are met.
- int result = IContentDescriber.INVALID;
-
- if (description == null) {
- // purely request for validty
- result = determineValidity(result, contents);
- }
- else {
- result = calculateSupportedOptions(result, contents, description);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.content.ITextContentDescriber#describe(java.io.Reader,
- * org.eclipse.core.runtime.content.IContentDescription)
- */
- public int describe(Reader contents, IContentDescription description) throws IOException {
- // for this special case, always assume invalid, unless
- // our special circumstances are met.
- int result = IContentDescriber.INVALID;
-
- if (description == null) {
- // purely request for validty
- result = determineValidity(result, contents);
- }
- else {
- result = calculateSupportedOptions(result, contents, description);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.content.IContentDescriber#getSupportedOptions()
- */
- public QualifiedName[] getSupportedOptions() {
-
- return SUPPORTED_OPTIONS;
- }
-
- private int calculateSupportedOptions(int result, InputStream contents, IContentDescription description) throws IOException {
- int returnResult = result;
- if (isRelevent(description)) {
- IResourceCharsetDetector detector = getDetector();
- contents.reset();
- detector.set(contents);
- returnResult = handleCalculations(result, description, detector);
- }
- return returnResult;
- }
-
- private int determineValidity(int result, InputStream contents) throws IOException {
- int returnResult = result;
- IResourceCharsetDetector detector = getDetector();
- contents.reset();
- detector.set(contents);
- returnResult = determineValidity(detector, returnResult);
- return returnResult;
- }
- private int determineValidity(int result, Reader contents) throws IOException {
- int returnResult = result;
- IResourceCharsetDetector detector = getDetector();
- contents.reset();
- detector.set(contents);
- returnResult = determineValidity(detector, returnResult);
- return returnResult;
- }
- /**
- * @param contents
- * @param description
- * @throws IOException
- */
- private int calculateSupportedOptions(int result, Reader contents, IContentDescription description) throws IOException {
- int returnResult = result;
- if (isRelevent(description)) {
- IResourceCharsetDetector detector = getDetector();
- detector.set(contents);
- returnResult = handleCalculations(result, description, detector);
- }
- return returnResult;
- }
-
- private void handleDetectedSpecialCase(IContentDescription description, Object detectedCharset, Object javaCharset) {
- // since equal, we don't need to add, but if our detected version is
- // different than
- // javaCharset, then we should add it. This will happen, for example,
- // if there's
- // differences in case, or differences due to override properties
- if (detectedCharset != null) {
- // if (!detectedCharset.equals(javaCharset)) {
- // description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET,
- // detectedCharset);
- // }
-
- // Once we detected a charset, we should set the property even
- // though it's the same as javaCharset
- // because there are clients that rely on this property to
- // determine if the charset is actually detected in file or not.
- description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, detectedCharset);
- }
- }
-
- /**
- * @param description
- * @return
- */
- private boolean isRelevent(IContentDescription description) {
- boolean result = false;
- if (description == null)
- result = false;
- else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK))
- result = true;
- else if (description.isRequested(IContentDescription.CHARSET))
- result = true;
- else if (description.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT))
- result = true;
- else if (description.isRequested(IContentDescriptionExtended.DETECTED_CHARSET))
- result = true;
- else if (description.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET))
- result = true;
- return result;
- }
-
- /**
- * @param description
- * @param detector
- * @throws IOException
- */
- private int handleCalculations(int result, IContentDescription description, IResourceCharsetDetector detector) throws IOException {
- int returnResult = result;
- EncodingMemento encodingMemento = ((XMLResourceEncodingDetector) detector).getEncodingMemento();
- if (description != null) {
- // TODO: I need to verify to see if this BOM work is always done
- // by text type.
- Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
- if (detectedByteOrderMark != null) {
- Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
- // not sure why would ever be different, so if is different,
- // may
- // need to "push" up into base.
- if (!detectedByteOrderMark.equals(existingByteOrderMark))
- description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
- }
-
-
- if (!encodingMemento.isValid()) {
- // note: after setting here, its the mere presence of
- // IContentDescriptionExtended.UNSUPPORTED_CHARSET
- // in the resource's description that can be used to determine
- // if invalid in those cases, the "detected" property contains
- // an "appropriate default" to use.
- description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
- description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
- }
-
- Object detectedCharset = encodingMemento.getDetectedCharsetName();
- Object javaCharset = encodingMemento.getJavaCharsetName();
-
- // we always include detected, if its different than java
- handleDetectedSpecialCase(description, detectedCharset, javaCharset);
-
- if (javaCharset != null) {
- Object existingCharset = description.getProperty(IContentDescription.CHARSET);
- if (javaCharset.equals(existingCharset)) {
- handleDetectedSpecialCase(description, detectedCharset, javaCharset);
- }
- else {
- // we may need to add what we found, but only need to add
- // if different from the default
- Object defaultCharset = detector.getSpecDefaultEncoding();
- if (defaultCharset != null) {
- if (!defaultCharset.equals(javaCharset)) {
- description.setProperty(IContentDescription.CHARSET, javaCharset);
- }
- }
- else {
- // assuming if there is no spec default, we always
- // need to add.
- // TODO: this is probably a dead branch in current
- // code, should re-examine for removal.
- description.setProperty(IContentDescription.CHARSET, javaCharset);
- }
- }
- }
- }
-
- returnResult = determineValidity(detector, returnResult);
- return returnResult;
- }
-
- private int determineValidity(IResourceCharsetDetector detector, int returnResult) {
- // we always expect XMLResourceEncodingDetector, but just to make safe
- // cast.
- if (detector instanceof XMLResourceEncodingDetector) {
- XMLResourceEncodingDetector xmlResourceDetector = (XMLResourceEncodingDetector) detector;
- if (xmlResourceDetector.isDeclDetected()) {
- if (restrictedMode) {
- // if there is no initial whitespace, then platform's
- // default one will do.
- if (xmlResourceDetector.hasInitialWhiteSpace()) {
- returnResult = IContentDescriber.VALID;
- }
- }
- else {
- returnResult = IContentDescriber.VALID;
- }
- }
- }
- return returnResult;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java
deleted file mode 100644
index d4542a43cb..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.contenttype;
-
-
-public interface EncodingParserConstants {
-
- final String EOF = "EOF"; //$NON-NLS-1$
- final String InvalidTerminatedStringValue = "InvalidTerminatedStringValue"; //$NON-NLS-1$
- final String InvalidTermintatedUnDelimitedStringValue = "InvalidTermintatedUnDelimitedStringValue"; //$NON-NLS-1$
- final String MAX_CHARS_REACHED = "MAX_CHARS_REACHED"; //$NON-NLS-1$
- final String StringValue = "strval"; //$NON-NLS-1$
- final String UnDelimitedStringValue = "UnDelimitedStringValue"; //$NON-NLS-1$
- public final String UTF16BE = "UTF16BE"; //$NON-NLS-1$
- public final String UTF16LE = "UTF16LE"; //$NON-NLS-1$
-
-
- public final String UTF83ByteBOM = "UTF83ByteBOM"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java
deleted file mode 100644
index 0f14b8b570..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.contenttype;
-
-public class HeadParserToken {
- private int fStart;
-
- private String fText;
- private String fType;
-
- protected HeadParserToken() {
- super();
- }
-
- public HeadParserToken(String type, int start, String text) {
- this();
- fType = type;
- fStart = start;
- fText = text;
-
- }
-
- public String getText() {
- return fText;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return ("text: " + fText + " offset: " + fStart + " type: " + fType); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java
deleted file mode 100644
index 52dbae6905..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.contenttype;
-
-/*
- *
- * A non-resizable class implementing the behavior of java.util.Stack, but
- * directly for the <code> integer </code> primitive.
- */
-import java.util.EmptyStackException;
-
-public class IntStack {
- private int[] list = null;
-
- private int size = 0;
-
- public IntStack() {
- this(100);
- }
-
- public IntStack(int maxdepth) {
- super();
- list = new int[maxdepth];
- initialize();
- }
-
- public void clear() {
- initialize();
- }
-
- public boolean empty() {
- return size == 0;
- }
-
- public int get(int slot) {
- return list[slot];
- }
-
- private void initialize() {
- for (int i = 0; i < list.length; i++)
- list[i] = -1;
- }
-
- /**
- * Returns the int at the top of the stack without removing it
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int peek() {
- if (size == 0)
- throw new EmptyStackException();
- return list[size - 1];
- }
-
- /**
- * Removes and returns the int at the top of the stack
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int pop() {
- int value = peek();
- list[size - 1] = -1;
- size--;
- return value;
- }
-
- /**
- * Pushes an item onto the top of this stack.
- *
- * @param newValue -
- * the int to be pushed onto this stack.
- * @return the <code>newValue</code> argument.
- */
- public int push(int newValue) {
- if (size == list.length) {
- throw new StackOverflowError();
- }
- list[size++] = newValue;
- return newValue;
- }
-
- public int size() {
- return size;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer s = new StringBuffer(getClass().getName() + ":" +size + " [");
- for (int i = 0; i < size; i++) {
- s.append(list[i]);
- if(i < size - 1) {
- s.append(", ");
- }
- }
- s.append("]");
- return s.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/NullMemento.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/NullMemento.java
deleted file mode 100644
index 23f7462181..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/NullMemento.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.contenttype;
-
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
-
-
-
-/**
- * This class can be used in place of an EncodingMemento (its super class),
- * when there is not in fact ANY encoding information. For example, when a
- * structuredDocument is created directly from a String
- */
-public class NullMemento extends EncodingMemento {
- /**
- *
- */
- public NullMemento() {
- super();
- String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null);
- setJavaCharsetName(defaultCharset);
- setAppropriateDefault(defaultCharset);
- setDetectedCharsetName(null);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java
deleted file mode 100644
index 4bc3552811..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- * David Carver (STAR) - bug 297006 - String Comparison
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-public class XMLDeclDetector {
- private static final int MAX_BUF_SIZE = 1024 * 8;
- private static final int MAX_MARK_SIZE = 1024 * 8;
- protected boolean fHeaderParsed;
- private boolean fIsXML;
- protected Reader fReader;
- //private boolean DEBUG = false;
- private XMLHeadTokenizer fTokenizer;
-
- private boolean canHandleAsUnicodeStream(String tokenType) {
- boolean canHandleAsUnicodeStream = false;
- if (EncodingParserConstants.UTF83ByteBOM.equals(tokenType)) {
- canHandleAsUnicodeStream = true;
- //fUnicode = "UTF-8"; //$NON-NLS-1$
- } else if (EncodingParserConstants.UTF16BE.equals(tokenType)) {
- canHandleAsUnicodeStream = true;
- //fUnicode = "UTF-16BE"; //$NON-NLS-1$
- } else if (EncodingParserConstants.UTF16LE.equals(tokenType)) {
- canHandleAsUnicodeStream = true;
- //fUnicode = "UTF-16"; //$NON-NLS-1$
- }
- return canHandleAsUnicodeStream;
- }
-
- final private void ensureInputSet() {
- if (fReader == null) {
- throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$
- }
- }
-
- //private String fUnicode;
-
- /**
- * @return Returns the tokenizer.
- */
- private XMLHeadTokenizer getTokenizer() {
- if (fTokenizer == null) {
- fTokenizer = new XMLHeadTokenizer();
- }
- return fTokenizer;
- }
-
- /**
- * @return Returns the isXML.
- */
- public boolean isXML() throws IOException {
- ensureInputSet();
- if (!fHeaderParsed) {
- parseInput();
- }
- return fIsXML;
- }
-
- private void parseInput() throws IOException {
- XMLHeadTokenizer tokenizer = getTokenizer();
- tokenizer.reset(fReader);
- HeadParserToken token = null;
- String tokenType = null;
- do {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (canHandleAsUnicodeStream(tokenType)) {
- fReader.reset();
- // this is (obviously) not always true.
- // TODO: need to fix so we "remember" original iFile or
- // inputstream, and
- // create appropriate InputStreamReader.
- // I'm not sure what to do for the set(reader) case ... if its
- // even relevent.
- // plus, ensure against infinite loops!
- fIsXML = true;
- //fReader = new InputStreamReader(fReader, fUnicode);
- // parseInput();
- } else {
- if (XMLHeadTokenizerConstants.XMLDelEncoding.equals(tokenType)) {
- fIsXML = true;
- }
- }
- } while (tokenizer.hasMoreTokens());
-
- }
-
- private void resetAll() {
- fReader = null;
- fHeaderParsed = false;
- fIsXML = false;
- //fUnicode = null;
-
- }
-
- public void set(IFile iFile) throws CoreException {
- resetAll();
- InputStream inputStream = iFile.getContents(true);
- InputStream resettableStream = new BufferedInputStream(inputStream, MAX_BUF_SIZE);
- resettableStream.mark(MAX_MARK_SIZE);
- set(resettableStream);
- }
-
- public void set(InputStream inputStream) {
- resetAll();
- fReader = new ByteReader(inputStream);
- try {
- fReader.mark(MAX_MARK_SIZE);
- } catch (IOException e) {
- // impossible, since we know ByteReader supports marking
- throw new Error(e);
- }
- }
-
- /**
- * Note: this is not part of interface to help avoid confusion ... it
- * expected this Reader is a well formed character reader ... that is, its
- * all ready been determined to not be a unicode marked input stream. And,
- * its assumed to be in the correct position, at position zero, ready to
- * read first character.
- */
- public void set(Reader reader) {
- resetAll();
- fReader = reader;
- if (!fReader.markSupported()) {
- fReader = new BufferedReader(fReader);
- }
-
- try {
- fReader.mark(MAX_MARK_SIZE);
- } catch (IOException e) {
- // impossble, since we just checked if markable
- throw new Error(e);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java
deleted file mode 100644
index 76fb40b2fc..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java
+++ /dev/null
@@ -1,1451 +0,0 @@
-/* The following code was generated by JFlex 1.4.2 on 7/28/08 9:29 AM */
-
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- *******************************************************************************/
-/*nlsXXX*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizerConstants;
-
-
-
-/**
- * This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4.2
- * on 7/28/08 9:29 AM from the specification file
- * <tt>D:/workspaces/wtp301/workspace/org.eclipse.wst.xml.core/DevTimeSupport/HeadParsers/XMLHeadTokenizer.jFlex</tt>
- */
-public class XMLHeadTokenizer {
-
- /** This character denotes the end of file */
- public static final int YYEOF = -1;
-
- /** initial size of the lookahead buffer */
- private static final int ZZ_BUFFERSIZE = 8192;
-
- /** lexical states */
- public static final int YYINITIAL = 0;
- public static final int UnDelimitedString = 10;
- public static final int DQ_STRING = 6;
- public static final int SQ_STRING = 8;
- public static final int ST_XMLDecl = 2;
- public static final int QuotedAttributeValue = 4;
-
- /**
- * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
- * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
- * at the beginning of a line
- * l is of the form l = 2*k, k a non negative integer
- */
- private static final int ZZ_LEXSTATE[] = {
- 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6
- };
-
- /**
- * Translates characters to character classes
- */
- private static final String ZZ_CMAP_PACKED =
- "\1\11\10\0\1\6\1\10\2\0\1\7\22\0\1\6\1\0\1\33"+
- "\2\0\1\35\1\0\1\34\24\0\1\13\1\12\1\32\1\14\3\0"+
- "\1\27\1\30\1\21\1\0\1\31\1\0\1\24\2\0\1\17\1\16"+
- "\1\26\1\25\2\0\1\22\1\23\2\0\1\20\1\0\1\15\12\0"+
- "\1\27\1\30\1\21\1\0\1\31\1\0\1\24\2\0\1\17\1\16"+
- "\1\26\1\25\2\0\1\22\1\23\2\0\1\20\1\0\1\15\102\0"+
- "\1\4\3\0\1\5\17\0\1\3\16\0\1\1\20\0\1\3\16\0"+
- "\1\1\1\2\170\0\1\2\ufe87\0";
-
- /**
- * Translates characters to character classes
- */
- private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
-
- /**
- * Translates DFA states to action switch labels.
- */
- private static final int [] ZZ_ACTION = zzUnpackAction();
-
- private static final String ZZ_ACTION_PACKED_0 =
- "\7\0\13\1\2\2\1\1\1\2\1\3\1\4\1\5"+
- "\1\6\1\1\1\5\1\7\1\1\1\5\1\10\1\1"+
- "\1\11\1\12\1\13\12\0\1\14\5\0\1\2\1\3"+
- "\1\4\1\6\2\0\1\15\1\7\2\0\1\10\1\11"+
- "\1\16\3\0\1\14\4\0\1\2\1\15\14\0\1\17"+
- "\5\0\1\17\6\0\1\20\3\0\1\20\2\0\1\21"+
- "\1\0\1\21\1\0";
-
- private static int [] zzUnpackAction() {
- int [] result = new int[111];
- int offset = 0;
- offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
- return result;
- }
-
- private static int zzUnpackAction(String packed, int offset, int [] result) {
- int i = 0; /* index in packed string */
- int j = offset; /* index in unpacked array */
- int l = packed.length();
- while (i < l) {
- int count = packed.charAt(i++);
- int value = packed.charAt(i++);
- do result[j++] = value; while (--count > 0);
- }
- return j;
- }
-
-
- /* error codes */
- private static final int ZZ_UNKNOWN_ERROR = 0;
- private static final int ZZ_NO_MATCH = 1;
- private static final int ZZ_PUSHBACK_2BIG = 2;
-
- /* error messages for the codes above */
- private static final String ZZ_ERROR_MSG[] = {
- "Unkown internal scanner error",
- "Error: could not match input",
- "Error: pushback value was too large"
- };
-
- /** the input device */
- private java.io.Reader zzReader;
-
- /** the current state of the DFA */
- private int zzState;
-
- /** the current lexical state */
- private int zzLexicalState = YYINITIAL;
-
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
-
- /** the textposition at the last accepting state */
- private int zzMarkedPos;
-
- /** the current text position in the buffer */
- private int zzCurrentPos;
-
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int zzStartRead;
-
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int zzEndRead;
-
- /** number of newlines encountered up to the start of the matched text */
-// private int yyline;
-
- /** the number of characters up to the start of the matched text */
- private int yychar;
-
- /**
- * the number of characters from the last newline up to the start of the
- * matched text
- */
-// private int yycolumn;
-
- /**
- * zzAtBOL == true <=> the scanner is currently at the beginning of a line
- */
- private boolean zzAtBOL = true;
-
- /** zzAtEOF == true <=> the scanner is at the EOF */
- private boolean zzAtEOF;
-
- /** denotes if the user-EOF-code has already been executed */
- private boolean zzEOFDone;
-
- /* user code: */
-
-
- private boolean hasMore = true;
- private final static int MAX_TO_SCAN = 8000;
- StringBuffer string = new StringBuffer();
- // state stack for easier state handling
- private IntStack fStateStack = new IntStack();
- private String valueText = null;
-
-
- public XMLHeadTokenizer() {
- super();
- }
-
- public void reset (Reader in) {
- /* the input device */
- zzReader = in;
-
- /* the current state of the DFA */
- zzState = 0;
-
- /* the current lexical state */
- zzLexicalState = YYINITIAL;
-
- /* this buffer contains the current text to be matched and is
- the source of the yytext() string */
- java.util.Arrays.fill(zzBuffer, (char)0);
-
- /* the textposition at the last accepting state */
- zzMarkedPos = 0;
-
- /* the textposition at the last state to be included in yytext */
-// zzPushbackPos = 0;
-
- /* the current text position in the buffer */
- zzCurrentPos = 0;
-
- /* startRead marks the beginning of the yytext() string in the buffer */
- zzStartRead = 0;
-
- /**
- * endRead marks the last character in the buffer, that has been read
- * from input
- */
- zzEndRead = 0;
-
- /* number of newlines encountered up to the start of the matched text */
-// yyline = 0;
-
- /* the number of characters up to the start of the matched text */
- yychar = 0;
-
- /**
- * the number of characters from the last newline up to the start
- * of the matched text
- */
-// yycolumn = 0;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning
- * of a line
- */
- zzAtBOL = true;
-
- /* yy_atEOF == true <=> the scanner has returned a value for EOF */
- zzAtEOF = false;
-
- /* denotes if the user-EOF-code has already been executed */
- zzEOFDone = false;
-
-
- fStateStack.clear();
-
- hasMore = true;
-
- }
-
-
- public final HeadParserToken getNextToken() throws IOException {
- String context = null;
- context = primGetNextToken();
- HeadParserToken result = null;
- if (valueText != null) {
- result = createToken(context, yychar, valueText);
- valueText = null;
- } else {
- result = createToken(context, yychar, yytext());
- }
- return result;
- }
-
- public final boolean hasMoreTokens() {
- return hasMore && yychar < MAX_TO_SCAN;
- }
- private void pushCurrentState() {
- fStateStack.push(yystate());
-
- }
-
- private void popState() {
- yybegin(fStateStack.pop());
- }
-
- private HeadParserToken createToken(String context, int start, String text) {
- return new HeadParserToken(context, start, text);
- }
-
-
-
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- public XMLHeadTokenizer(java.io.Reader in) {
- this.zzReader = in;
- }
-
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- public XMLHeadTokenizer(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
-
- /**
- * Unpacks the compressed character translation table.
- *
- * @param packed the packed character translation table
- * @return the unpacked character translation table
- */
- private static char [] zzUnpackCMap(String packed) {
- char [] map = new char[0x10000];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 150) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do map[j++] = value; while (--count > 0);
- }
- return map;
- }
-
-
- /**
- * Refills the input buffer.
- *
- * @return <code>false</code>, iff there was new input.
- *
- * @exception java.io.IOException if any I/O-Error occurs
- */
- private boolean zzRefill() throws java.io.IOException {
-
- /* first: make room (if you can) */
- if (zzStartRead > 0) {
- System.arraycopy(zzBuffer, zzStartRead,
- zzBuffer, 0,
- zzEndRead-zzStartRead);
-
- /* translate stored positions */
- zzEndRead-= zzStartRead;
- zzCurrentPos-= zzStartRead;
- zzMarkedPos-= zzStartRead;
- zzStartRead = 0;
- }
-
- /* is the buffer big enough? */
- if (zzCurrentPos >= zzBuffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[zzCurrentPos*2];
- System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
- zzBuffer = newBuffer;
- }
-
- /* finally: fill the buffer with new input */
- int numRead = zzReader.read(zzBuffer, zzEndRead,
- zzBuffer.length-zzEndRead);
-
- if (numRead > 0) {
- zzEndRead+= numRead;
- return false;
- }
- // unlikely but not impossible: read 0 characters, but not at end of stream
- if (numRead == 0) {
- int c = zzReader.read();
- if (c == -1) {
- return true;
- } else {
- zzBuffer[zzEndRead++] = (char) c;
- return false;
- }
- }
-
- // numRead < 0
- return true;
- }
-
-
- /**
- * Closes the input stream.
- */
- public final void yyclose() throws java.io.IOException {
- zzAtEOF = true; /* indicate end of file */
- zzEndRead = zzStartRead; /* invalidate buffer */
-
- if (zzReader != null)
- zzReader.close();
- }
-
-
- /**
- * Resets the scanner to read from a new input stream.
- * Does not close the old reader.
- *
- * All internal variables are reset, the old input stream
- * <b>cannot</b> be reused (internal buffer is discarded and lost).
- * Lexical state is set to <tt>ZZ_INITIAL</tt>.
- *
- * @param reader the new input stream
- */
- public final void yyreset(java.io.Reader reader) {
- zzReader = reader;
- zzAtBOL = true;
- zzAtEOF = false;
- zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = 0;
- yychar = 0;
- zzLexicalState = YYINITIAL;
- }
-
-
- /**
- * Returns the current lexical state.
- */
- public final int yystate() {
- return zzLexicalState;
- }
-
-
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
- public final void yybegin(int newState) {
- zzLexicalState = newState;
- }
-
-
- /**
- * Returns the text matched by the current regular expression.
- */
- public final String yytext() {
- return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
- }
-
-
- /**
- * Returns the character at position <tt>pos</tt> from the
- * matched text.
- *
- * It is equivalent to yytext().charAt(pos), but faster
- *
- * @param pos the position of the character to fetch.
- * A value from 0 to yylength()-1.
- *
- * @return the character at position pos
- */
- public final char yycharat(int pos) {
- return zzBuffer[zzStartRead+pos];
- }
-
-
- /**
- * Returns the length of the matched text region.
- */
- public final int yylength() {
- return zzMarkedPos-zzStartRead;
- }
-
-
- /**
- * Reports an error that occured while scanning.
- *
- * In a wellformed scanner (no or only correct usage of
- * yypushback(int) and a match-all fallback rule) this method
- * will only be called with things that "Can't Possibly Happen".
- * If this method is called, something is seriously wrong
- * (e.g. a JFlex bug producing a faulty scanner etc.).
- *
- * Usual syntax/scanner level error handling should be done
- * in error fallback rules.
- *
- * @param errorCode the code of the errormessage to display
- */
- private void zzScanError(int errorCode) {
- String message;
- try {
- message = ZZ_ERROR_MSG[errorCode];
- }
- catch (ArrayIndexOutOfBoundsException e) {
- message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
- }
-
- throw new Error(message);
- }
-
-
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
- public void yypushback(int number) {
- if ( number > yylength() )
- zzScanError(ZZ_PUSHBACK_2BIG);
-
- zzMarkedPos -= number;
- }
-
-
- /**
- * Contains user EOF-code, which will be executed exactly once,
- * when the end of file is reached
- */
- private void zzDoEOF() {
- if (!zzEOFDone) {
- zzEOFDone = true;
- hasMore=false;
-
- }
- }
-
-
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception java.io.IOException if any I/O-Error occurs
- */
- public String primGetNextToken() throws java.io.IOException {
- int zzInput;
- int zzAction;
-
- // cached fields:
- int zzCurrentPosL;
- int zzMarkedPosL;
- int zzEndReadL = zzEndRead;
- char [] zzBufferL = zzBuffer;
- char [] zzCMapL = ZZ_CMAP;
-
-
- while (true) {
- zzMarkedPosL = zzMarkedPos;
-
- yychar+= zzMarkedPosL-zzStartRead;
-
- if (zzMarkedPosL > zzStartRead) {
- switch (zzBufferL[zzMarkedPosL-1]) {
- case '\n':
- case '\u000B':
- case '\u000C':
- case '\u0085':
- case '\u2028':
- case '\u2029':
- zzAtBOL = true;
- break;
- case '\r':
- if (zzMarkedPosL < zzEndReadL)
- zzAtBOL = zzBufferL[zzMarkedPosL] != '\n';
- else if (zzAtEOF)
- zzAtBOL = false;
- else {
- boolean eof = zzRefill();
- zzMarkedPosL = zzMarkedPos;
- zzEndReadL = zzEndRead;
- zzBufferL = zzBuffer;
- if (eof)
- zzAtBOL = false;
- else
- zzAtBOL = zzBufferL[zzMarkedPosL] != '\n';
- }
- break;
- default:
- zzAtBOL = false;
- }
- }
- zzAction = -1;
-
- zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
-
- if (zzAtBOL)
- zzState = ZZ_LEXSTATE[zzLexicalState+1];
- else
- zzState = ZZ_LEXSTATE[zzLexicalState];
-
-
- zzForAction: {
- while (true) {
-
- if (zzCurrentPosL < zzEndReadL)
- zzInput = zzBufferL[zzCurrentPosL++];
- else if (zzAtEOF) {
- zzInput = YYEOF;
- break zzForAction;
- }
- else {
- // store back cached positions
- zzCurrentPos = zzCurrentPosL;
- zzMarkedPos = zzMarkedPosL;
- boolean eof = zzRefill();
- // get translated positions and possibly new buffer
- zzCurrentPosL = zzCurrentPos;
- zzMarkedPosL = zzMarkedPos;
- zzBufferL = zzBuffer;
- zzEndReadL = zzEndRead;
- if (eof) {
- zzInput = YYEOF;
- break zzForAction;
- }
- else {
- zzInput = zzBufferL[zzCurrentPosL++];
- }
- }
- zzInput = zzCMapL[zzInput];
-
- boolean zzIsFinal = false;
- boolean zzNoLookAhead = false;
-
- zzForNext: { switch (zzState) {
- case 0:
- switch (zzInput) {
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 7; break zzForNext;
- }
-
- case 1:
- switch (zzInput) {
- case 1: zzIsFinal = true; zzState = 8; break zzForNext;
- case 2: zzIsFinal = true; zzState = 9; break zzForNext;
- case 3: zzIsFinal = true; zzState = 10; break zzForNext;
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 11; break zzForNext;
- case 9: zzIsFinal = true; zzState = 12; break zzForNext;
- case 11: zzIsFinal = true; zzState = 13; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 7; break zzForNext;
- }
-
- case 2:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzState = 14; break zzForNext;
- case 12: zzIsFinal = true; zzState = 15; break zzForNext;
- case 16: zzIsFinal = true; zzState = 16; break zzForNext;
- case 17: zzIsFinal = true; zzState = 17; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 7; break zzForNext;
- }
-
- case 3:
- switch (zzInput) {
- case 6:
- case 7: zzIsFinal = true; zzState = 19; break zzForNext;
- case 8: zzIsFinal = true; zzState = 20; break zzForNext;
- case 9: zzIsFinal = true; zzState = 21; break zzForNext;
- case 27: zzIsFinal = true; zzState = 22; break zzForNext;
- case 28: zzIsFinal = true; zzState = 23; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 18; break zzForNext;
- }
-
- case 4:
- switch (zzInput) {
- case 7:
- case 8:
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 9: zzIsFinal = true; zzState = 26; break zzForNext;
- case 12: zzIsFinal = true; zzState = 27; break zzForNext;
- case 27: zzIsFinal = true; zzState = 28; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
- }
-
- case 5:
- switch (zzInput) {
- case 7:
- case 8:
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 28: zzIsFinal = true; zzState = 28; break zzForNext;
- case 9: zzIsFinal = true; zzState = 29; break zzForNext;
- case 29: zzIsFinal = true; zzState = 30; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
- }
-
- case 6:
- switch (zzInput) {
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 12: zzIsFinal = true; zzState = 30; break zzForNext;
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 31; break zzForNext;
- case 9: zzIsFinal = true; zzState = 32; break zzForNext;
- case 27:
- case 28: zzIsFinal = true; zzState = 33; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
- }
-
- case 8:
- switch (zzInput) {
- case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 34; break zzForNext;
- default: break zzForAction;
- }
-
- case 9:
- switch (zzInput) {
- case 1: zzIsFinal = true; zzNoLookAhead = true; zzState = 35; break zzForNext;
- default: break zzForAction;
- }
-
- case 10:
- switch (zzInput) {
- case 4: zzState = 36; break zzForNext;
- default: break zzForAction;
- }
-
- case 11:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 37; break zzForNext;
- case 9: zzState = 38; break zzForNext;
- case 11: zzState = 39; break zzForNext;
- default: break zzForAction;
- }
-
- case 12:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 37; break zzForNext;
- case 11: zzState = 39; break zzForNext;
- default: break zzForAction;
- }
-
- case 13:
- switch (zzInput) {
- case 9: zzState = 40; break zzForNext;
- case 12: zzState = 41; break zzForNext;
- default: break zzForAction;
- }
-
- case 14:
- switch (zzInput) {
- case 12: zzState = 42; break zzForNext;
- case 16: zzState = 43; break zzForNext;
- case 17: zzState = 44; break zzForNext;
- default: break zzForAction;
- }
-
- case 15:
- switch (zzInput) {
- case 9: zzState = 45; break zzForNext;
- case 26: zzIsFinal = true; zzState = 46; break zzForNext;
- default: break zzForAction;
- }
-
- case 16:
- switch (zzInput) {
- case 9: zzState = 47; break zzForNext;
- case 17: zzState = 48; break zzForNext;
- default: break zzForAction;
- }
-
- case 17:
- switch (zzInput) {
- case 9: zzState = 49; break zzForNext;
- case 22: zzState = 50; break zzForNext;
- default: break zzForAction;
- }
-
- case 19:
- switch (zzInput) {
- case 6:
- case 7: zzIsFinal = true; break zzForNext;
- case 8: zzState = 51; break zzForNext;
- case 9: zzIsFinal = true; zzState = 52; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 18; break zzForNext;
- }
-
- case 20:
- switch (zzInput) {
- case 6:
- case 7: zzIsFinal = true; zzState = 19; break zzForNext;
- case 8: zzState = 51; break zzForNext;
- case 9: zzIsFinal = true; zzState = 52; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 18; break zzForNext;
- }
-
- case 21:
- switch (zzInput) {
- case 27: zzIsFinal = true; zzState = 22; break zzForNext;
- case 28: zzIsFinal = true; zzState = 23; break zzForNext;
- case 6:
- case 7:
- case 8: zzState = 51; break zzForNext;
- default: break zzForAction;
- }
-
- case 22:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 53; break zzForNext;
- default: break zzForAction;
- }
-
- case 23:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 54; break zzForNext;
- default: break zzForAction;
- }
-
- case 25:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 55; break zzForNext;
- default: break zzForAction;
- }
-
- case 26:
- switch (zzInput) {
- case 7:
- case 8:
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 27: zzIsFinal = true; zzState = 28; break zzForNext;
- case 12: zzState = 56; break zzForNext;
- default: break zzForAction;
- }
-
- case 27:
- switch (zzInput) {
- case 9: zzState = 57; break zzForNext;
- case 26: zzIsFinal = true; zzState = 58; break zzForNext;
- default: break zzForAction;
- }
-
- case 28:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 59; break zzForNext;
- default: break zzForAction;
- }
-
- case 29:
- switch (zzInput) {
- case 7:
- case 8:
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 28: zzIsFinal = true; zzState = 28; break zzForNext;
- case 29: zzState = 60; break zzForNext;
- default: break zzForAction;
- }
-
- case 30:
- switch (zzInput) {
- case 26: zzIsFinal = true; zzState = 25; break zzForNext;
- case 9: zzState = 61; break zzForNext;
- default: break zzForAction;
- }
-
- case 31:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 62; break zzForNext;
- default: break zzForAction;
- }
-
- case 32:
- switch (zzInput) {
- case 11: zzIsFinal = true; zzState = 25; break zzForNext;
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 31; break zzForNext;
- case 27:
- case 28: zzIsFinal = true; zzState = 33; break zzForNext;
- case 12: zzState = 60; break zzForNext;
- default: break zzForAction;
- }
-
- case 33:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 63; break zzForNext;
- default: break zzForAction;
- }
-
- case 36:
- switch (zzInput) {
- case 5: zzIsFinal = true; zzNoLookAhead = true; zzState = 64; break zzForNext;
- default: break zzForAction;
- }
-
- case 37:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: break zzForNext;
- case 9: zzState = 38; break zzForNext;
- case 11: zzState = 39; break zzForNext;
- default: break zzForAction;
- }
-
- case 38:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 37; break zzForNext;
- case 11: zzState = 39; break zzForNext;
- case 9: zzState = 65; break zzForNext;
- default: break zzForAction;
- }
-
- case 39:
- switch (zzInput) {
- case 9: zzState = 40; break zzForNext;
- case 12: zzState = 41; break zzForNext;
- default: break zzForAction;
- }
-
- case 40:
- switch (zzInput) {
- case 12: zzState = 41; break zzForNext;
- default: break zzForAction;
- }
-
- case 41:
- switch (zzInput) {
- case 9: zzState = 66; break zzForNext;
- case 13: zzState = 67; break zzForNext;
- default: break zzForAction;
- }
-
- case 42:
- switch (zzInput) {
- case 9: zzState = 45; break zzForNext;
- case 26: zzIsFinal = true; zzState = 46; break zzForNext;
- default: break zzForAction;
- }
-
- case 43:
- switch (zzInput) {
- case 9: zzState = 47; break zzForNext;
- case 17: zzState = 48; break zzForNext;
- default: break zzForAction;
- }
-
- case 44:
- switch (zzInput) {
- case 9: zzState = 49; break zzForNext;
- case 22: zzState = 50; break zzForNext;
- default: break zzForAction;
- }
-
- case 45:
- switch (zzInput) {
- case 26: zzIsFinal = true; zzState = 46; break zzForNext;
- default: break zzForAction;
- }
-
- case 46:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 68; break zzForNext;
- default: break zzForAction;
- }
-
- case 47:
- switch (zzInput) {
- case 17: zzState = 48; break zzForNext;
- default: break zzForAction;
- }
-
- case 48:
- switch (zzInput) {
- case 9: zzState = 69; break zzForNext;
- case 18: zzState = 70; break zzForNext;
- default: break zzForAction;
- }
-
- case 49:
- switch (zzInput) {
- case 22: zzState = 50; break zzForNext;
- default: break zzForAction;
- }
-
- case 50:
- switch (zzInput) {
- case 9: zzState = 71; break zzForNext;
- case 23: zzState = 72; break zzForNext;
- default: break zzForAction;
- }
-
- case 51:
- switch (zzInput) {
- case 6:
- case 7: zzIsFinal = true; zzState = 19; break zzForNext;
- case 8: break zzForNext;
- case 9: zzIsFinal = true; zzState = 52; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 18; break zzForNext;
- }
-
- case 52:
- switch (zzInput) {
- case 6:
- case 7: zzIsFinal = true; zzState = 19; break zzForNext;
- case 8: zzState = 51; break zzForNext;
- case 9: zzIsFinal = true; zzState = 73; break zzForNext;
- default: zzIsFinal = true; zzNoLookAhead = true; zzState = 18; break zzForNext;
- }
-
- case 56:
- switch (zzInput) {
- case 9: zzState = 57; break zzForNext;
- case 26: zzIsFinal = true; zzState = 58; break zzForNext;
- default: break zzForAction;
- }
-
- case 57:
- switch (zzInput) {
- case 26: zzIsFinal = true; zzState = 58; break zzForNext;
- default: break zzForAction;
- }
-
- case 58:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 74; break zzForNext;
- default: break zzForAction;
- }
-
- case 60:
- switch (zzInput) {
- case 26: zzIsFinal = true; zzState = 25; break zzForNext;
- case 9: zzState = 61; break zzForNext;
- default: break zzForAction;
- }
-
- case 61:
- switch (zzInput) {
- case 26: zzIsFinal = true; zzState = 25; break zzForNext;
- default: break zzForAction;
- }
-
- case 65:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 37; break zzForNext;
- case 11: zzState = 39; break zzForNext;
- default: break zzForAction;
- }
-
- case 66:
- switch (zzInput) {
- case 13: zzState = 67; break zzForNext;
- default: break zzForAction;
- }
-
- case 67:
- switch (zzInput) {
- case 9: zzState = 75; break zzForNext;
- case 14: zzState = 76; break zzForNext;
- default: break zzForAction;
- }
-
- case 69:
- switch (zzInput) {
- case 18: zzState = 70; break zzForNext;
- default: break zzForAction;
- }
-
- case 70:
- switch (zzInput) {
- case 9: zzState = 77; break zzForNext;
- case 19: zzState = 78; break zzForNext;
- default: break zzForAction;
- }
-
- case 71:
- switch (zzInput) {
- case 23: zzState = 72; break zzForNext;
- default: break zzForAction;
- }
-
- case 72:
- switch (zzInput) {
- case 9: zzState = 79; break zzForNext;
- case 21: zzState = 80; break zzForNext;
- default: break zzForAction;
- }
-
- case 73:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 51; break zzForNext;
- default: break zzForAction;
- }
-
- case 75:
- switch (zzInput) {
- case 14: zzState = 76; break zzForNext;
- default: break zzForAction;
- }
-
- case 76:
- switch (zzInput) {
- case 9: zzState = 81; break zzForNext;
- case 15: zzState = 82; break zzForNext;
- default: break zzForAction;
- }
-
- case 77:
- switch (zzInput) {
- case 19: zzState = 78; break zzForNext;
- default: break zzForAction;
- }
-
- case 78:
- switch (zzInput) {
- case 9: zzState = 83; break zzForNext;
- case 20: zzState = 84; break zzForNext;
- default: break zzForAction;
- }
-
- case 79:
- switch (zzInput) {
- case 21: zzState = 80; break zzForNext;
- default: break zzForAction;
- }
-
- case 80:
- switch (zzInput) {
- case 9: zzState = 85; break zzForNext;
- case 24: zzState = 86; break zzForNext;
- default: break zzForAction;
- }
-
- case 81:
- switch (zzInput) {
- case 15: zzState = 82; break zzForNext;
- default: break zzForAction;
- }
-
- case 82:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 87; break zzForNext;
- case 9: zzState = 88; break zzForNext;
- default: break zzForAction;
- }
-
- case 83:
- switch (zzInput) {
- case 20: zzState = 84; break zzForNext;
- default: break zzForAction;
- }
-
- case 84:
- switch (zzInput) {
- case 9: zzState = 89; break zzForNext;
- case 21: zzState = 90; break zzForNext;
- default: break zzForAction;
- }
-
- case 85:
- switch (zzInput) {
- case 24: zzState = 86; break zzForNext;
- default: break zzForAction;
- }
-
- case 86:
- switch (zzInput) {
- case 9: zzState = 91; break zzForNext;
- case 20: zzState = 92; break zzForNext;
- default: break zzForAction;
- }
-
- case 87:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; break zzForNext;
- case 9: zzIsFinal = true; zzState = 93; break zzForNext;
- default: break zzForAction;
- }
-
- case 88:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 87; break zzForNext;
- case 9: zzState = 94; break zzForNext;
- default: break zzForAction;
- }
-
- case 89:
- switch (zzInput) {
- case 21: zzState = 90; break zzForNext;
- default: break zzForAction;
- }
-
- case 90:
- switch (zzInput) {
- case 9: zzState = 95; break zzForNext;
- case 22: zzState = 96; break zzForNext;
- default: break zzForAction;
- }
-
- case 91:
- switch (zzInput) {
- case 20: zzState = 92; break zzForNext;
- default: break zzForAction;
- }
-
- case 92:
- switch (zzInput) {
- case 9: zzState = 97; break zzForNext;
- case 22: zzState = 98; break zzForNext;
- default: break zzForAction;
- }
-
- case 93:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 87; break zzForNext;
- case 9: zzState = 94; break zzForNext;
- default: break zzForAction;
- }
-
- case 94:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 87; break zzForNext;
- default: break zzForAction;
- }
-
- case 95:
- switch (zzInput) {
- case 22: zzState = 96; break zzForNext;
- default: break zzForAction;
- }
-
- case 96:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: break zzForNext;
- case 9: zzState = 99; break zzForNext;
- case 10: zzIsFinal = true; zzState = 100; break zzForNext;
- default: break zzForAction;
- }
-
- case 97:
- switch (zzInput) {
- case 22: zzState = 98; break zzForNext;
- default: break zzForAction;
- }
-
- case 98:
- switch (zzInput) {
- case 9: zzState = 101; break zzForNext;
- case 25: zzState = 102; break zzForNext;
- default: break zzForAction;
- }
-
- case 99:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 96; break zzForNext;
- case 10: zzIsFinal = true; zzState = 100; break zzForNext;
- case 9: zzState = 103; break zzForNext;
- default: break zzForAction;
- }
-
- case 100:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 104; break zzForNext;
- case 9: zzState = 105; break zzForNext;
- default: break zzForAction;
- }
-
- case 101:
- switch (zzInput) {
- case 25: zzState = 102; break zzForNext;
- default: break zzForAction;
- }
-
- case 102:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: break zzForNext;
- case 9: zzState = 106; break zzForNext;
- case 10: zzIsFinal = true; zzState = 107; break zzForNext;
- default: break zzForAction;
- }
-
- case 103:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 96; break zzForNext;
- default: break zzForAction;
- }
-
- case 104:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzState = 100; break zzForNext;
- case 6:
- case 7:
- case 8: zzIsFinal = true; break zzForNext;
- default: break zzForAction;
- }
-
- case 105:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 104; break zzForNext;
- default: break zzForAction;
- }
-
- case 106:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 102; break zzForNext;
- case 10: zzIsFinal = true; zzState = 107; break zzForNext;
- case 9: zzState = 108; break zzForNext;
- default: break zzForAction;
- }
-
- case 107:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 109; break zzForNext;
- case 9: zzState = 110; break zzForNext;
- default: break zzForAction;
- }
-
- case 108:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzState = 102; break zzForNext;
- default: break zzForAction;
- }
-
- case 109:
- switch (zzInput) {
- case 9: zzIsFinal = true; zzState = 107; break zzForNext;
- case 6:
- case 7:
- case 8: zzIsFinal = true; break zzForNext;
- default: break zzForAction;
- }
-
- case 110:
- switch (zzInput) {
- case 6:
- case 7:
- case 8: zzIsFinal = true; zzState = 109; break zzForNext;
- default: break zzForAction;
- }
-
- default:
- // if this is ever reached, there is a serious bug in JFlex
- zzScanError(ZZ_UNKNOWN_ERROR);
- break;
- } }
-
- if ( zzIsFinal ) {
- zzAction = zzState;
- zzMarkedPosL = zzCurrentPosL;
- if ( zzNoLookAhead ) break zzForAction;
- }
-
- }
- }
-
- // store back cached position
- zzMarkedPos = zzMarkedPosL;
-
- switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 12:
- { yybegin(YYINITIAL); hasMore = false; return XMLHeadTokenizerConstants.XMLDeclEnd;
- }
- case 18: break;
- case 14:
- { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF83ByteBOM;}
- }
- case 19: break;
- case 9:
- { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;
- }
- case 20: break;
- case 2:
- { yypushback(1); yybegin(UnDelimitedString); string.setLength(0);
- }
- case 21: break;
- case 7:
- { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue;
- }
- case 22: break;
- case 10:
- { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16BE;}
- }
- case 23: break;
- case 1:
- { if(yychar > MAX_TO_SCAN) {hasMore=false; return EncodingParserConstants.MAX_CHARS_REACHED;}
- }
- case 24: break;
- case 6:
- { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 25: break;
- case 5:
- { string.append( yytext() );
- }
- case 26: break;
- case 13:
- { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 27: break;
- case 4:
- { yybegin(SQ_STRING); string.setLength(0);
- }
- case 28: break;
- case 3:
- { yybegin(DQ_STRING); string.setLength(0);
- }
- case 29: break;
- case 8:
- { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue;
- }
- case 30: break;
- case 17:
- { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDelEncoding;
- }
- case 31: break;
- case 15:
- { if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;}
- }
- case 32: break;
- case 11:
- { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16LE;}
- }
- case 33: break;
- case 16:
- { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDeclVersion;
- }
- case 34: break;
- default:
- if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
- zzAtEOF = true;
- zzDoEOF();
- {
- hasMore = false; return EncodingParserConstants.EOF;
- }
- }
- else {
- zzScanError(ZZ_NO_MATCH);
- }
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java
deleted file mode 100644
index ccf23f8aa9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.contenttype;
-
-public interface XMLHeadTokenizerConstants extends EncodingParserConstants {
-
- final String XMLDeclEnd = "XMLDeclEnd"; //$NON-NLS-1$
- final String XMLDeclStart = "XMLDeclStart"; //$NON-NLS-1$
- final String XMLDelEncoding = "XMLDelEncoding"; //$NON-NLS-1$
- final String XMLDeclVersion = "XMLDeclVersion"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLResourceEncodingDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLResourceEncodingDetector.java
deleted file mode 100644
index 1f1079b37d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLResourceEncodingDetector.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- * David Carver (STAR) - bug 297006 - String Comparison
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
-
-
-public class XMLResourceEncodingDetector extends AbstractResourceEncodingDetector implements IResourceCharsetDetector {
- private XMLHeadTokenizer fTokenizer;
- private boolean fDeclDetected = false;
- private boolean fInitialWhiteSpace = false;
-
- private boolean canHandleAsUnicodeStream(String tokenType) {
- boolean canHandleAsUnicodeStream = false;
- if (EncodingParserConstants.UTF83ByteBOM.equals(tokenType)) {
- canHandleAsUnicodeStream = true;
- String enc = "UTF-8"; //$NON-NLS-1$
- createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
- fEncodingMemento.setUTF83ByteBOMUsed(true);
- }
- else if (EncodingParserConstants.UTF16BE.equals(tokenType) || EncodingParserConstants.UTF16LE.equals(tokenType)) {
- canHandleAsUnicodeStream = true;
- String enc = "UTF-16"; //$NON-NLS-1$
- byte[] bom = (EncodingParserConstants.UTF16BE.equals(tokenType)) ? IContentDescription.BOM_UTF_16BE : IContentDescription.BOM_UTF_16LE;
- createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
- fEncodingMemento.setUnicodeStream(true);
- fEncodingMemento.setUnicodeBOM(bom);
- }
- return canHandleAsUnicodeStream;
- }
-
- public String getSpecDefaultEncoding() {
- // by default, UTF-8 as per XML spec
- final String enc = "UTF-8"; //$NON-NLS-1$
- return enc;
- }
-
- /**
- * @return Returns the tokenizer.
- */
- private XMLHeadTokenizer getTokenizer() {
- // TODO: need to work on 'reset' in tokenizer, so new instance isn't
- // always needed
- // if (fTokenizer == null) {
- fTokenizer = new XMLHeadTokenizer();
- // }
- return fTokenizer;
- }
-
- private boolean isLegalString(String valueTokenType) {
- if (valueTokenType == null)
- return false;
- else
- return valueTokenType.equals(EncodingParserConstants.StringValue) || valueTokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue);
- }
-
- protected void parseInput() throws IOException {
- XMLHeadTokenizer tokenizer = getTokenizer();
- tokenizer.reset(fReader);
- HeadParserToken token = null;
- String tokenType = null;
- do {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
-
- // handle xml content type detection
- if (tokenType == XMLHeadTokenizerConstants.XMLDeclStart) {
- fDeclDetected = true;
- String declText = token.getText();
- if (declText.startsWith("<?")) { //$NON-NLS-1$
- fInitialWhiteSpace = false;
- }
- else {
- fInitialWhiteSpace = true;
- }
- }
-
- // handle encoding detection
- if (canHandleAsUnicodeStream(tokenType)) {
- // side effect of canHandle is to create appropriate memento
- }
- else {
- if (tokenType == XMLHeadTokenizerConstants.XMLDelEncoding) {
- if (tokenizer.hasMoreTokens()) {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (isLegalString(tokenType)) {
- String enc = token.getText();
- if (enc != null && enc.length() > 0) {
- createEncodingMemento(enc, EncodingMemento.FOUND_ENCODING_IN_CONTENT);
- }
- }
- }
- }
- }
- }
- while (tokenizer.hasMoreTokens());
-
- }
-
- public boolean isDeclDetected() {
- if (!fHeaderParsed) {
- try {
- parseInput();
- }
- catch (IOException e) {
- fDeclDetected = false;
- }
- // we keep track of if header's already been
- // parse, so can make
- // multiple 'get' calls, without causing
- // reparsing.
- fHeaderParsed = true;
- }
- // fDeclDetected is set as part of parsing.
- return fDeclDetected;
- }
-
- public boolean hasInitialWhiteSpace() {
- return fInitialWhiteSpace;
- }
-
- protected void resetAll() {
- super.resetAll();
- fDeclDetected = false;
- fInitialWhiteSpace = false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
deleted file mode 100644
index 7c0af3399b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
+++ /dev/null
@@ -1,780 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- *
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLCharEntity;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLNamespace;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * AttrImpl class
- */
-public class AttrImpl extends NodeImpl implements IDOMAttr {
-
- private ITextRegion equalRegion = null;
-
- private char[] fName = null;
- private ITextRegion nameRegion = null;
- private ElementImpl ownerElement = null;
- private ITextRegion fValueRegion = null;
- private char[] fValueSource = null;
- private char[] fNamespaceURI = null;
-
- /**
- * AttrImpl constructor
- */
- protected AttrImpl() {
- super();
- }
-
- /**
- * AttrImpl constructor
- *
- * @param that
- * AttrImpl
- */
- protected AttrImpl(AttrImpl that) {
- super(that);
-
- if (that != null) {
- this.fName = that.fName;
- String valueSource = that.getValueSource();
- if (valueSource != null)
- this.fValueSource = valueSource.toCharArray();
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- */
- public Node cloneNode(boolean deep) {
- AttrImpl cloned = new AttrImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- */
- protected CMAttributeDeclaration getDeclaration() {
- ElementImpl element = (ElementImpl) getOwnerElement();
- if (element == null)
- return null;
- CMElementDeclaration elementDecl = element.getDeclaration();
- if (elementDecl == null)
- return null;
-
- List nodes = ModelQueryUtil.getModelQuery(getOwnerDocument()).getAvailableContent(getOwnerElement(), elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- String name = getName();
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION && name.equals(cmnode.getNodeName())) {
- return (CMAttributeDeclaration) cmnode;
- }
- }
- return null;
- }
-
- /**
- * getEndOffset method
- *
- * @return int
- */
- public int getEndOffset() {
- if (this.ownerElement == null)
- return 0;
- int offset = this.ownerElement.getStartOffset();
- if (this.fValueRegion != null) {
- return (offset + this.fValueRegion.getEnd());
- }
- if (this.equalRegion != null) {
- return (offset + this.equalRegion.getEnd());
- }
- if (this.nameRegion != null) {
- return (offset + this.nameRegion.getEnd());
- }
- return 0;
- }
-
-
- public ITextRegion getEqualRegion() {
- return this.equalRegion;
- }
-
- public String getLocalName() {
- if (this.fName == null)
- return null;
- int index = CharOperation.indexOf(this.fName, ':');
- if (index < 0)
- return new String(this.fName);
- return new String(this.fName, index + 1, this.fName.length - index - 1);
- }
-
- /**
- * getName method
- *
- * @return java.lang.String
- */
- public String getName() {
- if (this.fName == null)
- return NodeImpl.EMPTY_STRING;
- return new String(this.fName);
- }
-
-
- public ITextRegion getNameRegion() {
- return this.nameRegion;
- }
-
- public int getNameRegionEndOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getEndOffset(this.nameRegion);
- }
-
- public int getNameRegionStartOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getStartOffset(this.nameRegion);
- }
-
- public String getNameRegionText() {
- if (this.ownerElement == null)
- return null;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- return flatNode.getText(this.nameRegion);
- }
-
- public int getNameRegionTextEndOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getTextEndOffset(this.nameRegion);
- }
-
- public String getNamespaceURI() {
- String nsAttrName = null;
- String prefix = getPrefix();
- if (prefix != null && prefix.length() > 0) {
- if (prefix.equals(IXMLNamespace.XMLNS)) {
- // fixed URI
- return IXMLNamespace.XMLNS_URI;
- }
- else if (prefix.equals(IXMLNamespace.XML)) {
- // fixed URI
- return IXMLNamespace.XML_URI;
- }
-
- nsAttrName = IXMLNamespace.XMLNS_PREFIX + prefix;
- }
- else {
- String name = getName();
- if (name != null && name.equals(IXMLNamespace.XMLNS)) {
- // fixed URI
- return IXMLNamespace.XMLNS_URI;
- }
- // does not inherit namespace from owner element
- // if (this.ownerElement != null) return
- // this.ownerElement.getNamespaceURI();
- if (this.fNamespaceURI == null)
- return null;
- return new String(this.fNamespaceURI);
- }
-
- for (Node node = this.ownerElement; node != null; node = node.getParentNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- break;
- Element element = (Element) node;
- Attr attr = element.getAttributeNode(nsAttrName);
- if (attr != null)
- return attr.getValue();
- }
-
- if (this.fNamespaceURI == null)
- return null;
- return new String(this.fNamespaceURI);
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return getName();
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return ATTRIBUTE_NODE;
- }
-
- /**
- * getNodeValue method
- *
- * @return java.lang.String
- */
- public String getNodeValue() {
- return getValue();
- }
-
- /**
- * getOwnerElement method
- *
- * @return org.w3c.dom.Element
- */
- public Element getOwnerElement() {
- return this.ownerElement;
- }
-
- /**
- */
- public String getPrefix() {
- if (this.fName == null)
- return null;
- int index = CharOperation.indexOf(this.fName, ':');
- if (index <= 0)
- return null;
- // exclude JSP tag in name
- if (this.fName[0] == '<')
- return null;
- return new String(this.fName, 0, index);
- }
-
- /**
- * getSpecified method
- *
- * @return boolean
- */
- public boolean getSpecified() {
- // if there is no underlying document region,
- // then this attributes value has not really be specified
- // yet in the document, and any returned values, such as
- // an empty string or a default value are being supplied
- // as per spec, not per what's in the users document.
- return this.fValueRegion != null;
- }
-
- /**
- * getStartOffset method
- *
- * @return int
- */
- public int getStartOffset() {
- if (this.ownerElement == null)
- return 0;
- int offset = this.ownerElement.getStartOffset();
- if (this.nameRegion != null) {
- return (offset + this.nameRegion.getStart());
- }
- if (this.equalRegion != null) {
- return (offset + this.equalRegion.getStart());
- }
- if (this.fValueRegion != null) {
- return (offset + this.fValueRegion.getStart());
- }
- return 0;
- }
-
- /**
- * getValue method
- *
- * @return java.lang.String
- */
- public String getValue() {
- return getValue(getValueSource());
- }
-
- /**
- * Returns value for the source
- */
- private String getValue(String source) {
- if (source == null)
- return NodeImpl.EMPTY_STRING;
- if (source.length() == 0)
- return source;
- StringBuffer buffer = null;
- int offset = 0;
- int length = source.length();
- int ref = source.indexOf('&');
- while (ref >= 0) {
- int end = source.indexOf(';', ref + 1);
- if (end > ref + 1) {
- String name = source.substring(ref + 1, end);
- String value = getCharValue(name);
- if (value != null) {
- if (buffer == null)
- buffer = new StringBuffer(length);
- if (ref > offset)
- buffer.append(source.substring(offset, ref));
- buffer.append(value);
- offset = end + 1;
- ref = end;
- }
- }
- ref = source.indexOf('&', ref + 1);
- }
- if (buffer == null)
- return source;
- if (length > offset)
- buffer.append(source.substring(offset));
- return buffer.toString();
- }
-
- public ITextRegion getValueRegion() {
- return this.fValueRegion;
- }
-
- /**
- * ISSUE: what should behavior be if this.value == null? It's an "error"
- * to be in that state, but seems to occur relatively easily ... probably
- * due to threading bugs ... but this just shows its needs to be spec'd.
- *
- */
- public int getValueRegionStartOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // the valueRegion -- should make smarter?
- IStructuredDocumentRegion structuredDocumentRegion = this.ownerElement.getFirstStructuredDocumentRegion();
- if (structuredDocumentRegion == null)
- return 0;
- // ensure we never pass null to getStartOffset.
- if (this.fValueRegion == null) {
- return 0;
- }
- return structuredDocumentRegion.getStartOffset(this.fValueRegion);
- }
-
- public String getValueRegionText() {
- if (this.ownerElement == null)
- return null;
- // assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- if (this.fValueRegion == null)
- return null;
- return flatNode.getText(this.fValueRegion);
- }
-
- /**
- */
- public String getValueSource() {
- if (this.fValueSource != null)
- return new String(this.fValueSource);
- // DW: 4/16/2003 due to change in structuredDocument ... we need a
- // flatnode to
- // get at region values. For now I'll assume this is always the first
- // flatnode .. may need to make smarter later (e.g. to search for
- // the flatnode that this.valueRegion belongs to.
- // DW: 4/30/2003 For some reason, this method is getting called a lot
- // Not sure if its a threading problem, or a fundamental error
- // elsewhere.
- // It needs more investigation, but in the use cases I've seen,
- // doesn't
- // seem to hurt to simply return null in those cases. I saw this null
- // case,
- // when trying go format an XML file.
- if (this.ownerElement == null)
- return null;
- //attribute values will always be in the start region
- IStructuredDocumentRegion ownerRegion = this.ownerElement.getStartStructuredDocumentRegion();
- if (ownerRegion == null)
- return null;
- if (this.fValueRegion != null)
- return StructuredDocumentRegionUtil.getAttrValue(ownerRegion, this.fValueRegion);
- return NodeImpl.EMPTY_STRING;
- }
-
- private String getValueSource(ElementImpl ownerElement) {
- if (this.fValueSource != null)
- return new String(this.fValueSource);
- // DW: 4/16/2003 due to change in structuredDocument ... we need a
- // flatnode to
- // get at region values. For now I'll assume this is always the first
- // flatnode .. may need to make smarter later (e.g. to search for
- // the flatnode that this.valueRegion belongs to.
- if (this.fValueRegion != null)
- return StructuredDocumentRegionUtil.getAttrValue(ownerElement.getStructuredDocumentRegion(), this.fValueRegion);
- return NodeImpl.EMPTY_STRING;
- }
-
- /**
- */
- private String getValueSource(String value) {
- if (value == null)
- return null;
- if (value.length() == 0)
- return value;
- StringBuffer buffer = null;
- int offset = 0;
- int length = value.length();
- int amp = value.indexOf('&');
- while (amp >= 0) {
- if (buffer == null)
- buffer = new StringBuffer(length + 4);
- if (amp > offset)
- buffer.append(value.substring(offset, amp));
- buffer.append(IXMLCharEntity.AMP_REF);
- offset = amp + 1;
- amp = value.indexOf('&', offset);
- }
- if (buffer == null)
- return value;
- if (length > offset)
- buffer.append(value.substring(offset));
- return buffer.toString();
- }
-
- /**
- * Check if Attr has JSP in value
- */
- public boolean hasNestedValue() {
- if (this.fValueRegion == null)
- return false;
- if (!(this.fValueRegion instanceof ITextRegionContainer))
- return false;
- ITextRegionList regions = ((ITextRegionContainer) this.fValueRegion).getRegions();
- if (regions == null)
- return false;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- if (region == null)
- continue;
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_OPEN || isNestedLanguageOpening(regionType))
- return true;
- }
- return false;
- }
-
- /**
- * Check if Attr has only name but not equal sign nor value
- */
- public boolean hasNameOnly() {
- return (this.nameRegion != null && this.equalRegion == null && this.fValueRegion == null);
- }
-
- /**
- */
- protected final boolean hasPrefix() {
- if (this.fName == null || this.fName.length == 0)
- return false;
- return CharOperation.indexOf(this.fName, ':') > 0 && this.fName[0] != '<';
- }
-
- /**
- */
- protected final boolean ignoreCase() {
- if (this.ownerElement != null) {
- if (this.ownerElement.ignoreCase()) {
- return !hasPrefix();
- }
- }
- else {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && document.ignoreCase()) {
- // even in case insensitive document, if having prefix, it's
- // case sensitive
- return !hasPrefix();
- }
- }
- return false;
- }
-
- /**
- */
- public boolean isGlobalAttr() {
- if (hasPrefix())
- return false;
- if (this.ownerElement == null)
- return false;
- return this.ownerElement.isGlobalTag();
- }
-
- /**
- */
- public final boolean isXMLAttr() {
- if (this.ownerElement != null) {
- if (!this.ownerElement.isXMLTag()) {
- return hasPrefix();
- }
- }
- else {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && !document.isXMLType()) {
- // even in non-XML document, if having prefix, it's XML tag
- return hasPrefix();
- }
- }
- return true;
- }
-
- /**
- * matchName method
- *
- * @return boolean
- * @param name
- * java.lang.String
- */
- protected boolean matchName(String name) {
- if (name == null)
- return (this.fName == null);
- if (this.fName == null)
- return false;
- return CharOperation.equals(this.fName, name.toCharArray(), ignoreCase());
- }
-
- protected boolean matchName(char[] name) {
- if (name == null)
- return (this.fName == null);
- if (this.fName == null)
- return false;
- return CharOperation.equals(this.fName, name, ignoreCase());
- }
-
-
- /**
- * notifyValueChanged method
- */
- protected void notifyNameChanged() {
- if (this.ownerElement == null)
- return;
- DocumentImpl document = (DocumentImpl) this.ownerElement.getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.nameChanged(this);
- }
-
- /**
- * notifyValueChanged method
- */
- protected void notifyValueChanged() {
- if (this.ownerElement == null)
- return;
- DocumentImpl document = (DocumentImpl) this.ownerElement.getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.valueChanged(this);
- }
-
- /**
- * removeRegions method
- */
- void removeRegions() {
- this.nameRegion = null;
- this.fValueRegion = null;
- this.equalRegion = null;
- }
-
- /**
- */
- void resetRegions() {
- this.fValueSource = getValueSource().toCharArray();
- removeRegions();
- }
-
- /**
- */
- void resetRegions(ElementImpl ownerElement) {
- this.fValueSource = getValueSource(ownerElement).toCharArray();
- removeRegions();
- }
-
- void setEqualRegion(ITextRegion equalRegion) {
- this.equalRegion = equalRegion;
- }
-
- /**
- * setName method
- *
- * @param name
- * java.lang.String
- */
- protected void setName(String name) {
- String value = null;
- int startOffset = 0;
- if (this.ownerElement != null) {
- value = getValue();
- startOffset = this.ownerElement.getStartOffset();
- this.ownerElement.notify(REMOVE, this, value, null, startOffset);
- }
- this.fName = CharacterStringPool.getCharString(name);
- if (this.ownerElement != null) {
- this.ownerElement.notify(ADD, this, null, value, startOffset);
- }
- }
-
- void setNameRegion(ITextRegion nameRegion) {
- this.nameRegion = nameRegion;
- }
-
- protected void setNamespaceURI(String namespaceURI) {
- if (namespaceURI == null)
- this.fNamespaceURI = null;
- else
- this.fNamespaceURI = namespaceURI.toCharArray();
- }
-
- /**
- * setNodeValue method
- *
- * @param nodeValue
- * java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- setValue(nodeValue);
- }
-
- /**
- * setOwnerElement method
- *
- * @param ownerElement
- * org.w3c.dom.Element
- */
- protected void setOwnerElement(Element ownerElement) {
- this.ownerElement = (ElementImpl) ownerElement;
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- if (this.ownerElement != null && !this.ownerElement.isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- int prefixLength = (prefix != null ? prefix.length() : 0);
- String localName = getLocalName();
- if (prefixLength == 0) {
- setName(localName);
- return;
- }
- if (localName == null)
- localName = NodeImpl.EMPTY_STRING;
- int localLength = localName.length();
- StringBuffer buffer = new StringBuffer(prefixLength + 1 + localLength);
- buffer.append(prefix);
- buffer.append(':');
- buffer.append(localName);
- setName(buffer.toString());
-
- notifyNameChanged();
- }
-
- /**
- * setValue method
- *
- * @param value
- * java.lang.String
- */
- public void setValue(String value) {
- // Remember: as we account for "floaters" in
- // future, remember that some are created
- // in the natural process of implementing
- // DOM apis.
- // this "self notification" of about/changed,
- // is added for this case, because it known to
- // be called from properties pages. Should be a
- // added to all DOM Modifiying APIs eventually.
- try {
- getModel().aboutToChangeModel();
- setValueSource(getValueSource(value));
- }
- finally {
- getModel().changedModel();
- }
- }
-
- void setValueRegion(ITextRegion valueRegion) {
- this.fValueRegion = valueRegion;
- if (valueRegion != null)
- this.fValueSource = null;
- }
-
- public void setValueSource(String source) {
- if (this.ownerElement != null && !this.ownerElement.isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- this.fValueSource = (source != null) ? source.toCharArray() : null;
-
- notifyValueChanged();
- }
-
- /**
- * Subclasses must override
- *
- * @param regionType
- * @return
- */
- protected boolean isNestedLanguageOpening(String regionType) {
- boolean result = false;
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java
deleted file mode 100644
index 1a3ad5748d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- *
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * CDATASectionImpl class
- */
-public class CDATASectionImpl extends TextImpl implements CDATASection {
-
- /**
- * CDATASectionImpl constructor
- */
- protected CDATASectionImpl() {
- super();
- }
-
- /**
- * CDATASectionImpl constructor
- *
- * @param that
- * CDATASectionImpl
- */
- protected CDATASectionImpl(CDATASectionImpl that) {
- super(that);
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- CDATASectionImpl cloned = new CDATASectionImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- // instead of super(TextImpl).getData(), call getCharacterData()
- char[] data = getCharacterData();
- if (data == null) {
- String sdata = getData(getStructuredDocumentRegion());
- if (sdata != null)
- return sdata;
- return NodeImpl.EMPTY_STRING;
- }
- return new String(data);
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return null;
-
- ITextRegion contentRegion = null;
- StringBuffer buffer = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_CDATA_OPEN || regionType == DOMRegionContext.XML_CDATA_CLOSE) {
- continue;
- }
- if (contentRegion == null) { // first content
- contentRegion = region;
- } else { // multiple contents
- if (buffer == null) {
- buffer = new StringBuffer(flatNode.getText(contentRegion));
- }
- buffer.append(flatNode.getText(region));
- }
- }
-
- if (buffer != null)
- return buffer.toString();
- if (contentRegion != null)
- return flatNode.getText(contentRegion);
- return null;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#cdata-section";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return CDATA_SECTION_NODE;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == DOMRegionContext.XML_CDATA_CLOSE);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java
deleted file mode 100644
index ae533abf5e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CMNodeUtil {
-
- /**
- */
- public static CMAttributeDeclaration getAttributeDeclaration(Attr attr) {
- if (attr == null)
- return null;
- return ((AttrImpl) attr).getDeclaration();
- }
-
- /**
- */
- public static CMElementDeclaration getElementDeclaration(Element element) {
- if (element == null)
- return null;
- return ((ElementImpl) element).getDeclaration();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java
deleted file mode 100644
index a446bde52a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-class CharOperation {
-
- private CharOperation() {
- }
-
- static int indexOf(char[] array, char c) {
- return indexOf(array, c, 0);
- }
-
- static int indexOf(char[] array, char c, int start) {
- for (int i = start; i < array.length; i++) {
- if (array[i] == c)
- return i;
- }
- return -1;
- }
-
-
- /**
- * note: This method taken from org.eclipse.jdt.core.compiler.CharOperation
- *
- * Answers true if the two arrays are identical character by character, otherwise false.
- * The equality is case sensitive.
- * <br>
- * <br>
- * For example:
- * <ol>
- * <li><pre>
- * first = null
- * second = null
- * result => true
- * </pre>
- * </li>
- * <li><pre>
- * first = { }
- * second = null
- * result => false
- * </pre>
- * </li>
- * <li><pre>
- * first = { 'a' }
- * second = { 'a' }
- * result => true
- * </pre>
- * </li>
- * <li><pre>
- * first = { 'a' }
- * second = { 'A' }
- * result => false
- * </pre>
- * </li>
- * </ol>
- * @param first the first array
- * @param second the second array
- * @return true if the two arrays are identical character by character, otherwise false
- */
- public static final boolean equals(char[] first, char[] second, boolean ignoreCase) {
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;) {
- if (ignoreCase) {
- if (Character.toUpperCase(first[i]) != Character.toUpperCase(second[i])) {
- return false;
- }
- }
- else {
- if (first[i] != second[i]) {
- return false;
- }
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java
deleted file mode 100644
index 1eb28920bb..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-
-
-/**
- * CharacterDataImpl class
- */
-public abstract class CharacterDataImpl extends NodeImpl implements CharacterData {
-
- private char[] data = null;
-
- /**
- * CharacterDataImpl constructor
- */
- protected CharacterDataImpl() {
- super();
- }
-
- /**
- * CharacterDataImpl constructor
- *
- * @param that
- * CharacterDataImpl
- */
- protected CharacterDataImpl(CharacterDataImpl that) {
- super(that);
-
- if (that != null) {
- this.data = that.getData().toCharArray();
- }
- }
-
- /**
- * appendData method
- *
- * @param arg
- * java.lang.String
- */
- public void appendData(String arg) throws DOMException {
- if (arg == null)
- return;
-
- String data = getData();
- if (data == null)
- data = arg;
- else
- data += arg;
- setData(data);
- }
-
- /**
- * deleteData method
- *
- * @param offset
- * int
- * @param count
- * int
- */
- public void deleteData(int offset, int count) throws DOMException {
- if (count == 0)
- return;
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (count < 0 || offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int length = data.length();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (offset == 0) {
- if (count > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (count == length)
- data = NodeImpl.EMPTY_STRING;
- else
- data = data.substring(count);
- } else {
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (end == length)
- data = data.substring(0, offset);
- else
- data = data.substring(0, offset) + data.substring(end);
- }
- setData(data);
- }
-
- /**
- */
- protected final char[] getCharacterData() {
- return this.data;
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- char[] cdata = getCharacterData();
- if (cdata != null)
- return new String(cdata);
- return null;
- }
-
- /**
- * getLength method
- *
- * @return int
- */
- public int getLength() {
- String data = getData();
- if (data == null)
- return 0;
- return data.length();
- }
-
- /**
- * getNodeValue method
- *
- * @return java.lang.String
- */
- public String getNodeValue() {
- return getData();
- }
-
- /**
- * insertData method
- *
- * @param offset
- * int
- * @param arg
- * java.lang.String
- */
- public void insertData(int offset, String arg) throws DOMException {
- if (arg == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String data = getData();
- if (data == null) {
- if (offset > 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- data = arg;
- } else if (offset == 0) {
- data = arg + data;
- } else {
- int length = data.length();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (offset == length)
- data += arg;
- else
- data = data.substring(0, offset) + arg + data.substring(offset);
- }
- setData(data);
- }
-
- /**
- * isJSPContent method
- *
- * @return boolean
- */
- public boolean isJSPContent() {
- Node parent = getParentNode();
- if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE)
- return false;
- ElementImpl element = (ElementImpl) parent;
- return element.isJSPContainer();
- }
-
- /**
- * replaceData method
- *
- * @param offset
- * int
- * @param count
- * int
- * @param arg
- * java.lang.String
- */
- public void replaceData(int offset, int count, String arg) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (arg == null) {
- deleteData(offset, count);
- return;
- }
- if (count == 0) {
- insertData(offset, arg);
- return;
- }
- if (offset < 0 || count < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- } else if (offset == 0) {
- int length = data.length();
- if (count > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (count == length)
- data = arg;
- else
- data = arg + data.substring(count);
- } else {
- int length = data.length();
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- if (end == length)
- data = data.substring(0, offset) + arg;
- else
- data = data.substring(0, offset) + arg + data.substring(end);
- }
- setData(data);
- }
-
- /**
- */
- void resetStructuredDocumentRegions() {
- this.data = getData().toCharArray();
- setStructuredDocumentRegion(null);
- }
-
- /**
- * setData method
- *
- * @param data
- * java.lang.String
- */
- public void setData(String data) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.data = (data != null ? data.toCharArray() : null);
-
- notifyValueChanged();
- }
-
- /**
- * setNodeValue method
- *
- * @param nodeValue
- * java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- setData(nodeValue);
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- super.setStructuredDocumentRegion(flatNode);
- if (flatNode != null)
- this.data = null;
- }
-
- /**
- * substringData method
- *
- * @return java.lang.String
- * @param offset
- * int
- * @param count
- * int
- */
- public String substringData(int offset, int count) throws DOMException {
- if (count == 0)
- return NodeImpl.EMPTY_STRING;
- if (offset < 0 || count < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int length = data.length();
- if (offset == 0 && count == length)
- return data;
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int end = offset + count;
- if (end > length) {
- // no DOMException specified to be thrown
- end = length;
- }
- return data.substring(offset, end);
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getNodeName());
- buffer.append('(');
- buffer.append(getData());
- buffer.append(')');
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null) {
- buffer.append('@');
- buffer.append(flatNode.toString());
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterStringPool.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterStringPool.java
deleted file mode 100644
index 3bdb388dd2..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterStringPool.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-import java.util.LinkedHashMap;
-
-/**
- * Organizes a pool of frequently used Strings as character arrays.
- *
- */
-final class CharacterStringPool {
-
- static private LinkedHashMap fPool = new LimitedHashMap();
-
- static private class LimitedHashMap extends LinkedHashMap {
- private static final long serialVersionUID = 1L;
- private static final int MAX = 500;
-
- public LimitedHashMap() {
- super(MAX / 10, .75f, true);
- }
- protected boolean removeEldestEntry(java.util.Map.Entry eldest) {
- return size() > MAX;
- }
- }
-
- static private class CharArray {
- char[] fArray;
- /**
- * Answers a hashcode for the array. Algorithm from org.eclipse.jdt.core.compiler.CharOperation
- *
- * @param array the array for which a hashcode is required
- * @return the hashcode
- * @throws NullPointerException if array is null
- */
- public int hashCode() {
- int length = fArray.length;
- int hash = length == 0 ? 31 : fArray[0];
- if (length < 8) {
- for (int i = length; --i > 0;)
- hash = (hash * 31) + fArray[i];
- } else {
- // 8 characters is enough to compute a decent hash code, don't waste time examining every character
- for (int i = length - 1, last = i > 16 ? i - 16 : 0; i > last; i -= 2)
- hash = (hash * 31) + fArray[i];
- }
- return hash & 0x7FFFFFFF;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof CharArray))
- return false;
- CharArray other = (CharArray) obj;
- if (fArray.length != other.fArray.length)
- return false;
- for (int i = 0; i < fArray.length; i++) {
- if (fArray[i] != other.fArray[i])
- return false;
- }
- return true;
- }
- }
-
- private CharacterStringPool() {
- }
-
- /**
- * Returns the character array for <code>string</code>. If
- * the character array is already in the pool for character arrays,
- * the array is reused.
- *
- * @param string the string to retrieve the character array for
- * @return a pooled instance of the character array
- */
- public static char[] getCharString(String string) {
- CharArray array = new CharArray();
- array.fArray = string.toCharArray();
-
- Object obj = null;
- synchronized (fPool) {
- obj = fPool.get(array);
- if (obj == null) {
- obj = array;
- fPool.put(obj, obj);
- }
- }
- return ((CharArray) obj).fArray;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java
deleted file mode 100644
index 4a817e07b4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * CommentImpl class
- */
-public class CommentImpl extends CharacterDataImpl implements Comment {
-
- private boolean isJSPTag = false;
-
- /**
- * CommentImpl constructor
- */
- protected CommentImpl() {
- super();
- }
-
- /**
- * CommentImpl constructor
- *
- * @param that
- * CommentImpl
- */
- protected CommentImpl(CommentImpl that) {
- super(that);
-
- if (that != null) {
- this.isJSPTag = that.isJSPTag;
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- CommentImpl cloned = new CommentImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- char[] data = getCharacterData();
- if (data == null) {
- String sdata = getData(getStructuredDocumentRegion());
- if (sdata != null)
- return sdata;
- return NodeImpl.EMPTY_STRING;
- }
- return new String(data);
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return null;
-
- ITextRegion contentRegion = null;
- StringBuffer buffer = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_COMMENT_CLOSE || isNestedCommentOpenClose(regionType)) {
- continue;
- }
- if (contentRegion == null) { // first content
- contentRegion = region;
- }
- else { // multiple contents
- if (buffer == null) {
- buffer = new StringBuffer(flatNode.getText(contentRegion));
- }
- buffer.append(flatNode.getText(region));
- }
- }
-
- if (buffer != null)
- return buffer.toString();
- if (contentRegion != null)
- return flatNode.getText(contentRegion);
- return null;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#comment";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return COMMENT_NODE;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == DOMRegionContext.XML_COMMENT_CLOSE || isNestedCommentClose(regionType));
- }
-
- /**
- * Subclasses must override
- * @param regionType
- * @return
- */
- protected boolean isNestedCommentClose(String regionType) {
- boolean result = false;
- return result;
- }
- /**
- * Subclasses must override
- * @param regionType
- * @return
- */
- protected boolean isNestedCommentOpenClose(String regionType) {
- boolean result = false;
- return result;
- }
-
- public boolean isJSPTag() {
- return this.isJSPTag;
- }
-
- /**
- * setJSPTag method
- *
- * @param isJSPTag
- * boolean
- */
- public void setJSPTag(boolean isJSPTag) {
- if (isJSPTag == this.isJSPTag)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (isJSPTag) {
- if (document == null || !document.isJSPType())
- return;
- }
-
- this.isJSPTag = isJSPTag;
-
- if (getContainerDocument() != null) {
- // already in the tree, update IStructuredDocument
- setData(getData()); // calls notifyValueChanged();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.java
deleted file mode 100644
index 5907bfda18..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-import org.eclipse.osgi.util.NLS;
-
-class DOMMessages extends NLS {
- private static String BUNDLE_NAME = "org.eclipse.wst.xml.core.internal.document.DOMMessages"; //$NON-NLS-1$
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, DOMMessages.class);
- }
-
- private DOMMessages() {
- }
-
- public static String DOMSTRING_SIZE_ERR;
- public static String HIERARCHY_REQUEST_ERR;
- public static String INDEX_SIZE_ERR;
- public static String INUSE_ATTRIBUTE_ERR;
- public static String INVALID_ACCESS_ERR;
- public static String INVALID_CHARACTER_ERR;
- public static String INVALID_MODIFICATION_ERR;
- public static String INVALID_STATE_ERR;
- public static String NAMESPACE_ERR;
- public static String NO_DATA_ALLOWED_ERR;
- public static String NO_MODIFICATION_ALLOWED_ERR;
- public static String NOT_FOUND_ERR;
- public static String NOT_SUPPORTED_ERR;
- public static String SYNTAX_ERR;
- public static String TYPE_MISMATCH_ERR;
- public static String VALIDATION_ERR;
- public static String WRONG_DOCUMENT_ERR;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.properties b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.properties
deleted file mode 100644
index 039213ef30..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMMessages.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-DOMSTRING_SIZE_ERR=DOMString Size Error
-HIERARCHY_REQUEST_ERR=Invalid Hierarchy Request
-INDEX_SIZE_ERR=Index Size Error
-INUSE_ATTRIBUTE_ERR=Attribute Node In Use Error
-INVALID_ACCESS_ERR=Invalid Access Error
-INVALID_CHARACTER_ERR=Invalid Characer Error
-INVALID_MODIFICATION_ERR=Invalid Modification Error
-INVALID_STATE_ERR=Invalid State Error
-NAMESPACE_ERR=Namespace Error
-NO_DATA_ALLOWED_ERR=No Data Allowed
-NO_MODIFICATION_ALLOWED_ERR=No Modification Allowed
-NOT_FOUND_ERR=Not Found
-NOT_SUPPORTED_ERR=Not Supported
-SYNTAX_ERR=Syntax Error
-TYPE_MISMATCH_ERR=Type Mismatch Error
-VALIDATION_ERR=Validation Error
-WRONG_DOCUMENT_ERR=Wrong Document
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java
deleted file mode 100644
index 9fc72aa9db..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java
+++ /dev/null
@@ -1,981 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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.document;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLNamespace;
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * XMLModelImpl class
- */
-public class DOMModelImpl extends AbstractStructuredModel implements IStructuredDocumentListener, IDOMModel, DOMImplementation {
- private static String TRACE_PARSER_MANAGEMENT_EXCEPTION = "parserManagement"; //$NON-NLS-1$
- private Object active = null;
- private DocumentImpl document = null;
- private ISourceGenerator generator = null;
- private XMLModelNotifier notifier = null;
- private XMLModelParser parser = null;
- private boolean refresh = false;
- private XMLModelUpdater updater = null;
-
- /**
- * XMLModelImpl constructor
- */
- public DOMModelImpl() {
- super();
- this.document = (DocumentImpl) internalCreateDocument();
- }
-
- /**
- * This API allows clients to declare that they are about to make a
- * "large" change to the model. This change might be in terms of content
- * or it might be in terms of the model id or base location.
- *
- * Note that in the case of embedded calls, notification to listeners is
- * sent only once.
- *
- * Note that the client who is making these changes has the responsibility
- * to restore the models state once finished with the changes. See
- * getMemento and restoreState.
- *
- * The method isModelStateChanging can be used by a client to determine if
- * the model is already in a change sequence.
- */
- public void aboutToChangeModel() {
- super.aboutToChangeModel();
- // technically, no need to call beginChanging so often,
- // since aboutToChangeModel can be nested.
- // but will leave as is for this release.
- // see modelChanged, and be sure stays coordinated there.
- getModelNotifier().beginChanging();
- }
-
- public void aboutToReinitializeModel() {
- XMLModelNotifier notifier = getModelNotifier();
- notifier.cancelPending();
- super.aboutToReinitializeModel();
- }
-
- /**
- * attrReplaced method
- *
- * @param element
- * org.w3c.dom.Element
- * @param newAttr
- * org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- protected void attrReplaced(Element element, Attr newAttr, Attr oldAttr) {
- if (element == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.replaceAttr(element, newAttr, oldAttr);
- setActive(null);
- }
- getModelNotifier().attrReplaced(element, newAttr, oldAttr);
- }
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called after aboutToChangeModel ...
- * or some listeners could be left waiting indefinitely for the changed
- * event. So, its suggested that changedModel always be in a finally
- * clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first.
- *
- * In the case of embedded calls, the notification is just sent once.
- *
- */
- public void changedModel() {
- // NOTE: the order of 'changedModel' and 'endChanging' is significant.
- // By calling changedModel first, this basically decrements the
- // "isChanging" counter
- // in super class and when zero all listeners to model state events
- // will be notified
- // that the model has been changed. 'endChanging' will notify all
- // deferred adapters.
- // So, the significance of order is that adapters (and methods they
- // call)
- // can count on the state of model "isChanging" to be accurate.
- // But, remember, that this means the "modelChanged" event can be
- // received before all
- // adapters have finished their processing.
- // NOTE NOTE: The above note is obsolete in fact (though still states
- // issue correctly).
- // Due to popular demand, the order of these calls were reversed and
- // behavior
- // changed on 07/22/2004.
- //
- // see also
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4302
- // for motivation for this 'on verge of' call.
- // this could be improved in future if notifier also used counting
- // flag to avoid nested calls. If/when changed be sure to check if
- // aboutToChangeModel needs any changes too.
- if (isModelChangeStateOnVergeOfEnding()) {
- // end lock before noticiation loop, since directly or indirectly
- // we may be "called from foriegn code" during notification.
- endLock();
- // we null out here to avoid spurious"warning" message while debug
- // tracing is enabled
- fLockObject = null;
- // the notifier is what controls adaper notification, which
- // should be sent out before the 'modelChanged' event.
- getModelNotifier().endChanging();
- }
- // changedModel handles 'nesting', so only one event sent out
- // when mulitple calls to 'aboutToChange/Changed'.
- super.changedModel();
- handleRefresh();
- }
-
- /**
- * childReplaced method
- *
- * @param parentNode
- * org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- protected void childReplaced(Node parentNode, Node newChild, Node oldChild) {
- if (parentNode == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.replaceChild(parentNode, newChild, oldChild);
- setActive(null);
- }
- getModelNotifier().childReplaced(parentNode, newChild, oldChild);
- }
-
- /**
- * Creates an XML <code>Document</code> object of the specified type
- * with its document element. HTML-only DOM implementations do not need to
- * implement this method.
- *
- * @param namespaceURIThe
- * namespace URI of the document element to create.
- * @param qualifiedNameThe
- * qualified name of the document element to be created.
- * @param doctypeThe
- * type of document to be created or <code>null</code>. When
- * <code>doctype</code> is not <code>null</code>, its
- * <code>Node.ownerDocument</code> attribute is set to the
- * document being created.
- * @return A new <code>Document</code> object.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified qualified
- * name contains an illegal character. <br>
- * NAMESPACE_ERR: Raised if the <code>qualifiedName</code>
- * is malformed, if the <code>qualifiedName</code> has a
- * prefix and the <code>namespaceURI</code> is
- * <code>null</code>, or if the
- * <code>qualifiedName</code> has a prefix that is "xml"
- * and the <code>namespaceURI</code> is different from "
- * http://www.w3.org/XML/1998/namespace" .<br>
- * WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has
- * already been used with a different document or was
- * created from a different implementation.
- * @see DOM Level 2
- */
- public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) throws DOMException {
- final DocumentImpl document = new DocumentImpl();
- if (namespaceURI == null && qualifiedName == null && doctype == null)
- return document;
-
- if (qualifiedName != null) {
-
- final int idx = qualifiedName.indexOf(':');
- if (idx > 0) {
- if (namespaceURI == null)
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
- final String prefix = qualifiedName.substring(0, idx);
- if (prefix.equals(IXMLNamespace.XML) && !namespaceURI.equals(IXMLNamespace.XML_URI))
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
-
- // Check if the qualifiedName is malformed
- if (idx == qualifiedName.length() - 1) // No local name
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
-
- String localName = qualifiedName.substring(idx + 1);
- final int length = localName.length();
- if (length == 0)
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
-
- switch (localName.charAt(0)) {
- case '-':
- case '.':
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
- }
-
- final int qualifiedLength = qualifiedName.length();
- for (int i = 0; i < qualifiedLength; i++) {
- final char c = qualifiedName.charAt(i);
- if (Character.isWhitespace(c))
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, null);
- else if (c == ':' && i != idx)
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
- }
- }
- if (!NameValidator.isValid(qualifiedName))
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, null);
- }
- else if (namespaceURI != null){
- throw new DOMException(DOMException.NAMESPACE_ERR, null);
- }
-
- final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- if (model != null) {
- document.setModel(model);
- model.document = document;
- }
-
- if (doctype != null) {
- if (doctype.getOwnerDocument() != null)
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
- document.appendChild(doctype);
- }
-
- final ElementImpl root = new ElementImpl();
- document.appendChild(root);
- root.setNamespaceURI(namespaceURI);
- root.setTagName(qualifiedName);
-
- return document;
- }
-
- /**
- * Creates an empty <code>DocumentType</code> node. Entity declarations
- * and notations are not made available. Entity reference expansions and
- * default attribute additions do not occur. It is expected that a future
- * version of the DOM will provide a way for populating a
- * <code>DocumentType</code>.<br>
- * HTML-only DOM implementations do not need to implement this method.
- *
- * @param qualifiedNameThe
- * qualified name of the document type to be created.
- * @param publicIdThe
- * external subset public identifier.
- * @param systemIdThe
- * external subset system identifier.
- * @return A new <code>DocumentType</code> node with
- * <code>Node.ownerDocument</code> set to <code>null</code>.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified qualified
- * name contains an illegal character. <br>
- * NAMESPACE_ERR: Raised if the <code>qualifiedName</code>
- * is malformed.
- * @see DOM Level 2
- */
- public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId) throws DOMException {
- DocumentTypeImpl documentType = new DocumentTypeImpl();
- documentType.setName(qualifiedName);
- documentType.setPublicId(publicId);
- documentType.setSystemId(systemId);
- return documentType;
- }
-
- /**
- */
- protected void documentTypeChanged() {
- if (this.refresh)
- return;
- // unlike 'resfresh', 'reinitialize' finishes loop
- // and flushes remaining notification que before
- // actually reinitializing.
- // ISSUE: should reinit be used instead of handlerefresh?
- // this.setReinitializeNeeded(true);
- if (this.active != null || getModelNotifier().isChanging())
- return; // defer
- handleRefresh();
- }
-
- protected void editableChanged(Node node) {
- if (node != null) {
- getModelNotifier().editableChanged(node);
- }
- }
-
- /**
- */
- protected void endTagChanged(Element element) {
- if (element == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.changeEndTag(element);
- setActive(null);
- }
- getModelNotifier().endTagChanged(element);
- }
-
- /**
- */
- private XMLModelParser getActiveParser() {
- if (this.parser == null)
- return null;
- if (this.parser != this.active)
- return null;
- return this.parser;
- }
-
- /**
- */
- private XMLModelUpdater getActiveUpdater() {
- if (this.updater == null)
- return null;
- if (this.updater != this.active)
- return null;
- return this.updater;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (Document.class.equals(adapter))
- return getDocument();
- return super.getAdapter(adapter);
- }
-
- /**
- * getDocument method
- *
- * @return XMLDocument
- */
- public IDOMDocument getDocument() {
- return this.document;
- }
-
- public ISourceGenerator getGenerator() {
- if (this.generator == null) {
- this.generator = XMLGeneratorImpl.getInstance();
- }
- return this.generator;
- }
-
- /**
- * getNode method
- *
- * @param offset
- * int
- */
- public IndexedRegion getIndexedRegion(int offset) {
- if (this.document == null)
- return null;
- // search in document children
- IDOMNode parent = null;
- int length = this.document.getEndOffset();
- if (offset * 2 < length) {
- // search from the first
- IDOMNode child = (IDOMNode) this.document.getFirstChild();
- while (child != null) {
- if (child.getEndOffset() <= offset) {
- child = (IDOMNode) child.getNextSibling();
- continue;
- }
- if (child.getStartOffset() > offset) {
- break;
- }
- IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- if (startStructuredDocumentRegion.getEnd() > offset)
- return child;
- }
- IStructuredDocumentRegion endStructuredDocumentRegion = child.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- if (endStructuredDocumentRegion.getStart() <= offset)
- return child;
- }
- // dig more
- parent = child;
- child = (IDOMNode) parent.getFirstChild();
- }
- }
- else {
- // search from the last
- IDOMNode child = (IDOMNode) this.document.getLastChild();
- while (child != null) {
- if (child.getStartOffset() > offset) {
- child = (IDOMNode) child.getPreviousSibling();
- continue;
- }
- if (child.getEndOffset() <= offset) {
- break;
- }
- IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- if (startStructuredDocumentRegion.getEnd() > offset)
- return child;
- }
- IStructuredDocumentRegion endStructuredDocumentRegion = child.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- if (endStructuredDocumentRegion.getStart() <= offset)
- return child;
- }
- // dig more
- parent = child;
- child = (IDOMNode) parent.getLastChild();
- }
- }
- return parent;
- }
-
- /**
- */
- public XMLModelNotifier getModelNotifier() {
- if (this.notifier == null) {
- this.notifier = new XMLModelNotifierImpl();
- }
- return this.notifier;
- }
-
- /**
- */
- private XMLModelParser getModelParser() {
- if (this.parser == null) {
- this.parser = createModelParser();
- }
- return this.parser;
- }
-
- protected XMLModelParser createModelParser() {
- return new XMLModelParser(this);
- }
-
- /**
- */
- private XMLModelUpdater getModelUpdater() {
- if (this.updater == null) {
- this.updater = createModelUpdater();
- }
- return this.updater;
- }
-
- protected XMLModelUpdater createModelUpdater() {
- return new XMLModelUpdater(this);
- }
-
- /**
- */
- private void handleRefresh() {
- if (!this.refresh)
- return;
- XMLModelNotifier notifier = getModelNotifier();
- boolean isChanging = notifier.isChanging();
- if (!isChanging)
- notifier.beginChanging(true);
- XMLModelParser parser = getModelParser();
- setActive(parser);
- this.document.removeChildNodes();
- try {
- this.refresh = false;
- parser.replaceStructuredDocumentRegions(getStructuredDocument().getRegionList(), null);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- }
- finally {
- setActive(null);
- if (!isChanging)
- notifier.endChanging();
- }
- }
-
- /**
- * Test if the DOM implementation implements a specific feature.
- *
- * @param featureThe
- * name of the feature to test (case-insensitive). The values
- * used by DOM features are defined throughout the DOM Level 2
- * specifications and listed in the section. The name must be
- * an XML name. To avoid possible conflicts, as a convention,
- * names referring to features defined outside the DOM
- * specification should be made unique by reversing the name of
- * the Internet domain name of the person (or the organization
- * that the person belongs to) who defines the feature,
- * component by component, and using this as a prefix. For
- * instance, the W3C SVG Working Group defines the feature
- * "org.w3c.dom.svg".
- * @param versionThis
- * is the version number of the feature to test. In Level 2,
- * the string can be either "2.0" or "1.0". If the version is
- * not specified, supporting any version of the feature causes
- * the method to return <code>true</code>.
- * @return <code>true</code> if the feature is implemented in the
- * specified version, <code>false</code> otherwise.
- */
- public boolean hasFeature(String feature, String version) {
- if (feature == null)
- return false;
- if (version != null) {
- if (!version.equals("1.0") && !version.equals("2.0")) { //$NON-NLS-2$//$NON-NLS-1$
- return false;
- }
- }
- if (feature.equalsIgnoreCase("Core")) //$NON-NLS-1$
- return true; //$NON-NLS-1$
- if (feature.equalsIgnoreCase("XML")) //$NON-NLS-1$
- return true; //$NON-NLS-1$
- return false;
- }
-
- /**
- * createDocument method
- *
- * @return org.w3c.dom.Document
- */
- protected Document internalCreateDocument() {
- DocumentImpl document = new DocumentImpl();
- document.setModel(this);
- return document;
- }
-
- boolean isReparsing() {
- return (active != null);
- }
-
- /**
- * nameChanged method
- *
- * @param node
- * org.w3c.dom.Node
- */
- protected void nameChanged(Node node) {
- if (node == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.changeName(node);
- setActive(null);
- }
- // notification is already sent
- }
-
- /**
- * newModel method
- *
- */
- public void newModel(NewDocumentEvent structuredDocumentEvent) {
- if (structuredDocumentEvent == null)
- return;
- IStructuredDocument structuredDocument = structuredDocumentEvent.getStructuredDocument();
- if (structuredDocument == null)
- return;
- // this should not happen, but for the case
- if (fStructuredDocument != null && fStructuredDocument != structuredDocument)
- setStructuredDocument(structuredDocument);
-
- internalSetNewDocument(structuredDocument);
- }
-
- private void internalSetNewDocument(IStructuredDocument structuredDocument) {
- if (structuredDocument == null)
- return;
- IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
- if ((flatNodes == null) || (flatNodes.getLength() == 0)) {
- return;
- }
- if (this.document == null)
- return; // being constructed
- XMLModelUpdater updater = getActiveUpdater();
- if (updater != null) { // being updated
- try {
- updater.replaceStructuredDocumentRegions(flatNodes, null);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- }
- // // for new model, we might need to
- // // re-init, e.g. if someone calls setText
- // // on an existing model
- // checkForReinit();
- return;
- }
- XMLModelNotifier notifier = getModelNotifier();
- boolean isChanging = notifier.isChanging();
- // call even if changing to notify doing new model
- getModelNotifier().beginChanging(true);
- XMLModelParser parser = getModelParser();
- setActive(parser);
- this.document.removeChildNodes();
- try {
- parser.replaceStructuredDocumentRegions(flatNodes, null);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- // meaningless to refresh, because the result might be the same
- }
- finally {
- setActive(null);
- if (!isChanging) {
- getModelNotifier().endChanging();
- }
- // ignore refresh
- this.refresh = false;
- }
- }
-
- /**
- */
- public void noChange(NoChangeEvent event) {
- XMLModelUpdater updater = getActiveUpdater();
- if (updater != null) { // being updated
- // cleanup updater staffs
- try {
- updater.replaceStructuredDocumentRegions(null, null);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- }
- // I guess no chanage means the model could not need re-init
- // checkForReinit();
- return;
- }
- }
-
- /**
- * nodesReplaced method
- *
- */
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) {
- if (event == null)
- return;
- IStructuredDocumentRegionList oldStructuredDocumentRegions = event.getOldStructuredDocumentRegions();
- IStructuredDocumentRegionList newStructuredDocumentRegions = event.getNewStructuredDocumentRegions();
- XMLModelUpdater updater = getActiveUpdater();
- if (updater != null) { // being updated
- try {
- updater.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
- }
- catch (Exception ex) {
- if (ex.getClass().equals(StructuredDocumentRegionManagementException.class)) {
- Logger.traceException(TRACE_PARSER_MANAGEMENT_EXCEPTION, ex);
- }
- else {
- Logger.logException(ex);
- }
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- }
- // checkForReinit();
- return;
- }
- XMLModelNotifier notifier = getModelNotifier();
- boolean isChanging = notifier.isChanging();
- if (!isChanging)
- notifier.beginChanging();
- XMLModelParser parser = getModelParser();
- setActive(parser);
- try {
- parser.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- if (!isChanging) {
- notifier.endChanging();
- handleRefresh();
- }
- }
-
- }
-
- /**
- * regionChanged method
- *
- * @param structuredDocumentEvent
- */
- public void regionChanged(RegionChangedEvent event) {
- if (event == null)
- return;
- IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion();
- if (flatNode == null)
- return;
- ITextRegion region = event.getRegion();
- if (region == null)
- return;
- XMLModelUpdater updater = getActiveUpdater();
- if (updater != null) { // being updated
- try {
- updater.changeRegion(event, flatNode, region);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- }
- // checkForReinit();
- return;
- }
- XMLModelNotifier notifier = getModelNotifier();
- boolean isChanging = notifier.isChanging();
- if (!isChanging)
- notifier.beginChanging();
- XMLModelParser parser = getModelParser();
- setActive(parser);
- try {
- parser.changeRegion(event, flatNode, region);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- if (!isChanging) {
- notifier.endChanging();
- handleRefresh();
- }
- }
- // checkForReinit();
- }
-
- /**
- * regionsReplaced method
- *
- * @param event
- */
- public void regionsReplaced(RegionsReplacedEvent event) {
- if (event == null)
- return;
- IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion();
- if (flatNode == null)
- return;
- ITextRegionList oldRegions = event.getOldRegions();
- ITextRegionList newRegions = event.getNewRegions();
- if (oldRegions == null && newRegions == null)
- return;
- XMLModelUpdater updater = getActiveUpdater();
- if (updater != null) { // being updated
- try {
- updater.replaceRegions(flatNode, newRegions, oldRegions);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- }
- // checkForReinit();
- return;
- }
- XMLModelNotifier notifier = getModelNotifier();
- boolean isChanging = notifier.isChanging();
- if (!isChanging)
- notifier.beginChanging();
- XMLModelParser parser = getModelParser();
- setActive(parser);
- try {
- parser.replaceRegions(flatNode, newRegions, oldRegions);
- }
- catch (Exception ex) {
- Logger.logException(ex);
- this.refresh = true;
- handleRefresh();
- }
- finally {
- setActive(null);
- if (!isChanging) {
- notifier.endChanging();
- handleRefresh();
- }
- }
- // checkForReinit();
- }
-
- /**
- */
- public void releaseFromEdit() {
- if (!isShared()) {
- // this.document.releaseStyleSheets();
- // this.document.releaseDocumentType();
- }
- super.releaseFromEdit();
- }
-
- /**
- */
- public void releaseFromRead() {
- if (!isShared()) {
- // this.document.releaseStyleSheets();
- // this.document.releaseDocumentType();
- }
- super.releaseFromRead();
- }
-
- /**
- */
- private void setActive(Object active) {
- this.active = active;
- // side effect
- // when ever becomes active, besure tagNameCache is cleared
- // (and not used)
- if (active == null) {
- document.activateTagNameCache(true);
- }
- else {
- document.activateTagNameCache(false);
- }
-
- }
-
- /**
- */
- public void setGenerator(ISourceGenerator generator) {
- this.generator = generator;
- }
-
- /**
- */
- public void setModelNotifier(XMLModelNotifier notifier) {
- this.notifier = notifier;
- }
-
- /**
- */
- public void setModelParser(XMLModelParser parser) {
- this.parser = parser;
- }
-
- /**
- */
- public void setModelUpdater(XMLModelUpdater updater) {
- this.updater = updater;
- }
-
- /**
- * setStructuredDocument method
- *
- * @param structuredDocument
- */
- public void setStructuredDocument(IStructuredDocument structuredDocument) {
- IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
- if (structuredDocument == oldStructuredDocument)
- return; // nothing to do
- if (oldStructuredDocument != null)
- oldStructuredDocument.removeDocumentChangingListener(this);
- super.setStructuredDocument(structuredDocument);
- if (structuredDocument != null) {
- internalSetNewDocument(structuredDocument);
- structuredDocument.addDocumentChangingListener(this);
- }
- }
-
- /**
- */
- protected void startTagChanged(Element element) {
- if (element == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.changeStartTag(element);
- setActive(null);
- }
- getModelNotifier().startTagChanged(element);
- }
-
- /**
- * valueChanged method
- *
- * @param node
- * org.w3c.dom.Node
- */
- protected void valueChanged(Node node) {
- if (node == null)
- return;
- if (getActiveParser() == null) {
- XMLModelUpdater updater = getModelUpdater();
- setActive(updater);
- updater.initialize();
- updater.changeValue(node);
- setActive(null);
- }
- getModelNotifier().valueChanged(node);
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation of DOM 3.
- */
- public Object getFeature(String feature, String version) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java
deleted file mode 100644
index cde882c636..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * DocumentFragmentImpl class
- */
-public class DocumentFragmentImpl extends NodeContainer implements DocumentFragment {
-
- /**
- * DocumentFragmentImpl constructor
- */
- protected DocumentFragmentImpl() {
- super();
- }
-
- /**
- * DocumentFragmentImpl constructor
- *
- * @param that
- * DocumentFragmentImpl
- */
- protected DocumentFragmentImpl(DocumentFragmentImpl that) {
- super(that);
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentFragmentImpl cloned = new DocumentFragmentImpl(this);
- if (deep)
- cloneChildNodes(cloned, deep);
-
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#document-fragment";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_FRAGMENT_NODE;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java
deleted file mode 100644
index 34a3e31707..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java
+++ /dev/null
@@ -1,1208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- * David Carver (Intalio) - bug 273004 - add check for valid xml characters in createAttribute
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-// for org.apache.xerces 3.2.1
-// import org.apache.xerces.utils.XMLCharacterProperties;
-// DMW modified for XML4J 4.0.1
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.xerces.dom.TreeWalkerImpl;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementRegistry;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMEntityDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLCharEntity;
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Entity;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Notation;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.w3c.dom.UserDataHandler;
-import org.w3c.dom.ranges.DocumentRange;
-import org.w3c.dom.ranges.Range;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
-
-
-/**
- * DocumentImpl class
- */
-public class DocumentImpl extends NodeContainer implements IDOMDocument, DocumentRange, DocumentTraversal {
-
- private static int maxDocTypeSearch = 500;
- private static int noMaxSearch = -1;
- /**
- * Internal-use only class. This class was added to better able to handle
- * repetetive request for getElementsByTagName. The cache is cleared when
- * ever the document changes at all, so still not real efficient,
- */
- class TagNameCache {
-
- private boolean active = true;
-
- private Map cache;
-
- public TagNameCache() {
- super();
- cache = new HashMap();
- }
-
- /**
- * @param b
- */
- public void activate(boolean b) {
- active = b;
- if (!b)
- clear();
- }
-
- public void addItem(String tagname, NodeListImpl nodelist) {
- if (tagname == null || nodelist == null)
- return;
- cache.put(tagname, nodelist);
- }
-
- public void clear() {
- cache.clear();
- }
-
- public NodeListImpl getItem(String tagName) {
- NodeListImpl result = null;
- if (active) {
- result = (NodeListImpl) cache.get(tagName);
- // if (result != null) {
- // System.out.println("getElementsByTagname from cache: " +
- // tagName);
- // }
- }
- return result;
- }
-
- }
-
- private class LimitedCache extends LinkedHashMap {
- private static final long serialVersionUID = 1L;
- private static final int MAX_SIZE = 10;
- public LimitedCache() {
- super(0, 0.75f, true);
- }
-
- protected boolean removeEldestEntry(java.util.Map.Entry entry) {
- return size() > MAX_SIZE;
- }
- }
-
- // this is a constant just to give compile-time control over
- // whether or not to use the cache. If, in future, its found that
- // there are no (or few) "duplicate requests" ... then this cache
- // is not needed.
- private static final boolean usetagnamecache = true;
-
- // private DocumentTypeAdapter documentTypeAdapter = null;
-
- private DOMModelImpl model = null;
- private TagNameCache tagNameCache;
-
- private Map fCMCache;
- /**
- * DocumentImpl constructor
- */
- protected DocumentImpl() {
- super();
- if (usetagnamecache) {
- tagNameCache = new TagNameCache();
- }
- fCMCache = Collections.synchronizedMap(new LimitedCache());
- }
-
- /**
- * DocumentImpl constructor
- *
- * @param that
- * DocumentImpl
- */
- protected DocumentImpl(DocumentImpl that) {
- super(that);
- if (usetagnamecache) {
- tagNameCache = new TagNameCache();
- }
- fCMCache = Collections.synchronizedMap(new LimitedCache());
- }
-
- /**
- * @param b
- */
- void activateTagNameCache(boolean b) {
- tagNameCache.activate(b);
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * Changes the <code>ownerDocument</code> of a node, its children, as
- * well as the attached attribute nodes if there are any. If the node has
- * a parent it is first removed from its parent child list. This
- * effectively allows moving a subtree from one document to another. The
- * following list describes the specifics for each type of node.
- * <dl>
- * <dt>ATTRIBUTE_NODE</dt>
- * <dd>The <code>ownerElement</code> attribute is set to
- * <code>null</code> and the <code>specified</code> flag is set to
- * <code>true</code> on the adopted <code>Attr</code>. The
- * descendants of the source <code>Attr</code> are recursively adopted.
- * </dd>
- * <dt>DOCUMENT_FRAGMENT_NODE</dt>
- * <dd>The descendants of the source node are recursively adopted.</dd>
- * <dt>DOCUMENT_NODE</dt>
- * <dd><code>Document</code> nodes cannot be adopted.</dd>
- * <dt>DOCUMENT_TYPE_NODE</dt>
- * <dd><code>DocumentType</code> nodes cannot be adopted.</dd>
- * <dt>ELEMENT_NODE</dt>
- * <dd>Specified attribute nodes of the source element are adopted, and
- * the generated <code>Attr</code> nodes. Default attributes are
- * discarded, though if the document being adopted into defines default
- * attributes for this element name, those are assigned. The descendants
- * of the source element are recursively adopted.</dd>
- * <dt>ENTITY_NODE</dt>
- * <dd><code>Entity</code> nodes cannot be adopted.</dd>
- * <dt>ENTITY_REFERENCE_NODE</dt>
- * <dd>Only the <code>EntityReference</code> node itself is adopted,
- * the descendants are discarded, since the source and destination
- * documents might have defined the entity differently. If the document
- * being imported into provides a definition for this entity name, its
- * value is assigned.</dd>
- * <dt>NOTATION_NODE</dt>
- * <dd><code>Notation</code> nodes cannot be adopted.</dd>
- * <dt>PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE,
- * COMMENT_NODE</dt>
- * <dd>These nodes can all be adopted. No specifics.</dd>
- * Should this method simply return null when it fails? How "exceptional"
- * is failure for this method?Stick with raising exceptions only in
- * exceptional circumstances, return null on failure (F2F 19 Jun 2000).Can
- * an entity node really be adopted?No, neither can Notation nodes (Telcon
- * 13 Dec 2000).Does this affect keys and hashCode's of the adopted
- * subtree nodes?If so, what about readonly-ness of key and hashCode?if
- * not, would appendChild affect keys/hashCodes or would it generate
- * exceptions if key's are duplicate? Update: Hashcodes have been dropped.
- * Given that the key is only unique within a document an adopted node
- * needs to be given a new key, but what does it mean for the application?
- *
- * TODO: Needs to notify UserDataHandlers for the node if any
- *
- * @param source
- * The node to move into this document.
- * @return The adopted node, or <code>null</code> if this operation
- * fails, such as when the source node comes from a different
- * implementation.
- * @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if the source node is of type
- * <code>DOCUMENT</code>,<code>DOCUMENT_TYPE</code>.
- * <br>
- * NO_MODIFICATION_ALLOWED_ERR: Raised when the source node
- * is readonly.
- * @see DOM Level 3
- */
- public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws org.w3c.dom.DOMException {
- return null;
- }
-
- /**
- * @param tagName
- */
- protected void checkTagNameValidity(String tagName) {
- if (!isValidName(tagName)) {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, createDOMExceptionMessage(DOMException.INVALID_CHARACTER_ERR, tagName));
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentImpl cloned = new DocumentImpl(this);
- if (deep)
- cloned.importChildNodes(this, true);
- return cloned;
- }
-
- /**
- * createAttribute method
- *
- * @return org.w3c.dom.Attr
- * @param name
- * java.lang.String
- */
- public Attr createAttribute(String name) throws DOMException {
- checkTagNameValidity(name);
- AttrImpl attr = new AttrImpl();
- attr.setOwnerDocument(this);
- attr.setName(name);
- return attr;
- }
-
- /**
- */
- public Attr createAttributeNS(String uri, String name) throws DOMException {
- checkTagNameValidity(name);
- AttrImpl attr = new AttrImpl();
- attr.setOwnerDocument(this);
- attr.setName(name);
- attr.setNamespaceURI(uri);
- return attr;
- }
-
- /**
- * createCDATASection method
- *
- * @return org.w3c.dom.CDATASection
- * @param data
- * java.lang.String
- */
- public CDATASection createCDATASection(String data) throws DOMException {
- // allow CDATA section
- // if (!isXMLType()) {
- // throw new DOMException(DOMException.NOT_SUPPORTED_ERR, new
- // String());
- // }
- CDATASectionImpl cdata = new CDATASectionImpl();
- cdata.setOwnerDocument(this);
- if (data != null)
- cdata.setData(data);
- return cdata;
- }
-
- /**
- * createComment method
- *
- * @return org.w3c.dom.Comment
- * @param data
- * java.lang.String
- */
- public Comment createComment(String data) {
- CommentImpl comment = new CommentImpl();
- comment.setOwnerDocument(this);
- if (data != null)
- comment.setData(data);
- return comment;
- }
-
- public Element createCommentElement(String tagName, boolean isJSPTag) throws DOMException {
- Element result = null;
- if (!isJSPType() && isJSPTag) {
- throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMMessages.INVALID_MODIFICATION_ERR);
- }
- ElementImpl element = (ElementImpl) createElement(tagName);
- element.setJSPTag(isJSPTag);
- CommentElementRegistry registry = CommentElementRegistry.getInstance();
- if (registry.setupCommentElement(element)) {
- result = element;
- }
- else {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, DOMMessages.INVALID_CHARACTER_ERR);
- }
- return result;
- }
-
- /**
- * createDoctype method
- *
- * @return org.w3c.dom.DocumentType
- * @param name
- * java.lang.String
- */
- public DocumentType createDoctype(String name) {
- DocumentTypeImpl docType = new DocumentTypeImpl();
- docType.setOwnerDocument(this);
- docType.setName(name);
- return docType;
- }
-
- /**
- * createDocumentFragment method
- *
- * @return org.w3c.dom.DocumentFragment
- */
- public DocumentFragment createDocumentFragment() {
- DocumentFragmentImpl fragment = new DocumentFragmentImpl();
- fragment.setOwnerDocument(this);
- return fragment;
- }
-
- /**
- * createElement method
- *
- * @return org.w3c.dom.Element
- * @param tagName
- * java.lang.String
- */
- public Element createElement(String tagName) throws DOMException {
- checkTagNameValidity(tagName);
-
- ElementImpl element = new ElementImpl();
- element.setOwnerDocument(this);
- element.setTagName(tagName);
- return element;
- }
-
- /**
- */
- public Element createElementNS(String uri, String tagName) throws DOMException {
- if (!isValidName(tagName)) {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, DOMMessages.INVALID_CHARACTER_ERR);
- }
-
- ElementImpl element = (ElementImpl) createElement(tagName);
- element.setNamespaceURI(uri);
- return element;
- }
-
- /**
- * createEntity method
- *
- * @return org.w3c.dom.Entity
- * @param name
- * java.lang.String
- */
- public Entity createEntity(String name) {
- EntityImpl entity = new EntityImpl();
- entity.setOwnerDocument(this);
- entity.setName(name);
- return entity;
- }
-
- /**
- * createEntityReference method
- *
- * @return org.w3c.dom.EntityReference
- * @param name
- * java.lang.String
- */
- public EntityReference createEntityReference(String name) throws DOMException {
- if (!isXMLType()) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, DOMMessages.NOT_SUPPORTED_ERR);
- }
-
- EntityReferenceImpl ref = new EntityReferenceImpl();
- ref.setOwnerDocument(this);
- ref.setName(name);
- return ref;
- }
-
- /**
- */
- public NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) {
- if (root == null)
- root = this;
- return new NodeIteratorImpl(root, whatToShow, filter);
- }
-
- /**
- * createNotation method
- *
- * @return org.w3c.dom.Notation
- * @param name
- * java.lang.String
- */
- public Notation createNotation(String name) {
- NotationImpl notation = new NotationImpl();
- notation.setOwnerDocument(this);
- notation.setName(name);
- return notation;
- }
-
- /**
- * createProcessingInstruction method
- *
- * @return org.w3c.dom.ProcessingInstruction
- * @param target
- * java.lang.String
- * @param data
- * java.lang.String
- */
- public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
- ProcessingInstructionImpl pi = new ProcessingInstructionImpl();
- pi.setOwnerDocument(this);
- pi.setTarget(target);
- if (data != null)
- pi.setData(data);
- return pi;
- }
-
- /**
- */
- public Range createRange() {
- return new RangeImpl();
- }
-
- /**
- * createTextNode method
- *
- * @return org.w3c.dom.Text
- * @param data
- * java.lang.String
- */
- public Text createTextNode(String data) {
- TextImpl text = new TextImpl();
- text.setOwnerDocument(this);
- text.setData(data);
- return text;
- }
-
- /**
- * Return an instance of tree walk
- */
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.dom.traversal.DocumentTraversal#createTreeWalker(org.w3c.dom.Node,
- * int, org.w3c.dom.traversal.NodeFilter, boolean)
- */
- public TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) {
- if (root == null) {
- String msg = DOMMessages.NOT_SUPPORTED_ERR + " - Program Error: root node can not be null for TreeWalker";
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
- }
- // ISSUE: we just use Xerces implementation for now, but longer term,
- // we should make a
- // thread/job safe version (as well as not rely on Xerces "impl"
- // class.
- return new TreeWalkerImpl(root, whatToShow, filter, entityReferenceExpansion);
-
- }
-
- private DocumentType findDoctype(Node node) {
-
- int countSearch = 0;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (countSearch++ > maxDocTypeSearch) {
- break;
- }
- if (child.getNodeType() == DOCUMENT_TYPE_NODE && child instanceof DocumentType) {
- return (DocumentType) child;
- }
- else if (child.getNodeType() == ELEMENT_NODE && ((IDOMElement) child).isCommentTag()) {
- // search DOCTYPE inside of generic comment element
- DocumentType docType = findDoctype(child);
- if (docType != null) {
- return docType;
- }
- }
- }
-
- return null;
- }
-
- private Element findDocumentElement(String docName, Node node, Node[] firstFound, int max) {
- int countSearch = 0;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
-
- /*
- * maxDocTypeSearch limits added via bug 151929
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=151929
- * but, in other contexts,
- * if noMaxSearch is specified, then do not "break out" of long searches
- * */
- if (max != noMaxSearch && countSearch++ > max) {
- break;
- }
- if (child.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) child;
- if (element.isCommentTag()) {
- Element docElement = findDocumentElement(docName, element, firstFound, max);
- if (docElement != null) {
- return docElement;
- }
- else {
- // added 'else continue' to better handle cases where
- // there is "more than one root" element
- // especially complicated by CommentElements, which are
- // sometimes treated as elements, but should
- // be treated as comments in this context.
- continue;
- }
- }
- // note: the "name" won't match in the event of a jsp tag ... but
- // incase
- // the name is null, we do not want the jsp element returned as
- // documentElement
- if (element.isJSPTag())
- continue;
- if (docName == null)
- return element;
- // use local name for namespace
- String localName = element.getLocalName();
- if (localName == null)
- continue;
- if (isXMLType()) {
- if (localName.equals(docName))
- return element;
- }
- else {
- if (localName.equalsIgnoreCase(docName))
- return element;
- }
- if (firstFound[0] == null)
- firstFound[0] = element;
- }
- return null;
- }
-
- /**
- * getCharValue method
- *
- * @return java.lang.String
- * @param name
- * java.lang.String
- */
- protected String getCharValue(String name) {
- if (name == null)
- return null;
- int length = name.length();
- if (length == 0)
- return null;
-
- if (name.charAt(0) == '#') { // character reference
- if (length == 1)
- return null;
- int radix = 10;
- String s = null;
- // now allow hexadecimal also for non XML document
- if (name.charAt(1) == 'x') { // hexadecimal
- radix = 16;
- s = name.substring(2);
- }
- else { // decimal
- s = name.substring(1);
- }
- if (s == null || s.length() == 0)
- return null;
- if (s.charAt(0) == '-')
- return null; // no minus accepted
- char c = 0;
- try {
- c = (char) Integer.parseInt(s, radix);
- }
- catch (NumberFormatException ex) {
- }
- if (c == 0)
- return null;
- return String.valueOf(c);
- }
-
- // implicit character entities for XML
- if (name.equals(IXMLCharEntity.LT_NAME))
- return IXMLCharEntity.LT_VALUE;
- if (name.equals(IXMLCharEntity.GT_NAME))
- return IXMLCharEntity.GT_VALUE;
- if (name.equals(IXMLCharEntity.AMP_NAME))
- return IXMLCharEntity.AMP_VALUE;
- if (name.equals(IXMLCharEntity.QUOT_NAME))
- return IXMLCharEntity.QUOT_VALUE;
- if (isXMLType()) {
- if (name.equals(IXMLCharEntity.APOS_NAME))
- return IXMLCharEntity.APOS_VALUE;
- }
-
- CMDocument cm = getCMDocument();
- if (cm != null) {
- CMNamedNodeMap map = cm.getEntities();
- if (map != null) {
- CMEntityDeclaration decl = (CMEntityDeclaration) map.getNamedItem(name);
- if (decl != null) {
- String value = decl.getValue();
- if (value == null)
- return null;
- int valueLength = value.length();
- if (valueLength > 1 && value.charAt(0) == '&' && value.charAt(1) == '#' && value.charAt(valueLength - 1) == ';') {
- // character reference
- return getCharValue(value.substring(1, valueLength - 1));
- }
- return value;
- }
- }
- }
-
- return null;
- }
-
- /**
- */
- protected CMDocument getCMDocument() {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(this);
- if (modelQuery == null)
- return null;
- return modelQuery.getCorrespondingCMDocument(this);
- }
-
- /**
- * getDoctype method
- *
- * @return org.w3c.dom.DocumentType
- */
- public DocumentType getDoctype() {
- return findDoctype(this);
- }
-
- /**
- * getDocumentElement
- *
- * @return org.w3c.dom.Element From DOM 2 Spec: documentElement of type
- * Element [p.62] , readonly This is a convenience [p.119]
- * attribute that allows direct access to the child node that is
- * the root element of the document. For HTML documents, this is
- * the element with the tagName "HTML". Note: we differ from this
- * definition a little in that we don't necessarily take the first
- * child but also look to match the name. In a well formed
- * document, of course, the result is the same, but not
- * necessarily the same in an ill-formed document.
- */
- public Element getDocumentElement() {
- String name = null;
- DocumentType docType = getDocumentType();
- if (docType != null) {
- name = docType.getName();
- }
-
- Element first[] = new Element[1];
- Element docElement = findDocumentElement(name, this, first, noMaxSearch);
- if (docElement == null) {
- docElement = first[0];
- }
-
- return docElement;
- }
-
- /**
- */
- protected DocumentType getDocumentType() {
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) getAdapterFor(DocumentTypeAdapter.class);
- if (adapter == null)
- return getDoctype();
- return adapter.getDocumentType();
- }
-
-
- public String getDocumentTypeId() {
- DocumentType docType = getDocumentType();
- if (docType == null)
- return null;
- String id = docType.getPublicId();
- if (id == null)
- id = docType.getSystemId();
- return id;
- }
-
- public Element getElementById(String id) {
- if (id == null)
- return null;
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return null;
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- if (element.hasAttribute("id") && id.equals(element.getAttribute("id"))) //$NON-NLS-1$ //$NON-NLS-2$
- return element;
- }
-
- return null;
- }
-
- public NodeList getElementsByTagName(String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- NodeListImpl elements = null;
-
- if (usetagnamecache) {
- elements = tagNameCache.getItem(tagName);
- }
-
- if (elements == null) {
- elements = internalGetElementsByTagName(tagName);
-
- }
-
- return elements;
- }
-
- /**
- */
- public NodeList getElementsByTagNameNS(String uri, String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
- uri = null; // do not care
- }
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- if (tagName != null) {
- String localName = element.getLocalName();
- if (localName == null || !localName.equals(tagName))
- continue;
- }
- if (uri != null) {
- String nsURI = element.getNamespaceURI();
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
- elements.appendNode(element);
- }
-
- return elements;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the encoding
- * of this document. This is <code>null</code> when unspecified.
- *
- * @see DOM Level 3
- */
- public java.lang.String getEncoding() {
- return null;
- }
-
- /**
- */
- public DOMImplementation getImplementation() {
- return model;
- }
-
- /**
- * other nodes will be referring to this one to get the owning model
- */
- public IDOMModel getModel() {
- return model;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#document";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_NODE;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, whether this
- * document is standalone.
- *
- * @see DOM Level 3
- */
- public boolean getStandalone() {
- return false;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying whether errors checking is enforced or not.
- * When set to <code>false</code>, the implementation is free to not
- * test every possible error case normally defined on DOM operations, and
- * not raise any <code>DOMException</code>. In case of error, the
- * behavior is undefined. This attribute is <code>true</code> by
- * defaults.
- *
- * @see DOM Level 3
- */
- public boolean getStrictErrorChecking() {
- return false;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the version
- * number of this document. This is <code>null</code> when unspecified.
- *
- * @see DOM Level 3
- */
- public String getVersion() {
- return null;
- }
-
- /**
- */
- protected boolean ignoreCase() {
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) getAdapterFor(DocumentTypeAdapter.class);
- if (adapter == null)
- return false;
- return (adapter.getTagNameCase() != DocumentTypeAdapter.STRICT_CASE);
- }
-
- /**
- */
- protected void importChildNodes(Node parent, boolean deep) {
- if (parent == null)
- return;
-
- removeChildNodes();
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- Node imported = importNode(child, deep);
- if (imported == null)
- continue;
- appendChild(imported);
- }
- }
-
- /**
- */
- public Node importNode(Node node, boolean deep) throws DOMException {
- if (node == null)
- return null;
- NodeImpl imported = (NodeImpl) node.cloneNode(deep);
- if (imported == null)
- return null;
- //successful import, notify UserDataHandlers if any
- NodeImpl nodeToNotify=(NodeImpl) node;
- nodeToNotify.notifyUserDataHandlers(UserDataHandler.NODE_IMPORTED, null);
- imported.setOwnerDocument(this, deep);
- return imported;
- }
-
- private NodeListImpl internalGetElementsByTagName(String tagName) {
- // System.out.println("getElementsByTagname: " + tagName);
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- if (tagName != null) {
- ElementImpl element = (ElementImpl) node;
- if (!element.matchTagName(tagName))
- continue;
- }
- elements.appendNode(node);
- }
- if (usetagnamecache) {
- tagNameCache.addItem(tagName, elements);
- }
- return elements;
- }
-
- /**
- */
- public boolean isJSPDocument() {
- Element element = getDocumentElement();
- if (element == null)
- return false;
- String tagName = element.getTagName();
- if (tagName == null)
- return false;
- return tagName.equals(JSPTag.JSP_ROOT);
- }
-
- /**
- */
- public boolean isJSPType() {
- if (this.model == null)
- return false;
- IModelHandler handler = this.model.getModelHandler();
- if (handler == null)
- return false;
- String id = handler.getAssociatedContentTypeId();
- if (id == null)
- return false;
- // ISSUE: -- avoid this hardcoded string
- return id.equals("org.eclipse.jst.jsp.core.jspsource"); //$NON-NLS-1$
- }
-
- /**
- */
- protected boolean isValidName(String name) {
- if (name == null || name.length() == 0)
- return false;
- // // DMW: modified for XML4J 4.0.1
- // if (XMLChar.isValidName(name)) return true;
- if (NameValidator.isValid(name))
- return true;
- // special for invalid declaration
- if (name.length() == 1 && name.charAt(0) == '!')
- return true;
- // special for JSP tag in tag name
- if (name.startsWith(JSPTag.TAG_OPEN))
- return true;
- return false;
- }
-
- /**
- */
- public boolean isXMLType() {
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) getAdapterFor(DocumentTypeAdapter.class);
- if (adapter == null)
- return true;
- return adapter.isXMLType();
- }
-
- /**
- */
- // protected void releaseDocumentType() {
- // if (this.documentTypeAdapter == null)
- // return;
- // this.documentTypeAdapter.release();
- // this.documentTypeAdapter = null;
- // }
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the encoding
- * of this document. This is <code>null</code> when unspecified.
- *
- * @see DOM Level 3
- */
- public void setEncoding(java.lang.String encoding) {
- }
-
- /**
- * setModel method
- *
- * @param model
- * XMLModel
- */
-
- protected void setModel(IDOMModel model) {
- this.model = (DOMModelImpl) model;
- }
-
- /**
- * Provides an element's attribute declarations
- * @param element the element to retrieve the attribute map of
- * @return a <code>CMNamedNodeMap</code> of attributes if the declaration exists; null otherwise.
- */
- CMNamedNodeMap getCMAttributes(Element element) {
- CMNamedNodeMap map = (CMNamedNodeMap) fCMCache.get(element);
- if (map == null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(this);
- CMElementDeclaration decl = modelQuery != null ? modelQuery.getCMElementDeclaration(element) : null;
- if (decl != null) {
- map = decl.getAttributes();
- fCMCache.put(element, map);
- }
- }
- return map;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, whether this
- * document is standalone.
- *
- * @see DOM Level 3
- */
- public void setStandalone(boolean standalone) {
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying whether errors checking is enforced or not.
- * When set to <code>false</code>, the implementation is free to not
- * test every possible error case normally defined on DOM operations, and
- * not raise any <code>DOMException</code>. In case of error, the
- * behavior is undefined. This attribute is <code>true</code> by
- * defaults.
- *
- * @see DOM Level 3
- */
- public void setStrictErrorChecking(boolean strictErrorChecking) {
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the version
- * number of this document. This is <code>null</code> when unspecified.
- *
- * @see DOM Level 3
- */
- public void setVersion(java.lang.String version) {
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public String getInputEncoding() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public String getXmlEncoding() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public boolean getXmlStandalone() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public String getXmlVersion() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setXmlVersion(String xmlVersion) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public String getDocumentURI() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setDocumentURI(String documentURI) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public DOMConfiguration getDomConfig() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void normalizeDocument() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapter.java
deleted file mode 100644
index d2167048dd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.w3c.dom.DocumentType;
-
-
-/**
- */
-public interface DocumentTypeAdapter extends INodeAdapter {
- static final int LOWER_CASE = 2;
- static final int STRICT_CASE = 0;
- static final int UPPER_CASE = 1;
-
- /**
- */
- int getAttrNameCase();
-
- /**
- */
- DocumentType getDocumentType();
-
- /**
- */
- int getTagNameCase();
-
- /**
- */
- boolean hasFeature(String feature);
-
- /**
- */
- boolean isXMLType();
-
- /**
- */
- void release();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java
deleted file mode 100644
index 29c3e95c44..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.DocumentType;
-
-
-/**
- */
-public class DocumentTypeAdapterImpl implements DocumentTypeAdapter {
-
- private IDOMDocument document = null;
- private DocumentType documentType = null;
-
- /**
- */
- protected DocumentTypeAdapterImpl() {
- super();
- }
-
- /**
- */
- protected DocumentTypeAdapterImpl(IDOMDocument document) {
- this.document = document;
- if (document != null) {
- this.documentType = document.getDoctype();
- }
- }
-
- /**
- */
- public int getAttrNameCase() {
- return STRICT_CASE;
- }
-
- /**
- */
- protected IDOMDocument getDocument() {
- return this.document;
- }
-
- /**
- */
- public DocumentType getDocumentType() {
- return this.documentType;
- }
-
- /**
- */
- public int getTagNameCase() {
- return STRICT_CASE;
- }
-
- /**
- */
- public boolean hasFeature(String feature) {
- return false;
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == DocumentTypeAdapter.class);
- }
-
- /**
- */
- public boolean isXMLType() {
- return true;
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (eventType != INodeNotifier.STRUCTURE_CHANGED)
- return;
- if (notifier == null || !(notifier instanceof IDOMDocument))
- return;
- this.documentType = ((IDOMDocument) notifier).getDoctype();
- }
-
- /**
- */
- protected void notifyDocumentTypeChanged() {
- if (this.document == null)
- return;
- IDOMModel model = this.document.getModel();
- if (model == null)
- return;
- ((DOMModelImpl) model).documentTypeChanged();
- }
-
- /**
- */
- public void release() {
- // nothing to do
- }
-
- /**
- */
- protected void setDocumentType(DocumentType documentType) {
- this.documentType = documentType;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java
deleted file mode 100644
index 5ff86bf393..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * DocumentType class
- */
-public class DocumentTypeImpl extends NodeImpl implements IDOMDocumentType {
- private String internalSubset = null;
-
- private String name = null;
- private String publicId = null;
- private String systemId = null;
-
- /**
- * DocumentTypeImpl constructor
- */
- protected DocumentTypeImpl() {
- super();
- }
-
- /**
- * DocumentTypeImpl constructor
- *
- * @param that
- * DocumentTypeImpl
- */
- protected DocumentTypeImpl(DocumentTypeImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentTypeImpl cloned = new DocumentTypeImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getEntities method
- *
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getEntities() {
- return null;
- }
-
- /**
- */
- public String getInternalSubset() {
- return this.internalSubset;
- }
-
- /**
- * getName method
- *
- * @return java.lang.String
- */
- public String getName() {
- if (this.name == null)
- return NodeImpl.EMPTY_STRING;
- return this.name;
- }
-
- /**
- * getNodeName
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return getName();
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_TYPE_NODE;
- }
-
- /**
- * getNotations method
- *
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getNotations() {
- return null;
- }
-
- /**
- * getPublicId method
- *
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- *
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE || regionType == DOMRegionContext.XML_DECLARATION_CLOSE);
- }
-
- /**
- */
- public void setInternalSubset(String internalSubset) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.internalSubset = internalSubset;
- }
-
- /**
- * setName method
- *
- * @param name
- * java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setPublicId method
- *
- * @param publicId
- * java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.publicId = publicId;
-
- notifyValueChanged();
- }
-
- /**
- * setSystemId method
- *
- * @param systemId
- * java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.systemId = systemId;
-
- notifyValueChanged();
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getName());
- buffer.append('(');
- buffer.append(getPublicId());
- buffer.append(')');
- buffer.append('(');
- buffer.append(getSystemId());
- buffer.append(')');
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null) {
- buffer.append('@');
- buffer.append(flatNode.toString());
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java
deleted file mode 100644
index 8e5121e572..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java
+++ /dev/null
@@ -1,1552 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- *
- * Valentin Baciu - https://bugs.eclipse.org/bugs/show_bug.cgi?id=139552
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-import java.util.Stack;
-
-import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLNamespace;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.UserDataHandler;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-
-/**
- * ElementImpl class
- */
-public class ElementImpl extends NodeContainer implements IDOMElement {
-
- private class Attributes implements NamedNodeMap {
- Attributes() {
- super();
- }
-
- public int getLength() {
- if (attrNodes == null)
- return 0;
- return attrNodes.getLength();
- }
-
- public Node getNamedItem(String name) {
- return getAttributeNode(name);
- }
-
- public Node getNamedItemNS(String uri, String name) {
- return getAttributeNodeNS(uri, name);
- }
-
- public Node item(int index) {
- if (attrNodes == null)
- return null;
- if (index >= attrNodes.getLength())
- return null;
- return attrNodes.item(index);
- }
-
- public Node removeNamedItem(String name) throws DOMException {
- return removeAttributeNode(name);
- }
-
- public Node removeNamedItemNS(String uri, String name) throws DOMException {
- return removeAttributeNodeNS(uri, name);
- }
-
- public Node setNamedItem(Node arg) throws DOMException {
- return setAttributeNode((AttrImpl) arg);
- }
-
- public Node setNamedItemNS(Node arg) throws DOMException {
- return setAttributeNodeNS((AttrImpl) arg);
- }
- }
-
-// private static final char[] XMLNS_PREFIX = IXMLNamespace.XMLNS_PREFIX.toCharArray();
- private static final byte FLAG_COMMENT = 0x1;
- private static final byte FLAG_EMPTY = 0x2;
- private static final byte FLAG_JSP = 0x4;
-
- private byte fTagFlags = 0;
-
- NodeListImpl attrNodes = null;
- private IStructuredDocumentRegion endStructuredDocumentRegion = null;
-
- private char[] fTagName = null;
-
- private char[] fNamespaceURI = null;
-
- private Stack fDefaultValueLookups = null;
-
- /**
- * ElementImpl constructor
- */
- protected ElementImpl() {
- super();
- }
-
- /**
- * ElementImpl constructor
- *
- * @param that
- * ElementImpl
- */
- protected ElementImpl(ElementImpl that) {
- super(that);
-
- if (that != null) {
- this.fTagName = that.fTagName;
- this.fTagFlags = that.fTagFlags;
-
- // clone attributes
- that.cloneAttributes(this);
- }
- }
-
- /**
- * addEndTag method
- *
- * @param end
- * org.w3c.dom.Element
- */
- protected void addEndTag(Element endTag) {
- if (endTag == null)
- return;
- if (hasEndTag())
- return;
- ElementImpl end = (ElementImpl) endTag;
-
- // move the end flat node from the end tag
- IStructuredDocumentRegion flatNode = end.getEndStructuredDocumentRegion();
- if (flatNode == null)
- return;
- end.setEndStructuredDocumentRegion(null);
- setEndStructuredDocumentRegion(flatNode);
- }
-
- /**
- * appendAttibuteNode method
- *
- * @return org.w3c.dom.Attr
- * @param newAttr
- * org.w3c.dom.Attr
- */
- public Attr appendAttributeNode(Attr newAttr) {
- if (newAttr == null)
- return null;
- AttrImpl attr = (AttrImpl) newAttr;
- if (attr.getOwnerElement() != null)
- return null;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (this.attrNodes == null)
- this.attrNodes = new NodeListImpl();
- this.attrNodes.appendNode(attr);
- attr.setOwnerElement(this);
-
- notifyAttrReplaced(attr, null);
- return attr;
- }
-
- /**
- * cloneAttributes method
- *
- * @param newOwner
- * org.w3c.dom.Element
- */
- protected void cloneAttributes(Element newOwner) {
- if (newOwner == null || newOwner == this)
- return;
-
- ElementImpl element = (ElementImpl) newOwner;
- element.removeAttributes();
-
- if (this.attrNodes == null)
- return;
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- Node node = this.attrNodes.item(i);
- if (node == null)
- continue;
- Attr cloned = (Attr) node.cloneNode(false);
- if (cloned != null)
- element.appendAttributeNode(cloned);
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- ElementImpl cloned = newInstance();
- if (deep)
- cloneChildNodes(cloned, deep);
-
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- protected ElementImpl newInstance() {
- return new ElementImpl(this);
- }
-
- /**
- * getAttribute method
- *
- * @return java.lang.String
- * @param name
- * java.lang.String
- */
- public String getAttribute(String name) {
- Attr attr = getAttributeNode(name);
- // In the absence of the attribute, get the default value
- if (attr == null) {
- final String defaultValue = getDefaultValue(name, NodeImpl.EMPTY_STRING);
- return defaultValue != null ? defaultValue : NodeImpl.EMPTY_STRING ;
- }
- return attr.getValue();
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
- */
- public Attr getAttributeNode(String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- final Attr attr = findAttributeNode(name);
- if (attr != null)
- return attr;
-
- String implied = getDefaultValue(name, null);
- if (implied != null) {
- Attr createdAttribute = getOwnerDocument().createAttribute(name);
- createdAttribute.setNodeValue(implied);
- ((AttrImpl) createdAttribute).setOwnerElement(this);
- return createdAttribute;
- }
-
- return null; // not found
- }
-
- /**
- * Finds an attribute node in this element's attribute nodelist
- * @param name the name of the attribute to find
- * @return The {@link Attr} whose name matches <code>name</code>. Returns null if an attribute by <code>name</code>
- * could not be found.
- */
- private Attr findAttributeNode(String name) {
- if (attrNodes == null)
- return null; // no attribute
-
- int length = attrNodes.getLength();
- char[] nameChars = name.toCharArray();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) attrNodes.item(i);
- if (attr == null)
- continue;
- if (attr.matchName(nameChars))
- return attr; // found
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
- */
- public Attr getAttributeNodeNS(String uri, String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- String localName = attr.getLocalName();
- if (localName == null || !localName.equals(name))
- continue;
- String nsURI = attr.getNamespaceURI();
- if (uri == null) {
- if (nsURI != null)
- continue;
- }
- else {
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
-
- // found
- return attr;
- }
-
- return null; // not found
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
- */
- public String getAttributeNS(String uri, String name) {
- Attr attr = getAttributeNodeNS(uri, name);
- // In the absence of the attribute, get the default value
- if (attr == null) {
- final String defaultValue = getDefaultValue(name, NodeImpl.EMPTY_STRING);
- return defaultValue != null ? defaultValue : NodeImpl.EMPTY_STRING;
- }
- return attr.getValue();
- }
-
- /**
- * getAttributes method
- *
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getAttributes() {
- return new Attributes();
- }
-
- /**
- */
- protected CMElementDeclaration getDeclaration() {
- Document document = getOwnerDocument();
- if (document == null)
- return null;
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery == null)
- return null;
- return modelQuery.getCMElementDeclaration(this);
- }
-
- /**
- * Get the implied default value for attribute <code>name</code>
- *
- * @param name
- * @return returns the default value for attribute <code>name</code> if it
- * is found in the content model, <code>unknownDefault</code> otherwise
- */
- private String getDefaultValue(String name, String unknownDefault) {
- if (fDefaultValueLookups != null && fDefaultValueLookups.contains(name))
- return null;
- try {
- if (fDefaultValueLookups == null)
- fDefaultValueLookups = new Stack();
- fDefaultValueLookups.push(name);
- CMNamedNodeMap map = ((DocumentImpl) getOwnerDocument()).getCMAttributes(this);
- if (map != null) {
- CMNode attribute = map.getNamedItem(name);
- if (attribute instanceof CMAttributeDeclaration)
- return ((CMAttributeDeclaration) attribute).getAttrType().getImpliedValue();
- }
- return unknownDefault;
- }
- finally {
- fDefaultValueLookups.pop();
- }
- }
-
- /**
- * getElementsByTagName method
- *
- * @return org.w3c.dom.NodeList
- * @param tagName
- * java.lang.String
- */
- public NodeList getElementsByTagName(String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return new NodeListImpl();
- NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- it.nextNode(); // skip the first node since it is the root from createNodeIterator
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- if (tagName != null) {
- ElementImpl element = (ElementImpl) node;
- if (!element.matchTagName(tagName))
- continue;
- }
- elements.appendNode(node);
- }
-
- return elements;
- }
-
- /**
- */
- public NodeList getElementsByTagNameNS(String uri, String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return new NodeListImpl();
- NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
- uri = null; // do not care
- }
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- it.nextNode(); // skip the first node since it is the root from createNodeIterator
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- if (tagName != null) {
- String localName = element.getLocalName();
- if (localName == null || !localName.equals(tagName))
- continue;
- }
- if (uri != null) {
- String nsURI = element.getNamespaceURI();
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
- elements.appendNode(element);
- }
-
- return elements;
- }
-
- /**
- * getEndOffset method
- *
- * @return int
- */
- public int getEndOffset() {
- if (this.endStructuredDocumentRegion != null)
- return this.endStructuredDocumentRegion.getEnd();
- return super.getEndOffset();
- }
-
- /**
- * getEndStartOffset method
- *
- * @return int
- */
- public int getEndStartOffset() {
- if (this.endStructuredDocumentRegion != null)
- return this.endStructuredDocumentRegion.getStart();
- return super.getEndOffset();
- }
-
- /**
- * getEndStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getEndStructuredDocumentRegion() {
- return this.endStructuredDocumentRegion;
- }
-
- public String getEndTagName() {
- if (this.endStructuredDocumentRegion == null)
- return null;
-
- ITextRegionList regions = this.endStructuredDocumentRegion.getRegions();
- if (regions == null)
- return null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedEndTag(regionType)) {
- return this.endStructuredDocumentRegion.getText(region);
- }
- }
-
- return null;
- }
-
- protected boolean isNestedEndTag(String regionType) {
- boolean result = false;
- return result;
- }
-
- /**
- * getFirstStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null)
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(flatNode);
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.endStructuredDocumentRegion);
- }
-
- /**
- * getLastStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- if (this.endStructuredDocumentRegion != null)
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.endStructuredDocumentRegion);
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(getStructuredDocumentRegion());
- }
-
- /**
- */
- public String getLocalName() {
- if (this.fTagName == null)
- return null;
- int index = CharOperation.indexOf(this.fTagName, ':');
- if (index < 0)
- return new String(this.fTagName);
- return new String(this.fTagName, index + 1, this.fTagName.length - index - 1);
- }
-
- public String getNamespaceURI() {
- if (this.fNamespaceURI != null)
- return new String(this.fNamespaceURI);
-
- String nsAttrName = null;
- String prefix = getPrefix();
- if (prefix != null && prefix.length() > 0) {
- nsAttrName = IXMLNamespace.XMLNS_PREFIX + prefix;
- }
- else {
- nsAttrName = IXMLNamespace.XMLNS;
- }
-
- for (Node node = this; node != null; node = node.getParentNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- break;
- Element element = (Element) node;
- Attr attr = element.getAttributeNode(nsAttrName);
- if (attr != null)
- return attr.getValue();
- }
-
- return null;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return getTagName();
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return ELEMENT_NODE;
- }
-
- /**
- */
- public String getPrefix() {
- if (this.fTagName == null)
- return null;
- int index = CharOperation.indexOf(this.fTagName, ':');
- if (index <= 0)
- return null;
- // exclude JSP tag in name
- if (this.fTagName[0] == '<')
- return null;
- return new String(this.fTagName, 0, index);
- }
-
- /**
- * getStartEndOffset method
- *
- * @return int
- */
- public int getStartEndOffset() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null)
- return flatNode.getEnd();
- return super.getStartOffset();
- }
-
- /**
- * getStartOffset method
- *
- * @return int
- */
- public int getStartOffset() {
- if (getStartStructuredDocumentRegion() == null && this.endStructuredDocumentRegion != null && !hasChildNodes()) {
- return this.endStructuredDocumentRegion.getStart();
- }
- return super.getStartOffset();
- }
-
- /**
- * getStartStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getStartStructuredDocumentRegion() {
- return getStructuredDocumentRegion();
- }
-
- /**
- * getTagName method
- *
- * @return java.lang.String
- */
- public String getTagName() {
- if (this.fTagName == null)
- return NodeImpl.EMPTY_STRING;
- return new String(fTagName);
- }
-
- /**
- */
- public boolean hasAttribute(String name) {
- return (getAttributeNode(name) != null);
- }
-
- /**
- */
- public boolean hasAttributeNS(String uri, String name) {
- return (getAttributeNodeNS(uri, name) != null);
- }
-
- /**
- */
- public boolean hasAttributes() {
- return (this.attrNodes != null && this.attrNodes.getLength() > 0);
- }
-
- /**
- * hasEndTag method
- *
- * @return boolean
- */
- public boolean hasEndTag() {
- return (this.endStructuredDocumentRegion != null);
- }
-
- /**
- */
- protected final boolean hasPrefix() {
- if (this.fTagName == null || this.fTagName.length == 0)
- return false;
- return CharOperation.indexOf(this.fTagName, ':') > 0 && this.fTagName[0] != '<';
- }
-
- /**
- * hasStartTag method
- *
- * @return boolean
- */
- public boolean hasStartTag() {
- return (getStructuredDocumentRegion() != null);
- }
-
- /**
- */
- protected final boolean ignoreCase() {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && document.ignoreCase()) {
- // even in case insensitive document, if having prefix, it's case
- // sensitive tag
- return !hasPrefix();
- }
- return false;
- }
-
- /**
- */
- protected Attr insertAttributeNode(Attr newAttr, int index) {
- if (newAttr == null)
- return null;
- AttrImpl attr = (AttrImpl) newAttr;
- if (attr.getOwnerElement() != null)
- return null;
-
- if (this.attrNodes == null)
- this.attrNodes = new NodeListImpl();
- this.attrNodes.insertNode(attr, index);
- attr.setOwnerElement(this);
-
- notifyAttrReplaced(attr, null);
- return attr;
- }
-
- /**
- * insertBefore method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param refChild
- * org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- // should throw DOMException instead of return null?
- if (newChild == null)
- return null;
- if (!isContainer()) { // never be container
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
- if (newChild.getNodeType() != TEXT_NODE && newChild.getNodeType() != CDATA_SECTION_NODE) {
- if (isJSPContainer() || isCDATAContainer()) { // accepts only
- // Text
- // child
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
- }
- return super.insertBefore(newChild, refChild);
- }
-
- /**
- */
- protected boolean isCDATAContainer() {
- // use BlockMaker instead of CMElementDeclaration
- // because <style> and <script> in XHTML is not CDATA content type
- IDOMModel model = getModel();
- if (model == null)
- return false; // error
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument == null || fTagName == null)
- return false; // eror
- RegionParser parser = structuredDocument.getParser();
- if (parser == null || !(parser instanceof XMLSourceParser))
- return false;
- return (((XMLSourceParser) parser).getBlockMarker(new String(this.fTagName)) != null);
- /*
- * CMElementDeclaration decl = getDeclaration(); if (decl == null)
- * return false; if (decl instanceof CMNodeWrapper) { decl =
- * (CMElementDeclaration)((CMNodeWrapper)decl).getOriginNode(); if
- * (decl == null) return false; } if (decl instanceof
- * TLDElementDeclaration) { String content =
- * ((TLDElementDeclaration)decl).getBodycontent(); if (content ==
- * null) return false; return
- * content.equals(JSP11TLDNames.CONTENT_TAGDEPENDENT); } if
- * (!isGlobalTag()) return false; return (decl.getContentType() ==
- * CMElementDeclaration.CDATA);
- */
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = null;
- if (isEmptyTag() || !isContainer()) {
- flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- }
- else {
- flatNode = getEndStructuredDocumentRegion();
- if (flatNode == null)
- return false; // must be generated
- }
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- if (isCommentTag()) {
- return (isNestedClosedComment(regionType) || regionType == DOMRegionContext.XML_COMMENT_CLOSE);
- }
- if (isJSPTag()) {
- return isNestedClosed(regionType);
- }
- return (regionType == DOMRegionContext.XML_TAG_CLOSE || regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE || regionType == DOMRegionContext.XML_DECLARATION_CLOSE);
- }
-
- protected boolean isNestedClosed(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected boolean isNestedClosedComment(String regionType) {
- boolean result = false;
- return result;
- }
-
- /**
- */
- public final boolean isCommentTag() {
- return (fTagFlags & FLAG_COMMENT) != 0;
- }
-
- /**
- * isContainer method
- *
- * @return boolean
- */
- public boolean isContainer() {
- if (isCommentTag()) {
- CommentElementAdapter adapter = (CommentElementAdapter) getAdapterFor(CommentElementAdapter.class);
- if (adapter != null) {
- return (adapter.isContainer());
- }
- return (getDeclaration() == null);
- }
- if (isJSPTag()) {
- // exclude JSP directive
- return (matchTagName(JSPTag.JSP_SCRIPTLET) || matchTagName(JSPTag.JSP_DECLARATION) || matchTagName(JSPTag.JSP_EXPRESSION));
- }
- if (!isXMLTag()) { // non-XML tag
- CMElementDeclaration decl = getDeclaration();
- if (decl == null)
- return true; // undefined tag
- return (decl.getContentType() != CMElementDeclaration.EMPTY);
- }
- return true;
- }
-
- /**
- * isEmptyTag method
- *
- * @return boolean
- */
- public boolean isEmptyTag() {
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- if (!isXMLTag())
- return false;
- return (fTagFlags & FLAG_EMPTY) != 0;
- }
-
- /**
- */
- public boolean isEndTag() {
- return (hasEndTag() && !hasStartTag() && !hasChildNodes());
- }
-
- /**
- */
- public boolean isGlobalTag() {
- return !hasPrefix();
- }
-
- /**
- */
- public boolean isImplicitTag() {
- if (hasStartTag() || hasEndTag())
- return false;
- // make sure this is in the document tree
- // because if not in the document tree, no tags are generated yet
- return (getContainerDocument() != null);
- }
-
- /**
- */
- public boolean isJSPContainer() {
- return (isJSPTag() && !isCommentTag() && isContainer());
- }
-
- /**
- * isJSPTag method
- *
- * @return boolean
- */
- public final boolean isJSPTag() {
- return (fTagFlags & FLAG_JSP) != 0;
- }
-
- /**
- */
- public boolean isStartTagClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- if (isCommentTag()) {
- return (isNestedClosedComment(regionType) || regionType == DOMRegionContext.XML_COMMENT_CLOSE);
- }
- if (isJSPTag()) {
- if (isContainer())
- return true; // start tag always has a single region
- return isClosedNestedDirective(regionType);
- }
- return (regionType == DOMRegionContext.XML_TAG_CLOSE || regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE || regionType == DOMRegionContext.XML_DECLARATION_CLOSE);
- }
-
- protected boolean isClosedNestedDirective(String regionType) {
- boolean result = false;
- return result;
- }
-
- /**
- */
- public final boolean isXMLTag() {
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && !document.isXMLType()) {
- // even in non-XML document, if having prefix, it's XML tag
- return hasPrefix();
- }
- return true;
- }
-
- /**
- */
- protected boolean matchEndTag(Element element) {
- if (element == null)
- return false;
- ElementImpl impl = (ElementImpl) element;
- if (isJSPTag() && !isCommentTag()) {
- return (impl.isJSPTag() && !impl.isCommentTag());
- }
- return matchTagName(element.getTagName());
- }
-
- /**
- * matchTagName method
- *
- * @return boolean
- * @param tagName
- * java.lang.String
- */
- public boolean matchTagName(String tagName) {
- if (tagName == null)
- return (this.fTagName == null);
- if (this.fTagName == null)
- return false;
- if (this.fTagName.length != tagName.length())
- return false;
- String stringName = new String(this.fTagName);
- if (!ignoreCase())
- return stringName.equals(tagName);
- return stringName.equalsIgnoreCase(tagName);
- }
-
- /**
- * notifyAttrReplaced method
- *
- * @param newAttr
- * org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- protected void notifyAttrReplaced(Attr newAttr, Attr oldAttr) {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.attrReplaced(this, newAttr, oldAttr);
- }
-
- /**
- * notifyValueChanged method
- */
- public void notifyEndTagChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.endTagChanged(this);
- }
-
- /**
- */
- public void notifyStartTagChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.startTagChanged(this);
- }
-
- /**
- */
- public boolean preferEmptyTag() {
- if (hasChildNodes())
- return false;
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- if (!isXMLTag())
- return false;
- CMElementDeclaration decl = getDeclaration();
- if (decl == null)
- return false;
- return (decl.getContentType() == CMElementDeclaration.EMPTY);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
- */
- public void removeAttribute(String name) throws DOMException {
- removeAttributeNode(name, false);
- }
-
- /**
- * removeAttributeNode method
- *
- * @return org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
- if (oldAttr == null)
- return null; // invalid parameter
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (this.attrNodes == null) { // no attribute
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr != oldAttr)
- continue;
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- // not found
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- }
-
- /**
- * @param name
- * @return
- */
- public Attr removeAttributeNode(String name) {
- return removeAttributeNode(name, true);
- }
-
- private Attr removeAttributeNode(String name, boolean exceptionOnNotFound) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- if (!attr.matchName(name))
- continue;
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- if (exceptionOnNotFound)
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- return null; // not found
- }
-
- /**
- */
- public Attr removeAttributeNodeNS(String uri, String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- String localName = attr.getLocalName();
- if (localName == null || !localName.equals(name))
- continue;
- String nsURI = attr.getNamespaceURI();
- if (uri == null) {
- if (nsURI != null)
- continue;
- }
- else {
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- return null; // not found
- }
-
- /**
- */
- public void removeAttributeNS(String uri, String name) throws DOMException {
- removeAttributeNodeNS(uri, name);
- }
-
- /**
- * removeAttributes method
- */
- public void removeAttributes() {
- if (this.attrNodes == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr != null) {
- attr.setOwnerElement(null);
- notifyAttrReplaced(null, attr);
- }
- }
-
- this.attrNodes = null;
- }
-
- /**
- * removeEndTag method
- *
- * @return org.w3c.dom.Element
- */
- protected Element removeEndTag() {
- if (!hasEndTag())
- return null;
- NodeListImpl attrNodes = this.attrNodes;
- this.attrNodes = null; // not to copy attributes
- ElementImpl end = (ElementImpl) cloneNode(false);
- this.attrNodes = attrNodes;
- if (end == null)
- return null;
-
- // move the end flat node to the end tag
- IStructuredDocumentRegion flatNode = getEndStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- setEndStructuredDocumentRegion(null);
- end.setEndStructuredDocumentRegion(flatNode);
- return end;
- }
-
- /**
- */
- protected void removeStartTag() {
- removeAttributes();
- }
-
- /**
- * Resets attribute values from IStructuredDocumentRegion.
- */
- void resetStructuredDocumentRegions() {
- if (this.attrNodes != null) {
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- attr.resetRegions();
- }
- }
-
- super.resetStructuredDocumentRegions(); // for children
-
- this.endStructuredDocumentRegion = null;
- }
-
- /**
- * setAttribute method
- *
- * @param name
- * java.lang.String
- * @param value
- * java.lang.String
- */
- public void setAttribute(String name, String value) throws DOMException {
- if (name == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- Attr attr = findAttributeNode(name);
- if (attr != null) {
- attr.setValue(value); // change value
- return;
- }
-
- // new attribute
- Document doc = getOwnerDocument();
- if (doc == null)
- return;
- attr = doc.createAttribute(name);
- if (attr == null)
- return;
- attr.setValue(value);
- appendAttributeNode(attr);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
- */
- public Attr setAttributeNode(Attr newAttr) throws DOMException {
- if (newAttr == null)
- return null; // nothing to do
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- AttrImpl attr = (AttrImpl) newAttr;
- Element owner = attr.getOwnerElement();
- if (owner != null) {
- if (owner == this)
- return null; // nothing to do
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, DOMMessages.INUSE_ATTRIBUTE_ERR);
- }
-
- Attr oldAttr = removeAttributeNode(newAttr.getName(), false);
- appendAttributeNode(attr);
- return oldAttr;
- }
-
- /**
- */
- public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
- if (newAttr == null)
- return null; // nothing to do
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- AttrImpl attr = (AttrImpl) newAttr;
- Element owner = attr.getOwnerElement();
- if (owner != null) {
- if (owner == this)
- return null; // nothing to do
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, DOMMessages.INUSE_ATTRIBUTE_ERR);
- }
-
- String name = newAttr.getLocalName();
- String uri = newAttr.getNamespaceURI();
- Attr oldAttr = removeAttributeNodeNS(uri, name);
- appendAttributeNode(attr);
- return oldAttr;
- }
-
- /**
- * ISSUE: we should check for and throw NAMESPACE_ERR, according to spec.
- */
- public void setAttributeNS(String uri, String qualifiedName, String value) throws DOMException {
- if (qualifiedName == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=139552
- // fix provided by Valentin Baciu
- int index = qualifiedName.indexOf(':');
- String localName = index != -1 ? qualifiedName.substring(index + 1) : qualifiedName;
-
- Attr attr = getAttributeNodeNS(uri, localName);
- if (attr != null) {
- attr.setValue(value); // change value
- }
- else {
-
- // new attribute
- Document doc = getOwnerDocument();
- if (doc != null) {
- attr = doc.createAttributeNS(uri, qualifiedName);
- if (attr != null) {
- attr.setValue(value);
- appendAttributeNode(attr);
- }
- }
- }
- }
-
- /**
- */
- public void setCommentTag(boolean isCommentTag) {
- IDOMNode parent = (IDOMNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (isCommentTag)
- fTagFlags |= FLAG_COMMENT;
- else
- fTagFlags &= ~FLAG_COMMENT;
- }
-
- /**
- * setEmptyTag method
- *
- * @param isEmptyTag
- * boolean
- */
- public void setEmptyTag(boolean isEmptyTag) {
- IDOMNode parent = (IDOMNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (isEmptyTag)
- fTagFlags |= FLAG_EMPTY;
- else
- fTagFlags &= ~FLAG_EMPTY;
- }
-
- /**
- * setEndStructuredDocumentRegion method
- *
- * @param flatNode
- */
- void setEndStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- this.endStructuredDocumentRegion = flatNode;
-
- NodeContainer parent = (NodeContainer) getParentNode();
- if (parent != null) {
- parent.syncChildEditableState(this);
- }
- }
-
- /**
- * setJSPTag method
- *
- * @param isJSPTag
- * boolean
- */
- public void setJSPTag(boolean isJSPTag) {
- IDOMNode parent = (IDOMNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, NodeImpl.EMPTY_STRING);
- }
-
- if (isJSPTag)
- fTagFlags |= FLAG_JSP;
- else
- fTagFlags &= ~FLAG_JSP;
- }
-
- protected void setNamespaceURI(String namespaceURI) {
- if (namespaceURI == null)
- this.fNamespaceURI = null;
- else
- this.fNamespaceURI = namespaceURI.toCharArray();
- }
-
- /**
- */
- protected void setOwnerDocument(Document ownerDocument, boolean deep) {
- super.setOwnerDocument(ownerDocument, deep);
-
- if (this.attrNodes == null)
- return;
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- attr.setOwnerDocument(ownerDocument);
- }
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- IDOMNode parent = (IDOMNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, NodeImpl.EMPTY_STRING);
- }
-
- int prefixLength = (prefix != null ? prefix.length() : 0);
- String localName = getLocalName();
- if (prefixLength == 0) {
- if (localName == null || localName.length() == 0) {
- // invalid local name
- return;
- }
- setTagName(localName);
- }
- else {
- int localLength = (localName != null ? localName.length() : 0);
- StringBuffer buffer = new StringBuffer(prefixLength + 1 + localLength);
- buffer.append(prefix);
- buffer.append(':');
- if (localName != null)
- buffer.append(localName);
- setTagName(buffer.toString());
- }
-
- boolean changeEndTag = hasEndTag();
- notifyStartTagChanged();
- if (changeEndTag)
- notifyEndTagChanged();
- }
-
- /**
- * setStartStructuredDocumentRegion method
- *
- * @param flatNode
- */
- void setStartStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- setStructuredDocumentRegion(flatNode);
- }
-
- /**
- * setTagName method
- *
- * @param tagName
- * java.lang.String
- */
- protected void setTagName(String tagName) {
- this.fTagName = tagName != null ? CharacterStringPool.getCharString(tagName) : null;
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- String tagName = getTagName();
- if (hasStartTag())
- buffer.append(tagName);
- if (isEmptyTag())
- buffer.append('/');
- if (hasEndTag()) {
- buffer.append('/');
- buffer.append(tagName);
- }
- if (buffer.length() == 0)
- buffer.append(tagName);
-
- IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- buffer.append('@');
- buffer.append(startStructuredDocumentRegion.toString());
- }
- IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- buffer.append('@');
- buffer.append(endStructuredDocumentRegion.toString());
- }
- return buffer.toString();
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttribute(String name, boolean isId) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not supported in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not supported in this version"); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not supported in this version"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java
deleted file mode 100644
index fae39ca20a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Entity;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * EntityImpl class
- */
-public class EntityImpl extends NodeImpl implements Entity {
-
- private String name = null;
- private String notationName = null;
- private String publicId = null;
- private String systemId = null;
-
- /**
- * EntityImpl constructor
- */
- protected EntityImpl() {
- super();
- }
-
- /**
- * EntityImpl constructor
- *
- * @param that
- * EntityImpl
- */
- protected EntityImpl(EntityImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- this.publicId = that.publicId;
- this.systemId = that.systemId;
- this.notationName = that.notationName;
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- EntityImpl cloned = new EntityImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the encoding
- * of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- *
- * @see DOM Level 3
- */
- public java.lang.String getEncoding() {
- return null;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return NodeImpl.EMPTY_STRING;
- return this.name;
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return ENTITY_NODE;
- }
-
- /**
- * getNotationName method
- *
- * @return java.lang.String
- */
- public String getNotationName() {
- return this.notationName;
- }
-
- /**
- * getPublicId method
- *
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- *
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the version
- * number of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- *
- * @see DOM Level 3
- */
- public java.lang.String getVersion() {
- return null;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the encoding
- * of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- *
- * @see DOM Level 3
- */
- public void setEncoding(java.lang.String encoding) {
- }
-
- /**
- * setName method
- *
- * @param name
- * java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setNotationName method
- *
- * @param notationName
- * java.lang.String
- */
- public void setNotationName(String notationName) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.notationName = notationName;
- }
-
- /**
- * setPublicId method
- *
- * @param publicId
- * java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.publicId = publicId;
- }
-
- /**
- * setSystemId method
- *
- * @param systemId
- * java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.systemId = systemId;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the version
- * number of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- *
- * @see DOM Level 3
- */
- public void setVersion(java.lang.String version) {
- }
-
- public String getInputEncoding() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
- public String getXmlEncoding() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
-
- public String getXmlVersion() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java
deleted file mode 100644
index a4edb32bca..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * EntityReference class
- */
-public class EntityReferenceImpl extends NodeImpl implements EntityReference {
-
- private String name = null;
-
- /**
- * EntityReferenceImpl constructor
- */
- protected EntityReferenceImpl() {
- super();
- }
-
- /**
- * EntityReferenceImpl constructor
- *
- * @param that
- * EntityReferenceImpl
- */
- protected EntityReferenceImpl(EntityReferenceImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- EntityReferenceImpl cloned = new EntityReferenceImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return NodeImpl.EMPTY_STRING;
- return this.name;
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return ENTITY_REFERENCE_NODE;
- }
-
- /**
- * setName method
- *
- * @param name
- * java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/InvalidCharacterException.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/InvalidCharacterException.java
deleted file mode 100644
index 1a3a079a97..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/InvalidCharacterException.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-/**
- * Thrown an invalid character is specified in : XMLNode#setSource(String)
- */
-public class InvalidCharacterException extends Exception {
-
- /**
- * Default <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
- private char invalidChar = 0;
- private int offset = -1;
-
- /**
- */
- public InvalidCharacterException() {
- super();
- }
-
- /**
- */
- public InvalidCharacterException(String s) {
- super(s);
- }
-
- /**
- */
- public InvalidCharacterException(String s, char c) {
- super(s);
- this.invalidChar = c;
- }
-
- /**
- */
- public InvalidCharacterException(String s, char c, int offset) {
- super(s);
- this.invalidChar = c;
- this.offset = offset;
- }
-
- /**
- */
- public char getInvalidChar() {
- return this.invalidChar;
- }
-
- /**
- */
- public int getOffset() {
- return this.offset;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/JSPTag.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/JSPTag.java
deleted file mode 100644
index 6f2de44010..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/JSPTag.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-/**
- * JSPTag interface
- */
-public interface JSPTag {
- static final String COMMENT_CLOSE = "--%>";//$NON-NLS-1$
- static final String COMMENT_OPEN = "<%--";//$NON-NLS-1$
- static final String DECLARATION_TOKEN = "!";//$NON-NLS-1$
- static final String DIRECTIVE_TOKEN = "@";//$NON-NLS-1$
- static final String EXPRESSION_TOKEN = "=";//$NON-NLS-1$
- static final String JSP_DECLARATION = "jsp:declaration";//$NON-NLS-1$
- static final String JSP_DIRECTIVE = "jsp:directive";//$NON-NLS-1$
- static final String JSP_EXPRESSION = "jsp:expression";//$NON-NLS-1$
- static final String JSP_ROOT = "jsp:root";//$NON-NLS-1$
-
- static final String JSP_SCRIPTLET = "jsp:scriptlet";//$NON-NLS-1$
- static final String TAG_CLOSE = "%>";//$NON-NLS-1$
- static final String TAG_OPEN = "<%";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java
deleted file mode 100644
index e61907dd5d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- */
-public interface ModelParserAdapter extends INodeAdapter {
-
- /**
- */
- public boolean canBeImplicitTag(Element element);
-
- /**
- */
- public boolean canBeImplicitTag(Element element, Node child);
-
- /**
- */
- public boolean canContain(Element element, Node child);
-
- /**
- */
- public Element createCommentElement(Document document, String data, boolean isJSPTag);
-
- /**
- */
- public Element createImplicitElement(Document document, Node parent, Node child);
-
- /**
- */
- public String getFindRootName(String tagName);
-
- /**
- */
- public boolean isEndTag(IDOMElement element);
-
- boolean isEndTagOmissible(Element element);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java
deleted file mode 100644
index ac7a403352..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * NodeContainer class
- */
-public abstract class NodeContainer extends NodeImpl implements Node, NodeList {
-
- /**
- */
- private class ChildNodesCache implements NodeList {
- private Node curChild = null;
- private int curIndex = -1;
- private int length = 0;
-
- ChildNodesCache() {
- initializeCache();
- }
-
- public int getLength() {
- // atomic
- return this.length;
- }
-
- private void initializeCache() {
- // note we use the outter objects lockobject
- // (since we are using their "children".
- synchronized (lockObject) {
- for (Node child = firstChild; child != null; child = child.getNextSibling()) {
- this.length++;
- }
- }
- }
-
- public Node item(int index) {
- synchronized (lockObject) {
- if (this.length == 0)
- return null;
- if (index < 0)
- return null;
- if (index >= this.length)
- return null;
-
- if (this.curIndex < 0) { // first time
- if (index * 2 >= this.length) { // search from the last
- this.curIndex = this.length - 1;
- this.curChild = lastChild;
- } else { // search from the first
- this.curIndex = 0;
- this.curChild = firstChild;
- }
- }
-
- if (index == this.curIndex)
- return this.curChild;
-
- if (index > this.curIndex) {
- while (index > this.curIndex) {
- this.curIndex++;
- this.curChild = this.curChild.getNextSibling();
- }
- } else { // index < this.curIndex
- while (index < this.curIndex) {
- this.curIndex--;
- this.curChild = this.curChild.getPreviousSibling();
- }
- }
-
- return this.curChild;
- }
- }
- }
-
- private NodeList childNodesCache = null;
-
- private boolean fChildEditable = true;
- NodeImpl firstChild = null;
- NodeImpl lastChild = null;
-
- Object lockObject = new byte[0];
-
- /**
- * NodeContainer constructor
- */
- protected NodeContainer() {
- super();
- }
-
- /**
- * NodeContainer constructor
- *
- * @param that
- * NodeContainer
- */
- protected NodeContainer(NodeContainer that) {
- super(that);
- }
-
- /**
- * appendChild method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- */
- public Node appendChild(Node newChild) throws DOMException {
- return insertBefore(newChild, null);
- }
-
- /**
- * cloneChildNodes method
- *
- * @param container
- * org.w3c.dom.Node
- * @param deep
- * boolean
- */
- protected void cloneChildNodes(Node newParent, boolean deep) {
- if (newParent == null || newParent == this)
- return;
- if (!(newParent instanceof NodeContainer))
- return;
-
- NodeContainer container = (NodeContainer) newParent;
- container.removeChildNodes();
-
- for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) {
- Node cloned = child.cloneNode(deep);
- if (cloned != null)
- container.appendChild(cloned);
- }
- }
-
- /**
- * getChildNodes method
- *
- * @return org.w3c.dom.NodeList
- */
- public NodeList getChildNodes() {
- return this;
- }
-
- /**
- * getFirstChild method
- *
- * @return org.w3c.dom.Node
- */
- public Node getFirstChild() {
- return this.firstChild;
- }
-
- /**
- * getLastChild method
- *
- * @return org.w3c.dom.Node
- */
- public Node getLastChild() {
- return this.lastChild;
- }
-
- /**
- * getLength method
- *
- * @return int
- */
- public int getLength() {
- if (this.firstChild == null)
- return 0;
- synchronized (lockObject) {
- if (this.childNodesCache == null)
- this.childNodesCache = new ChildNodesCache();
- return this.childNodesCache.getLength();
- }
- }
-
- /**
- */
- public String getSource() {
- StringBuffer buffer = new StringBuffer();
-
- IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- String source = startStructuredDocumentRegion.getText();
- if (source != null)
- buffer.append(source);
- }
-
- for (NodeImpl child = firstChild; child != null; child = (NodeImpl) child.getNextSibling()) {
- String source = child.getSource();
- if (source != null)
- buffer.append(source);
- }
-
- IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- String source = endStructuredDocumentRegion.getText();
- if (source != null)
- buffer.append(source);
- }
-
- return buffer.toString();
- }
-
- /**
- * hasChildNodes method
- *
- * @return boolean
- */
- public boolean hasChildNodes() {
- return (this.firstChild != null);
- }
-
- /**
- * insertBefore method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param refChild
- * org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- if (newChild == null)
- return null; // nothing to do
- if (refChild != null && refChild.getParentNode() != this) {
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- }
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- if (newChild == refChild)
- return newChild; // nothing to do
- //new child can not be a parent of this, would cause cycle
- if(isParent(newChild)) {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
-
- if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) {
- // insert child nodes instead
- for (Node child = newChild.getFirstChild(); child != null; child = newChild.getFirstChild()) {
- newChild.removeChild(child);
- insertBefore(child, refChild);
- }
- return newChild;
- }
- // synchronized in case another thread is getting item, or length
- synchronized (lockObject) {
- this.childNodesCache = null; // invalidate child nodes cache
- }
-
- NodeImpl child = (NodeImpl) newChild;
- NodeImpl next = (NodeImpl) refChild;
- NodeImpl prev = null;
- Node oldParent = child.getParentNode();
- if (oldParent != null)
- oldParent.removeChild(child);
- if (next == null) {
- prev = this.lastChild;
- this.lastChild = child;
- } else {
- prev = (NodeImpl) next.getPreviousSibling();
- next.setPreviousSibling(child);
- }
- if (prev == null)
- this.firstChild = child;
- else
- prev.setNextSibling(child);
- child.setPreviousSibling(prev);
- child.setNextSibling(next);
- child.setParentNode(this);
- // make sure having the same owner document
- if (child.getOwnerDocument() == null) {
- if (getNodeType() == DOCUMENT_NODE) {
- child.setOwnerDocument((Document) this);
- } else {
- child.setOwnerDocument(getOwnerDocument());
- }
- }
-
- notifyChildReplaced(child, null);
-
- return child;
- }
-
- public boolean isChildEditable() {
- if (!fChildEditable) {
- DOMModelImpl model = (DOMModelImpl) getModel();
- if (model != null && model.isReparsing()) {
- return true;
- }
- }
- return fChildEditable;
- }
-
- /**
- * isContainer method
- *
- * @return boolean
- */
- public boolean isContainer() {
- return true;
- }
-
- /**
- * item method
- *
- * @return org.w3c.dom.Node
- * @param index
- * int
- */
- public Node item(int index) {
- if (this.firstChild == null)
- return null;
- synchronized (lockObject) {
- if (this.childNodesCache == null)
- this.childNodesCache = new ChildNodesCache();
- return this.childNodesCache.item(index);
- }
- }
-
- /**
- * notifyChildReplaced method
- *
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- protected void notifyChildReplaced(Node newChild, Node oldChild) {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
-
- syncChildEditableState(newChild);
-
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.childReplaced(this, newChild, oldChild);
- }
-
- /**
- * removeChild method
- *
- * @return org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- public Node removeChild(Node oldChild) throws DOMException {
- if (oldChild == null)
- return null;
- if (oldChild.getParentNode() != this) {
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- }
-
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- // synchronized in case another thread is getting item, or length
- synchronized (lockObject) {
- this.childNodesCache = null; // invalidate child nodes cache
- }
-
- NodeImpl child = (NodeImpl) oldChild;
- NodeImpl prev = (NodeImpl) child.getPreviousSibling();
- NodeImpl next = (NodeImpl) child.getNextSibling();
-
- child.setEditable(true, true); // clear ReadOnly flags
-
- if (prev == null)
- this.firstChild = next;
- else
- prev.setNextSibling(next);
- if (next == null)
- this.lastChild = prev;
- else
- next.setPreviousSibling(prev);
- child.setPreviousSibling(null);
- child.setNextSibling(null);
- child.setParentNode(null);
-
- notifyChildReplaced(null, child);
-
- return child;
- }
-
- /**
- * removeChildNodes method
- */
- public void removeChildNodes() {
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- Node nextChild = null;
- for (Node child = getFirstChild(); child != null; child = nextChild) {
- nextChild = child.getNextSibling();
- removeChild(child);
- }
- }
-
- /**
- * removeChildNodes method
- *
- * @return org.w3c.dom.DocumentFragment
- * @param firstChild
- * org.w3c.dom.Node
- * @param lastChild
- * org.w3c.dom.Node
- */
- public DocumentFragment removeChildNodes(Node firstChild, Node lastChild) {
- if (!hasChildNodes())
- return null;
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- Document document = null;
- if (getNodeType() == DOCUMENT_NODE)
- document = (Document) this;
- else
- document = getOwnerDocument();
- if (document == null)
- return null;
- DocumentFragment fragment = document.createDocumentFragment();
- if (fragment == null)
- return null;
-
- if (firstChild == null)
- firstChild = getFirstChild();
- if (lastChild == null)
- lastChild = getLastChild();
- Node nextChild = null;
- for (Node child = firstChild; child != null; child = nextChild) {
- nextChild = child.getNextSibling();
- removeChild(child);
- fragment.appendChild(child);
- if (child == lastChild)
- break;
- }
-
- return fragment;
- }
-
- /**
- * replaceChild method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- if (oldChild == null || oldChild == newChild)
- return newChild;
- if (newChild != null)
- insertBefore(newChild, oldChild);
- return removeChild(oldChild);
- }
-
- public void setChildEditable(boolean editable) {
- if (fChildEditable == editable) {
- return;
- }
-
- ReadOnlyController roc = ReadOnlyController.getInstance();
- Node node;
- if (editable) {
- for (node = getFirstChild(); node != null; node = node.getNextSibling()) {
- roc.unlockNode((IDOMNode) node);
- }
- } else {
- for (node = getFirstChild(); node != null; node = node.getNextSibling()) {
- roc.lockNode((IDOMNode) node);
- }
- }
-
- fChildEditable = editable;
- notifyEditableChanged();
- }
-
- protected void syncChildEditableState(Node child) {
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (fChildEditable) {
- roc.unlockNode((NodeImpl) child);
- } else {
- roc.lockNode((NodeImpl) child);
- }
- }
-
- /**
- * <p>Checks to see if the given <code>Node</code> is a parent of <code>this</code> node</p>
- *
- * @param possibleParent the possible parent <code>Node</code> of <code>this</code> node
- * @return <code>true</code> if <code>possibleParent</code> is the parent of <code>this</code>,
- * <code>false</code> otherwise.
- */
- private boolean isParent(Node possibleParent) {
- Node parent = this.getParentNode();
- while(parent != null && parent != possibleParent) {
- parent = parent.getParentNode();
- }
-
- return parent == possibleParent;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java
deleted file mode 100644
index 44e5df5140..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java
+++ /dev/null
@@ -1,1171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- *
- * David Carver (STAR) - bug 295127 - implement isSameNode and compareDocumentPosition methods.
- * Unit Tests covered in wst.xsl XPath 2.0 tests.
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.w3c.dom.TypeInfo;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * NodeImpl class
- */
-public abstract class NodeImpl extends AbstractNotifier implements Node, IDOMNode {
- // define one empty nodelist, for repeated use
- private final static NodeList EMPTY_NODE_LIST = new NodeListImpl();
- // DocumentPosition
- //private final static short DOCUMENT_POSITION_DISCONNECTED = 0x01;
- private final static short DOCUMENT_POSITION_PRECEDING = 0x02;
- private final static short DOCUMENT_POSITION_FOLLOWING = 0x04;
- //private final static short DOCUMENT_POSITION_CONTAINS = 0x08;
- //private final static short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
- private final static short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
-
-
- private boolean fDataEditable = true;
- private IStructuredDocumentRegion flatNode = null;
- private NodeImpl nextSibling = null;
-
- private DocumentImpl ownerDocument = null;
- private NodeImpl parentNode = null;
- private NodeImpl previousSibling = null;
- // define one empty String constant for repeated use
- static final String EMPTY_STRING = "";
-
- /**
- * NodeImpl constructor
- */
- protected NodeImpl() {
- super();
- }
-
- /**
- * NodeImpl constructor
- *
- * @param that
- * NodeImpl
- */
- protected NodeImpl(NodeImpl that) {
- if (that != null) {
- this.ownerDocument = that.ownerDocument;
- }
- }
-
- /**
- * appendChild method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- */
- public Node appendChild(Node newChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
-
- /**
- * contains method
- *
- * @return boolean
- * @param offset
- * int
- */
- public boolean contains(int offset) {
- return (offset >= getStartOffset() && offset < getEndOffset());
- }
-
- /**
- * @param s
- * @param tagName
- * @return
- */
- protected String createDOMExceptionMessage(short s, String tagName) {
- String result = null;
- // TODO: Should localize these messages, and provide /u escaped
- // version of tagName
- result = lookupMessage(s) + " " + tagName; //$NON-NLS-1$
- return result;
- }
-
- /**
- * getAttributes method
- *
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getAttributes() {
- return null;
- }
-
- /**
- */
- protected String getCharValue(String name) {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return null;
- return document.getCharValue(name);
- }
-
- /**
- * getChildNodes method
- *
- * @return org.w3c.dom.NodeList
- */
- public NodeList getChildNodes() {
- // As per DOM spec, correct behavior for getChildNodes is to return a
- // zero length NodeList, not null, when there are no children.
- // We'll use a common instance of an empty node list, just to prevent
- // creating a trival object many many times.
-
- return EMPTY_NODE_LIST;
- }
-
- /**
- * getCommonAncestor method
- *
- * @return org.w3c.dom.Node
- * @param node
- * org.w3c.dom.Node
- */
- public Node getCommonAncestor(Node node) {
- if (node == null)
- return null;
-
- for (Node na = node; na != null; na = na.getParentNode()) {
- for (Node ta = this; ta != null; ta = ta.getParentNode()) {
- if (ta == na)
- return ta;
- }
- }
-
- return null; // not found
- }
-
- /**
- * getContainerDocument method
- *
- * @return org.w3c.dom.Document
- */
- public Document getContainerDocument() {
- Node parent = null;
- for (Node node = this; node != null; node = parent) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return (Document) node;
- }
- /* Break out of a bad hierarchy */
- if ((parent = node.getParentNode()) == node)
- break;
- }
- return null;
- }
-
- /**
- * getEndOffset method
- *
- * @return int
- */
- public int getEndOffset() {
- Node node = this;
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) node;
- IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null)
- return endStructuredDocumentRegion.getEnd();
- }
-
- Node last = node.getLastChild();
- if (last != null) { // dig into the last
- node = last;
- continue;
- }
-
- IStructuredDocumentRegion lastStructuredDocumentRegion = ((NodeImpl) node).getStructuredDocumentRegion();
- if (lastStructuredDocumentRegion != null)
- return lastStructuredDocumentRegion.getEnd();
-
- Node prev = node.getPreviousSibling();
- if (prev != null) { // move to the previous
- node = prev;
- continue;
- }
-
- Node parent = node.getParentNode();
- node = null;
- while (parent != null) {
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- IStructuredDocumentRegion startStructuredDocumentRegion = element.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null)
- return startStructuredDocumentRegion.getEnd();
- }
- Node parentPrev = parent.getPreviousSibling();
- if (parentPrev != null) { // move to the previous
- node = parentPrev;
- break;
- }
- parent = parent.getParentNode();
- }
- }
- return 0;
- }
-
- public IStructuredDocumentRegion getEndStructuredDocumentRegion() {
- return null;
- }
-
- /**
- */
- public FactoryRegistry getFactoryRegistry() {
- IDOMModel model = getModel();
- if (model != null) {
- FactoryRegistry reg = model.getFactoryRegistry();
- if (reg != null)
- return reg;
- }
- return null;
- }
-
- /**
- * getFirstChild method
- *
- * @return org.w3c.dom.Node
- */
- public Node getFirstChild() {
- return null;
- }
-
- /**
- * getFirstStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.flatNode);
- }
-
- /**
- */
- public int getIndex() {
- Node parent = getParentNode();
- if (parent == null)
- return -1; // error
- int index = 0;
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child == this)
- return index;
- index++;
- }
- return -1; // error
- }
-
- /**
- * getLastChild method
- *
- * @return org.w3c.dom.Node
- */
- public Node getLastChild() {
- return null;
- }
-
- /**
- * getLastStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.flatNode);
- }
-
- /**
- */
- public String getLocalName() {
- return null;
- }
-
- /**
- * the default implementation can just refer to the owning document
- */
- public IDOMModel getModel() {
- if (this.ownerDocument == null)
- return null;
- return this.ownerDocument.getModel();
- }
-
- /**
- * all but attr return null
- */
- public ITextRegion getNameRegion() {
- return null;
- }
-
- /**
- */
- public String getNamespaceURI() {
- return null;
- }
-
- /**
- * getNextSibling method
- *
- * @return org.w3c.dom.Node
- */
- public Node getNextSibling() {
- return this.nextSibling;
- }
-
- /**
- * getNodeAt method
- *
- * @return org.w3c.dom.Node
- * @param offset
- * int
- */
- Node getNodeAt(int offset) {
- IDOMNode parent = this;
- IDOMNode child = (IDOMNode) getFirstChild();
- while (child != null) {
- if (child.getEndOffset() <= offset) {
- child = (IDOMNode) child.getNextSibling();
- continue;
- }
- if (child.getStartOffset() > offset) {
- break;
- }
-
- IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- if (startStructuredDocumentRegion.getEnd() > offset)
- return child;
- }
-
- // dig more
- parent = child;
- child = (IDOMNode) parent.getFirstChild();
- }
-
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNodeValue()
- */
- public String getNodeValue() throws DOMException {
- return null;
- }
-
- /**
- * getOwnerDocument method
- *
- * @return org.w3c.dom.Document
- */
- public Document getOwnerDocument() {
- return this.ownerDocument;
- }
-
- /**
- * getParentNode method
- *
- * @return org.w3c.dom.Node
- */
- public Node getParentNode() {
- return this.parentNode;
- }
-
- /**
- */
- public String getPrefix() {
- return null;
- }
-
- /**
- * getPreviousSibling method
- *
- * @return org.w3c.dom.Node
- */
- public Node getPreviousSibling() {
- return this.previousSibling;
- }
-
- /**
- */
- public String getSource() {
- if (this.flatNode == null)
- return NodeImpl.EMPTY_STRING;
- return this.flatNode.getText();
- }
-
- /**
- * getStartOffset method
- *
- * @return int
- */
- public int getStartOffset() {
- if (this.flatNode != null)
- return this.flatNode.getStart();
- NodeImpl prev = (NodeImpl) getPreviousSibling();
- if (prev != null)
- return prev.getEndOffset();
- Node parent = getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- if (element.hasStartTag())
- return element.getStartEndOffset();
- return element.getStartOffset();
- }
- // final fallback to look into first child
- NodeImpl child = (NodeImpl) getFirstChild();
- while (child != null) {
- IStructuredDocumentRegion childStructuredDocumentRegion = child.getStructuredDocumentRegion();
- if (childStructuredDocumentRegion != null)
- return childStructuredDocumentRegion.getStart();
- child = (NodeImpl) child.getFirstChild();
- }
- return 0;
- }
-
- public IStructuredDocumentRegion getStartStructuredDocumentRegion() {
- return getFirstStructuredDocumentRegion();
- }
-
- /**
- * Every node (indirectly) knows its structuredDocument
- */
- public IStructuredDocument getStructuredDocument() {
- return getModel().getStructuredDocument();
- }
-
- /**
- */
- IStructuredDocumentRegion getStructuredDocumentRegion() {
- return this.flatNode;
- }
-
- /**
- * all but attr return null
- */
- public ITextRegion getValueRegion() {
- return null;
- }
-
- /**
- */
- public String getValueSource() {
- return getNodeValue();
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#hasAttributes()
- */
- public boolean hasAttributes() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#hasChildNodes()
- */
- public boolean hasChildNodes() {
- return false;
- }
-
- /**
- * hasProperties method
- *
- * @return boolean
- */
- public boolean hasProperties() {
- return false;
- }
-
- /**
- * insertBefore method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param refChild
- * org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
-
- public boolean isChildEditable() {
- return false;
- }
-
- /**
- */
- public boolean isClosed() {
- return true;
- }
-
- /**
- * isContainer method
- *
- * @return boolean
- */
- public boolean isContainer() {
- return false;
- }
-
- public boolean isDataEditable() {
- if (!fDataEditable) {
- DOMModelImpl model = (DOMModelImpl) getModel();
- if (model != null && model.isReparsing()) {
- return true;
- }
- }
- return fDataEditable;
- }
-
- /**
- */
- public boolean isSupported(String feature, String version) {
- if (this.ownerDocument == null)
- return false;
- DOMImplementation impl = this.ownerDocument.getImplementation();
- if (impl == null)
- return false;
- return impl.hasFeature(feature, version);
- }
-
- /**
- * @param s
- * @return
- */
- private String lookupMessage(short s) {
- // TODO: make localized version
- String result = null;
- switch (s) {
- case DOMException.DOMSTRING_SIZE_ERR :
- result = DOMMessages.DOMSTRING_SIZE_ERR;
- break;
- case DOMException.HIERARCHY_REQUEST_ERR :
- result = DOMMessages.HIERARCHY_REQUEST_ERR;
- break;
- case DOMException.INDEX_SIZE_ERR :
- result = DOMMessages.INDEX_SIZE_ERR;
- break;
- case DOMException.INUSE_ATTRIBUTE_ERR :
- result = DOMMessages.INUSE_ATTRIBUTE_ERR;
- break;
- case DOMException.INVALID_ACCESS_ERR :
- result = DOMMessages.INVALID_ACCESS_ERR;
- break;
- case DOMException.INVALID_CHARACTER_ERR :
- result = DOMMessages.INVALID_CHARACTER_ERR;
- break;
- case DOMException.INVALID_MODIFICATION_ERR :
- result = DOMMessages.INVALID_MODIFICATION_ERR;
- break;
- case DOMException.INVALID_STATE_ERR :
- result = DOMMessages.INVALID_STATE_ERR;
- break;
- case DOMException.NAMESPACE_ERR :
- result = DOMMessages.NAMESPACE_ERR;
- break;
- case DOMException.NO_DATA_ALLOWED_ERR :
- result = DOMMessages.NO_DATA_ALLOWED_ERR;
- break;
- case DOMException.NO_MODIFICATION_ALLOWED_ERR :
- result = DOMMessages.NO_MODIFICATION_ALLOWED_ERR;
- break;
- case DOMException.NOT_FOUND_ERR :
- result = DOMMessages.NOT_FOUND_ERR;
- break;
- case DOMException.NOT_SUPPORTED_ERR :
- result = DOMMessages.NOT_SUPPORTED_ERR;
- break;
- case DOMException.SYNTAX_ERR :
- result = DOMMessages.SYNTAX_ERR;
- break;
- case 17:// DOMException.TYPE_MISMATCH_ERR :
- result = DOMMessages.TYPE_MISMATCH_ERR;
- break;
- case 16:// DOMException.VALIDATION_ERR :
- result = DOMMessages.VALIDATION_ERR;
- break;
- case DOMException.WRONG_DOCUMENT_ERR :
- result = DOMMessages.WRONG_DOCUMENT_ERR;
- break;
- default :
- result = NodeImpl.EMPTY_STRING;
- break;
- }
- return result;
- }
-
- /**
- * normalize method
- */
- public void normalize() {
- TextImpl prevText = null;
- for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) {
- switch (child.getNodeType()) {
- case TEXT_NODE : {
- if (prevText == null) {
- prevText = (TextImpl) child;
- break;
- }
- Text text = (Text) child;
- removeChild(text);
- prevText.appendText(text);
- child = prevText;
- break;
- }
- case ELEMENT_NODE : {
- Element element = (Element) child;
- element.normalize();
- prevText = null;
- break;
- }
- default :
- prevText = null;
- break;
- }
- }
- }
-
- protected void notifyEditableChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.editableChanged(this);
- }
-
- /**
- * notifyValueChanged method
- */
- protected void notifyValueChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
-
- syncDataEditableState();
-
- DOMModelImpl model = (DOMModelImpl) document.getModel();
- if (model == null)
- return;
- model.valueChanged(this);
- }
-
- /**
- * removeChild method
- *
- * @return org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- public Node removeChild(Node oldChild) throws DOMException {
- throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessages.NOT_FOUND_ERR);
- }
-
- /**
- * removeChildNodes method
- */
- public void removeChildNodes() {
- }
-
- /**
- * removeChildNodes method
- *
- * @return org.w3c.dom.DocumentFragment
- * @param firstChild
- * org.w3c.dom.Node
- * @param lastChild
- * org.w3c.dom.Node
- */
- public DocumentFragment removeChildNodes(Node firstChild, Node lastChild) {
- return null;
- }
-
- /**
- * replaceChild method
- *
- * @return org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, DOMMessages.HIERARCHY_REQUEST_ERR);
- }
-
- /**
- * Resets children values from IStructuredDocumentRegion.
- */
- void resetStructuredDocumentRegions() {
- for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) {
- child.resetStructuredDocumentRegions();
- }
- this.flatNode = null;
- }
-
- public void setChildEditable(boolean editable) {
- // nop
- }
-
- public void setDataEditable(boolean editable) {
- if (fDataEditable == editable) {
- return;
- }
-
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (editable) {
- roc.unlockData(this);
- }
- else {
- roc.lockData(this);
- }
-
- fDataEditable = editable;
-
- notifyEditableChanged();
- }
-
- public void setEditable(boolean editable, boolean deep) {
- if (deep) {
- IDOMNode node = (IDOMNode) getFirstChild();
- while (node != null) {
- node.setEditable(editable, deep);
- node = (IDOMNode) node.getNextSibling();
- }
- }
- setChildEditable(editable);
- setDataEditable(editable);
- }
-
- /**
- * setNextSibling method
- *
- * @param nextSibling
- * org.w3c.dom.Node
- */
- protected void setNextSibling(Node nextSibling) {
- this.nextSibling = (NodeImpl) nextSibling;
- }
-
- /**
- * setNodeValue method
- *
- * @param nodeValue
- * java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- }
-
- /**
- * setOwnerDocument method
- *
- * @param ownerDocument
- * org.w3c.dom.Document
- */
- protected void setOwnerDocument(Document ownerDocument) {
- this.ownerDocument = (DocumentImpl) ownerDocument;
- }
-
- /**
- */
- protected void setOwnerDocument(Document ownerDocument, boolean deep) {
- this.ownerDocument = (DocumentImpl) ownerDocument;
-
- if (deep) {
- for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) {
- child.setOwnerDocument(ownerDocument, deep);
- }
- }
- }
-
- /**
- * setParentNode method
- *
- * @param parentNode
- * org.w3c.dom.Node
- */
- protected void setParentNode(Node parentNode) {
- this.parentNode = (NodeImpl) parentNode;
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- }
-
- /**
- * setPreviousSibling method
- *
- * @param previousSibling
- * org.w3c.dom.Node
- */
- protected void setPreviousSibling(Node previousSibling) {
- this.previousSibling = (NodeImpl) previousSibling;
- }
-
- /**
- */
- public void setSource(String source) throws InvalidCharacterException {
- // not supported
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- this.flatNode = flatNode;
- }
-
- /**
- */
- public void setValueSource(String source) {
- setNodeValue(source);
- }
-
- protected void syncDataEditableState() {
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (fDataEditable) {
- roc.unlockData(this);
- }
- else {
- roc.lockData(this);
- }
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- return getNodeName();
- }
-
- public int getLength() {
- int result = -1;
- int start = getStartOffset();
- if (start >= 0) {
- int end = getEndOffset();
- if (end >= 0) {
- result = end - start;
- if (result < -1) {
- result = -1;
- }
- }
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
- */
- public short compareDocumentPosition(Node other) throws DOMException {
- if (!(other instanceof IDOMNode))
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, DOMMessages.NOT_SUPPORTED_ERR);
-
- int nodeStart = this.getStartOffset();
- int otherStart = ((IDOMNode) other).getStartOffset();
-
- if (otherStart > nodeStart) {
- return DOCUMENT_POSITION_FOLLOWING;
- }
- else if (otherStart < nodeStart) {
- return DOCUMENT_POSITION_PRECEDING;
- }
- return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String getBaseURI() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public Object getFeature(String feature, String version) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.dom.Node#getTextContent()
- */
- public String getTextContent() throws DOMException {
- switch (getNodeType()) {
- case Node.DOCUMENT_NODE :
- case Node.DOCUMENT_TYPE_NODE :
- case Node.NOTATION_NODE :
- return null;
- case Node.TEXT_NODE :
- case Node.CDATA_SECTION_NODE :
- case Node.COMMENT_NODE :
- case Node.PROCESSING_INSTRUCTION_NODE :
- return getNodeValue();
- }
-
- if (hasChildNodes()) {
- final StringBuffer builder = new StringBuffer();
-
- Node child = getFirstChild();
- while (child != null) {
- short nodeType = child.getNodeType();
- if (nodeType == Node.COMMENT_NODE || nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
- child = child.getNextSibling();
- continue;
- }
-
- String text = ((IDOMNode) child).getTextContent();
- if (text != null) {
- builder.append(text);
- }
- child = child.getNextSibling();
- }
-
- return builder.toString();
- }
-
- return EMPTY_STRING;
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isDefaultNamespace(String namespaceURI) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
- */
- public boolean isEqualNode(Node arg) {
- return this.equals(arg);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
- */
- public boolean isSameNode(Node other) {
- return this == other;
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String lookupNamespaceURI(String prefix) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String lookupPrefix(String namespaceURI) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public void setTextContent(String textContent) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public TypeInfo getSchemaTypeInfo() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isId() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented in this version."); //$NON-NLS-1$
- }
-
- /**
- * Retrieves the object for a node associated to a key.
- *
- * @param key The key associated with the object.
- * @return object The object for this node, associated with the key passed
- * or null if there was none set.
- *
- * @since DOM Level 3
- */
- public Object getUserData(String key) {
-
- if (key==null) return null;
- Map userDataTable = UserData.getInstance().getUserDataTable(this);
- if (userDataTable!=null) {
- UserDataAndHandler userDataAndHandler = (UserDataAndHandler) userDataTable.get(key);
- if (userDataAndHandler!=null) {
- return userDataAndHandler.getData();
- }
- }
- return null;
- }
-
- /**
- * Sets the user data and handler for a key
- *
- * @param key The key associated with the object.
- * @param object The object for this node, associated with the key passed.
- * Null passed removes the existing association to the key.
- * @param handler UserDataHandler for the userdata associated with this key
- * @return Object The previous userdata object if set, null if it was none.
- *
- * @since DOM Level 3
- */
- public Object setUserData(String key, Object data, UserDataHandler handler) {
-
- UserDataAndHandler previousDataAndHandler=null;
-
- //return immediately for null keys
- if (key ==null) return null;
- Map userDataTable = UserData.getInstance().getUserDataTable(this);
- //remove association for the key if data is null
- if (data==null) {
- if (userDataTable==null) return null;
-
- //see if there is a previous value set
- previousDataAndHandler = (UserDataAndHandler) userDataTable.get(key);
- if (previousDataAndHandler!=null) {
- userDataTable.remove(key);
- return previousDataAndHandler.getData();
- }
- //there is no previous value found
- return null;
- }
-
- //if data passed is not null
- //the first data in the hashtable
- if (userDataTable==null) {
- userDataTable=new Hashtable();
- UserDataAndHandler userDataAndHandler=new UserDataAndHandler(data,handler);
- userDataTable.put(key,userDataAndHandler);
- return null;
- //there is already data in the hashtable
- } else {
- UserDataAndHandler userDataAndHandler=new UserDataAndHandler(data,handler);
- previousDataAndHandler=(UserDataAndHandler) userDataTable.put(key,userDataAndHandler);
-
- //if we replace a value
- if (previousDataAndHandler!=null)
- return previousDataAndHandler.getData();
- else {
- return null;
- }
- }
- }
-
- /**
- * Notifies the UserDataHandlers of the node.
- *
- * @param operation
- * @param destination
- */
- protected void notifyUserDataHandlers(short operation, Node destination) {
-
- if (operation!=UserDataHandler.NODE_ADOPTED
- & operation!=UserDataHandler.NODE_CLONED
- & operation!=UserDataHandler.NODE_DELETED
- & operation!=UserDataHandler.NODE_IMPORTED
- & operation!=UserDataHandler.NODE_RENAMED)
- return;
- Map userDataTable = UserData.getInstance().getUserDataTable(this);
- if (userDataTable!=null) {
- Iterator entries =userDataTable.entrySet().iterator();
- while (entries.hasNext()) {
- Map.Entry entry = (Map.Entry) entries.next();
- String key = entry.getKey().toString(); //should always be a string
- UserDataAndHandler dataAndHandler = (UserDataAndHandler) entry.getValue();
- if (dataAndHandler!=null) {
- UserDataHandler dataHandler=dataAndHandler.getHandler();
- if (dataHandler!=null) {
- dataHandler.handle(operation, key, dataAndHandler.getData(), this, destination);
- }
- }
- }
- }
- }
-
- /**
- *
- * Class for user data and UserDataHandler
- */
- protected static class UserDataAndHandler implements Serializable {
-
- /**
- * Generated Serial ID
- */
- private static final long serialVersionUID = 4860521237315444841L;
- /**
- * Generated serialization version
- */
-
- private Object data;
- private UserDataHandler handler;
-
- public UserDataAndHandler(Object data, UserDataHandler handler)
- {
- this.data=data;
- this.handler=handler;
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public UserDataHandler getHandler() {
- return handler;
- }
-
- public void setHandler(UserDataHandler handler) {
- this.handler = handler;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java
deleted file mode 100644
index c4a278b694..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-/**
- * NodeIteratorImpl class
- */
-public class NodeIteratorImpl implements NodeIterator {
- private NodeFilter filter = null;
- private Node nextNode = null;
-
- private Node rootNode = null;
- private int whatToShow = NodeFilter.SHOW_ALL;
-
- /**
- * NodeIteratorImpl constructor
- *
- * @param rootNode
- * org.w3c.dom.Node
- */
- NodeIteratorImpl(Node rootNode, int whatToShow, NodeFilter filter) {
- this.rootNode = rootNode;
- this.nextNode = rootNode;
- this.whatToShow = whatToShow;
- this.filter = filter;
- }
-
- /**
- */
- private final boolean acceptNode(Node node) {
- if (this.whatToShow != NodeFilter.SHOW_ALL) {
- if (node == null)
- return false;
- short nodeType = node.getNodeType();
- switch (this.whatToShow) {
- case NodeFilter.SHOW_ELEMENT :
- if (nodeType != Node.ELEMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ATTRIBUTE :
- if (nodeType != Node.ATTRIBUTE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_TEXT :
- if (nodeType != Node.TEXT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_CDATA_SECTION :
- if (nodeType != Node.CDATA_SECTION_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ENTITY_REFERENCE :
- if (nodeType != Node.ENTITY_REFERENCE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ENTITY :
- if (nodeType != Node.ENTITY_NODE)
- return false;
- break;
- case NodeFilter.SHOW_PROCESSING_INSTRUCTION :
- if (nodeType != Node.PROCESSING_INSTRUCTION_NODE)
- return false;
- break;
- case NodeFilter.SHOW_COMMENT :
- if (nodeType != Node.COMMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT :
- if (nodeType != Node.DOCUMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT_TYPE :
- if (nodeType != Node.DOCUMENT_TYPE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT_FRAGMENT :
- if (nodeType != Node.DOCUMENT_FRAGMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_NOTATION :
- if (nodeType != Node.NOTATION_NODE)
- return false;
- break;
- default :
- return false;
- }
- }
- if (this.filter != null) {
- return (this.filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT);
- }
- return true;
- }
-
- /**
- * Detaches the <code>NodeIterator</code> from the set which it iterated
- * over, releasing any computational resources and placing the iterator in
- * the INVALID state. After <code>detach</code> has been invoked, calls
- * to <code>nextNode</code> or <code>previousNode</code> will raise
- * the exception INVALID_STATE_ERR.
- */
- public void detach() {
- this.rootNode = null;
- this.nextNode = null;
- this.filter = null;
- }
-
- /**
- * The value of this flag determines whether the children of entity
- * reference nodes are visible to the iterator. If false, they and their
- * descendants will be rejected. Note that this rejection takes precedence
- * over <code>whatToShow</code> and the filter. Also note that this is
- * currently the only situation where <code>NodeIterators</code> may
- * reject a complete subtree rather than skipping individual nodes. <br>
- * <br>
- * To produce a view of the document that has entity references expanded
- * and does not expose the entity reference node itself, use the
- * <code>whatToShow</code> flags to hide the entity reference node and
- * set <code>expandEntityReferences</code> to true when creating the
- * iterator. To produce a view of the document that has entity reference
- * nodes but no entity expansion, use the <code>whatToShow</code> flags
- * to show the entity reference node and set
- * <code>expandEntityReferences</code> to false.
- */
- public boolean getExpandEntityReferences() {
- // not supported
- return false;
- }
-
- /**
- * The <code>NodeFilter</code> used to screen nodes.
- */
- public NodeFilter getFilter() {
- return this.filter;
- }
-
- /**
- */
- private final Node getNextNode() {
- if (this.nextNode == null)
- return null;
- Node oldNext = this.nextNode;
- Node child = this.nextNode.getFirstChild();
- if (child != null) {
- this.nextNode = child;
- return oldNext;
- }
- for (Node node = this.nextNode; node != null && node != this.rootNode; node = node.getParentNode()) {
- Node next = node.getNextSibling();
- if (next != null) {
- this.nextNode = next;
- return oldNext;
- }
- }
- this.nextNode = null;
- return oldNext;
- }
-
- /**
- */
- private final Node getPreviousNode() {
- if (this.nextNode == this.rootNode)
- return null;
- Node prev = null;
- if (this.nextNode == null) {
- prev = this.rootNode; // never null
- } else {
- prev = this.nextNode.getPreviousSibling();
- if (prev == null) {
- this.nextNode = this.nextNode.getParentNode();
- return this.nextNode;
- }
- }
- Node last = prev.getLastChild();
- while (last != null) {
- prev = last;
- last = prev.getLastChild();
- }
- this.nextNode = prev;
- return this.nextNode;
- }
-
- /**
- * The root node of the <code>NodeIterator</code>, as specified when it
- * was created.
- */
- public Node getRoot() {
- return this.rootNode;
- }
-
- /**
- * This attribute determines which node types are presented via the
- * iterator. The available set of constants is defined in the
- * <code>NodeFilter</code> interface. Nodes not accepted by
- * <code>whatToShow</code> will be skipped, but their children may still
- * be considered. Note that this skip takes precedence over the filter, if
- * any.
- */
- public int getWhatToShow() {
- return this.whatToShow;
- }
-
- /**
- * Returns the next node in the set and advances the position of the
- * iterator in the set. After a <code>NodeIterator</code> is created,
- * the first call to <code>nextNode()</code> returns the first node in
- * the set.
- *
- * @return The next <code>Node</code> in the set being iterated over, or
- * <code>null</code> if there are no more members in that set.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if this method is called after
- * the <code>detach</code> method was invoked.
- */
- public Node nextNode() throws DOMException {
- for (Node node = getNextNode(); node != null; node = getNextNode()) {
- if (acceptNode(node))
- return node;
- }
- return null;
- }
-
- /**
- * Returns the previous node in the set and moves the position of the
- * <code>NodeIterator</code> backwards in the set.
- *
- * @return The previous <code>Node</code> in the set being iterated
- * over, or <code>null</code> if there are no more members in
- * that set.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if this method is called after
- * the <code>detach</code> method was invoked.
- */
- public Node previousNode() throws DOMException {
- for (Node node = getPreviousNode(); node != null; node = getPreviousNode()) {
- if (acceptNode(node))
- return node;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java
deleted file mode 100644
index a620f329ec..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.document;
-
-
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * An array-backed NodeList, used to keep the array size down
- */
-public class NodeListImpl implements NodeList {
-
- private Object fLockObject = new byte[0];
- private final static int growthConstant = 2;
- private Node[] fNodes = null;
- private int fNodeCount = 0;
-
- /**
- * NodeListImpl constructor
- */
- public NodeListImpl() {
- super();
- }
-
- protected NodeListImpl(NodeListImpl list) {
- super();
- fNodeCount = list.fNodeCount;
- fNodes = list.fNodes;
- }
-
- /**
- * appendNode method
- *
- * @return org.w3c.dom.Node
- * @param node
- * org.w3c.dom.Node
- */
- protected Node appendNode(Node node) {
- if (node == null)
- return null;
- synchronized (fLockObject) {
- ensureCapacity(fNodeCount + 1);
- fNodes[fNodeCount++] = node;
- }
- return node;
- }
-
- /**
- * Grow the node array to at least the given size while keeping the
- * contents the same
- *
- * @param needed
- */
- private void ensureCapacity(int needed) {
- if (fNodes == null) {
- // first time
- fNodes = new Node[needed];
- return;
- }
- int oldLength = fNodes.length;
- if (oldLength < needed) {
- Node[] oldNodes = fNodes;
- Node[] newNodes = new Node[needed + growthConstant];
- System.arraycopy(oldNodes, 0, newNodes, 0, fNodeCount);
- fNodes = newNodes;
- }
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NodeList#getLength()
- */
- public int getLength() {
- return fNodeCount;
- }
-
- protected final Node[] getNodes() {
- return fNodes;
- }
-
- /**
- */
- protected Node insertNode(Node node, int index) {
- if (node == null)
- return null;
- synchronized (fLockObject) {
- if (fNodes == null) {
- // first time, ignore index
- fNodes = new Node[1];
- fNodes[fNodeCount++] = node;
- return node;
- }
-
- // gracefully handle out of bounds
- if (index < 0 || index > fNodeCount + 1)
- return appendNode(node);
-
- /*
- * Grow a new Node array, copying the old contents around the new
- * Node
- */
- Node[] newNodes = new Node[fNodeCount + growthConstant];
- System.arraycopy(fNodes, 0, newNodes, 0, index);
- newNodes[index] = node;
- System.arraycopy(fNodes, index, newNodes, index + 1, fNodeCount - index);
- fNodes = newNodes;
- fNodeCount++;
- }
- return node;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NodeList#item(int)
- */
- public Node item(int index) {
- if (index < 0 || index >= fNodeCount)
- return null; // invalid parameter
- return fNodes[index];
- }
-
- /**
- * removeNode method
- *
- * @return org.w3c.dom.Node
- * @param index
- * int
- */
- protected Node removeNode(int index) {
- if (this.fNodes == null)
- return null; // no node
-
- synchronized (fLockObject) {
- if (index < 0 || index >= fNodeCount)
- return null; // invalid parameter
-
- Node removed = fNodes[index];
- Node[] newNodes = new Node[fNodeCount - 1];
- // copy around node being removed
- System.arraycopy(fNodes, 0, newNodes, 0, index);
- System.arraycopy(fNodes, index + 1, newNodes, index, fNodeCount - index - 1);
- fNodes = newNodes;
- fNodeCount--;
- return removed;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java
deleted file mode 100644
index 186eea2e7e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.Notation;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * NotationImpl class
- */
-public class NotationImpl extends NodeImpl implements Notation {
-
- private String name = null;
- private String publicId = null;
- private String systemId = null;
-
- /**
- * NotationImpl constructor
- */
- protected NotationImpl() {
- super();
- }
-
- /**
- * NotationImpl constructor
- *
- * @param that
- * NotationImpl
- */
- protected NotationImpl(NotationImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- this.publicId = that.publicId;
- this.systemId = that.systemId;
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- NotationImpl cloned = new NotationImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return NodeImpl.EMPTY_STRING;
- return this.name;
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return NOTATION_NODE;
- }
-
- /**
- * getPublicId method
- *
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- *
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- * setName method
- *
- * @param name
- * java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setPublicId method
- *
- * @param publicId
- * java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- this.publicId = publicId;
- }
-
- /**
- * setSystemId method
- *
- * @param systemId
- * java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- this.systemId = systemId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java
deleted file mode 100644
index 044eb53b3b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.UserDataHandler;
-
-
-/**
- * ProcessingInstructionImpl class
- */
-public class ProcessingInstructionImpl extends NodeImpl implements ProcessingInstruction {
- private String data = null;
-
- private String target = null;
-
- /**
- * ProcessingInstructionImpl constructor
- */
- protected ProcessingInstructionImpl() {
- super();
- }
-
- /**
- * ProcessingInstructionImpl constructor
- *
- * @param that
- * ProcessingInstructionImpl
- */
- protected ProcessingInstructionImpl(ProcessingInstructionImpl that) {
- super(that);
-
- if (that != null) {
- this.target = that.target;
- this.data = that.getData();
- }
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- ProcessingInstructionImpl cloned = new ProcessingInstructionImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public String getData() {
- if (this.data != null)
- return this.data;
-
- IStructuredDocumentRegion flatNode = getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return NodeImpl.EMPTY_STRING;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return NodeImpl.EMPTY_STRING;
-
- ITextRegion targetRegion = null;
- ITextRegion dataRegion = null;
- ITextRegion closeRegion = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_PI_OPEN)
- continue;
- if (regionType == DOMRegionContext.XML_PI_CLOSE) {
- closeRegion = region;
- }
- else {
- if (targetRegion == null)
- targetRegion = region;
- else if (dataRegion == null)
- dataRegion = region;
- }
- }
- if (dataRegion == null)
- return NodeImpl.EMPTY_STRING;
- int offset = dataRegion.getStart();
- int end = flatNode.getLength();
- if (closeRegion != null)
- end = closeRegion.getStart();
- String source = flatNode.getText();
- return source.substring(offset, end);
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return getTarget();
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return PROCESSING_INSTRUCTION_NODE;
- }
-
- /**
- * getNodeValue method
- *
- * @return java.lang.String
- */
- public String getNodeValue() {
- return getData();
- }
-
- /**
- * getTarget method
- *
- * @return java.lang.String
- */
- public String getTarget() {
- if (this.target == null)
- return NodeImpl.EMPTY_STRING;
- return this.target;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == DOMRegionContext.XML_PI_CLOSE);
- }
-
- /**
- */
- void resetStructuredDocumentRegions() {
- this.data = getData();
- setStructuredDocumentRegion(null);
- }
-
- /**
- * setData method
- *
- * @param data
- * java.lang.String
- */
- public void setData(String data) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.data = data;
-
- notifyValueChanged();
- }
-
- /**
- * setNodeValue method
- *
- * @param nodeValue
- * java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- setData(nodeValue);
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- super.setStructuredDocumentRegion(flatNode);
- if (flatNode != null)
- this.data = null;
- }
-
- /**
- * setTarget method
- *
- * @param target
- * java.lang.String
- */
- protected void setTarget(String target) {
- this.target = target;
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getTarget());
- buffer.append('(');
- buffer.append(getData());
- buffer.append(')');
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/RangeImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/RangeImpl.java
deleted file mode 100644
index ad30e282ec..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/RangeImpl.java
+++ /dev/null
@@ -1,630 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.document;
-
-
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.w3c.dom.ranges.Range;
-import org.w3c.dom.ranges.RangeException;
-
-
-/**
- */
-public class RangeImpl implements Range {
- private Node endContainer = null;
- private int endOffset = 0;
-
- private Node startContainer = null;
- private int startOffset = 0;
-
- /**
- */
- protected RangeImpl() {
- super();
- }
-
- /**
- */
- protected RangeImpl(RangeImpl that) {
- super();
-
- if (that != null) {
- this.startContainer = that.startContainer;
- this.startOffset = that.startOffset;
- this.endContainer = that.endContainer;
- this.endOffset = that.endOffset;
- }
- }
-
- /**
- * Duplicates the contents of a Range
- *
- * @return A DocumentFragment that contains content equivalent to this
- * Range.
- * @exception DOMException
- * HIERARCHY_REQUEST_ERR: Raised if a DocumentType node
- * would be extracted into the new DocumentFragment. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public DocumentFragment cloneContents() throws DOMException {
- // not supported
- return null;
- }
-
- /**
- * Produces a new Range whose boundary-points are equal to the
- * boundary-points of the Range.
- *
- * @return The duplicated Range.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public Range cloneRange() throws DOMException {
- return new RangeImpl(this);
- }
-
- /**
- * Collapse a Range onto one of its boundary-points
- *
- * @param toStartIf
- * TRUE, collapses the Range onto its start; if FALSE,
- * collapses it onto its end.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void collapse(boolean toStart) throws DOMException {
- if (toStart) {
- this.endContainer = this.startContainer;
- this.endOffset = this.startOffset;
- } else {
- this.startContainer = this.endContainer;
- this.startOffset = this.endOffset;
- }
- }
-
- /**
- * Compare the boundary-points of two Ranges in a document.
- *
- * @param howA
- * code representing the type of comparison, as defined above.
- * @param sourceRangeThe
- * <code>Range</code> on which this current
- * <code>Range</code> is compared to.
- * @return -1, 0 or 1 depending on whether the corresponding
- * boundary-point of the Range is respectively before, equal to,
- * or after the corresponding boundary-point of
- * <code>sourceRange</code>.
- * @exception DOMException
- * WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in
- * the same Document or DocumentFragment. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public short compareBoundaryPoints(short how, Range sourceRange) throws DOMException {
- if (sourceRange == null)
- return (short) 0; // error
-
- Node container1 = null;
- int offset1 = 0;
- Node container2 = null;
- int offset2 = 0;
-
- switch (how) {
- case START_TO_START :
- container1 = this.startContainer;
- offset1 = this.startOffset;
- container2 = sourceRange.getStartContainer();
- offset2 = sourceRange.getStartOffset();
- break;
- case START_TO_END :
- container1 = this.startContainer;
- offset1 = this.startOffset;
- container2 = sourceRange.getEndContainer();
- offset2 = sourceRange.getEndOffset();
- break;
- case END_TO_END :
- container1 = this.endContainer;
- offset1 = this.endOffset;
- container2 = sourceRange.getEndContainer();
- offset2 = sourceRange.getEndOffset();
- break;
- case END_TO_START :
- container1 = this.endContainer;
- offset1 = this.endOffset;
- container2 = sourceRange.getStartContainer();
- offset2 = sourceRange.getStartOffset();
- break;
- default :
- return (short) 0; // error
- }
-
- return comparePoints(container1, offset1, container2, offset2);
- }
-
- /*
- */
- protected short comparePoints(Node container1, int offset1, Node container2, int offset2) {
- if (container1 == null || container2 == null)
- return (short) 0; // error
-
- if (container1 == container2) {
- if (offset1 > offset2)
- return (short) 1;
- if (offset1 < offset2)
- return (short) -1;
- return 0;
- }
-
- // get node offsets
- IDOMNode node1 = null;
- if (container1.hasChildNodes()) {
- Node child = container1.getFirstChild();
- for (int i = 0; i < offset1; i++) {
- Node next = child.getNextSibling();
- if (next == null)
- break;
- child = next;
- }
- node1 = (IDOMNode) child;
- offset1 = 0;
- } else {
- node1 = (IDOMNode) container1;
- }
- int nodeOffset1 = node1.getStartOffset();
- IDOMNode node2 = null;
- if (container2.hasChildNodes()) {
- Node child = container2.getFirstChild();
- for (int i = 0; i < offset2; i++) {
- Node next = child.getNextSibling();
- if (next == null)
- break;
- child = next;
- }
- node2 = (IDOMNode) child;
- offset2 = 0;
- } else {
- node2 = (IDOMNode) container2;
- }
- int nodeOffset2 = node2.getStartOffset();
-
- if (nodeOffset1 > nodeOffset2)
- return (short) 1;
- if (nodeOffset1 < nodeOffset2)
- return (short) -1;
- if (offset1 > offset2)
- return (short) 1;
- if (offset1 < offset2)
- return (short) -1;
- return (short) 0;
- }
-
- /**
- * Removes the contents of a Range from the containing document or
- * document fragment without returning a reference to the removed content.
- *
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of
- * the content of the Range is read-only or any of the
- * nodes that contain any of the content of the Range are
- * read-only. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void deleteContents() throws DOMException {
- // not supported
- }
-
- /**
- * Called to indicate that the Range is no longer in use and that the
- * implementation may relinquish any resources associated with this Range.
- * Subsequent calls to any methods or attribute getters on this Range will
- * result in a <code>DOMException</code> being thrown with an error code
- * of <code>INVALID_STATE_ERR</code>.
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void detach() throws DOMException {
- this.startContainer = null;
- this.startOffset = 0;
- this.endContainer = null;
- this.endOffset = 0;
- }
-
- /**
- * Moves the contents of a Range from the containing document or document
- * fragment to a new DocumentFragment.
- *
- * @return A DocumentFragment containing the extracted contents.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of
- * the content of the Range is read-only or any of the
- * nodes which contain any of the content of the Range are
- * read-only. <br>
- * HIERARCHY_REQUEST_ERR: Raised if a DocumentType node
- * would be extracted into the new DocumentFragment. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public DocumentFragment extractContents() throws DOMException {
- // not supported
- return null;
- }
-
- /**
- * TRUE if the Range is collapsed
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public boolean getCollapsed() throws DOMException {
- if (this.startContainer == this.endContainer && this.startOffset == this.endOffset)
- return true;
- return false;
- }
-
- /**
- * The deepest common ancestor container of the Range's two
- * boundary-points.
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public Node getCommonAncestorContainer() throws DOMException {
- if (this.startContainer == null)
- return null;
- return ((NodeImpl) this.startContainer).getCommonAncestor(this.endContainer);
- }
-
- /**
- * Node within which the Range ends
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public Node getEndContainer() throws DOMException {
- return this.endContainer;
- }
-
- /**
- * Offset within the ending node of the Range.
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public int getEndOffset() throws DOMException {
- return this.endOffset;
- }
-
- /**
- * Node within which the Range begins
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public Node getStartContainer() throws DOMException {
- return this.startContainer;
- }
-
- /**
- * Offset within the starting node of the Range.
- *
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public int getStartOffset() throws DOMException {
- return this.startOffset;
- }
-
- /**
- * Inserts a node into the Document or DocumentFragment at the start of
- * the Range. If the container is a Text node, this will be split at the
- * start of the Range (as if the Text node's splitText method was
- * performed at the insertion point) and the insertion will occur between
- * the two resulting Text nodes. Adjacent Text nodes will not be
- * automatically merged. If the node to be inserted is a DocumentFragment
- * node, the children will be inserted rather than the DocumentFragment
- * node itself.
- *
- * @param newNodeThe
- * node to insert at the start of the Range
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor
- * container of the start of the Range is read-only. <br>
- * WRONG_DOCUMENT_ERR: Raised if <code>newNode</code> and
- * the container of the start of the Range were not created
- * from the same document. <br>
- * HIERARCHY_REQUEST_ERR: Raised if the container of the
- * start of the Range is of a type that does not allow
- * children of the type of <code>newNode</code> or if
- * <code>newNode</code> is an ancestor of the container.
- * <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if <code>newNode</code>
- * is an Attr, Entity, Notation, or Document node.
- */
- public void insertNode(Node newNode) throws RangeException, DOMException {
- // not supported
- }
-
- /**
- * Select a node and its contents
- *
- * @param refNodeThe
- * node to select.
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if an ancestor of
- * <code>refNode</code> is an Entity, Notation or
- * DocumentType node or if <code>refNode</code> is a
- * Document, DocumentFragment, Attr, Entity, or Notation
- * node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void selectNode(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- Node parent = refNode.getParentNode();
- if (parent == null)
- return;
- int index = ((NodeImpl) refNode).getIndex();
- if (index < 0)
- return;
- setStart(parent, index);
- setEnd(parent, index + 1);
- }
-
- /**
- * Select the contents within a node
- *
- * @param refNodeNode
- * to select from
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code>
- * or an ancestor of <code>refNode</code> is an Entity,
- * Notation or DocumentType node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void selectNodeContents(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- if (refNode.getNodeType() == Node.TEXT_NODE) {
- Text text = (Text) refNode;
- setStart(refNode, 0);
- setEnd(refNode, text.getLength());
- } else {
- NodeList childNodes = refNode.getChildNodes();
- int length = (childNodes != null ? childNodes.getLength() : 0);
- setStart(refNode, 0);
- setEnd(refNode, length);
- }
- }
-
- /**
- * Sets the attributes describing the end of a Range.
- *
- * @param refNodeThe
- * <code>refNode</code> value. This parameter must be
- * different from <code>null</code>.
- * @param offsetThe
- * <code>endOffset</code> value.
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code>
- * or an ancestor of <code>refNode</code> is an Entity,
- * Notation, or DocumentType node.
- * @exception DOMException
- * INDEX_SIZE_ERR: Raised if <code>offset</code> is
- * negative or greater than the number of child units in
- * <code>refNode</code>. Child units are 16-bit units if
- * <code>refNode</code> is a type of CharacterData node
- * (e.g., a Text or Comment node) or a
- * ProcessingInstruction node. Child units are Nodes in all
- * other cases. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setEnd(Node refNode, int offset) throws RangeException, DOMException {
- this.endContainer = refNode;
- this.endOffset = offset;
- }
-
- /**
- * Sets the end of a Range to be after a node
- *
- * @param refNodeRange
- * ends after <code>refNode</code>.
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if the root container of
- * <code>refNode</code> is not an Attr, Document or
- * DocumentFragment node or if <code>refNode</code> is a
- * Document, DocumentFragment, Attr, Entity, or Notation
- * node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setEndAfter(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- Node parent = refNode.getParentNode();
- if (parent == null)
- return;
- int index = ((NodeImpl) refNode).getIndex();
- if (index < 0)
- return;
- setEnd(parent, index + 1);
- }
-
- /**
- * Sets the end position to be before a node.
- *
- * @param refNodeRange
- * ends before <code>refNode</code>
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if the root container of
- * <code>refNode</code> is not an Attr, Document, or
- * DocumentFragment node or if <code>refNode</code> is a
- * Document, DocumentFragment, Attr, Entity, or Notation
- * node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setEndBefore(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- Node parent = refNode.getParentNode();
- if (parent == null)
- return;
- int index = ((NodeImpl) refNode).getIndex();
- if (index < 0)
- return;
- setEnd(parent, index);
- }
-
- /**
- * Sets the attributes describing the start of the Range.
- *
- * @param refNodeThe
- * <code>refNode</code> value. This parameter must be
- * different from <code>null</code>.
- * @param offsetThe
- * <code>startOffset</code> value.
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code>
- * or an ancestor of <code>refNode</code> is an Entity,
- * Notation, or DocumentType node.
- * @exception DOMException
- * INDEX_SIZE_ERR: Raised if <code>offset</code> is
- * negative or greater than the number of child units in
- * <code>refNode</code>. Child units are 16-bit units if
- * <code>refNode</code> is a type of CharacterData node
- * (e.g., a Text or Comment node) or a
- * ProcessingInstruction node. Child units are Nodes in all
- * other cases. <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setStart(Node refNode, int offset) throws RangeException, DOMException {
- this.startContainer = refNode;
- this.startOffset = offset;
- }
-
- /**
- * Sets the start position to be after a node
- *
- * @param refNodeRange
- * starts after <code>refNode</code>
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if the root container of
- * <code>refNode</code> is not an Attr, Document, or
- * DocumentFragment node or if <code>refNode</code> is a
- * Document, DocumentFragment, Attr, Entity, or Notation
- * node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setStartAfter(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- Node parent = refNode.getParentNode();
- if (parent == null)
- return;
- int index = ((NodeImpl) refNode).getIndex();
- if (index < 0)
- return;
- setStart(parent, index + 1);
- }
-
- /**
- * Sets the start position to be before a node
- *
- * @param refNodeRange
- * starts before <code>refNode</code>
- * @exception RangeException
- * INVALID_NODE_TYPE_ERR: Raised if the root container of
- * <code>refNode</code> is not an Attr, Document, or
- * DocumentFragment node or if <code>refNode</code> is a
- * Document, DocumentFragment, Attr, Entity, or Notation
- * node.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- */
- public void setStartBefore(Node refNode) throws RangeException, DOMException {
- if (refNode == null)
- return;
- Node parent = refNode.getParentNode();
- if (parent == null)
- return;
- int index = ((NodeImpl) refNode).getIndex();
- if (index < 0)
- return;
- setStart(parent, index);
- }
-
- /**
- * Reparents the contents of the Range to the given node and inserts the
- * node at the position of the start of the Range.
- *
- * @param newParentThe
- * node to surround the contents with.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor
- * container of either boundary-point of the Range is
- * read-only. <br>
- * WRONG_DOCUMENT_ERR: Raised if <code> newParent</code>
- * and the container of the start of the Range were not
- * created from the same document. <br>
- * HIERARCHY_REQUEST_ERR: Raised if the container of the
- * start of the Range is of a type that does not allow
- * children of the type of <code>newParent</code> or if
- * <code>newParent</code> is an ancestor of the container
- * or if <code>node</code> would end up with a child node
- * of a type not allowed by the type of <code>node</code>.
- * <br>
- * INVALID_STATE_ERR: Raised if <code>detach()</code> has
- * already been invoked on this object.
- * @exception RangeException
- * BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially
- * selects a non-text node. <br>
- * INVALID_NODE_TYPE_ERR: Raised if <code> node</code> is
- * an Attr, Entity, DocumentType, Notation, Document, or
- * DocumentFragment node.
- */
- public void surroundContents(Node newParent) throws RangeException, DOMException {
- // not supported
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ReadOnlyController.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ReadOnlyController.java
deleted file mode 100644
index 57c2375444..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ReadOnlyController.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Node;
-
-
-class ReadOnlyController {
-
- class Span {
- int length;
- int offset;
-
- Span(int offset, int length) {
- this.offset = offset;
- this.length = length;
- }
- }
-
- private static ReadOnlyController fInstance;
-
- static synchronized ReadOnlyController getInstance() {
- if (fInstance == null) {
- fInstance = new ReadOnlyController();
- }
- return fInstance;
- }
-
- static private void lock(IStructuredDocument doc, int offset, int length, boolean canInsertBefore, boolean canInsertAfter) {
- if (doc == null) {
- return;
- }
- if (doc instanceof BasicStructuredDocument) {
- ((BasicStructuredDocument)doc).makeReadOnly(offset, length, canInsertBefore, canInsertAfter);
- } else {
- doc.makeReadOnly(offset, length);
- }
- }
-
- static private void lock(IStructuredDocumentRegion node, boolean canInsertBefore, boolean canInsertAfter) {
- if (node == null) {
- return;
- }
- IStructuredDocument doc = node.getParentDocument();
- if (doc == null) {
- return;
- }
- if (doc instanceof BasicStructuredDocument) {
- ((BasicStructuredDocument)doc).makeReadOnly(node.getStart(), node.getLength(), canInsertBefore, canInsertAfter);
- } else {
- doc.makeReadOnly(node.getStart(), node.getLength());
- }
- }
-
- static private void unlock(IStructuredDocumentRegion node) {
- if (node == null) {
- return;
- }
- IStructuredDocument doc = node.getParentDocument();
- if (doc == null) {
- return;
- }
- doc.clearReadOnly(node.getStart(), node.getLength());
- }
-
- private ReadOnlyController() {
- super();
- }
-
- private Span getDataSpan(IDOMNode node) {
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE :
- return getDataSpanForElement((IDOMElement) node);
- case Node.TEXT_NODE :
- return getDataSpanForText((IDOMText) node);
- default :
- return new Span(0, -1);
- }
- }
-
- private Span getDataSpanForElement(IDOMElement node) {
- IStructuredDocumentRegion docRegion = node.getStartStructuredDocumentRegion();
- if (docRegion == null) {
- return new Span(0, -1);
- }
-
- ITextRegionList regions = docRegion.getRegions();
- if (regions == null) {
- return new Span(0, -1);
- }
-
- String startType;
- String endType;
- if (node.isCommentTag()) {
- startType = DOMRegionContext.XML_COMMENT_OPEN;
- endType = DOMRegionContext.XML_COMMENT_CLOSE;
- } else {
- startType = DOMRegionContext.XML_TAG_NAME;
- endType = DOMRegionContext.XML_TAG_CLOSE;
- }
-
- int startOffset = -1;
- int endOffset = -1;
- ITextRegion prevRegion = null;
- ITextRegion region;
- for (int i = 0; i < regions.size(); i++) {
- region = regions.get(i);
- String type = region.getType();
- if (type == startType) {
- startOffset = region.getEnd();
- } else if (type == endType && prevRegion != null) {
- endOffset = prevRegion.getTextEnd();
- }
- prevRegion = region;
- }
-
- if (0 <= startOffset && 0 <= endOffset) {
- return new Span(startOffset, endOffset - startOffset);
- } else {
- return new Span(0, -1);
- }
- }
-
- private Span getDataSpanForText(IDOMText node) {
- IStructuredDocumentRegion docRegion = ((NodeImpl) node).getStructuredDocumentRegion();
- if (docRegion == null) {
- return new Span(0, -1);
- }
- return new Span(0, docRegion.getLength());
- }
-
- /**
- * This method is used from parent's setChildEditable()
- *
- * case 1:<parent><node attr="value"/> <node2></parent>
- * x####################x case 2:<parent><node attr="value"> <child>
- * </child> </node> </parent> x###################? ?#######x (? :
- * editable if node.isEditable() == true)
- */
- void lockBoth(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- IStructuredDocumentRegion flatNode;
- boolean canInsert = false;
-
- // end node (element)
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- flatNode = node.getEndStructuredDocumentRegion();
- if (flatNode != null) {
- canInsert = node.isChildEditable();
- lock(flatNode, canInsert, false);
- }
- }
- // start node
- flatNode = node.getStartStructuredDocumentRegion();
- if (flatNode != null) {
- lock(flatNode, false, canInsert);
- }
- }
-
- void lockData(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- Span span = getDataSpan(node);
- if (0 <= span.length) {
- lock(node.getModel().getStructuredDocument(), node.getStartOffset() + span.offset, span.length, false, false);
- }
- }
-
- /**
- * lock itself and all descendants
- */
- void lockDeep(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- int offset = node.getStartOffset();
- int length = node.getEndOffset() - offset;
-
- boolean canInsert = true;
- IDOMNode parent = (IDOMNode) node.getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- canInsert = false;
- }
- lock(node.getStructuredDocument(), offset, length, canInsert, canInsert);
- }
-
- /**
- * This method is used from parent's setChildEditable()
- *
- * case 1:<parent><node attr="value"/> <node2></parent> x######x x##x
- * case 2:<parent><node attr="value"> <child></child> </node> </parent>
- * x######x x#? ?#######x (? : editable if node.isEditable() == true)
- */
- void lockNode(IDOMNode node) {
- if (node == null) {
- return;
- }
- if (!node.isDataEditable()) {
- lockBoth(node);
- return;
- }
-
- IStructuredDocumentRegion flatNode;
- boolean canInsert = false;
-
- // end node (element)
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- flatNode = node.getEndStructuredDocumentRegion();
- if (flatNode != null) {
- canInsert = node.isChildEditable();
- lock(flatNode, canInsert, false);
- }
- }
- // start node
- flatNode = node.getStartStructuredDocumentRegion();
- if (flatNode != null) {
- Span span = getDataSpan(node);
- if (0 <= span.length) {
- IStructuredDocument structuredDocument = flatNode.getParentDocument();
- int offset, length;
- offset = flatNode.getStart();
- length = span.offset;
- lock(structuredDocument, offset, length, false, false);
- offset = offset + span.offset + span.length;
- length = flatNode.getEnd() - offset;
- lock(structuredDocument, offset, length, false, canInsert);
- } else {
- lock(flatNode, false, canInsert);
- }
- }
- }
-
- private void unlock(IStructuredDocument doc, int offset, int length) {
- if (doc == null) {
- return;
- }
- doc.clearReadOnly(offset, length);
- }
-
- void unlockBoth(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- IStructuredDocumentRegion flatNode;
- // start node
- flatNode = node.getStartStructuredDocumentRegion();
- if (flatNode != null) {
- unlock(flatNode);
- }
- // end node
- flatNode = node.getEndStructuredDocumentRegion();
- if (flatNode != null) {
- unlock(flatNode);
- }
- }
-
- void unlockData(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- Span span = getDataSpan(node);
- if (0 <= span.length) {
- unlock(node.getModel().getStructuredDocument(), span.offset, span.length);
- }
- }
-
- void unlockDeep(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- int offset = node.getStartOffset();
- int length = node.getEndOffset() - offset;
-
- unlock(node.getStructuredDocument(), offset, length);
- }
-
- void unlockNode(IDOMNode node) {
- if (node == null) {
- return;
- }
-
- IStructuredDocumentRegion flatNode;
- // end node
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- flatNode = node.getEndStructuredDocumentRegion();
- if (flatNode != null) {
- unlock(flatNode);
- }
- }
-
- // start node
- flatNode = node.getStartStructuredDocumentRegion();
- if (flatNode != null) {
- if (node.isDataEditable()) {
- unlock(flatNode);
- } else {
- Span span = getDataSpan(node);
- if (span.length <= 0) {
- unlock(flatNode);
- } else {
- IStructuredDocument structuredDocument = flatNode.getParentDocument();
- int offset, length;
- offset = flatNode.getStart();
- length = span.offset - offset;
- unlock(structuredDocument, offset, length);
- offset = span.offset + span.length;
- length = flatNode.getEnd() - span.offset;
- unlock(structuredDocument, offset, length);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/SourceValidator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/SourceValidator.java
deleted file mode 100644
index 2051222cfd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/SourceValidator.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.document;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.XMLCoreMessages;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLCharEntity;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- */
-public class SourceValidator {
-
- private NodeImpl node = null;
-
- /**
- */
- public SourceValidator(Node node) {
- super();
-
- if (node != null) {
- this.node = (NodeImpl) node;
- }
- }
-
- /**
- */
- public String convertSource(String source) {
- if (source == null)
- return null;
- if (this.node == null)
- return null; // error
-
- // setup conversion conditions
- boolean acceptTag = false;
- boolean acceptClose = false;
- boolean acceptQuote = false;
- boolean acceptAmpersand = false;
- boolean acceptEntityRef = true;
- boolean acceptJSPEnd = true;
- String endTagName = null;
- if (this.node.getNodeType() == Node.ATTRIBUTE_NODE) {
- IDOMDocument document = (IDOMDocument) this.node.getOwnerDocument();
- if (document != null && document.isJSPType())
- acceptTag = true;
- if (acceptTag) {
- Attr attr = (Attr) this.node;
- ElementImpl element = (ElementImpl) attr.getOwnerElement();
- if (element != null && element.isJSPTag())
- acceptTag = false;
- }
- // if the source does not include single quote,
- // double quote is valid
- acceptQuote = (source.indexOf('\'') < 0);
- } else if (this.node.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) this.node;
- if (text.isJSPContent()) {
- int index = source.indexOf(JSPTag.TAG_CLOSE);
- if (index < 0)
- return source;
- acceptTag = true;
- acceptClose = true;
- acceptQuote = true;
- acceptAmpersand = true;
- acceptJSPEnd = false;
- } else if (text.isCDATAContent()) {
- endTagName = text.getParentNode().getNodeName();
- if (endTagName == null)
- return null; // error
- acceptTag = true;
- acceptClose = true;
- acceptQuote = true;
- acceptAmpersand = true;
- }
- } else {
- IDOMDocument document = null;
- if (this.node.getNodeType() == Node.DOCUMENT_NODE) {
- document = (IDOMDocument) this.node;
- } else {
- document = (IDOMDocument) this.node.getOwnerDocument();
- }
- if (document != null && document.isJSPType())
- acceptTag = true;
- }
-
- StringBuffer buffer = null;
- int copiedLength = 0;
- int length = source.length();
- for (int i = 0; i < length; i++) {
- String ref = null;
- char c = source.charAt(i);
- switch (c) {
- case '<' :
- if (acceptTag) {
- if (endTagName != null) {
- if (!matchEndTag(source, i + 1, endTagName))
- continue;
- } else {
- int skip = skipTag(source, i + 1);
- if (skip >= 0) {
- i += skip;
- continue;
- }
- }
- // invalid JSP tag
- }
- ref = IXMLCharEntity.LT_REF;
- break;
- case '>' :
- if (acceptClose)
- continue;
- ref = IXMLCharEntity.GT_REF;
- break;
- case '&' :
- if (acceptAmpersand)
- continue;
- if (acceptEntityRef) {
- int skip = skipEntityRef(source, i + 1);
- if (skip >= 0) {
- i += skip;
- continue;
- }
- }
- ref = IXMLCharEntity.AMP_REF;
- break;
- case '"' :
- if (acceptQuote)
- continue;
- ref = IXMLCharEntity.QUOT_REF;
- break;
- case '%' :
- if (acceptJSPEnd)
- continue;
- if (source.charAt(i + 1) != '>')
- continue;
- i++;
- ref = IXMLCharEntity.GT_REF;
- break;
- default :
- continue;
- }
-
- if (ref != null) {
- if (buffer == null) {
- buffer = new StringBuffer(length + 8);
- }
- if (i > copiedLength) {
- buffer.append(source.substring(copiedLength, i));
- }
- buffer.append(ref);
- copiedLength = i + 1; // skip this character
- }
- }
-
- if (buffer != null) {
- if (copiedLength < length) {
- buffer.append(source.substring(copiedLength, length));
- }
- return buffer.toString();
- }
- return source;
- }
-
- /**
- */
- private final boolean matchEndTag(String source, int offset, String endTagName) {
- if (source == null || endTagName == null)
- return false;
- int length = source.length();
- if (offset < 0 || offset >= length)
- return false;
- if (source.charAt(offset) != '/')
- return false;
- offset++;
- int end = offset + endTagName.length();
- if (end > length)
- return false;
- return endTagName.equalsIgnoreCase(source.substring(offset, end));
- }
-
- /**
- */
- private final int skipEntityRef(String source, int offset) {
- if (source == null)
- return -1;
- if (offset < 0 || offset >= source.length())
- return -1;
- DocumentImpl document = (DocumentImpl) this.node.getOwnerDocument();
- if (document == null)
- return -1; // error
-
- int end = source.indexOf(';', offset);
- if (end < 0 || end == offset)
- return -1;
- String name = source.substring(offset, end);
- if (name == null || document.getCharValue(name) == null)
- return -1;
- return (end + 1 - offset);
- }
-
- /**
- */
- private final int skipTag(String source, int offset) {
- if (source == null)
- return -1;
- if (offset < 0 || offset >= source.length())
- return -1;
-
- int end = offset;
- if (source.charAt(offset) == '%') {
- // JSP tag
- int found = source.indexOf(JSPTag.TAG_CLOSE, offset + 1);
- if (found < 0)
- return -1; // invalid JSP tag
- end = found + 2;
- } else {
- // normal tag
- int found = source.lastIndexOf('>');
- if (found < offset)
- return -1; // invalid tag
- end = found + 1;
- }
- return (end - offset);
- }
-
- /**
- */
- public boolean validateSource(String source) throws InvalidCharacterException {
- if (source == null)
- return true;
- if (this.node == null)
- return false; // error
- String message = null;
-
-
- // setup validation conditions
- boolean acceptTag = false;
- boolean acceptClose = false;
- boolean acceptQuote = true;
- boolean acceptEntityRef = true;
- String endTagName = null;
- if (this.node.getNodeType() == Node.ATTRIBUTE_NODE) {
- IDOMDocument document = (IDOMDocument) this.node.getOwnerDocument();
- if (document != null && document.isJSPType())
- acceptTag = true;
- if (acceptTag) {
- Attr attr = (Attr) this.node;
- ElementImpl element = (ElementImpl) attr.getOwnerElement();
- if (element != null && element.isJSPTag())
- acceptTag = false;
- }
- // if the source does not include single quote,
- // double quote is valid
- acceptQuote = (source.indexOf('\'') < 0);
- } else if (this.node.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) this.node;
- if (text.isJSPContent()) {
- int index = source.indexOf(JSPTag.TAG_CLOSE);
- if (index < 0)
- return true;
- message = XMLCoreMessages.Invalid_character_gt_fo_ERROR_;
- throw new InvalidCharacterException(message, '>', index + 1);
- } else if (text.isCDATAContent()) {
- endTagName = text.getParentNode().getNodeName();
- if (endTagName == null)
- return false; // error
- acceptTag = true;
- acceptClose = true;
- } else if(hasNestedRegion(text)) {
- //there are cases (such as with EL) that the text is to complicated
- // to be verified by this validator
- return true;
- }
- } else {
- IDOMDocument document = null;
- if (this.node.getNodeType() == Node.DOCUMENT_NODE) {
- document = (IDOMDocument) this.node;
- } else {
- document = (IDOMDocument) this.node.getOwnerDocument();
- }
- if (document != null && document.isJSPType())
- acceptTag = true;
- }
-
- char c = 0;
- int length = source.length();
- for (int i = 0; i < length; i++) {
- c = source.charAt(i);
- switch (c) {
- case '<' :
- if (acceptTag) {
- if (endTagName != null) {
- if (!matchEndTag(source, i + 1, endTagName))
- continue;
- } else {
- int skip = skipTag(source, i + 1);
- if (skip >= 0) {
- i += skip;
- continue;
- }
- }
- // invalid tag
- }
- message = XMLCoreMessages.Invalid_character_lt_fo_ERROR_;
- break;
- case '>' :
- if (acceptClose)
- continue;
- message = XMLCoreMessages.Invalid_character_gt_fo_ERROR_;
- break;
- case '&' :
- if (acceptEntityRef) {
- if (endTagName != null)
- continue;
- int skip = skipEntityRef(source, i + 1);
- if (skip >= 0) {
- i += skip;
- continue;
- }
- // invalid entity reference
- }
- message = XMLCoreMessages.Invalid_character_amp_fo_ERROR_;
- break;
- case '"' :
- if (acceptQuote)
- continue;
- message = XMLCoreMessages.Invalid_character__f_EXC_;
- break;
- default :
- continue;
- }
-
- if (message != null) {
- throw new InvalidCharacterException(message, c, i);
- }
- }
-
- return true;
- }
-
- /**
- * True if the text has nested regions, meaning container is probably too
- * complicated (like EL regions) to validate with this validator.
- *
- * @param text
- * @return
- */
- private boolean hasNestedRegion(TextImpl text) {
- boolean done = false;
-
- IStructuredDocumentRegion currRegion = text.getFirstStructuredDocumentRegion();
- IStructuredDocumentRegion lastRegion = text.getLastStructuredDocumentRegion();
-
- while(currRegion != null && !done) {
-
- ITextRegionList regions = currRegion.getRegions();
- for(int i = 0; i < regions.size(); ++i) {
- ITextRegion container = regions.get(i);
- if ((container instanceof ITextRegionContainer)) {
- ITextRegionList regions2 = ((ITextRegionContainer) container).getRegions();
- if (regions2 != null) {
- return true;
- }
- }
- }
-
- done = currRegion == lastRegion;
- currRegion = currRegion.getNext();
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionChecker.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionChecker.java
deleted file mode 100644
index 547c8f35c5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionChecker.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Node;
-
-
-/**
- * This class is only for debug purpose.
- */
-public class StructuredDocumentRegionChecker {
- String EOL = System.getProperty("line.separator"); //$NON-NLS-1$
-
- private int offset = 0;
- Writer testWriter = null;
-
- /**
- */
- public StructuredDocumentRegionChecker() {
- super();
- }
-
- public StructuredDocumentRegionChecker(Writer writer) {
- super();
- testWriter = writer;
- }
-
- /**
- */
- private void checkChildNodes(Node node) {
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- checkNode(child);
- }
- }
-
- /**
- */
- public void checkModel(IDOMModel model) {
- checkChildNodes(model.getDocument());
- }
-
- /**
- */
- private void checkNode(Node node) {
- checkStructuredDocumentRegion(((NodeImpl) node).getStructuredDocumentRegion());
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- checkChildNodes(node);
- checkStructuredDocumentRegion(((ElementImpl) node).getEndStructuredDocumentRegion());
- }
- }
-
- /**
- */
- private void checkStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return;
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int n = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < n; i++) {
- IStructuredDocumentRegion c = container.getStructuredDocumentRegion(i);
- if (c == null) {
- reportError("null"); //$NON-NLS-1$
- continue;
- }
- checkStructuredDocumentRegion(c);
- }
- return;
- }
-
- int start = flatNode.getStart();
- if (start < this.offset)
- reportError("overwrap"); //$NON-NLS-1$
- if (start > this.offset)
- reportError("gap"); //$NON-NLS-1$
- int end = flatNode.getEnd();
- this.offset = end;
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- IStructuredDocumentRegion p = proxy.getStructuredDocumentRegion();
- if (p == null) {
- reportError("null"); //$NON-NLS-1$
- return;
- }
- int s = p.getStart();
- int e = p.getEnd();
- if (s > start || e < end)
- reportError("out"); //$NON-NLS-1$
- if (s == start && e == end)
- reportWarning("vain"); //$NON-NLS-1$
- }
- }
-
- /**
- */
- private void reportError(String message) {
- String msg = "StructuredDocumentRegionChecker : error : " + message; //$NON-NLS-1$
- if (testWriter != null) {
- try {
- testWriter.write(msg + EOL);
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- System.out.println(msg);
- }
- throw new StructuredDocumentRegionManagementException();
- }
-
- /**
- */
- private void reportWarning(String message) {
- String msg = "StructuredDocumentRegionChecker : warning : " + message; //$NON-NLS-1$
- if (testWriter != null) {
- try {
- testWriter.write(msg + EOL);
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- System.out.println(msg);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java
deleted file mode 100644
index 245211d84d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Vector;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-
-
-class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
-
- private Vector flatNodes = new Vector(2);
-
- /**
- */
- StructuredDocumentRegionContainer() {
- super();
- }
-
-
- public void addRegion(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjust(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustLength(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustStart(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustTextLength(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- /**
- */
- void appendStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return;
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- if (container.getStructuredDocumentRegionCount() > 0) {
- this.flatNodes.addAll(container.flatNodes);
- }
- }
- else {
- this.flatNodes.addElement(flatNode);
- }
- }
-
- public boolean containsOffset(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public boolean containsOffset(ITextRegion region, int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void equatePositions(ITextRegion region) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public ITextRegion getDeepestRegionAtCharacterOffset(int offset) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public int getEnd() {
- IStructuredDocumentRegion last = getLastStructuredDocumentRegion();
- if (last == null)
- return 0;
- return last.getEnd();
- }
-
- /**
- */
- public int getEndOffset() {
- return getEnd();
- }
-
- public int getEndOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public ITextRegion getFirstRegion() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- if (this.flatNodes.isEmpty())
- return null;
- return (IStructuredDocumentRegion) this.flatNodes.elementAt(0);
- }
-
- /**
- */
- public String getFullText() {
- return getText();
- }
-
- /**
- */
- public String getFullText(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public String getFullText(String context) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public ITextRegion getLastRegion() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- int size = this.flatNodes.size();
- if (size == 0)
- return null;
- return (IStructuredDocumentRegion) this.flatNodes.elementAt(size - 1);
- }
-
- /**
- */
- public int getLength() {
- return (getEnd() - getStart());
- }
-
- public IStructuredDocumentRegion getNext() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public int getNumberOfRegions() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public ITextRegionContainer getParent() {
- return null;
- }
-
- public IStructuredDocument getParentDocument() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getPrevious() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public ITextRegion getRegionAtCharacterOffset(int offset) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public ITextRegionList getRegions() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public int getStart() {
- IStructuredDocumentRegion first = getFirstStructuredDocumentRegion();
- if (first == null)
- return 0;
- return first.getStart();
- }
-
- /**
- */
- public int getStartOffset() {
- return getStart();
- }
-
- public int getStartOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public IStructuredDocument getStructuredDocument() {
- IStructuredDocumentRegion first = getFirstStructuredDocumentRegion();
- if (first == null)
- return null;
- return first.getParentDocument();
- }
-
- /**
- */
- IStructuredDocumentRegion getStructuredDocumentRegion(int index) {
- if (index < 0 || index >= this.flatNodes.size())
- return null;
- return (IStructuredDocumentRegion) this.flatNodes.elementAt(index);
- }
-
- /**
- */
- int getStructuredDocumentRegionCount() {
- return this.flatNodes.size();
- }
-
- /**
- */
- public String getText() {
- int size = this.flatNodes.size();
- if (size == 0)
- return NodeImpl.EMPTY_STRING;
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < size; i++) {
- IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) this.flatNodes.elementAt(i);
- if (flatNode == null)
- continue;
- buffer.append(flatNode.getText());
- }
- return buffer.toString();
- }
-
- /**
- */
- public String getText(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public String getText(String context) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public int getTextEnd() {
- return getEnd();
- }
-
- /**
- */
- public int getTextEndOffset() {
- return getTextEnd();
- }
-
- public int getTextEndOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- * The text length is equal to length if there is no white space at the
- * end of a region. Otherwise it is smaller than length.
- */
- public int getTextLength() {
- return (getTextEnd() - getStart());
- }
-
- /**
- */
- public String getType() {
- return "StructuredDocumentRegionContainer";//$NON-NLS-1$
- }
-
- /**
- */
- void insertStructuredDocumentRegion(IStructuredDocumentRegion flatNode, int index) {
- if (flatNode == null)
- return;
- if (index < 0)
- return;
- int size = this.flatNodes.size();
- if (index > size)
- return;
- if (index == size) {
- appendStructuredDocumentRegion(flatNode);
- return;
- }
- this.flatNodes.insertElementAt(flatNode, index);
- }
-
- public boolean isEnded() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- IStructuredDocumentRegion removeStructuredDocumentRegion(int index) {
- if (index < 0 || index >= this.flatNodes.size())
- return null;
- IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) this.flatNodes.elementAt(index);
- this.flatNodes.removeElementAt(index);
- return flatNode;
- }
-
- /**
- */
- IStructuredDocumentRegion removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (oldStructuredDocumentRegion == null)
- return null;
- int size = this.flatNodes.size();
- for (int i = 0; i < size; i++) {
- IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) this.flatNodes.elementAt(i);
- if (flatNode == oldStructuredDocumentRegion) {
- this.flatNodes.removeElementAt(i);
- return flatNode;
- }
- }
- return null; // not found
- }
-
- /**
- */
- IStructuredDocumentRegion replaceStructuredDocumentRegion(IStructuredDocumentRegion flatNode, int index) {
- if (flatNode == null)
- return removeStructuredDocumentRegion(index);
- if (index < 0 || index >= this.flatNodes.size())
- return null;
- IStructuredDocumentRegion oldStructuredDocumentRegion = (IStructuredDocumentRegion) this.flatNodes.elementAt(index);
- this.flatNodes.setElementAt(flatNode, index);
- return oldStructuredDocumentRegion;
- }
-
- public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public boolean sameAs(ITextRegion region, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setEnded(boolean hasEnd) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setLength(int newLength) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setNext(IStructuredDocumentRegion newNext) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setParentDocument(IStructuredDocument document) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setPrevious(IStructuredDocumentRegion newPrevious) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public void setRegions(ITextRegionList embeddedRegions) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setStart(int newStart) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append('{');
- int count = getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- if (i != 0)
- buffer.append(',');
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion(i);
- if (flatNode == null)
- buffer.append("null");//$NON-NLS-1$
- else
- buffer.append(flatNode.toString());
- }
- buffer.append('}');
- return buffer.toString();
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
-
- public boolean isDeleted() {
- // if someone "gets" these temp regions by
- // accident, we'll always return "deleted".
- return true;
- }
-
-
- public void setDeleted(boolean deleted) {
- // do nothing
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionManagementException.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionManagementException.java
deleted file mode 100644
index 90fecbe615..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionManagementException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-
-/**
- */
-public class StructuredDocumentRegionManagementException extends RuntimeException {
-
- /**
- * Default <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * StructuredDocumentRegionManagementException constructor
- */
- public StructuredDocumentRegionManagementException() {
- super("IStructuredDocumentRegion management failed.");//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java
deleted file mode 100644
index 531226086a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-
-
-class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
- private IStructuredDocumentRegion flatNode = null;
- private int length = 0;
-
- private int offset = 0;
-
- /**
- */
- StructuredDocumentRegionProxy() {
- super();
- }
-
- /**
- */
- StructuredDocumentRegionProxy(int offset, int length) {
- super();
-
- this.offset = offset;
- this.length = length;
- }
-
- /**
- */
- StructuredDocumentRegionProxy(int offset, int length, IStructuredDocumentRegion flatNode) {
- super();
-
- this.offset = offset;
- this.length = length;
- this.flatNode = flatNode;
- if (this.flatNode != null)
- this.offset -= this.flatNode.getStart();
- }
-
- public void addRegion(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjust(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustLength(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustStart(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public void adjustTextLength(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public boolean containsOffset(int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public boolean containsOffset(ITextRegion region, int i) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void equatePositions(ITextRegion region) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
-
- }
-
- public ITextRegion getDeepestRegionAtCharacterOffset(int offset) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public int getEnd() {
- int flatNodeOffset = 0;
- if (this.flatNode != null)
- flatNodeOffset = this.flatNode.getStart();
- return flatNodeOffset + this.offset + this.length;
- }
-
- public int getEndOffset() {
- return getEnd();
- }
-
- public int getEndOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public ITextRegion getFirstRegion() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public String getFullText() {
- return getText();
- }
-
- public String getFullText(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public String getFullText(String context) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public ITextRegion getLastRegion() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public int getLength() {
- return this.length;
- }
-
- public IStructuredDocumentRegion getNext() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public int getNumberOfRegions() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- int getOffset() {
- int flatNodeOffset = 0;
- if (this.flatNode != null)
- flatNodeOffset = this.flatNode.getStart();
- return flatNodeOffset + this.offset;
- }
-
- /**
- */
- public ITextRegionContainer getParent() {
- return null;
- }
-
- public IStructuredDocument getParentDocument() {
- return null;
- // throw new Error("intentionally not implemented since should never
- // be called");
- }
-
- public IStructuredDocumentRegion getPrevious() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public ITextRegion getRegionAtCharacterOffset(int offset) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public ITextRegionList getRegions() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public int getStart() {
- int flatNodeOffset = 0;
- if (this.flatNode != null)
- flatNodeOffset = this.flatNode.getStart();
- return flatNodeOffset + this.offset;
- }
-
- /**
- */
- public int getStartOffset() {
- return getStart();
- }
-
- public int getStartOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public IStructuredDocument getStructuredDocument() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- IStructuredDocumentRegion getStructuredDocumentRegion() {
- return this.flatNode;
- }
-
- /**
- */
- public String getText() {
- if (this.flatNode == null)
- return NodeImpl.EMPTY_STRING;
- String text = this.flatNode.getText();
- if (text == null)
- return NodeImpl.EMPTY_STRING;
- int end = this.offset + this.length;
- return text.substring(this.offset, end);
- }
-
- /**
- */
- public String getText(ITextRegion aRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public String getText(String context) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public int getTextEnd() {
- return getEnd();
- }
-
- /**
- */
- public int getTextEndOffset() {
- return getTextEnd();
- }
-
- public int getTextEndOffset(ITextRegion containedRegion) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- * The text length is equal to length if there is no white space at the
- * end of a region. Otherwise it is smaller than length.
- */
- public int getTextLength() {
- return getLength();
- }
-
- /**
- */
- public String getType() {
- return "StructuredDocumentRegionProxy";//$NON-NLS-1$
- }
-
- public boolean isDeleted() {
- // I'll assume never really needed here
- return true;
- }
-
- public boolean isEnded() {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- public boolean sameAs(ITextRegion region, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setDeleted(boolean deleted) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setEnded(boolean hasEnd) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- * had to make public, due to API transition.
- */
- public void setLength(int length) {
- this.length = length;
- }
-
- public void setNext(IStructuredDocumentRegion newNext) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- void setOffset(int offset) {
- this.offset = offset;
- if (this.flatNode != null)
- this.offset -= this.flatNode.getStart();
- }
-
- public void setParentDocument(IStructuredDocument document) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setPrevious(IStructuredDocumentRegion newPrevious) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setRegions(ITextRegionList embeddedRegions) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- public void setStart(int newStart) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (this.flatNode != null)
- this.offset += this.flatNode.getStart();
- this.flatNode = flatNode;
- if (this.flatNode != null)
- this.offset -= flatNode.getStart();
- }
-
- /**
- * toString method
- *
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append('[');
- buffer.append(getStart());
- buffer.append(',');
- buffer.append(getEnd());
- buffer.append(']');
- buffer.append('(');
- if (this.flatNode != null)
- buffer.append(this.flatNode.toString());
- else
- buffer.append("null");//$NON-NLS-1$
- buffer.append(')');
- return buffer.toString();
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end) {
- throw new Error("intentionally not implemented since should never be called"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionUtil.java
deleted file mode 100644
index 84a378bea4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionUtil.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- * Provides convenient functions to handle IStructuredDocumentRegion and
- * ITextRegion.
- */
-class StructuredDocumentRegionUtil {
-
- /**
- * Extracts contents enclosed with quotes. Quotes may be double or single.
- */
- static String getAttrValue(IStructuredDocumentRegion flatNode, ITextRegion region) {
- if (region == null)
- return null;
- if (flatNode == null)
- return null;
- String value = flatNode.getText(region);
- if (value == null)
- return null;
- int length = value.length();
- if (length == 0)
- return value;
- char firstChar = value.charAt(0);
- if (firstChar == '"' || firstChar == '\'') {
- if (length == 1)
- return null;
- if (value.charAt(length - 1) == firstChar)
- length--;
- return value.substring(1, length);
- }
- return value;
- }
-
- /**
- * Extracts the name without heading '&' and tailing ';'.
- */
- static String getEntityRefName(IStructuredDocumentRegion flatNode, ITextRegion region) {
- if (region == null)
- return null;
- String ref = flatNode.getText(region);
- int length = ref.length();
- if (length == 0)
- return ref;
- int offset = 0;
- if (ref.charAt(0) == '&')
- offset = 1;
- if (ref.charAt(length - 1) == ';')
- length--;
- if (offset >= length)
- return null;
- return ref.substring(offset, length);
- }
-
- /**
- * Returns the first region.
- */
- static ITextRegion getFirstRegion(IStructuredDocumentRegion flatNode) {
- if(flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
- }
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null || regions.size() == 0)
- return null;
- return regions.get(0);
- }
-
- /**
- * Returns the type of the first region.
- */
- static String getFirstRegionType(IStructuredDocumentRegion flatNode) {
- if(flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
- }
- if (flatNode == null)
- return DOMRegionContext.UNDEFINED;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null || regions.size() == 0)
- return DOMRegionContext.UNDEFINED;
- ITextRegion region = regions.get(0);
- return region.getType();
- }
-
- /**
- */
- static IStructuredDocumentRegion getFirstStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- flatNode = ((StructuredDocumentRegionContainer) flatNode).getFirstStructuredDocumentRegion();
- }
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy) flatNode).getStructuredDocumentRegion();
- }
- return flatNode;
- }
-
- /**
- * Returns the last region.
- */
- static ITextRegion getLastRegion(IStructuredDocumentRegion flatNode) {
- if(flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
- }
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null || regions.size() == 0)
- return null;
- return regions.get(regions.size() - 1);
- }
-
- /**
- * Returns the type of the first region.
- */
- static String getLastRegionType(IStructuredDocumentRegion flatNode) {
- if(flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
- }
- if (flatNode == null)
- return DOMRegionContext.UNDEFINED;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null || regions.size() == 0)
- return DOMRegionContext.UNDEFINED;
- ITextRegion region = regions.get(regions.size() - 1);
- return region.getType();
- }
-
- /**
- */
- static IStructuredDocumentRegion getLastStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- flatNode = ((StructuredDocumentRegionContainer) flatNode).getLastStructuredDocumentRegion();
- }
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy) flatNode).getStructuredDocumentRegion();
- }
- return flatNode;
- }
-
- /**
- */
- static IStructuredDocumentRegion getStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- flatNode = ((StructuredDocumentRegionProxy) flatNode).getStructuredDocumentRegion();
- }
- return flatNode;
- }
-
- StructuredDocumentRegionUtil() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TagAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TagAdapter.java
deleted file mode 100644
index f49ff7b959..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TagAdapter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-/**
- */
-public interface TagAdapter extends INodeAdapter {
-
- /**
- */
- String getEndTag(IDOMElement element);
-
- /**
- */
- String getStartTag(IDOMElement element);
-
- /**
- */
- boolean isEndTag();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TextImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TextImpl.java
deleted file mode 100644
index d1d2c247d6..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TextImpl.java
+++ /dev/null
@@ -1,1192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- *
- * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * TextImpl class
- */
-public class TextImpl extends CharacterDataImpl implements IDOMText {
-
- /**
- */
- private class StringPair {
- private String fFirst = null;
- private String fSecond = null;
-
- StringPair(String first, String second) {
- this.fFirst = first;
- this.fSecond = second;
- }
-
- String getFirst() {
- return this.fFirst;
- }
-
- String getSecond() {
- return this.fSecond;
- }
- }
-
- private String fSource = null;
-
- /**
- * TextImpl constructor
- */
- protected TextImpl() {
- super();
- }
-
- /**
- * TextImpl constructor
- *
- * @param that
- * TextImpl
- */
- protected TextImpl(TextImpl that) {
- super(that);
-
- if (that != null) {
- this.fSource = that.getSource();
- }
- }
-
- /**
- * appendData method
- *
- * @param arg
- * java.lang.String
- */
- public void appendData(String arg) throws DOMException {
- if (arg == null || arg.length() == 0)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- String newSource = getSource(arg);
- if (newSource == null)
- return;
- String source = getSource();
- if (source != null)
- setTextSource(source + newSource);
- else
- setTextSource(newSource);
- }
-
- /**
- */
- IStructuredDocumentRegion appendStructuredDocumentRegion(IStructuredDocumentRegion newStructuredDocumentRegion) {
- if (newStructuredDocumentRegion == null)
- return null;
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null) {
- setStructuredDocumentRegion(newStructuredDocumentRegion);
- return newStructuredDocumentRegion;
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- container.appendStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- else {
- StructuredDocumentRegionContainer container = new StructuredDocumentRegionContainer();
- container.appendStructuredDocumentRegion(flatNode);
- container.appendStructuredDocumentRegion(newStructuredDocumentRegion);
- setStructuredDocumentRegion(container);
- }
-
- return newStructuredDocumentRegion;
- }
-
- /**
- * appendText method
- *
- * @param text
- * org.w3c.dom.Text
- */
- public void appendText(Text newText) {
- if (newText == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- TextImpl text = (TextImpl) newText;
- String newSource = text.getSource();
- if (newSource == null || newSource.length() == 0)
- return;
- String source = getSource();
- if (source != null)
- setTextSource(source + newSource);
- else
- setTextSource(newSource);
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- TextImpl cloned = new TextImpl(this);
- notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned);
- return cloned;
- }
-
- /**
- * deleteData method
- *
- * @param offset
- * int
- * @param count
- * int
- */
- public void deleteData(int offset, int count) throws DOMException {
- if (count == 0)
- return;
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- if (count < 0 || offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String source = getSource();
- if (source == null || source.length() == 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- StringPair pair = substringSourceExcluded(source, offset, count);
- if (pair == null)
- return;
- source = null;
- String first = pair.getFirst();
- if (first != null)
- source = first;
- String second = pair.getSecond();
- if (second != null) {
- if (source != null)
- source += second;
- else
- source = second;
- }
- if (source == null)
- source = NodeImpl.EMPTY_STRING; // delete all
- setTextSource(source);
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- if (this.fSource != null)
- return getData(this.fSource);
- String data = super.getData();
- if (data != null)
- return data;
- return getData(getStructuredDocumentRegion());
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return NodeImpl.EMPTY_STRING;
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int length = container.getLength();
- if (length < 16)
- length = 16; // default
- StringBuffer buffer = new StringBuffer(length);
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- String data = getData(content);
- if (data == null)
- continue;
- buffer.append(data);
- }
- return buffer.toString();
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- return flatNode.getText();
- }
-
- ITextRegion region = StructuredDocumentRegionUtil.getFirstRegion(flatNode);
- if (region != null) {
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_ENTITY_REFERENCE || regionType == DOMRegionContext.XML_CHAR_REFERENCE) {
- String name = StructuredDocumentRegionUtil.getEntityRefName(flatNode, region);
- if (name != null) {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null) {
- String value = document.getCharValue(name);
- if (value != null)
- return value;
- }
- }
- }
- }
-
- return flatNode.getText();
- }
-
- /**
- * Returns data for the source
- */
- private String getData(String source) {
- if (source == null)
- return null;
- StringBuffer buffer = null;
- int offset = 0;
- int length = source.length();
- int ref = source.indexOf('&');
- while (ref >= 0) {
- int end = source.indexOf(';', ref + 1);
- if (end > ref + 1) {
- String name = source.substring(ref + 1, end);
- String value = getCharValue(name);
- if (value != null) {
- if (buffer == null)
- buffer = new StringBuffer(length);
- if (ref > offset)
- buffer.append(source.substring(offset, ref));
- buffer.append(value);
- offset = end + 1;
- ref = end;
- }
- }
- ref = source.indexOf('&', ref + 1);
- }
- if (buffer == null)
- return source;
- if (length > offset)
- buffer.append(source.substring(offset));
- return buffer.toString();
- }
-
- /**
- * getFirstStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getFirstStructuredDocumentRegion(getStructuredDocumentRegion());
- }
-
- /**
- * getLastStructuredDocumentRegion method
- *
- */
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getLastStructuredDocumentRegion(getStructuredDocumentRegion());
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#text";//$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNodeType()
- */
- public short getNodeType() {
- return TEXT_NODE;
- }
-
- /**
- */
- public String getSource() {
- if (this.fSource != null)
- return this.fSource;
- String data = super.getData();
- if (data != null && data.length() > 0) {
- String source = getSource(data);
- if (source != null)
- return source;
- }
- return super.getSource();
- }
-
- /**
- * Returns source for the data
- */
- private String getSource(String data) {
- if (data == null)
- return null;
- IDOMModel model = getModel();
- if (model == null)
- return null; // error
- ISourceGenerator generator = model.getGenerator();
- if (generator == null)
- return null; // error
- return generator.generateTextData(this, data);
- }
-
- /**
- */
- String getTextSource() {
- return this.fSource;
- }
-
- /**
- */
- public String getValueSource() {
- return getSource();
- }
-
- /**
- */
- boolean hasStructuredDocumentRegion(IStructuredDocumentRegion askedStructuredDocumentRegion) {
- if (askedStructuredDocumentRegion == null)
- return false;
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return false;
-
- if (flatNode == askedStructuredDocumentRegion)
- return true;
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- if (proxy.getStructuredDocumentRegion() == askedStructuredDocumentRegion)
- return true;
- return false;
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue;
- if (content == askedStructuredDocumentRegion)
- return true;
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == askedStructuredDocumentRegion)
- return true;
- }
- }
- return false;
- }
-
- return false;
- }
-
- /**
- * insertData method
- *
- * @param offset
- * int
- * @param arg
- * java.lang.String
- */
- public void insertData(int offset, String arg) throws DOMException {
- if (arg == null || arg.length() == 0)
- return;
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- if (offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String source = getSource();
- if (source == null || source.length() == 0) {
- if (offset > 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- source = getSource(arg);
- if (source != null)
- setTextSource(source);
- return;
- }
-
- StringPair pair = substringSourceExcluded(source, offset, 0);
- if (pair == null)
- return; // error
- StringBuffer buffer = new StringBuffer(source.length() + arg.length());
- String first = pair.getFirst();
- if (first != null)
- buffer.append(first);
- source = getSource(arg);
- if (source != null)
- buffer.append(source);
- String second = pair.getSecond();
- if (second != null)
- buffer.append(second);
- setTextSource(buffer.toString());
- }
-
- /**
- */
- IStructuredDocumentRegion insertStructuredDocumentRegion(IStructuredDocumentRegion newStructuredDocumentRegion, IStructuredDocumentRegion nextStructuredDocumentRegion) {
- if (newStructuredDocumentRegion == null)
- return null;
- if (nextStructuredDocumentRegion == null)
- return appendStructuredDocumentRegion(newStructuredDocumentRegion);
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return null; // error
-
- if (flatNode == nextStructuredDocumentRegion) {
- StructuredDocumentRegionContainer container = new StructuredDocumentRegionContainer();
- container.appendStructuredDocumentRegion(newStructuredDocumentRegion);
- container.appendStructuredDocumentRegion(flatNode);
- setStructuredDocumentRegion(container);
- return newStructuredDocumentRegion;
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == nextStructuredDocumentRegion) {
- container.insertStructuredDocumentRegion(newStructuredDocumentRegion, i);
- return newStructuredDocumentRegion;
- }
- }
- return null; // error
- }
-
- return null; // error
- }
-
- /**
- * insertText method
- *
- * @param text
- * org.w3c.dom.Text
- * @param offset
- * int
- */
- public void insertText(Text newText, int offset) throws DOMException {
- if (newText == null)
- return;
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- TextImpl text = (TextImpl) newText;
- String newSource = text.getSource();
- if (newSource == null || newSource.length() == 0)
- return;
- if (offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String source = getSource();
- if (source == null || source.length() == 0) {
- if (offset > 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- setTextSource(newSource);
- return;
- }
-
- StringPair pair = substringSourceExcluded(source, offset, 0);
- if (pair == null)
- return; // error
- StringBuffer buffer = new StringBuffer(source.length() + newSource.length());
- String first = pair.getFirst();
- if (first != null)
- buffer.append(first);
- buffer.append(newSource);
- String second = pair.getSecond();
- if (second != null)
- buffer.append(second);
- setTextSource(buffer.toString());
- }
-
- /**
- * isCDATAContent method
- *
- * @return boolean
- */
- public boolean isCDATAContent() {
- Node parent = getParentNode();
- if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE)
- return false;
- ElementImpl element = (ElementImpl) parent;
- return element.isCDATAContainer();
- }
-
- /**
- */
- public boolean isInvalid() {
- return isInvalid(getStructuredDocumentRegion());
- }
-
- /**
- */
- private boolean isInvalid(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return false;
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (isInvalid(content))
- return true;
- }
- return false;
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- return isInvalid(proxy.getStructuredDocumentRegion());
- }
-
- String regionType = StructuredDocumentRegionUtil.getFirstRegionType(flatNode);
- if (regionType != DOMRegionContext.XML_CONTENT && isNotNestedContent(regionType) && regionType != DOMRegionContext.XML_ENTITY_REFERENCE && regionType != DOMRegionContext.XML_CHAR_REFERENCE && regionType != DOMRegionContext.BLOCK_TEXT && regionType != DOMRegionContext.WHITE_SPACE) {
- return true;
- }
-
- return false;
- }
-
- protected boolean isNotNestedContent(String regionType) {
- boolean result = true;
- return result;
- }
-
- /**
- */
- boolean isSharingStructuredDocumentRegion(IStructuredDocumentRegion sharedStructuredDocumentRegion) {
- if (sharedStructuredDocumentRegion == null)
- return false;
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return false;
-
- if (flatNode == sharedStructuredDocumentRegion)
- return false;
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- if (proxy.getStructuredDocumentRegion() == sharedStructuredDocumentRegion)
- return true;
- return false;
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue;
- if (content == sharedStructuredDocumentRegion)
- return false;
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == sharedStructuredDocumentRegion)
- return true;
- }
- }
- return false;
- }
-
- return false;
- }
-
- /**
- * Returns whether this text node contains <a
- * href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
- * element content whitespace</a>, often abusively called "ignorable
- * whitespace". The text node is determined to contain whitespace in
- * element content during the load of the document or if validation occurs
- * while using <code>Document.normalizeDocument()</code>.
- *
- * @see DOM Level 3
- */
- public boolean isElementContentWhitespace() {
- return isWhitespace();
- }
-
- /**
- */
- public boolean isWhitespace() {
- String data = getData();
- if (data == null)
- return true;
- int length = data.length();
- for (int i = 0; i < length; i++) {
- if (!Character.isWhitespace(data.charAt(i)))
- return false;
- }
- return true;
- }
-
- /**
- */
- IStructuredDocumentRegion removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (oldStructuredDocumentRegion == null)
- return null;
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return null; // error
-
- if (flatNode == oldStructuredDocumentRegion) {
- setStructuredDocumentRegion(null);
- return oldStructuredDocumentRegion;
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- // removed with proxy
- setStructuredDocumentRegion(null);
- return oldStructuredDocumentRegion;
- }
- return null; // error
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == oldStructuredDocumentRegion) {
- container.removeStructuredDocumentRegion(i);
- if (container.getStructuredDocumentRegionCount() == 1) {
- // get back to single IStructuredDocumentRegion
- setStructuredDocumentRegion(container.getStructuredDocumentRegion(0));
- }
- return oldStructuredDocumentRegion;
- }
-
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- // removed with proxy
- container.removeStructuredDocumentRegion(i);
- if (container.getStructuredDocumentRegionCount() == 1) {
- // get back to single IStructuredDocumentRegion
- setStructuredDocumentRegion(container.getStructuredDocumentRegion(0));
- }
- return oldStructuredDocumentRegion;
- }
- }
- }
- return null; // error
- }
-
- return null; // error
- }
-
- /**
- * replaceData method
- *
- * @param offset
- * int
- * @param count
- * int
- * @param arg
- * java.lang.String
- */
- public void replaceData(int offset, int count, String arg) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- if (arg == null || arg.length() == 0) {
- deleteData(offset, count);
- return;
- }
- if (count == 0) {
- insertData(offset, arg);
- return;
- }
- if (offset < 0 || count < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String source = getSource();
- if (source == null || source.length() == 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- StringPair pair = substringSourceExcluded(source, offset, count);
- if (pair == null)
- return; // error
- StringBuffer buffer = new StringBuffer(source.length() + arg.length());
- String first = pair.getFirst();
- if (first != null)
- buffer.append(first);
- source = getSource(arg);
- if (source != null)
- buffer.append(source);
- String second = pair.getSecond();
- if (second != null)
- buffer.append(second);
- setTextSource(buffer.toString());
- }
-
- /**
- */
- IStructuredDocumentRegion replaceStructuredDocumentRegion(IStructuredDocumentRegion newStructuredDocumentRegion, IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (oldStructuredDocumentRegion == null)
- return null;
- if (newStructuredDocumentRegion == null)
- return removeStructuredDocumentRegion(oldStructuredDocumentRegion);
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return null; // error
-
- if (flatNode == oldStructuredDocumentRegion) {
- setStructuredDocumentRegion(newStructuredDocumentRegion);
- return oldStructuredDocumentRegion;
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- if (newStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- // proxy must not be nested
- setStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- else {
- proxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- return oldStructuredDocumentRegion;
- }
- return null; // error
- }
-
- if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue; // error
- if (content == oldStructuredDocumentRegion) {
- container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
- return oldStructuredDocumentRegion;
- }
-
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- if (newStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- // proxy must not be nested
- container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
- }
- else {
- proxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- return oldStructuredDocumentRegion;
- }
- }
- }
- return null; // error
- }
-
- return null; // error
- }
-
- /**
- */
- void resetStructuredDocumentRegions() {
- String source = getSource();
- if (source != null && source.length() > 0)
- this.fSource = source;
- super.resetStructuredDocumentRegions();
- }
-
- /**
- * getData method
- *
- * @return java.lang.String
- */
- public void setData(String data) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.fSource = null;
- super.setData(data);
- }
-
- /**
- */
- public void setSource(String source) throws InvalidCharacterException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- SourceValidator validator = new SourceValidator(this);
- if (validator.validateSource(source))
- setTextSource(source);
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- super.setStructuredDocumentRegion(flatNode);
- if (flatNode != null)
- this.fSource = null;
- }
-
- /**
- */
- public void setTextSource(String source) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- this.fSource = source;
-
- notifyValueChanged();
- }
-
- /**
- */
- public void setValueSource(String source) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
-
- SourceValidator validator = new SourceValidator(this);
- setTextSource(validator.convertSource(source));
- }
-
- /**
- * splitText method
- *
- * @return org.w3c.dom.Text
- * @param offset
- * int
- */
- public Text splitText(int offset) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessages.NO_MODIFICATION_ALLOWED_ERR);
- }
- if (offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int length = getLength();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- Document document = getOwnerDocument();
- if (document == null)
- return null;
-
- String source = null;
- if (offset < length) {
- int count = length - offset;
- source = substringSource(offset, count);
- deleteData(offset, count);
- }
- TextImpl text = (TextImpl) document.createTextNode(null);
- if (source != null)
- text.setTextSource(source);
-
- Node parent = getParentNode();
- if (parent != null)
- parent.insertBefore(text, getNextSibling());
-
- return text;
- }
-
- /**
- */
- Text splitText(IStructuredDocumentRegion nextStructuredDocumentRegion) {
- if (nextStructuredDocumentRegion == null)
- return null;
-
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null || !(flatNode instanceof StructuredDocumentRegionContainer))
- return null; // error
-
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- int index = 0;
- for (; index < count; index++) {
- if (container.getStructuredDocumentRegion(index) == nextStructuredDocumentRegion)
- break;
- }
- if (index >= count) {
- // this is the case nextStructuredDocumentRegion is a new
- // IStructuredDocumentRegion
- // search gap by offset
- int offset = nextStructuredDocumentRegion.getStart();
- for (index = 0; index < count; index++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(index);
- if (content == null)
- continue; // error
- if (content.getStart() >= offset)
- break;
- }
- if (index >= count)
- return null; // error
- }
- if (index == 0)
- return this; // nothing to do
-
- Document document = getOwnerDocument();
- if (document == null)
- return null; // error
- Node parent = getParentNode();
- if (parent == null)
- return null; // error
- TextImpl nextText = (TextImpl) document.createTextNode(null);
- if (nextText == null)
- return null; // error
-
- for (; index < count; count--) {
- nextText.appendStructuredDocumentRegion(container.removeStructuredDocumentRegion(index));
- }
-
- // normalize IStructuredDocumentRegion
- if (index == 1) {
- setStructuredDocumentRegion(container.getStructuredDocumentRegion(0));
- }
-
- parent.insertBefore(nextText, getNextSibling());
- return nextText;
- }
-
- /**
- * Retruns data for the range
- */
- private String substringData(String data, int offset, int count) throws DOMException {
- // sure offset and count are non-negative
- if (count == 0)
- return NodeImpl.EMPTY_STRING;
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int length = data.length();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
- return data.substring(offset, end);
- }
-
- /**
- * Returns source for the range specified by: offset: data offset count:
- * data count
- */
- private String substringSource(int offset, int count) throws DOMException {
- // sure offset and count are non-negative
- if (this.fSource != null)
- return substringSource(this.fSource, offset, count);
-
- String data = super.getData();
- if (data != null && data.length() > 0) {
- data = substringData(data, offset, count);
- if (data == null)
- return NodeImpl.EMPTY_STRING;
- String source = getSource(data);
- if (source != null)
- return source;
- }
-
- return substringSource(getSource(), offset, count);
- }
-
- /**
- * Returns source for the range specified by: offset: data offset count:
- * data count
- */
- private String substringSource(String source, int offset, int count) throws DOMException {
- // sure offset and count are non-negative
- if (count == 0)
- return NodeImpl.EMPTY_STRING;
- if (source == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- int length = source.length();
- int end = offset + count;
-
- // find character reference
- int ref = source.indexOf('&');
- while (ref >= 0) {
- if (ref >= end)
- break;
- int refEnd = source.indexOf(';', ref + 1);
- if (refEnd > ref + 1) {
- String name = source.substring(ref + 1, refEnd);
- if (getCharValue(name) != null) {
- // found, shift for source offsets
- int refCount = refEnd - ref;
- if (ref < offset)
- offset += refCount;
- if (ref < end)
- end += refCount;
- ref = refEnd;
- }
- }
- ref = source.indexOf('&', ref + 1);
- }
-
- if (offset > length || end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- return source.substring(offset, end);
- }
-
- /**
- * Returns sources before and after the range specified by: offset: data
- * offset count: data count
- */
- private StringPair substringSourceExcluded(String source, int offset, int count) throws DOMException {
- // sure offset and count are non-negative
- if (source == null) {
- if (offset == 0 && count == 0)
- return new StringPair(null, null);
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- int length = source.length();
- int end = offset + count;
-
- // find character reference
- int ref = source.indexOf('&');
- while (ref >= 0) {
- if (ref >= end)
- break;
- int refEnd = source.indexOf(';', ref + 1);
- if (refEnd > ref + 1) {
- String name = source.substring(ref + 1, refEnd);
- if (getCharValue(name) != null) {
- // found, shift for source offsets
- int refCount = refEnd - ref;
- if (ref < offset)
- offset += refCount;
- if (ref < end)
- end += refCount;
- ref = refEnd;
- }
- }
- ref = source.indexOf('&', ref + 1);
- }
-
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessages.INDEX_SIZE_ERR);
- }
-
- String first = (offset > 0 ? source.substring(0, offset) : null);
- String second = (end < length ? source.substring(end, length) : null);
- return new StringPair(first, second);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Text#getWholeText()
- */
- public String getWholeText() {
- Node current = this;
- // rewind
- while (current.getPreviousSibling() != null)
- current = current.getPreviousSibling();
- // playback
- StringBuffer buffer = new StringBuffer();
- while (current != null) {
- if (current.getNodeType() == Node.TEXT_NODE || current.getNodeType() == Node.CDATA_SECTION_NODE) {
- buffer.append(current.getNodeValue());
- }
- current = current.getNextSibling();
- }
- return buffer.toString();
- }
- /**
- * Replaces the text of the current node and all logically-adjacent text
- * nodes with the specified text. All logically-adjacent text nodes are
- * removed including the current node unless it was the recipient of the
- * replacement text. <br>
- * This method returns the node which received the replacement text. The
- * returned node is:
- * <ul>
- * <li><code>null</code>, when the replacement text is the empty
- * string; </li>
- * <li>the current node, except when the current node is read-only; </li>
- * <li> a new <code>Text</code> node of the same type (
- * <code>Text</code> or <code>CDATASection</code>) as the current
- * node inserted at the location of the replacement. </li>
- * </ul>
- * <br>
- * For instance, in the above example calling
- * <code>replaceWholeText</code> on the <code>Text</code> node that
- * contains "bar" with "yo" in argument results in the following: <br>
- * Where the nodes to be removed are read-only descendants of an
- * <code>EntityReference</code>, the <code>EntityReference</code>
- * must be removed instead of the read-only nodes. If any
- * <code>EntityReference</code> to be removed has descendants that are
- * not <code>EntityReference</code>, <code>Text</code>, or
- * <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
- * method must fail before performing any modification of the document,
- * raising a <code>DOMException</code> with the code
- * <code>NO_MODIFICATION_ALLOWED_ERR</code>. <br>
- * For instance, in the example below calling
- * <code>replaceWholeText</code> on the <code>Text</code> node that
- * contains "bar" fails, because the <code>EntityReference</code> node
- * "ent" contains an <code>Element</code> node which cannot be removed.
- *
- * @param content
- * The content of the replacing <code>Text</code> node.
- * @return The <code>Text</code> node created with the specified
- * content.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the
- * <code>Text</code> nodes being replaced is readonly.
- * @see DOM Level 3
- */
- public Text replaceWholeText(String content)
- throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not implemented"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/UserData.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/UserData.java
deleted file mode 100644
index 695ff71f10..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/UserData.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.w3c.dom.Node;
-
-/**
- * Collects user data associated to a Node.
- *
- */
-final class UserData {
-
- private static UserData fInstance;
-
- /**
- * Mapping of a Node to its User Data table (represented by a Map)
- */
- private Map fData;
-
- private UserData() {
- fData = new WeakHashMap(0);
- }
-
- public static synchronized UserData getInstance() {
- if (fInstance == null)
- fInstance = new UserData();
- return fInstance;
- }
-
- /**
- * Get the user data table associated with <code>node</code>.
- *
- * @param node the node
- * @return the user data table associated with the <code>node</code>
- */
- public synchronized Map getUserDataTable(Node node) {
- if (fData.containsKey(node))
- return (Map) fData.get(node);
- Map table = new HashMap();
- fData.put(node, table);
- return table;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLGeneratorImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLGeneratorImpl.java
deleted file mode 100644
index 17c7eb9e03..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLGeneratorImpl.java
+++ /dev/null
@@ -1,735 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementRegistry;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLCharEntity;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-/**
- */
-public class XMLGeneratorImpl implements ISourceGenerator {
- private static final String CDATA_CLOSE = "]]>";//$NON-NLS-1$
- private static final String CDATA_OPEN = "<![CDATA[";//$NON-NLS-1$
- private static final String COMMENT_CLOSE = "-->";//$NON-NLS-1$
- private static final String COMMENT_OPEN = "<!--";//$NON-NLS-1$
- private static final String DOCTYPE_OPEN = "<!DOCTYPE";//$NON-NLS-1$
- private static final String EMPTY_CLOSE = " />";//$NON-NLS-1$
- private static final String END_OPEN = "</";//$NON-NLS-1$
-
- private static XMLGeneratorImpl instance = null;
- private static final String PI_CLOSE = "?>";//$NON-NLS-1$
- private static final String PI_OPEN = "<?";//$NON-NLS-1$
- private static final String PUBLIC_ID = "PUBLIC";//$NON-NLS-1$
- private static final String SSI_PREFIX = "ssi";//$NON-NLS-1$
- //private static final String SSI_FEATURE = "SSI";//$NON-NLS-1$
- private static final String SSI_TOKEN = "#";//$NON-NLS-1$
- private static final String SYSTEM_ID = "SYSTEM";//$NON-NLS-1$
- private static final String TAG_CLOSE = ">";//$NON-NLS-1$
-
- /**
- */
- public synchronized static ISourceGenerator getInstance() {
- if (instance == null)
- instance = new XMLGeneratorImpl();
- return instance;
- }
-
- /**
- */
- //private boolean isCommentTag(XMLElement element) {
- // if (element == null) return false;
- // DocumentImpl document = (DocumentImpl)element.getOwnerDocument();
- // if (document == null) return false;
- // DocumentTypeAdapter adapter = document.getDocumentTypeAdapter();
- // if (adapter == null) return false;
- // if (!adapter.hasFeature(SSI_FEATURE)) return false;
- // String prefix = element.getPrefix();
- // return (prefix != null && prefix.equals(SSI_PREFIX));
- //}
- /**
- * Helper to modify the tag name in sub-classes
- */
- private static void setTagName(Element element, String tagName) {
- if (element == null || tagName == null)
- return;
- ((ElementImpl) element).setTagName(tagName);
- }
-
- /**
- * XMLModelGenerator constructor
- */
- private XMLGeneratorImpl() {
- super();
- }
-
- /**
- */
- public String generateAttrName(Attr attr) {
- if (attr == null)
- return null;
- String attrName = attr.getName();
- if (attrName == null)
- return null;
- if (attrName.startsWith(JSPTag.TAG_OPEN)) {
- if (!attrName.endsWith(JSPTag.TAG_CLOSE)) {
- // close JSP
- return (attrName + JSPTag.TAG_CLOSE);
- }
- }
- if (((IDOMAttr) attr).isGlobalAttr() && CMNodeUtil.getAttributeDeclaration(attr) != null) {
- switch (getAttrNameCase(attr)) {
- case DocumentTypeAdapter.UPPER_CASE :
- attrName = attrName.toUpperCase();
- break;
- case DocumentTypeAdapter.LOWER_CASE :
- attrName = attrName.toLowerCase();
- break;
- default :
- // ASIS_CASE
- break;
- }
- }
- return attrName;
- }
-
- /**
- */
- public String generateAttrValue(Attr attr) {
- return generateAttrValue(attr, (char) 0); // no quote preference
- }
-
- /**
- */
- public String generateAttrValue(Attr attr, char quote) {
- if (attr == null)
- return null;
- String name = attr.getName();
- SourceValidator validator = new SourceValidator(attr);
- String value = validator.convertSource(((IDOMNode) attr).getValueSource());
- if (value == null || value.length() == 0) {
- if (name != null && name.startsWith(JSPTag.TAG_OPEN))
- return null;
- if (isBooleanAttr(attr)) {
- if (((AttrImpl) attr).isXMLAttr()) {
- // generate the name as value
- value = attr.getName();
- } else {
- // not to generate '=' and value for HTML boolean
- return null;
- }
- }
- }
- return generateAttrValue(value, quote);
- }
-
- /**
- */
- public String generateAttrValue(String value, char quote) {
- // assume the valid is already validated not to include both quotes
- if (quote == '"') {
- if ((value != null) && (value.indexOf('"') >= 0))
- quote = '\''; // force
- } else if (quote == '\'') {
- if ((value != null) && (value.indexOf('\'') >= 0))
- quote = '"'; // force
- } else { // no preference
- if ((value != null) && (value.indexOf('"') < 0))
- quote = '"';
- else
- quote = '\'';
- }
-
- int length = (value == null ? 0 : value.length());
- StringBuffer buffer = new StringBuffer(length + 2);
- buffer.append(quote);
- if (value != null)
- buffer.append(value);
- buffer.append(quote);
- return buffer.toString();
- }
-
- /**
- * generateCDATASection method
- *
- * @return java.lang.String
- * @param comment
- * org.w3c.dom.CDATASection
- */
- public String generateCDATASection(CDATASection cdata) {
- if (cdata == null)
- return null;
-
- String data = cdata.getData();
- int length = (data != null ? data.length() : 0);
- StringBuffer buffer = new StringBuffer(length + 16);
- buffer.append(CDATA_OPEN);
- if (data != null)
- buffer.append(data);
- buffer.append(CDATA_CLOSE);
- return buffer.toString();
- }
-
- /**
- * generateChild method
- *
- * @return java.lang.String
- * @param org.w3c.dom.Node
- */
- public String generateChild(Node parentNode) {
- if (parentNode == null)
- return null;
- if (!parentNode.hasChildNodes())
- return null;
-
- StringBuffer buffer = new StringBuffer();
- for (Node child = parentNode.getFirstChild(); child != null; child = child.getNextSibling()) {
- String childSource = generateSource(child);
- if (childSource != null)
- buffer.append(childSource);
- }
- return buffer.toString();
- }
-
- /**
- */
- public String generateCloseTag(Node node) {
- if (node == null)
- return null;
-
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE : {
- ElementImpl element = (ElementImpl) node;
- if (element.isCommentTag()) {
- if (element.isJSPTag())
- return JSPTag.COMMENT_CLOSE;
- return COMMENT_CLOSE;
- }
- if (element.isJSPTag())
- return JSPTag.TAG_CLOSE;
- if (element.isEmptyTag())
- return EMPTY_CLOSE;
- return TAG_CLOSE;
- }
- case Node.COMMENT_NODE : {
- CommentImpl comment = (CommentImpl) node;
- if (comment.isJSPTag())
- return JSPTag.COMMENT_CLOSE;
- return COMMENT_CLOSE;
- }
- case Node.DOCUMENT_TYPE_NODE :
- return TAG_CLOSE;
- case Node.PROCESSING_INSTRUCTION_NODE :
- return PI_CLOSE;
- case Node.CDATA_SECTION_NODE :
- return CDATA_CLOSE;
- default :
- break;
- }
-
- return null;
- }
-
- /**
- * generateComment method
- *
- * @return java.lang.String
- * @param comment
- * org.w3c.dom.Comment
- */
- public String generateComment(Comment comment) {
- if (comment == null)
- return null;
-
- String data = comment.getData();
- int length = (data != null ? data.length() : 0);
- StringBuffer buffer = new StringBuffer(length + 8);
- CommentImpl impl = (CommentImpl) comment;
- if (!impl.isJSPTag())
- buffer.append(COMMENT_OPEN);
- else
- buffer.append(JSPTag.COMMENT_OPEN);
- if (data != null)
- buffer.append(data);
- if (!impl.isJSPTag())
- buffer.append(COMMENT_CLOSE);
- else
- buffer.append(JSPTag.COMMENT_CLOSE);
- return buffer.toString();
- }
-
- /**
- * generateDoctype method
- *
- * @return java.lang.String
- * @param docType
- * org.w3c.dom.DocumentType
- */
- public String generateDoctype(DocumentType docType) {
- if (docType == null)
- return null;
-
- String name = docType.getName();
- int length = (name != null ? name.length() : 0);
- StringBuffer buffer = new StringBuffer(length + 16);
- buffer.append(DOCTYPE_OPEN);
- buffer.append(' ');
- if (name != null)
- buffer.append(name);
- DocumentTypeImpl dt = (DocumentTypeImpl) docType;
- String publicID = dt.getPublicId();
- String systemID = dt.getSystemId();
- if (publicID != null) {
- buffer.append(' ');
- buffer.append(PUBLIC_ID);
- buffer.append(' ');
- buffer.append('"');
- buffer.append(publicID);
- buffer.append('"');
- if (systemID != null) {
- buffer.append(' ');
- buffer.append('"');
- buffer.append(systemID);
- buffer.append('"');
- }
- } else {
- if (systemID != null) {
- buffer.append(' ');
- buffer.append(SYSTEM_ID);
- buffer.append(' ');
- buffer.append('"');
- buffer.append(systemID);
- buffer.append('"');
- }
- }
- buffer.append('>');
- return buffer.toString();
- }
-
- /**
- * generateElement method
- *
- * @return java.lang.String
- * @param element
- * Element
- */
- public String generateElement(Element element) {
- if (element == null)
- return null;
-
- // if empty tag is preferrable, generate as empty tag
- ElementImpl impl = (ElementImpl) element;
- if (impl.preferEmptyTag())
- impl.setEmptyTag(true);
-
- StringBuffer buffer = new StringBuffer();
- String startTag = generateStartTag(element);
- if (startTag != null)
- buffer.append(startTag);
- String child = generateChild(element);
- if (child != null)
- buffer.append(child);
- String endTag = generateEndTag(element);
- if (endTag != null)
- buffer.append(endTag);
- return buffer.toString();
- }
-
- /**
- * generateEndTag method
- *
- * @return java.lang.String
- * @param element
- * org.w3c.dom.Element
- */
- public String generateEndTag(Element element) {
- if (element == null)
- return null;
-
- ElementImpl impl = (ElementImpl) element;
-
- // first check if tag adapter exists
- TagAdapter adapter = (TagAdapter) impl.getExistingAdapter(TagAdapter.class);
- if (adapter != null) {
- String endTag = adapter.getEndTag(impl);
- if (endTag != null)
- return endTag;
- }
-
- if (impl.isEmptyTag())
- return null;
- if (!impl.isContainer())
- return null;
- if (impl.isJSPTag())
- return JSPTag.TAG_CLOSE;
-
- String tagName = generateTagName(element);
- int length = (tagName != null ? tagName.length() : 0);
- StringBuffer buffer = new StringBuffer(length + 4);
- buffer.append(END_OPEN);
- if (tagName != null)
- buffer.append(tagName);
- buffer.append('>');
- return buffer.toString();
- }
-
- /**
- * generateEntityRef method
- *
- * @return java.lang.String
- * @param entityRef
- * org.w3c.dom.EntityReference
- */
- public String generateEntityRef(EntityReference entityRef) {
- if (entityRef == null)
- return null;
-
- String name = entityRef.getNodeName();
- int length = (name != null ? name.length() : 0);
- StringBuffer buffer = new StringBuffer(length + 4);
- buffer.append('&');
- if (name != null)
- buffer.append(name);
- buffer.append(';');
- return buffer.toString();
- }
-
- /**
- * generatePI method
- *
- * @return java.lang.String
- * @param pi
- * org.w3c.dom.ProcessingInstruction
- */
- public String generatePI(ProcessingInstruction pi) {
- if (pi == null)
- return null;
-
- String target = pi.getTarget();
- String data = pi.getData();
- int length = (target != null ? target.length() : 0);
- if (data != null)
- length += data.length();
- StringBuffer buffer = new StringBuffer(length + 8);
- buffer.append(PI_OPEN);
- if (target != null)
- buffer.append(target);
- buffer.append(' ');
- if (data != null)
- buffer.append(data);
- buffer.append(PI_CLOSE);
- return buffer.toString();
- }
-
- /**
- * generateSource method
- *
- * @return java.lang.String
- * @param node
- * org.w3c.dom.Node
- */
- public String generateSource(Node node) {
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE :
- return generateElement((Element) node);
- case Node.TEXT_NODE :
- return generateText((Text) node);
- case Node.COMMENT_NODE :
- return generateComment((Comment) node);
- case Node.DOCUMENT_TYPE_NODE :
- return generateDoctype((DocumentType) node);
- case Node.PROCESSING_INSTRUCTION_NODE :
- return generatePI((ProcessingInstruction) node);
- case Node.CDATA_SECTION_NODE :
- return generateCDATASection((CDATASection) node);
- case Node.ENTITY_REFERENCE_NODE :
- return generateEntityRef((EntityReference) node);
- default :
- // DOCUMENT
- break;
- }
- return generateChild(node);
- }
-
- /**
- * generateStartTag method
- *
- * @return java.lang.String
- * @param element
- * Element
- */
- public String generateStartTag(Element element) {
- if (element == null)
- return null;
-
- ElementImpl impl = (ElementImpl) element;
-
- if (impl.isJSPTag()) {
- // check if JSP content type and JSP Document
- IDOMDocument document = (IDOMDocument) element.getOwnerDocument();
- if (document != null && document.isJSPType()) {
- if (document.isJSPDocument() && !impl.hasChildNodes()) {
- impl.setJSPTag(false);
- }
- } else {
- impl.setJSPTag(false);
- }
- }
- if (impl.isCommentTag() && impl.getExistingAdapter(TagAdapter.class) == null) {
- CommentElementRegistry registry = CommentElementRegistry.getInstance();
- registry.setupCommentElement(impl);
- }
-
- // first check if tag adapter exists
- TagAdapter adapter = (TagAdapter) impl.getExistingAdapter(TagAdapter.class);
- if (adapter != null) {
- String startTag = adapter.getStartTag(impl);
- if (startTag != null)
- return startTag;
- }
-
- StringBuffer buffer = new StringBuffer();
-
- if (impl.isCommentTag()) {
- if (impl.isJSPTag())
- buffer.append(JSPTag.COMMENT_OPEN);
- else
- buffer.append(COMMENT_OPEN);
- String tagName = generateTagName(element);
- if (tagName != null)
- buffer.append(tagName);
- } else if (impl.isJSPTag()) {
- buffer.append(JSPTag.TAG_OPEN);
- String tagName = generateTagName(element);
- if (tagName != null)
- buffer.append(tagName);
- if (impl.isContainer())
- return buffer.toString(); // JSP container
- } else {
- buffer.append('<');
- String tagName = generateTagName(element);
- if (tagName != null)
- buffer.append(tagName);
- }
-
- NamedNodeMap attributes = element.getAttributes();
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) attributes.item(i);
- if (attr == null)
- continue;
- buffer.append(' ');
- String attrName = generateAttrName(attr);
- if (attrName != null)
- buffer.append(attrName);
- String attrValue = generateAttrValue(attr);
- if (attrValue != null) {
- // attr name only for HTML boolean and JSP
- buffer.append('=');
- buffer.append(attrValue);
- }
- }
-
- String closeTag = generateCloseTag(element);
- if (closeTag != null)
- buffer.append(closeTag);
-
- return buffer.toString();
- }
-
- /**
- */
- public String generateTagName(Element element) {
- if (element == null)
- return null;
- IDOMElement xe = (IDOMElement) element;
- String tagName = element.getTagName();
- if (tagName == null)
- return null;
- if (xe.isJSPTag()) {
- if (tagName.equals(JSPTag.JSP_EXPRESSION))
- return JSPTag.EXPRESSION_TOKEN;
- if (tagName.equals(JSPTag.JSP_DECLARATION))
- return JSPTag.DECLARATION_TOKEN;
- if (tagName.equals(JSPTag.JSP_DIRECTIVE))
- return JSPTag.DIRECTIVE_TOKEN;
- if (tagName.startsWith(JSPTag.JSP_DIRECTIVE)) {
- int offset = JSPTag.JSP_DIRECTIVE.length() + 1; // after '.'
- return (JSPTag.DIRECTIVE_TOKEN + tagName.substring(offset));
- }
- return (xe.isCommentTag()) ? tagName : null;
- } else if (tagName.startsWith(JSPTag.TAG_OPEN)) {
- if (!tagName.endsWith(JSPTag.TAG_CLOSE)) {
- // close JSP
- return (tagName + JSPTag.TAG_CLOSE);
- }
- } else if (xe.isCommentTag()) {
- String prefix = element.getPrefix();
- if (prefix.equals(SSI_PREFIX)) {
- return (SSI_TOKEN + element.getLocalName());
- }
- } else {
- if (!xe.isJSPTag() && xe.isGlobalTag() && // global tag
- CMNodeUtil.getElementDeclaration(xe) != null) {
- String newName = tagName;
- switch (getTagNameCase(xe)) {
- case DocumentTypeAdapter.UPPER_CASE :
- newName = tagName.toUpperCase();
- break;
- case DocumentTypeAdapter.LOWER_CASE :
- newName = tagName.toLowerCase();
- break;
- }
- if (newName != tagName) {
- tagName = newName;
- setTagName(element, tagName);
- }
- }
- }
- return tagName;
- }
-
- /**
- * generateText method
- *
- * @return java.lang.String
- * @param text
- * org.w3c.dom.Text
- */
- public String generateText(Text text) {
- if (text == null)
- return null;
- TextImpl impl = (TextImpl) text;
- String source = impl.getTextSource();
- if (source != null)
- return source;
- return generateTextData(text, impl.getData());
- }
-
- /**
- */
- public String generateTextData(Text text, String data) {
- if (data == null)
- return null;
- if (text == null)
- return null;
- TextImpl impl = (TextImpl) text;
- if (impl.isJSPContent() || impl.isCDATAContent()) {
- return new SourceValidator(impl).convertSource(data);
- }
- String source = data;
-
- // convert special characters to character entities
- StringBuffer buffer = null;
- int offset = 0;
- int length = data.length();
- for (int i = 0; i < length; i++) {
- String name = getCharName(data.charAt(i));
- if (name == null)
- continue;
- if (buffer == null)
- buffer = new StringBuffer(length + 8);
- if (i > offset)
- buffer.append(data.substring(offset, i));
- buffer.append('&');
- buffer.append(name);
- buffer.append(';');
- offset = i + 1;
- }
- if (buffer != null) {
- if (length > offset)
- buffer.append(data.substring(offset));
- source = buffer.toString();
- }
-
- if (source == null || source.length() == 0)
- return null;
- return source;
- }
-
- /**
- */
- private int getAttrNameCase(Attr attr) {
- DocumentImpl document = (DocumentImpl) attr.getOwnerDocument();
- if (document == null)
- return DocumentTypeAdapter.STRICT_CASE;
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class);
- if (adapter == null)
- return DocumentTypeAdapter.STRICT_CASE;
- return adapter.getAttrNameCase();
- }
-
- /**
- */
- private String getCharName(char c) {
- switch (c) {
- case '<' :
- return IXMLCharEntity.LT_NAME;
- case '>' :
- return IXMLCharEntity.GT_NAME;
- case '&' :
- return IXMLCharEntity.AMP_NAME;
- case '"' :
- return IXMLCharEntity.QUOT_NAME;
- }
- return null;
- }
-
- /**
- */
- private int getTagNameCase(Element element) {
- DocumentImpl document = (DocumentImpl) element.getOwnerDocument();
- if (document == null)
- return DocumentTypeAdapter.STRICT_CASE;
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class);
- if (adapter == null)
- return DocumentTypeAdapter.STRICT_CASE;
- return adapter.getTagNameCase();
- }
-
- /**
- */
- private boolean isBooleanAttr(Attr attr) {
- if (attr == null)
- return false;
- CMAttributeDeclaration decl = CMNodeUtil.getAttributeDeclaration(attr);
- if (decl == null)
- return false;
- CMDataType type = decl.getAttrType();
- if (type == null)
- return false;
- String values[] = type.getEnumeratedValues();
- if (values == null)
- return false;
- return (values.length == 1 && values[0].equals(decl.getAttrName()));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelContext.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelContext.java
deleted file mode 100644
index 6a799f75f4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelContext.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.document;
-
-
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-/**
- * XMLModelContext class
- */
-class XMLModelContext {
- private Node nextNode = null;
- private Node parentNode = null;
-
- // private XMLModelImpl model = null;
- private Node rootNode = null;
-
- /**
- * XMLModelContext constructor
- *
- * @param rootNode
- * org.w3c.dom.Node
- */
- XMLModelContext(Node rootNode) {
- super();
-
- this.rootNode = rootNode;
- }
-
- /**
- * findEndTag method
- *
- * @return org.w3c.dom.Element
- * @param tagName
- * java.lang.String
- */
- Element findEndTag(String tagName) {
- if (tagName == null)
- return null;
- if (this.parentNode == null)
- return null;
-
- for (Node parent = this.parentNode.getParentNode(); parent != null; parent = parent.getParentNode()) {
- if (parent.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl element = (ElementImpl) parent;
- if (element.hasEndTag()) {
- if (element.matchTagName(tagName))
- return element;
- // if ancestor element has end tag stop search
- break;
- }
- if (element.getNextSibling() != null)
- break;
- }
-
- return null;
- }
-
- /**
- */
- Text findNextText() {
- Node node = this.nextNode;
- while (node != null) {
- if (node != this.nextNode && node.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) node;
- // skip empty text
- if (text.getStructuredDocumentRegion() != null)
- return text;
- }
- Node child = node.getFirstChild();
- if (child != null) {
- node = child;
- continue;
- }
- while (node != null) {
- Node next = node.getNextSibling();
- if (next != null) {
- node = next;
- break;
- }
- node = node.getParentNode();
- }
- }
- return null;
- }
-
- /**
- * findPreviousText method
- *
- * @return org.w3c.dom.Text
- */
- Text findPreviousText() {
- if (this.parentNode == null)
- return null;
- Node node = null;
- if (this.nextNode != null)
- node = this.nextNode.getPreviousSibling();
- else
- node = this.parentNode.getLastChild();
- if (node == null || node.getNodeType() != Node.TEXT_NODE)
- return null;
- return (Text) node;
- }
-
- /**
- * findStartTag method
- *
- * @return org.w3c.dom.Element
- * @param tagName
- * java.lang.String
- */
- Element findStartTag(String tagName, String rootName) {
- if (tagName == null)
- return null;
-
- // check previous for empty content element
- Node prev = null;
- if (this.nextNode != null)
- prev = this.nextNode.getPreviousSibling();
- else if (this.parentNode != null)
- prev = this.parentNode.getLastChild();
- if (prev != null && prev.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) prev;
- if (!element.hasEndTag() && !element.isEmptyTag() && element.matchTagName(tagName))
- return element;
- }
-
- for (Node parent = this.parentNode; parent != null; parent = parent.getParentNode()) {
- if (parent.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl element = (ElementImpl) parent;
- if (element.matchTagName(tagName))
- return element;
- if (rootName != null && element.matchTagName(rootName))
- break;
- }
-
- return null;
- }
-
- /**
- * getNextNode method
- *
- * @return org.w3c.dom.Node
- */
- Node getNextNode() {
- return this.nextNode;
- }
-
- /**
- * getParentNode method
- *
- * @return org.w3c.dom.Node
- */
- Node getParentNode() {
- return this.parentNode;
- }
-
- /**
- * getRootNode method
- *
- * @return org.w3c.dom.Node
- */
- Node getRootNode() {
- return this.rootNode;
- }
-
- /**
- * setLast method
- */
- void setLast() {
- if (this.parentNode == null)
- return;
- if (this.nextNode != null) {
- Node prev = this.nextNode.getPreviousSibling();
- if (prev == null || prev.getNodeType() != Node.ELEMENT_NODE)
- return;
- ElementImpl element = (ElementImpl) prev;
- if (element.hasEndTag() || !element.isContainer() || element.isEmptyTag())
- return;
- setParentNode(prev);
- }
-
- // find last open parent
- Node parent = this.parentNode;
- Node last = parent.getLastChild();
- while (last != null) {
- if (last.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl element = (ElementImpl) last;
- if (element.hasEndTag() || !element.isContainer() || element.isEmptyTag())
- break;
- parent = element;
- last = parent.getLastChild();
- }
- if (parent != this.parentNode)
- setParentNode(parent);
- }
-
- /**
- * setNextNode method
- *
- * @param nextNode
- * org.w3c.dom.Node
- */
- void setNextNode(Node nextNode) {
- this.nextNode = nextNode;
- if (nextNode == null)
- return;
- this.parentNode = nextNode.getParentNode();
- }
-
- /**
- * setParentNode method
- *
- * @param parentNode
- * org.w3c.dom.Node
- */
- void setParentNode(Node parentNode) {
- this.parentNode = parentNode;
- this.nextNode = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifier.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifier.java
deleted file mode 100644
index 9a3e255aeb..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifier.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.document;
-
-
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- *
- * XMLModelNotifier manages the notification process. Clients should not use
- * extend or reference.
- *
- * ISSUE: should be internalized.
- */
-
-public interface XMLModelNotifier {
-
- /**
- * attrReplaced method
- *
- * @param element
- * org.w3c.dom.Element
- * @param newAttr
- * org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- void attrReplaced(Element element, Attr newAttr, Attr oldAttr);
-
- /**
- * Signal that changing is starting.
- *
- */
- void beginChanging();
-
- /**
- * Signal that changing is starting with a brand new model.
- *
- */
- void beginChanging(boolean newModel);
-
- /**
- * Cancel pending notifications. This is called in the context of
- * "reinitialization" so is assumed ALL notifications can be safely
- * canceled, assuming that once factories and adapters are re-initialized
- * they will be re-notified as text is set in model, if still appropriate.
- */
- void cancelPending();
-
- /**
- * childReplaced method
- *
- * @param parentNode
- * org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- void childReplaced(Node parentNode, Node newChild, Node oldChild);
-
- /**
- * Editable state changed for node.
- *
- */
- void editableChanged(Node node);
-
- /**
- * Signal changing is finished.
- *
- */
- void endChanging();
-
- /**
- * Signal end tag changed.
- *
- * @param element
- *
- */
- void endTagChanged(Element element);
-
- /**
- * Used to reflect state of model.
- *
- * @return true if model had changed.
- *
- */
- boolean hasChanged();
-
- /**
- * Used to reflect state of parsing process.
- *
- * @return true if model is currently changing.
- */
- boolean isChanging();
-
- /**
- * signal property changed
- *
- * @param node
- */
- void propertyChanged(Node node);
-
- /**
- * signal start tag changed
- *
- * @param element
- */
- void startTagChanged(Element element);
-
- /**
- * signal structured changed.
- *
- * @param node
- */
- void structureChanged(Node node);
-
- /**
- * valueChanged method
- *
- * @param node
- * org.w3c.dom.Node
- */
- void valueChanged(Node node);
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifierImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifierImpl.java
deleted file mode 100644
index 75f89a089b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelNotifierImpl.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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.document;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class XMLModelNotifierImpl implements XMLModelNotifier {
-
- private static class NotifyEvent {
- Object changedFeature;
- boolean discarded;
- Object newValue;
- // note: don't initialize instance variables, since
- // that causes double assignments, and lots of these are created.
- INodeNotifier notifier;
- Object oldValue;
- int pos;
- String reason;
- int type;
- int index;
-
- NotifyEvent(INodeNotifier notifier, int type, Object changedFeature, Object oldValue, Object newValue, int pos) {
- this.notifier = notifier;
- this.type = type;
- this.changedFeature = changedFeature;
- this.oldValue = oldValue;
- this.newValue = newValue;
- this.pos = pos;
- this.reason = ""; //$NON-NLS-1$
- }
- }
-
- private final static String ADDED_THEN_REMOVED = "Discard: Added then removed rule"; //$NON-NLS-1$
- private final static boolean fOptimizeDeferred = true;
- private final static boolean fOptimizeDeferredAccordingToParentAdded = true;
- private final static boolean fOptimizeDeferredAccordingToParentRemoved = true;
- private final static String PARENT_IS_ADDED = "Disarded: Parent has just been added"; //$NON-NLS-1$
- /* start: for debugging only */
- private final static String PARENT_IS_REMOVED_TOO = "Discard: Parent was removed too"; //$NON-NLS-1$
- private final static String PARENT_IS_REPARENTED = "Not Discard: Parent was removed so this implies reparenting"; //$NON-NLS-1$
- private Node changedRoot = null;
-
- private boolean changing = false;
- private boolean doingNewModel = false;
- private List fEvents = null;
- private boolean flushing = false;
-
- /**
- */
- public XMLModelNotifierImpl() {
- super();
- }
-
- /**
- * attrReplaced method
- *
- * @param element
- * org.w3c.dom.Element
- * @param newAttr
- * org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- public void attrReplaced(Element element, Attr newAttr, Attr oldAttr) {
- if (element == null)
- return;
- Attr attr = null;
- String oldValue = null;
- String newValue = null;
- if (oldAttr != null) {
- attr = oldAttr;
- oldValue = oldAttr.getValue();
- }
- if (newAttr != null) {
- attr = newAttr;
- newValue = newAttr.getValue();
- }
- IDOMNode notifier = (IDOMNode) element;
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, attr, oldValue, newValue, offset);
- propertyChanged(notifier);
- }
-
- /**
- */
- public void beginChanging() {
- this.changing = true;
- }
-
- /**
- */
- public void beginChanging(boolean newModel) {
- beginChanging();
- this.doingNewModel = newModel;
- }
-
- public void cancelPending() {
- // we don't want to change the size of this array, since
- // the array may be being processed, in the deferred notification
- // loop, but we can signal that all
- // should be discarded, so any remaining ones will be ignored.
- if (this.fEvents != null) {
- int size = fEvents.size();
- for (int i = 0; i < size; i++) {
- NotifyEvent event = (NotifyEvent) fEvents.get(i);
- event.discarded = true;
- }
- }
- // this cancel is presumably being called as a function of
- // "reinitiailization" so we can ignore changes to the
- // old root, and changes to the new one will be triggered during
- // reinitialization.
- changedRoot = null;
- }
-
- /**
- * childReplaced method
- *
- * @param parentNode
- * org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- public void childReplaced(Node parentNode, Node newChild, Node oldChild) {
- if (parentNode == null)
- return;
- IDOMNode notifier = (IDOMNode) parentNode;
- int type = INodeNotifier.CHANGE;
- if (newChild == null)
- type = INodeNotifier.REMOVE;
- else if (oldChild == null)
- type = INodeNotifier.ADD;
- int offset = notifier.getStartOffset();
- notify(notifier, type, oldChild, oldChild, newChild, offset);
- structureChanged(notifier);
- }
-
- public void editableChanged(Node node) {
- if (node == null)
- return;
- IDOMNode notifier = (IDOMNode) node;
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, null, null, null, offset);
- propertyChanged(notifier);
- }
-
- /**
- */
- public void endChanging() {
- this.doingNewModel = false;
- if (!this.changing)
- return; // avoid nesting calls
- notifyDeferred();
- if (this.changedRoot != null) {
- notifyStructureChanged(this.changedRoot);
- if (Debug.debugNotifyDeferred) {
- String p = this.changedRoot.getNodeName();
- System.out.println("Deferred STRUCTURE_CHANGED: " + p); //$NON-NLS-1$
- }
- this.changedRoot = null;
- }
- this.changing = false;
- }
-
- /**
- */
- public void endTagChanged(Element element) {
- if (element == null)
- return;
- IDOMNode notifier = (IDOMNode) element;
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, null, null, null, offset);
- propertyChanged(element);
- }
-
- /**
- */
- public boolean hasChanged() {
- return (this.fEvents != null);
- }
-
- /**
- */
- public boolean isChanging() {
- return this.changing;
- }
-
- /**
- */
- private void notify(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (notifier == null)
- return;
- if (this.changing && !this.flushing) {
- // defer notification
- if (this.fEvents == null)
- this.fEvents = new ArrayList();
- // we do not defer anything if we are doing a new Model,
- // except for the document event, since all others are
- // trivial and not needed at that initial point.
- // But even for that one document event, in the new model case,
- // it is still important to defer it.
- if ((!doingNewModel) || (((Node) notifier).getNodeType() == Node.DOCUMENT_NODE)) {
- this.fEvents.add(new NotifyEvent(notifier, eventType, changedFeature, oldValue, newValue, pos));
- }
- return;
- }
- try {
- // Its important to "keep going" if exception occurs, since this
- // notification
- // comes in between "about to change" and "changed" events. We do
- // log, however,
- // since would indicate a program error.
- notifier.notify(eventType, changedFeature, oldValue, newValue, pos);
- } catch (Exception e) {
- Logger.logException("A structured model client threw following exception during adapter notification (" + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " )", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- */
- private void notifyDeferred() {
- if (this.fEvents == null)
- return;
- if (this.flushing)
- return;
- this.flushing = true; // force notification
- int count = this.fEvents.size();
-
- if (!doingNewModel && fOptimizeDeferred) {
- Map notifyEvents = new HashMap();
- for (int i = 0; i < count; i++) {
- NotifyEvent event = (NotifyEvent) this.fEvents.get(i);
- if (event == null)
- continue; // error
- event.index = i;
- if(event.type == INodeNotifier.REMOVE) {
- addToMap(event.oldValue, event, notifyEvents);
- }
- if(event.type == INodeNotifier.ADD) {
- addToMap(event.newValue, event, notifyEvents);
- }
- }
- Iterator it = notifyEvents.values().iterator();
- while (it.hasNext()) {
- NotifyEvent[] es = (NotifyEvent[]) it.next();
- for (int i = 0; i < es.length - 1; i++) {
- NotifyEvent event = es[i];
- if(es[i].discarded) continue;
- NotifyEvent next = es[i + 1];
- if(es[i].type == INodeNotifier.ADD && next.type == INodeNotifier.REMOVE) {
- // Added then removed later, discard both
- event.discarded = true;
- next.discarded = true;
- if (Debug.debugNotifyDeferred) {
- event.reason = event.reason + ADDED_THEN_REMOVED + "(see " + next.index + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- next.reason = next.reason + ADDED_THEN_REMOVED + "(see " + event.index + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
- for (int i = 0; i < count; i++) {
- NotifyEvent event = (NotifyEvent) this.fEvents.get(i);
- if (event == null)
- continue; // error
- if(event.discarded) continue;
- if (event.notifier != null && fOptimizeDeferredAccordingToParentAdded) {
- if (event.type == INodeNotifier.ADD) {
- NotifyEvent[] es = (NotifyEvent[])notifyEvents.get(event.notifier);
- if(es != null) for (int p = 0; p < es.length && es[p].index < event.index; p++) {
- NotifyEvent prev = es[p];
- if (prev.type == INodeNotifier.REMOVE && prev.oldValue == event.notifier) {
- // parent is reparented, do not discard
- if (Debug.debugNotifyDeferred) {
- event.reason = event.reason + PARENT_IS_REPARENTED + "(see " + prev.index + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- break;
- } else if (prev.type == INodeNotifier.ADD && prev.newValue == event.notifier) {
- // parent has been added, discard this
- event.discarded = true;
- if (Debug.debugNotifyDeferred) {
- event.reason = event.reason + PARENT_IS_ADDED + "(see " + prev.index + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- break;
- }
- }
- }
- }
- if(event.discarded) continue;
- if (event.notifier != null && fOptimizeDeferredAccordingToParentRemoved) {
- if (event.type == INodeNotifier.REMOVE) {
- NotifyEvent[] es = (NotifyEvent[])notifyEvents.get(event.notifier);
- if(es != null) for (int n = 0; n < es.length; n++) {
- NotifyEvent next = es[n];
- if(next.index > event.index && next.type == INodeNotifier.REMOVE) {
- if (next.oldValue == event.notifier) {
- // parent will be removed, discard this
- event.discarded = true;
- if (Debug.debugNotifyDeferred) {
- event.reason = event.reason + PARENT_IS_REMOVED_TOO + "(see " + next.index + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- break;
- }
- }
- }
- }
- }
- if(event.discarded) continue;
- }
- }
- for (int i = 0; i < count; i++) {
- NotifyEvent event = (NotifyEvent) this.fEvents.get(i);
- if (event == null)
- continue; // error
- if(event.discarded) continue;
- notify(event.notifier, event.type, event.changedFeature, event.oldValue, event.newValue, event.pos);
- }
- if (Debug.debugNotifyDeferred) {
- for (int l = 0; l < count; l++) {
- NotifyEvent event = (NotifyEvent) this.fEvents.get(l);
- Object o = null;
- String t = null;
- if (event.type == INodeNotifier.ADD) {
- o = event.newValue;
- t = " + "; //$NON-NLS-1$
- } else if (event.type == INodeNotifier.REMOVE) {
- o = event.oldValue;
- t = " - "; //$NON-NLS-1$
- }
- if (o instanceof Element) {
- String p = ((Node) event.notifier).getNodeName();
- String c = ((Node) o).getNodeName();
- String d = (event.discarded ? "! " : " "); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println(d + p + t + c);
- }
- }
- }
- this.flushing = false;
- this.fEvents = null;
- }
-
- void addToMap(Object o, NotifyEvent event, Map map) {
- if(o == null) return;
- Object x = map.get(o);
- if(x == null) {
- map.put(o, new NotifyEvent[]{event});
- } else {
- NotifyEvent[] es = (NotifyEvent[])x;
- NotifyEvent[] es2 = new NotifyEvent[es.length + 1];
- System.arraycopy(es, 0, es2, 0, es.length);
- es2[es.length] = event;
- map.put(o, es2);
- }
- }
-
- /**
- */
- private void notifyStructureChanged(Node root) {
- if (root == null)
- return;
- INodeNotifier notifier = (INodeNotifier) root;
- try {
- // Its important to "keep going" if exception occurs, since this
- // notification
- // comes in between "about to change" and "changed" events. We do
- // log, however,
- // since would indicate a program error.
- notifier.notify(INodeNotifier.STRUCTURE_CHANGED, null, null, null, -1);
- } catch (Exception e) {
- Logger.logException("A structured model client threw following exception during adapter notification (" + INodeNotifier.EVENT_TYPE_STRINGS[INodeNotifier.STRUCTURE_CHANGED] + " )", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- /**
- */
- public void propertyChanged(Node node) {
- }
-
- /**
- * @param node
- */
- private void setCommonRootIfNeeded(Node node) {
- // defer notification
- if (this.changedRoot == null) {
- this.changedRoot = node;
- } else {
- // tiny optimization: if previous commonAncestor (changedRoot) is
- // already 'document',
- // or if already equal to this 'node',
- // then no need to re-calculate
- if (changedRoot.getNodeType() != Node.DOCUMENT_NODE && changedRoot != node) {
- Node common = ((NodeImpl) this.changedRoot).getCommonAncestor(node);
- if (common != null)
- this.changedRoot = common;
- else
- this.changedRoot = node;
- }
- }
- }
-
- /**
- */
- public void startTagChanged(Element element) {
- if (element == null)
- return;
- IDOMNode notifier = (IDOMNode) element;
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, null, null, null, offset);
- propertyChanged(element);
- }
-
- /**
- */
- public void structureChanged(Node node) {
- if (node == null)
- return;
- if (isChanging()) {
- setCommonRootIfNeeded(node);
- if (Debug.debugNotifyDeferred) {
- String p = this.changedRoot.getNodeName();
- System.out.println("requested STRUCTURE_CHANGED: " + p); //$NON-NLS-1$
- }
- return;
- }
- if (Debug.debugNotifyDeferred) {
- String p = node.getNodeName();
- System.out.println("STRUCTURE_CHANGED: " + p); //$NON-NLS-1$
- }
- notifyStructureChanged(node);
- }
-
- /**
- * valueChanged method
- *
- * @param node
- * org.w3c.dom.Node
- */
- public void valueChanged(Node node) {
- if (node == null)
- return;
- IDOMNode notifier = null;
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- notifier = (IDOMNode) attr.getOwnerElement();
- // TODO_dmw: experimental: changed 06/29/2004 to send "structuure
- // changed" even for attribute value changes
- // there are pros and cons to considering attribute value
- // "structure changed". Will (re)consider
- // setCommonRootIfNeeded(notifier);
- if (notifier == null)
- return;
- String value = attr.getValue();
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, attr, null, value, offset);
- } else {
- // note: we do not send structured changed event for content
- // changed
- notifier = (IDOMNode) node;
- String value = node.getNodeValue();
- int offset = notifier.getStartOffset();
- notify(notifier, INodeNotifier.CHANGE, null, null, value, offset);
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- IDOMNode parent = (IDOMNode) node.getParentNode();
- if (parent != null) {
- notify(parent, INodeNotifier.CONTENT_CHANGED, node, null, value, offset);
- }
- }
- }
- propertyChanged(notifier);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelParser.java
deleted file mode 100644
index 9f893bb53c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelParser.java
+++ /dev/null
@@ -1,2422 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.document;
-
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementConfiguration;
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementRegistry;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-/**
- * XMLModelParser
- */
-public class XMLModelParser {
- private XMLModelContext context = null;
- private DOMModelImpl model = null;
- private TextImpl lastTextNode = null;
-
- /**
- */
- protected XMLModelParser(DOMModelImpl model) {
- super();
-
- if (model != null) {
- this.model = model;
- }
- }
-
- /**
- */
- protected boolean canBeImplicitTag(Element element) {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.canBeImplicitTag(element);
- }
- return false;
- }
-
- /**
- */
- protected boolean canBeImplicitTag(Element element, Node child) {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.canBeImplicitTag(element, child);
- }
- return false;
- }
-
- /**
- */
- protected boolean canContain(Element element, Node child) {
- if (element == null || child == null)
- return false;
- ElementImpl impl = (ElementImpl) element;
- if (impl.isEndTag())
- return false; // invalid (floating) end tag
- if (!impl.isContainer())
- return false;
- if (child.getNodeType() != Node.TEXT_NODE) {
- if (impl.isJSPContainer() || impl.isCDATAContainer()) {
- // accepts only Text child
- return false;
- }
- }
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.canContain(element, child);
- }
- return true;
- }
-
- /**
- */
- private void changeAttrEqual(IStructuredDocumentRegion flatNode, ITextRegion region) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return;
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return;
- Node node = root.getNodeAt(offset);
- if (node == null)
- return;
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- // just notify the change instead of setting data
- ProcessingInstructionImpl pi = (ProcessingInstructionImpl) node;
- pi.notifyValueChanged();
- }
- return;
- }
- // actually, do nothing
- }
-
- /**
- * changeAttrName method
- *
- */
- private void changeAttrName(IStructuredDocumentRegion flatNode, ITextRegion region) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return;
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return;
- Node node = root.getNodeAt(offset);
- if (node == null)
- return;
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- // just notify the change instead of setting data
- ProcessingInstructionImpl pi = (ProcessingInstructionImpl) node;
- pi.notifyValueChanged();
- }
- return;
- }
-
- ElementImpl element = (ElementImpl) node;
- NamedNodeMap attributes = element.getAttributes();
- if (attributes == null)
- return;
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) attributes.item(i);
- if (attr == null)
- continue;
- if (attr.getNameRegion() != region)
- continue;
-
- String name = flatNode.getText(region);
- attr.setName(name);
- break;
- }
- }
-
- /**
- * changeAttrValue method
- *
- */
- private void changeAttrValue(IStructuredDocumentRegion flatNode, ITextRegion region) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return;
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return;
- Node node = root.getNodeAt(offset);
- if (node == null)
- return;
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- // just notify the change instead of setting data
- ProcessingInstructionImpl pi = (ProcessingInstructionImpl) node;
- pi.notifyValueChanged();
- }
- return;
- }
-
- ElementImpl element = (ElementImpl) node;
- NamedNodeMap attributes = element.getAttributes();
- if (attributes == null)
- return;
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) attributes.item(i);
- if (attr == null)
- continue;
- if (attr.getValueRegion() != region)
- continue;
- // just notify the change instead of setting value
- attr.notifyValueChanged();
- break;
- }
- }
-
- /**
- * changeData method
- *
- */
- private void changeData(IStructuredDocumentRegion flatNode, ITextRegion region) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return;
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return;
- Node node = root.getNodeAt(offset);
- if (node == null)
- return;
- switch (node.getNodeType()) {
- case Node.TEXT_NODE : {
- TextImpl text = (TextImpl) node;
- if (text.isSharingStructuredDocumentRegion(flatNode)) {
- // has consecutive text sharing IStructuredDocumentRegion
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- this.context.setNextNode(node);
- cleanupText();
- break;
- }
- case Node.CDATA_SECTION_NODE :
- case Node.PROCESSING_INSTRUCTION_NODE :
- break;
- case Node.COMMENT_NODE :
- case Node.ELEMENT_NODE :
- // comment tag
- changeStructuredDocumentRegion(flatNode);
- return;
- default :
- return;
- }
-
- // just notify the change instead of setting data
- NodeImpl impl = (NodeImpl) node;
- impl.notifyValueChanged();
- }
-
- /**
- */
- private void changeEndTag(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return; // error
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return; // error
- Node node = root.getNodeAt(offset);
- if (node == null)
- return; // error
-
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- changeStructuredDocumentRegion(flatNode);
- return;
- }
-
- // check if change is only for close tag
- if (newRegions != null) {
- Iterator e = newRegions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_CLOSE)
- continue;
-
- // other region has changed
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- }
- if (oldRegions != null) {
- Iterator e = oldRegions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_CLOSE)
- continue;
-
- // other region has changed
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- }
-
- // change for close tag has no impact
- // do nothing
- }
-
- /**
- * changeRegion method
- *
- */
- void changeRegion(RegionChangedEvent change, IStructuredDocumentRegion flatNode, ITextRegion region) {
- if (flatNode == null || region == null)
- return;
- if (this.model.getDocument() == null)
- return;
- this.context = new XMLModelContext(this.model.getDocument());
-
- //determine if change was whitespace only change
- boolean isWhitespaceChange = false;
- if(change.getText() != null && change.getText().length() > 0) {
- isWhitespaceChange = Character.isWhitespace(change.getText().charAt(0));
- } else if(change.getDeletedText() != null && change.getDeletedText().length() > 0) {
- isWhitespaceChange = Character.isWhitespace(change.getDeletedText().charAt(0));
- }
-
- // optimize typical cases
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_CONTENT || regionType == DOMRegionContext.XML_COMMENT_TEXT || regionType == DOMRegionContext.XML_CDATA_TEXT || regionType == DOMRegionContext.BLOCK_TEXT || isNestedContent(regionType)) {
- changeData(flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- if (isWhitespaceChange && (change.getOffset() >= flatNode.getStartOffset() + region.getTextEnd())) {
- // change is entirely in white-space
- return;
- }
- changeAttrName(flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- if (isWhitespaceChange && (change.getOffset() >= flatNode.getStartOffset() + region.getTextEnd())) {
- // change is entirely in white-space
- return;
- }
- changeAttrValue(flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- if (isWhitespaceChange && (change.getOffset() >= flatNode.getStartOffset() + region.getTextEnd())) {
- // change is entirely in white-space
- return;
- }
- changeAttrEqual(flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedTagName(regionType)) {
- if (isWhitespaceChange && (change.getOffset() >= flatNode.getStartOffset() + region.getTextEnd())) {
- // change is entirely in white-space
- return;
- }
- changeTagName(flatNode, region);
- }
- else {
- changeStructuredDocumentRegion(flatNode);
- }
- }
-
-
-
- /**
- */
- private void changeStartTag(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return; // error
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return; // error
- Node node = root.getNodeAt(offset);
- if (node == null)
- return; // error
-
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- ElementImpl element = (ElementImpl) node;
-
- // check if changes are only for attributes and close tag
- boolean tagNameUnchanged = false;
- if (newRegions != null) {
- Iterator e = newRegions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS || regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- continue;
- if (regionType == DOMRegionContext.XML_TAG_CLOSE) {
- // change from empty tag may have impact on structure
- if (!element.isEmptyTag())
- continue;
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedTagName(regionType)) {
- String oldTagName = element.getTagName();
- String newTagName = flatNode.getText(region);
- if (oldTagName != null && newTagName != null && oldTagName.equals(newTagName)) {
- // the tag name is unchanged
- tagNameUnchanged = true;
- continue;
- }
- }
-
- // other region has changed
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- }
- if (oldRegions != null) {
- Iterator e = oldRegions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS || regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- continue;
- if (regionType == DOMRegionContext.XML_TAG_CLOSE) {
- // change from empty tag may have impact on structure
- if (!element.isEmptyTag())
- continue;
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedTagName(regionType)) {
- // if new tag name is unchanged, it's OK
- if (tagNameUnchanged)
- continue;
- }
-
- // other region has changed
- changeStructuredDocumentRegion(flatNode);
- return;
- }
- }
-
- // update attributes
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return; // error
- NamedNodeMap attributes = element.getAttributes();
- if (attributes == null)
- return; // error
-
- // first remove attributes
- int regionIndex = 0;
- int attrIndex = 0;
- AttrImpl attr = null;
- while (attrIndex < attributes.getLength()) {
- attr = (AttrImpl) attributes.item(attrIndex);
- if (attr == null) { // error
- attrIndex++;
- continue;
- }
- ITextRegion nameRegion = attr.getNameRegion();
- if (nameRegion == null) { // error
- element.removeAttributeNode(attr);
- continue;
- }
- boolean found = false;
- for (int i = regionIndex; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (region == nameRegion) {
- regionIndex = i + 1; // next region
- found = true;
- break;
- }
- }
- if (found) {
- attrIndex++;
- }
- else {
- element.removeAttributeNode(attr);
- }
- }
-
- // insert or update attributes
- attrIndex = 0; // reset to first
- AttrImpl newAttr = null;
- ITextRegion oldValueRegion = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- if (newAttr != null) {
- // insert deferred new attribute
- element.insertAttributeNode(newAttr, attrIndex++);
- newAttr = null;
- }
- else if (attr != null && oldValueRegion != null) {
- // notify existing attribute value removal
- attr.notifyValueChanged();
- }
-
- oldValueRegion = null;
- attr = (AttrImpl) attributes.item(attrIndex);
- if (attr != null && attr.getNameRegion() == region) {
- // existing attribute
- attrIndex++;
- // clear other regions
- oldValueRegion = attr.getValueRegion();
- attr.setEqualRegion(null);
- attr.setValueRegion(null);
- }
- else {
- String name = flatNode.getText(region);
- attr = (AttrImpl) this.model.getDocument().createAttribute(name);
- if (attr != null)
- attr.setNameRegion(region);
- // defer insertion of new attribute
- newAttr = attr;
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- if (attr != null) {
- attr.setEqualRegion(region);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- if (attr != null) {
- attr.setValueRegion(region);
- if (attr != newAttr && oldValueRegion != region) {
- // notify existing attribute value changed
- attr.notifyValueChanged();
- }
- oldValueRegion = null;
- attr = null;
- }
- }
- }
-
- if (newAttr != null) {
- // insert deferred new attribute
- element.appendAttributeNode(newAttr);
- }
- else if (attr != null && oldValueRegion != null) {
- // notify existing attribute value removal
- attr.notifyValueChanged();
- }
- }
-
- /**
- * changeStructuredDocumentRegion method
- *
- */
- private void changeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return;
- if (this.model.getDocument() == null)
- return;
-
- setupContext(flatNode);
-
- removeStructuredDocumentRegion(flatNode);
- // make sure the parent is set to deepest level
- // when end tag has been removed
- this.context.setLast();
- insertStructuredDocumentRegion(flatNode);
-
- cleanupText();
- cleanupEndTag();
- }
-
- /**
- */
- private void changeTagName(IStructuredDocumentRegion flatNode, ITextRegion region) {
- int offset = flatNode.getStart();
- if (offset < 0)
- return; // error
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return; // error
- Node node = root.getNodeAt(offset);
- if (node == null)
- return; // error
-
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- changeStructuredDocumentRegion(flatNode);
- return;
- }
-
- ElementImpl element = (ElementImpl) node;
- String newTagName = flatNode.getText(region);
- if (newTagName == null || !element.matchTagName(newTagName)) {
- // the tag name is changed
- changeStructuredDocumentRegion(flatNode);
- return;
- }
-
- // the tag name is unchanged
- // this happens when typing spaces after the tag name
- // do nothing, but...
- // if it's not a change in the end tag of an element with the start
- // tag,
- // and case has been changed, set to element and notify
- if (!element.hasStartTag() || StructuredDocumentRegionUtil.getFirstRegionType(flatNode) != DOMRegionContext.XML_END_TAG_OPEN) {
- String tagName = element.getTagName();
- if (tagName == null || !tagName.equals(newTagName)) {
- element.setTagName(newTagName);
- element.notifyValueChanged();
- }
- }
- }
-
- /**
- * cleanupContext method
- */
- private void cleanupEndTag() {
- Node parent = this.context.getParentNode();
- Node next = this.context.getNextNode();
- while (parent != null) {
- while (next != null) {
- if (next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) next;
- if (element.isEndTag()) {
- // floating end tag
- String tagName = element.getTagName();
- String rootName = getFindRootName(tagName);
- ElementImpl start = (ElementImpl) this.context.findStartTag(tagName, rootName);
- if (start != null) {
- insertEndTag(start);
- // move the end tag from 'element' to 'start'
- start.addEndTag(element);
- removeNode(element);
- parent = this.context.getParentNode();
- next = this.context.getNextNode();
- continue;
- }
- }
- }
-
- Node first = next.getFirstChild();
- if (first != null) {
- parent = next;
- next = first;
- this.context.setNextNode(next);
- }
- else {
- next = next.getNextSibling();
- this.context.setNextNode(next);
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- if (!element.hasEndTag() && element.hasStartTag() && element.getNextSibling() == null) {
- String tagName = element.getTagName();
- ElementImpl end = (ElementImpl) this.context.findEndTag(tagName);
- if (end != null) {
- // move the end tag from 'end' to 'element'
- element.addEndTag(end);
- removeEndTag(end);
- this.context.setParentNode(parent); // reset context
- continue;
- }
- }
- }
-
- next = parent.getNextSibling();
- parent = parent.getParentNode();
- if (next != null) {
- this.context.setNextNode(next);
- }
- else {
- this.context.setParentNode(parent);
- }
- }
- }
-
- /**
- */
- private void cleanupText() {
- if (lastTextNode != null) {
- lastTextNode.notifyValueChanged();
- lastTextNode = null;
- }
- Node parent = this.context.getParentNode();
- if (parent == null)
- return; // error
- Node next = this.context.getNextNode();
- Node prev = (next == null ? parent.getLastChild() : next.getPreviousSibling());
-
- TextImpl nextText = null;
- TextImpl prevText = null;
- if (next != null && next.getNodeType() == Node.TEXT_NODE) {
- nextText = (TextImpl) next;
- }
- if (prev != null && prev.getNodeType() == Node.TEXT_NODE) {
- prevText = (TextImpl) prev;
- }
- if (nextText == null && prevText == null)
- return;
- if (nextText != null && prevText != null) {
- // consecutive Text nodes created by setupContext(),
- // concat them
- IStructuredDocumentRegion flatNode = nextText.getStructuredDocumentRegion();
- if (flatNode != null)
- prevText.appendStructuredDocumentRegion(flatNode);
- Node newNext = next.getNextSibling();
- parent.removeChild(next);
- next = null;
- this.context.setNextNode(newNext);
- }
-
- TextImpl childText = (prevText != null ? prevText : nextText);
- if (childText.getNextSibling() == null && childText.getPreviousSibling() == null) {
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl parentElement = (ElementImpl) parent;
- if (!parentElement.hasStartTag() && !parentElement.hasEndTag()) {
- if (childText.isWhitespace() || childText.isInvalid()) {
- // implicit parent is not required
- Node newParent = parent.getParentNode();
- if (newParent != null) {
- Node newNext = parent.getNextSibling();
- newParent.removeChild(parent);
- parent.removeChild(childText);
- newParent.insertBefore(childText, newNext);
- if (childText == next) {
- this.context.setNextNode(childText);
- }
- else if (newNext != null) {
- this.context.setNextNode(newNext);
- }
- else {
- this.context.setParentNode(newParent);
- }
- // try again
- cleanupText();
- }
- }
- }
- }
- }
- }
-
- /**
- * This routine create an Element from comment data for comment style
- * elements, such as SSI and METADATA
- */
- protected Element createCommentElement(String data, boolean isJSPTag) {
- String trimmedData = data.trim();
- CommentElementConfiguration[] configs = CommentElementRegistry.getInstance().getConfigurations();
- for (int iConfig = 0; iConfig < configs.length; iConfig++) {
- CommentElementConfiguration config = configs[iConfig];
- if ((isJSPTag && !config.acceptJSPComment()) || (!isJSPTag && !config.acceptXMLComment())) {
- continue;
- }
- String[] prefixes = config.getPrefix();
- for (int iPrefix = 0; iPrefix < prefixes.length; iPrefix++) {
- if (trimmedData.startsWith(prefixes[iPrefix])) {
- return config.createElement(this.model.getDocument(), data, isJSPTag);
- }
- }
- }
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.createCommentElement(this.model.getDocument(), data, isJSPTag);
- }
- return null;
- }
-
- /**
- * This routine create an implicit Element for given parent and child,
- * such as HTML, BODY, HEAD, and TBODY for HTML document.
- */
- protected Element createImplicitElement(Node parent, Node child) {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.createImplicitElement(this.model.getDocument(), parent, child);
- }
- return null;
- }
-
- /**
- */
- private void demoteNodes(Node root, Node newParent, Node oldParent, Node next) {
- if (newParent.getNodeType() != Node.ELEMENT_NODE)
- return;
- ElementImpl newElement = (ElementImpl) newParent;
-
- // find next
- while (next == null) {
- if (oldParent.getNodeType() != Node.ELEMENT_NODE)
- return;
- ElementImpl oldElement = (ElementImpl) oldParent;
- if (oldElement.hasEndTag())
- return;
- oldParent = oldElement.getParentNode();
- if (oldParent == null)
- return; // error
- next = oldElement.getNextSibling();
- }
-
- while (next != null) {
- boolean done = false;
- if (next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl nextElement = (ElementImpl) next;
- if (!nextElement.hasStartTag()) {
- Node nextChild = nextElement.getFirstChild();
- if (nextChild != null) {
- // demote children
- next = nextChild;
- oldParent = nextElement;
- continue;
- }
-
- if (nextElement.hasEndTag()) {
- if (nextElement.matchEndTag(newElement)) {
- // stop at the matched invalid end tag
- next = nextElement.getNextSibling();
- oldParent.removeChild(nextElement);
- newElement.addEndTag(nextElement);
-
- if (newElement == root)
- return;
- Node p = newElement.getParentNode();
- // check if reached to top
- if (p == null || p == oldParent || p.getNodeType() != Node.ELEMENT_NODE)
- return;
- newElement = (ElementImpl) p;
- done = true;
- }
- }
- else {
- // remove implicit element
- next = nextElement.getNextSibling();
- oldParent.removeChild(nextElement);
- done = true;
- }
- }
- }
-
- if (!done) {
- if (!canContain(newElement, next)) {
- if (newElement == root)
- return;
- Node p = newElement.getParentNode();
- // check if reached to top
- if (p == null || p == oldParent || p.getNodeType() != Node.ELEMENT_NODE)
- return;
- newElement = (ElementImpl) p;
- continue;
- }
-
- Node child = next;
- next = next.getNextSibling();
- oldParent.removeChild(child);
- insertNode(newElement, child, null);
- Node childParent = child.getParentNode();
- if (childParent != newElement) {
- newElement = (ElementImpl) childParent;
- }
- }
-
- // find next parent and sibling
- while (next == null) {
- if (oldParent.getNodeType() != Node.ELEMENT_NODE)
- return;
- ElementImpl oldElement = (ElementImpl) oldParent;
-
- // dug parent must not have children at this point
- if (!oldElement.hasChildNodes() && !oldElement.hasStartTag()) {
- oldParent = oldElement.getParentNode();
- if (oldParent == null)
- return; // error
- next = oldElement;
- break;
- }
-
- if (oldElement.hasEndTag())
- return;
- oldParent = oldElement.getParentNode();
- if (oldParent == null)
- return; // error
- next = oldElement.getNextSibling();
- }
- }
- }
-
- private ModelParserAdapter getParserAdapter() {
- return (ModelParserAdapter) this.model.getDocument().getAdapterFor(ModelParserAdapter.class);
- }
-
- /**
- */
- protected String getFindRootName(String tagName) {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.getFindRootName(tagName);
- }
- return null;
- }
-
- /**
- */
- protected final IDOMModel getModel() {
- return this.model;
- }
-
- /**
- * insertCDATASection method
- *
- */
- private void insertCDATASection(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- CDATASectionImpl cdata = null;
- try {
- cdata = (CDATASectionImpl) this.model.getDocument().createCDATASection(null);
- }
- catch (DOMException ex) {
- }
- if (cdata == null) { // CDATA section might not be supported
- insertInvalidDecl(flatNode); // regard as invalid decl
- return;
- }
-
- cdata.setStructuredDocumentRegion(flatNode);
- insertNode(cdata);
- }
-
- /**
- * insertComment method
- *
- */
- private void insertComment(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- StringBuffer data = null;
- boolean isJSPTag = false;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (isNestedCommentOpen(regionType)) {
- isJSPTag = true;
- }
- else if (regionType == DOMRegionContext.XML_COMMENT_TEXT || isNestedCommentText(regionType)) {
- if (data == null) {
- data = new StringBuffer(flatNode.getText(region));
- }
- else {
- data.append(flatNode.getText(region));
- }
- }
- }
-
- if (data != null) {
- ElementImpl element = (ElementImpl) createCommentElement(data.toString(), isJSPTag);
- if (element != null) {
- if (!isEndTag(element)) {
- element.setStartStructuredDocumentRegion(flatNode);
- insertStartTag(element);
- return;
- }
-
- // end tag
- element.setEndStructuredDocumentRegion(flatNode);
-
- String tagName = element.getTagName();
- String rootName = getFindRootName(tagName);
- ElementImpl start = (ElementImpl) this.context.findStartTag(tagName, rootName);
- if (start != null) { // start tag found
- insertEndTag(start);
- start.addEndTag(element);
- return;
- }
-
- // invalid end tag
- insertNode(element);
- return;
- }
- }
-
- CommentImpl comment = (CommentImpl) this.model.getDocument().createComment(null);
- if (comment == null)
- return;
- if (isJSPTag)
- comment.setJSPTag(true);
- comment.setStructuredDocumentRegion(flatNode);
- insertNode(comment);
- }
-
- /**
- * insertDecl method
- *
- */
- private void insertDecl(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- boolean isDocType = false;
- String name = null;
- String publicId = null;
- String systemId = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_DOCTYPE_DECLARATION) {
- isDocType = true;
- }
- else if (regionType == DOMRegionContext.XML_DOCTYPE_NAME) {
- if (name == null)
- name = flatNode.getText(region);
- }
- else if (regionType == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF) {
- if (publicId == null)
- publicId = StructuredDocumentRegionUtil.getAttrValue(flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF) {
- if (systemId == null)
- systemId = StructuredDocumentRegionUtil.getAttrValue(flatNode, region);
- }
- }
-
- // invalid declaration
- if (!isDocType) {
- insertInvalidDecl(flatNode);
- return;
- }
-
- DocumentTypeImpl docType = (DocumentTypeImpl) this.model.getDocument().createDoctype(name);
- if (docType == null)
- return;
- if (publicId != null)
- docType.setPublicId(publicId);
- if (systemId != null)
- docType.setSystemId(systemId);
- docType.setStructuredDocumentRegion(flatNode);
- insertNode(docType);
- }
-
- /**
- * insertEndTag method can be used by subclasses, but not overrided.
- *
- * @param element
- * org.w3c.dom.Element
- */
- protected void insertEndTag(Element element) {
- if (element == null)
- return;
-
- Node newParent = element.getParentNode();
- if (newParent == null)
- return; // error
-
- if (!((ElementImpl) element).isContainer()) {
- // just update context
- Node elementNext = element.getNextSibling();
- if (elementNext != null)
- this.context.setNextNode(elementNext);
- else
- this.context.setParentNode(newParent);
- return;
- }
-
- // promote children
- Node newNext = element.getNextSibling();
- Node oldParent = this.context.getParentNode();
- if (oldParent == null)
- return; // error
- Node oldNext = this.context.getNextNode();
- promoteNodes(element, newParent, newNext, oldParent, oldNext);
-
- // update context
- // re-check the next sibling
- newNext = element.getNextSibling();
- if (newNext != null)
- this.context.setNextNode(newNext);
- else
- this.context.setParentNode(newParent);
- }
-
- /**
- * insertEndTag method
- *
- */
- private void insertEndTag(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- String tagName = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedTagName(regionType)) {
- if (tagName == null)
- tagName = flatNode.getText(region);
- }
- }
-
- if (tagName == null) { // invalid end tag
- insertText(flatNode); // regard as invalid text
- return;
- }
-
- String rootName = getFindRootName(tagName);
- ElementImpl start = (ElementImpl) this.context.findStartTag(tagName, rootName);
- if (start != null) { // start tag found
- insertEndTag(start);
- start.setEndStructuredDocumentRegion(flatNode);
- return;
- }
-
- // invalid end tag
- ElementImpl end = null;
- try {
- end = (ElementImpl) this.model.getDocument().createElement(tagName);
- }
- catch (DOMException ex) {
- }
- if (end == null) { // invalid end tag
- insertText(flatNode); // regard as invalid text
- return;
- }
- end.setEndStructuredDocumentRegion(flatNode);
- insertNode(end);
- }
-
- /**
- * insertEntityRef method
- *
- */
- private void insertEntityRef(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- String name = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_ENTITY_REFERENCE || regionType == DOMRegionContext.XML_CHAR_REFERENCE) {
- if (name == null)
- name = StructuredDocumentRegionUtil.getEntityRefName(flatNode, region);
- }
- }
-
- if (name == null) { // invalid entity
- insertText(flatNode);
- return;
- }
-
- // ISSUE: avoid this cast
- String value = ((DocumentImpl)this.model.getDocument()).getCharValue(name);
- if (value != null) { // character entity
- TextImpl text = (TextImpl) this.context.findPreviousText();
- if (text != null) { // existing text found
- // do not append data
- text.appendStructuredDocumentRegion(flatNode);
- // Adjacent text nodes, where changes were queued
- if (lastTextNode != null && lastTextNode != text)
- lastTextNode.notifyValueChanged();
- lastTextNode = text;
- return;
- }
-
- // new text
- text = (TextImpl) this.model.getDocument().createTextNode(null);
- if (text == null)
- return;
- text.setStructuredDocumentRegion(flatNode);
- insertNode(text);
- return;
- }
-
- // general entity reference
- EntityReferenceImpl ref = null;
- try {
- ref = (EntityReferenceImpl) this.model.getDocument().createEntityReference(name);
- }
- catch (DOMException ex) {
- }
- if (ref == null) { // entity reference might not be supported
- insertText(flatNode); // regard as invalid text
- return;
- }
-
- ref.setStructuredDocumentRegion(flatNode);
- insertNode(ref);
- }
-
- /**
- * insertInvalidDecl method
- *
- */
- private void insertInvalidDecl(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- ElementImpl element = null;
- try {
- element = (ElementImpl) this.model.getDocument().createElement("!");//$NON-NLS-1$
- }
- catch (DOMException ex) {
- }
- if (element == null) { // invalid tag
- insertText(flatNode); // regard as invalid text
- return;
- }
- element.setEmptyTag(true);
- element.setStartStructuredDocumentRegion(flatNode);
- insertNode(element);
- }
-
- /**
- * insertJSPTag method
- *
- */
- private void insertNestedTag(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- String tagName = null;
- AttrImpl attr = null;
- List attrNodes = null;
- boolean isCloseTag = false;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (isNestedTagOpen(regionType) || isNestedTagName(regionType)) {
- tagName = computeNestedTag(regionType, tagName, flatNode, region);
- }
- else if (isNestedTagClose(regionType)) {
- isCloseTag = true;
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- String name = flatNode.getText(region);
- attr = (AttrImpl) this.model.getDocument().createAttribute(name);
- if (attr != null) {
- attr.setNameRegion(region);
- if (attrNodes == null)
- attrNodes = new ArrayList();
- attrNodes.add(attr);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- if (attr != null) {
- attr.setEqualRegion(region);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- if (attr != null) {
- attr.setValueRegion(region);
- attr = null;
- }
- }
- }
-
- if (tagName == null) {
- if (isCloseTag) {
- // close JSP tag
- Node parent = this.context.getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl start = (ElementImpl) parent;
- if (start.isJSPContainer()) {
- insertEndTag(start);
- start.setEndStructuredDocumentRegion(flatNode);
- return;
- }
- }
- }
- // invalid JSP tag
- insertText(flatNode); // regard as invalid text
- return;
- }
-
- ElementImpl element = null;
- try {
- element = (ElementImpl) this.model.getDocument().createElement(tagName);
- }
- catch (DOMException ex) {
- }
- if (element == null) { // invalid tag
- insertText(flatNode); // regard as invalid text
- return;
- }
- if (attrNodes != null) {
- for (int i = 0; i < attrNodes.size(); i++) {
- element.appendAttributeNode((Attr) attrNodes.get(i));
- }
- }
- element.setJSPTag(true);
- element.setStartStructuredDocumentRegion(flatNode);
- insertStartTag(element);
- }
-
- protected boolean isNestedTagClose(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected boolean isNestedTagOpen(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected String computeNestedTag(String regionType, String tagName, IStructuredDocumentRegion structuredDocumentRegion, ITextRegion region) {
- return tagName;
- }
-
- /**
- * insertNode method
- *
- * @param child
- * org.w3c.dom.Node
- */
- private void insertNode(Node node) {
- if(node != null && this.context != null) {
- Node parent = this.context.getParentNode();
- if(parent != null) {
- Node next = this.context.getNextNode();
- // Reset parents which are closed container elements; should not be parents
- if(parent.getNodeType() == Node.ELEMENT_NODE) {
- String type = ((ElementImpl)parent).getStartStructuredDocumentRegion().getLastRegion().getType();
- if(((ElementImpl)parent).isContainer() && type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- next = parent.getNextSibling();
- parent = parent.getParentNode();
- }
- else {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- while (parent.getNodeType() == Node.ELEMENT_NODE && !adapter.canContain( (Element) parent, node) && adapter.isEndTagOmissible((Element) parent)) {
- next = parent.getNextSibling();
- parent = parent.getParentNode();
- }
- }
- }
- }
- insertNode(parent, node, next);
- next = node.getNextSibling();
- if (next != null) {
- this.context.setNextNode(next);
- } else {
- this.context.setParentNode(node.getParentNode());
- }
- }
- }
- }
-
- /**
- */
- private void insertNode(Node parent, Node node, Node next) {
- while (next != null && next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl nextElement = (ElementImpl) next;
- if (nextElement.hasStartTag())
- break;
- if (!canBeImplicitTag(nextElement, node))
- break;
- parent = nextElement;
- next = nextElement.getFirstChild();
- }
- Element implicitElement = createImplicitElement(parent, node);
- if (implicitElement != null)
- node = implicitElement;
- parent.insertBefore(node, next);
- }
-
- /**
- * insertPI method
- *
- */
- private void insertPI(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- String target = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_PI_CLOSE)
- continue;
- if (target == null)
- target = flatNode.getText(region);
- }
-
- ProcessingInstructionImpl pi = (ProcessingInstructionImpl) this.model.getDocument().createProcessingInstruction(target, null);
- if (pi == null)
- return;
- pi.setStructuredDocumentRegion(flatNode);
- insertNode(pi);
- }
-
- /**
- * insertStartTag method can be used by subclasses, but not overridden.
- *
- * @param element
- * org.w3c.dom.Element
- */
- protected void insertStartTag(Element element) {
- if (element == null)
- return;
- if (this.context == null)
- return;
-
- insertNode(element);
-
- ElementImpl newElement = (ElementImpl) element;
- if (newElement.isEmptyTag() || !newElement.isContainer())
- return;
-
- // Ignore container tags that have been closed
- String type = newElement.getStartStructuredDocumentRegion().getLastRegion().getType();
- if(newElement.isContainer() && type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
- return;
-
- // demote siblings
- Node parent = this.context.getParentNode();
- if (parent == null)
- return; // error
- Node next = this.context.getNextNode();
- demoteNodes(element, element, parent, next);
-
- // update context
- Node firstChild = element.getFirstChild();
- if (firstChild != null)
- this.context.setNextNode(firstChild);
- else
- this.context.setParentNode(element);
- }
-
- /**
- * insertStartTag method
- *
- */
- private void insertStartTag(IStructuredDocumentRegion flatNode) {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
-
- String tagName = null;
- boolean isEmptyTag = false;
- AttrImpl attr = null;
- List attrNodes = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedTagName(regionType)) {
- if (tagName == null)
- tagName = flatNode.getText(region);
- }
- else if (regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- isEmptyTag = true;
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- String name = flatNode.getText(region);
- attr = (AttrImpl) this.model.getDocument().createAttribute(name);
- if (attr != null) {
- attr.setNameRegion(region);
- if (attrNodes == null)
- attrNodes = new ArrayList();
- attrNodes.add(attr);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- if (attr != null) {
- attr.setEqualRegion(region);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- if (attr != null) {
- attr.setValueRegion(region);
- attr = null;
- }
- }
- }
-
- if (tagName == null) { // invalid start tag
- insertText(flatNode); // regard as invalid text
- return;
- }
-
- ElementImpl element = null;
- try {
- element = (ElementImpl) this.model.getDocument().createElement(tagName);
- }
- catch (DOMException ex) {
- // typically invalid name
- }
- if (element == null) { // invalid tag
- insertText(flatNode); // regard as invalid text
- return;
- }
- if (attrNodes != null) {
- for (int i = 0; i < attrNodes.size(); i++) {
- element.appendAttributeNode((Attr) attrNodes.get(i));
- }
- }
- if (isEmptyTag)
- element.setEmptyTag(true);
- element.setStartStructuredDocumentRegion(flatNode);
- insertStartTag(element);
- }
-
- /**
- * insertStructuredDocumentRegion method
- *
- */
- protected void insertStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- String regionType = StructuredDocumentRegionUtil.getFirstRegionType(flatNode);
- boolean isTextNode = false;
- if (regionType == DOMRegionContext.XML_TAG_OPEN) {
- insertStartTag(flatNode);
- }
- else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) {
- insertEndTag(flatNode);
- }
- else if (regionType == DOMRegionContext.XML_COMMENT_OPEN || isNestedCommentOpen(regionType)) {
- insertComment(flatNode);
- }
- else if (regionType == DOMRegionContext.XML_ENTITY_REFERENCE || regionType == DOMRegionContext.XML_CHAR_REFERENCE) {
- insertEntityRef(flatNode);
- isTextNode = true;
- }
- else if (regionType == DOMRegionContext.XML_DECLARATION_OPEN) {
- insertDecl(flatNode);
- }
- else if (regionType == DOMRegionContext.XML_PI_OPEN) {
- insertPI(flatNode);
- }
- else if (regionType == DOMRegionContext.XML_CDATA_OPEN) {
- insertCDATASection(flatNode);
- }
- else if (isNestedTag(regionType)) {
- insertNestedTag(flatNode);
- }
- else {
- insertText(flatNode);
- isTextNode = true;
- }
-
- // Changes to text regions are queued up, and once the value is done changing a notification is sent
- if (!isTextNode && lastTextNode != null) {
- lastTextNode.notifyValueChanged();
- lastTextNode = null;
- }
- }
-
- protected boolean isNestedTag(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected boolean isNestedCommentText(String regionType) {
- boolean result = false;
- return result;
- }
-
-
- protected boolean isNestedCommentOpen(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected boolean isNestedTagName(String regionType) {
- boolean result = false;
- return result;
- }
-
- protected boolean isNestedContent(String regionType) {
- boolean result = false;
- return result;
- }
-
- /**
- * insertText method Can be called from subclasses, not to be overrided or
- * re-implemented.
- *
- */
- protected void insertText(IStructuredDocumentRegion flatNode) {
- TextImpl text = (TextImpl) this.context.findPreviousText();
- if (text != null) { // existing text found
- text.appendStructuredDocumentRegion(flatNode);
- // Adjacent text nodes, where changes were queued
- if (lastTextNode != null && lastTextNode != text)
- lastTextNode.notifyValueChanged();
- lastTextNode = text;
- return;
- }
-
- // new text
- text = (TextImpl) this.model.getDocument().createTextNode(null);
- if (text == null)
- return;
- text.setStructuredDocumentRegion(flatNode);
- insertNode(text);
- }
-
- /**
- */
- protected boolean isEndTag(IDOMElement element) {
- ModelParserAdapter adapter = getParserAdapter();
- if (adapter != null) {
- return adapter.isEndTag(element);
- }
- return element.isEndTag();
- }
-
- /**
- */
- private void promoteNodes(Node root, Node newParent, Node newNext, Node oldParent, Node next) {
- ElementImpl newElement = null;
- if (newParent.getNodeType() == Node.ELEMENT_NODE) {
- newElement = (ElementImpl) newParent;
- }
-
- Node rootParent = root.getParentNode();
- while (oldParent != rootParent) {
- while (next != null) {
- boolean done = false;
- boolean endTag = false;
- if (next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl nextElement = (ElementImpl) next;
- if (!nextElement.hasStartTag()) {
- Node nextChild = nextElement.getFirstChild();
- if (nextChild != null) {
- // promote children
- next = nextChild;
- oldParent = nextElement;
- continue;
- }
-
- if (nextElement.hasEndTag()) {
- if (nextElement.matchEndTag(newElement)) {
- endTag = true;
- }
- }
- else {
- // remove implicit element
- next = nextElement.getNextSibling();
- oldParent.removeChild(nextElement);
- done = true;
- }
- }
- }
-
- if (!done) {
- if (!endTag && newElement != null && !canContain(newElement, next)) {
- newParent = newElement.getParentNode();
- if (newParent == null)
- return; // error
- Node elementNext = newElement.getNextSibling();
- // promote siblings
- promoteNodes(newElement, newParent, elementNext, newElement, newNext);
- newNext = newElement.getNextSibling();
- if (newParent.getNodeType() == Node.ELEMENT_NODE) {
- newElement = (ElementImpl) newParent;
- }
- else {
- newElement = null;
- }
- continue;
- }
-
- Node child = next;
- next = next.getNextSibling();
- oldParent.removeChild(child);
- insertNode(newParent, child, newNext);
- Node childParent = child.getParentNode();
- if (childParent != newParent) {
- newParent = childParent;
- newElement = (ElementImpl) newParent;
- newNext = child.getNextSibling();
- }
- }
- }
-
- if (oldParent.getNodeType() != Node.ELEMENT_NODE)
- return;
- ElementImpl oldElement = (ElementImpl) oldParent;
- oldParent = oldElement.getParentNode();
- if (oldParent == null)
- return; // error
- next = oldElement.getNextSibling();
-
- if (oldElement.hasEndTag()) {
- Element end = null;
- if (!oldElement.hasChildNodes() && !oldElement.hasStartTag()) {
- oldParent.removeChild(oldElement);
- end = oldElement;
- }
- else {
- end = oldElement.removeEndTag();
- }
- if (end != null) {
- insertNode(newParent, end, newNext);
- Node endParent = end.getParentNode();
- if (endParent != newParent) {
- newParent = endParent;
- newElement = (ElementImpl) newParent;
- newNext = end.getNextSibling();
- }
- }
- }
- }
- }
-
- /**
- * removeEndTag method
- *
- * @param element
- * org.w3c.dom.Element
- */
- private void removeEndTag(Element element) {
- if (element == null)
- return;
- if (this.context == null)
- return;
-
- Node parent = element.getParentNode();
- if (parent == null)
- return; // error
-
- if (!((ElementImpl) element).isContainer()) {
- // just update context
- Node elementNext = element.getNextSibling();
- if (elementNext != null)
- this.context.setNextNode(elementNext);
- else
- this.context.setParentNode(parent);
- return;
- }
-
- // demote siblings
- Node next = element.getNextSibling();
- ElementImpl newElement = (ElementImpl) element;
- // find new parent
- for (Node last = newElement.getLastChild(); last != null; last = last.getLastChild()) {
- if (last.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl lastElement = (ElementImpl) last;
- if (lastElement.hasEndTag() || lastElement.isEmptyTag() || !lastElement.isContainer())
- break;
- newElement = lastElement;
- }
- Node lastChild = newElement.getLastChild();
- demoteNodes(element, newElement, parent, next);
-
- // update context
- Node newNext = null;
- if (lastChild != null)
- newNext = lastChild.getNextSibling();
- else
- newNext = newElement.getFirstChild();
- if (newNext != null)
- this.context.setNextNode(newNext);
- else
- this.context.setParentNode(newElement);
- }
-
- /**
- * Remove the specified node if it is no longer required implicit tag with
- * remaining child nodes promoted.
- */
- private Element removeImplicitElement(Node parent) {
- if (parent == null)
- return null;
- if (parent.getNodeType() != Node.ELEMENT_NODE)
- return null;
- ElementImpl element = (ElementImpl) parent;
- if (!element.isImplicitTag())
- return null;
- if (canBeImplicitTag(element))
- return null;
-
- Node elementParent = element.getParentNode();
- if (elementParent == null)
- return null; // error
- Node firstChild = element.getFirstChild();
- Node child = firstChild;
- Node elementNext = element.getNextSibling();
- while (child != null) {
- Node nextChild = child.getNextSibling();
- element.removeChild(child);
- elementParent.insertBefore(child, elementNext);
- child = nextChild;
- }
-
- // reset context
- if (this.context.getParentNode() == element) {
- Node oldNext = this.context.getNextNode();
- if (oldNext != null) {
- this.context.setNextNode(oldNext);
- }
- else {
- if (elementNext != null) {
- this.context.setNextNode(elementNext);
- }
- else {
- this.context.setParentNode(elementParent);
- }
- }
- }
- else if (this.context.getNextNode() == element) {
- if (firstChild != null) {
- this.context.setNextNode(firstChild);
- }
- else {
- if (elementNext != null) {
- this.context.setNextNode(elementNext);
- }
- else {
- this.context.setParentNode(elementParent);
- }
- }
- }
-
- removeNode(element);
- return element;
- }
-
- /**
- * removeNode method
- *
- * @param node
- * org.w3c.dom.Node
- */
- private void removeNode(Node node) {
- if (node == null)
- return;
- if (this.context == null)
- return;
-
- Node parent = node.getParentNode();
- if (parent == null)
- return;
- Node next = node.getNextSibling();
- Node prev = node.getPreviousSibling();
-
- // update context
- Node oldParent = this.context.getParentNode();
- if (node == oldParent) {
- if (next != null)
- this.context.setNextNode(next);
- else
- this.context.setParentNode(parent);
- }
- else {
- Node oldNext = this.context.getNextNode();
- if (node == oldNext) {
- this.context.setNextNode(next);
- }
- }
-
- parent.removeChild(node);
-
- if (removeImplicitElement(parent) != null)
- return;
-
- // demote sibling
- if (prev != null && prev.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl newElement = (ElementImpl) prev;
- if (!newElement.hasEndTag() && !newElement.isEmptyTag() && newElement.isContainer()) {
- // find new parent
- for (Node last = newElement.getLastChild(); last != null; last = last.getLastChild()) {
- if (last.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl lastElement = (ElementImpl) last;
- if (lastElement.hasEndTag() || lastElement.isEmptyTag() || !lastElement.isContainer())
- break;
- newElement = lastElement;
- }
- Node lastChild = newElement.getLastChild();
- demoteNodes(prev, newElement, parent, next);
-
- // update context
- Node newNext = null;
- if (lastChild != null)
- newNext = lastChild.getNextSibling();
- else
- newNext = newElement.getFirstChild();
- if (newNext != null)
- this.context.setNextNode(newNext);
- else
- this.context.setParentNode(newElement);
- }
- }
- }
-
- /**
- * removeStartTag method
- *
- * @param element
- * org.w3c.dom.Element
- */
- private void removeStartTag(Element element) {
- if (element == null)
- return;
- if (this.context == null)
- return;
-
- // for implicit tag
- ElementImpl oldElement = (ElementImpl) element;
- if (canBeImplicitTag(oldElement)) {
- Node newParent = null;
- Node prev = oldElement.getPreviousSibling();
- if (prev != null && prev.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl prevElement = (ElementImpl) prev;
- if (!prevElement.hasEndTag()) {
- if (prevElement.hasStartTag() || prevElement.matchTagName(oldElement.getTagName())) {
- newParent = prevElement;
- }
- }
- }
- if (newParent == null) {
- // this element should stay as implicit tag
- // just remove all attributes
- oldElement.removeStartTag();
-
- // update context
- Node child = oldElement.getFirstChild();
- if (child != null) {
- this.context.setNextNode(child);
- }
- else if (oldElement.hasEndTag()) {
- this.context.setParentNode(oldElement);
- }
- return;
- }
- }
- // for comment tag
- if (oldElement.isCommentTag())
- oldElement.removeStartTag();
-
- // promote children
- Node elementParent = element.getParentNode();
- Node parent = elementParent;
- if (parent == null)
- return;
- Node first = element.getFirstChild();
- Node firstElement = null; // for the case first is removed as end
- // tag
- if (first != null) {
- // find new parent for children
- ElementImpl newElement = null;
- for (Node last = element.getPreviousSibling(); last != null; last = last.getLastChild()) {
- if (last.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl lastElement = (ElementImpl) last;
- if (lastElement.hasEndTag() || lastElement.isEmptyTag() || !lastElement.isContainer())
- break;
- newElement = lastElement;
- }
- Node next = first;
- if (newElement != null) {
- while (next != null) {
- if (!newElement.hasEndTag() && newElement.hasStartTag() && next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl nextElement = (ElementImpl) next;
- if (!nextElement.hasStartTag() && nextElement.hasEndTag() && nextElement.matchEndTag(newElement)) {
- // stop at the matched invalid end tag
- Node elementChild = nextElement.getFirstChild();
- while (elementChild != null) {
- Node nextChild = elementChild.getNextSibling();
- nextElement.removeChild(elementChild);
- newElement.appendChild(elementChild);
- elementChild = nextChild;
- }
-
- next = nextElement.getNextSibling();
- element.removeChild(nextElement);
- newElement.addEndTag(nextElement);
- if (nextElement == first)
- firstElement = newElement;
-
- Node newParent = newElement.getParentNode();
- if (newParent == parent)
- break;
- if (newParent == null || newParent.getNodeType() != Node.ELEMENT_NODE)
- break; // error
- newElement = (ElementImpl) newParent;
- continue;
- }
- }
- if (!canContain(newElement, next)) {
- Node newParent = newElement.getParentNode();
- if (newParent == parent)
- break;
- if (newParent == null || newParent.getNodeType() != Node.ELEMENT_NODE)
- break; // error
- newElement = (ElementImpl) newParent;
- continue;
- }
- Node child = next;
- next = next.getNextSibling();
- element.removeChild(child);
- newElement.appendChild(child);
- }
- newElement = null;
- }
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- newElement = (ElementImpl) parent;
- }
- while (next != null) {
- if (newElement == null || canContain(newElement, next)) {
- Node child = next;
- next = next.getNextSibling();
- element.removeChild(child);
- parent.insertBefore(child, element);
- continue;
- }
-
- parent = newElement.getParentNode();
- if (parent == null)
- return;
-
- // promote siblings
- Node newNext = newElement.getNextSibling();
- Node child = element;
- while (child != null) {
- Node nextChild = child.getNextSibling();
- newElement.removeChild(child);
- parent.insertBefore(child, newNext);
- child = nextChild;
- }
-
- // leave the old end tag where it is
- if (newElement.hasEndTag()) {
- Element end = newElement.removeEndTag();
- if (end != null) {
- parent.insertBefore(end, newNext);
- }
- }
- if (!newElement.hasStartTag()) {
- // implicit element
- if (!newElement.hasChildNodes()) {
- parent.removeChild(newElement);
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- newElement = (ElementImpl) parent;
- }
- else {
- newElement = null;
- }
- }
- }
-
- Node newNext = element;
- Node startElement = null; // for the case element is removed as end
- // tag
- if (oldElement.hasEndTag()) {
- // find new parent for invalid end tag and siblings
- ElementImpl newElement = null;
- for (Node last = element.getPreviousSibling(); last != null; last = last.getLastChild()) {
- if (last.getNodeType() != Node.ELEMENT_NODE)
- break;
- ElementImpl lastElement = (ElementImpl) last;
- if (lastElement.hasEndTag() || lastElement.isEmptyTag() || !lastElement.isContainer())
- break;
- newElement = lastElement;
- }
- if (newElement != null) {
- // demote invalid end tag and sibling
- Node next = element;
- while (next != null) {
- if (!newElement.hasEndTag() && newElement.hasStartTag() && next.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl nextElement = (ElementImpl) next;
- if (!nextElement.hasStartTag() && nextElement.hasEndTag() && nextElement.matchEndTag(newElement)) {
- // stop at the matched invalid end tag
- Node elementChild = nextElement.getFirstChild();
- while (elementChild != null) {
- Node nextChild = elementChild.getNextSibling();
- nextElement.removeChild(elementChild);
- newElement.appendChild(elementChild);
- elementChild = nextChild;
- }
-
- next = nextElement.getNextSibling();
- parent.removeChild(nextElement);
- newElement.addEndTag(nextElement);
- if (nextElement == newNext)
- startElement = newElement;
-
- Node newParent = newElement.getParentNode();
- if (newParent == parent)
- break;
- if (newParent == null || newParent.getNodeType() != Node.ELEMENT_NODE)
- break; // error
- newElement = (ElementImpl) newParent;
- continue;
- }
- }
- if (!canContain(newElement, next)) {
- Node newParent = newElement.getParentNode();
- if (newParent == parent)
- break;
- if (newParent == null || newParent.getNodeType() != Node.ELEMENT_NODE)
- break; // error
- newElement = (ElementImpl) newParent;
- continue;
- }
- Node child = next;
- next = next.getNextSibling();
- parent.removeChild(child);
- if (child == oldElement) {
- if (!oldElement.isCommentTag()) {
- // clone (re-create) end tag
- Element end = oldElement.removeEndTag();
- if (end != null) {
- child = end;
- newNext = end;
- }
- }
- }
- newElement.appendChild(child);
- }
- }
- else {
- if (!oldElement.isCommentTag()) {
- // clone (re-create) end tag
- Element end = oldElement.removeEndTag();
- if (end != null) {
- parent.insertBefore(end, oldElement);
- parent.removeChild(oldElement);
- newNext = end;
- }
- }
- }
- }
- else {
- newNext = oldElement.getNextSibling();
- parent.removeChild(oldElement);
- }
-
- // update context
- Node oldParent = this.context.getParentNode();
- Node oldNext = this.context.getNextNode();
- if (element == oldParent) {
- if (oldNext != null) {
- this.context.setNextNode(oldNext); // reset for new parent
- }
- else if (newNext != null) {
- this.context.setNextNode(newNext);
- }
- else {
- this.context.setParentNode(parent);
- }
- }
- else if (element == oldNext) {
- if (firstElement != null) {
- this.context.setParentNode(firstElement);
- }
- else if (first != null) {
- this.context.setNextNode(first);
- }
- else if (startElement != null) {
- this.context.setParentNode(startElement);
- }
- else {
- this.context.setNextNode(newNext);
- }
- }
-
- removeImplicitElement(elementParent);
- }
-
- /**
- * removeStructuredDocumentRegion method
- *
- */
- private void removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- NodeImpl next = (NodeImpl) this.context.getNextNode();
- if (next != null) {
- short nodeType = next.getNodeType();
- if (nodeType != Node.ELEMENT_NODE) {
- IStructuredDocumentRegion flatNode = next.getStructuredDocumentRegion();
- if (flatNode == oldStructuredDocumentRegion) {
- removeNode(next);
- return;
- }
- if (nodeType != Node.TEXT_NODE) {
- throw new StructuredDocumentRegionManagementException();
- }
- if (flatNode == null) {
- // this is the case for empty Text
- // remove and continue
- removeNode(next);
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- TextImpl text = (TextImpl) next;
- boolean isShared = text.isSharingStructuredDocumentRegion(oldStructuredDocumentRegion);
- if (isShared) {
- // make sure there is next Text node sharing this
- TextImpl nextText = (TextImpl) this.context.findNextText();
- if (nextText == null || !nextText.hasStructuredDocumentRegion(oldStructuredDocumentRegion)) {
- isShared = false;
- }
- }
- oldStructuredDocumentRegion = text.removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- if (oldStructuredDocumentRegion == null) {
- throw new StructuredDocumentRegionManagementException();
- }
- if (text.getStructuredDocumentRegion() == null) {
- // this is the case partial IStructuredDocumentRegion is
- // removed
- removeNode(text);
- }
- else {
- // notify the change
- text.notifyValueChanged();
- }
- // if shared, continue to remove IStructuredDocumentRegion
- // from them
- if (isShared)
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
-
- ElementImpl element = (ElementImpl) next;
- if (element.hasStartTag()) {
- IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion();
- if (flatNode != oldStructuredDocumentRegion) {
- throw new StructuredDocumentRegionManagementException();
- }
- if (element.hasEndTag() || element.hasChildNodes()) {
- element.setStartStructuredDocumentRegion(null);
- removeStartTag(element);
- }
- else {
- removeNode(element);
- }
- }
- else {
- Node child = element.getFirstChild();
- if (child != null) {
- this.context.setNextNode(child);
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
-
- if (!element.hasEndTag()) {
- // implicit element
- removeNode(element);
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
-
- IStructuredDocumentRegion flatNode = element.getEndStructuredDocumentRegion();
- if (flatNode != oldStructuredDocumentRegion) {
- throw new StructuredDocumentRegionManagementException();
- }
- removeNode(element);
- }
- return;
- }
-
- Node parent = this.context.getParentNode();
- if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) {
- throw new StructuredDocumentRegionManagementException();
- }
-
- ElementImpl end = (ElementImpl) parent;
- if (end.hasEndTag()) {
- IStructuredDocumentRegion flatNode = end.getEndStructuredDocumentRegion();
- if (flatNode != oldStructuredDocumentRegion) {
- throw new StructuredDocumentRegionManagementException();
- }
- if (!end.hasStartTag() && !end.hasChildNodes()) {
- this.context.setNextNode(end);
- removeNode(end);
- }
- else {
- end.setEndStructuredDocumentRegion(null);
- removeEndTag(end);
- }
- return;
- }
-
- next = (NodeImpl) end.getNextSibling();
- if (next != null) {
- this.context.setNextNode(next);
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
-
- parent = end.getParentNode();
- if (parent != null) {
- this.context.setParentNode(parent);
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- }
-
- /**
- * replaceRegions method
- *
- * @param newRegions
- * java.util.Vector
- * @param oldRegions
- * java.util.Vector
- */
- void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) {
- if (flatNode == null)
- return;
- if (this.model.getDocument() == null)
- return;
- this.context = new XMLModelContext(this.model.getDocument());
-
- // optimize typical cases
- String regionType = StructuredDocumentRegionUtil.getFirstRegionType(flatNode);
- if (regionType == DOMRegionContext.XML_TAG_OPEN) {
- changeStartTag(flatNode, newRegions, oldRegions);
- }
- else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) {
- changeEndTag(flatNode, newRegions, oldRegions);
- }
- else {
- changeStructuredDocumentRegion(flatNode);
- }
- }
-
- /**
- * replaceStructuredDocumentRegions method
- *
- */
- void replaceStructuredDocumentRegions(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
- if (this.model.getDocument() == null)
- return;
- this.context = new XMLModelContext(this.model.getDocument());
-
- int newCount = (newStructuredDocumentRegions != null ? newStructuredDocumentRegions.getLength() : 0);
- int oldCount = (oldStructuredDocumentRegions != null ? oldStructuredDocumentRegions.getLength() : 0);
-
- if (oldCount > 0) {
- setupContext(oldStructuredDocumentRegions.item(0));
- // Node startParent = this.context.getParentNode();
-
- for (int i = 0; i < oldCount; i++) {
- IStructuredDocumentRegion documentRegion = oldStructuredDocumentRegions.item(i);
- removeStructuredDocumentRegion(documentRegion);
- }
- }
- else {
- if (newCount == 0)
- return;
- setupContext(newStructuredDocumentRegions.item(0));
- }
- // make sure the parent is set to deepest level
- // when end tag has been removed
- this.context.setLast();
-
- if (newCount > 0) {
- for (int i = 0; i < newCount; i++) {
- IStructuredDocumentRegion documentRegion = newStructuredDocumentRegions.item(i);
- insertStructuredDocumentRegion(documentRegion);
- }
- }
-
- cleanupText();
- cleanupEndTag();
- }
-
- /**
- * setupContext method
- *
- */
- private void setupContext(IStructuredDocumentRegion startStructuredDocumentRegion) {
- int offset = startStructuredDocumentRegion.getStart();
- if (offset < 0)
- return;
- NodeImpl root = (NodeImpl) this.context.getRootNode();
- if (root == null)
- return;
-
- if (offset == 0) {
- // at the beginning of document
- Node child = root.getFirstChild();
- if (child != null)
- this.context.setNextNode(child);
- else
- this.context.setParentNode(root);
- return;
- }
-
- NodeImpl node = (NodeImpl) root.getNodeAt(offset);
- if (node == null) {
- // might be at the end of document
- this.context.setParentNode(root);
- this.context.setLast();
- return;
- }
-
- if (offset == node.getStartOffset()) {
- this.context.setNextNode(node);
- return;
- }
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) node;
- Text nextText = text.splitText(startStructuredDocumentRegion);
- // notify the change
- text.notifyValueChanged();
- if (nextText == null)
- return; // error
- this.context.setNextNode(nextText);
- return;
- }
-
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (offset >= ((NodeImpl) child).getEndOffset())
- continue;
- this.context.setNextNode(child);
- return;
- }
- this.context.setParentNode(node);
- this.context.setLast();
- }
-
- protected XMLModelContext getContext() {
- return context;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java
deleted file mode 100644
index a92b2338ec..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java
+++ /dev/null
@@ -1,1704 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-/**
- * XMLModelUpdater class
- */
-public class XMLModelUpdater {
- private int diff = 0;
- private int gapLength = 0;
- private int gapOffset = 0;
- private IStructuredDocumentRegion gapStructuredDocumentRegion = null;
- private ISourceGenerator generator = null;
- private DOMModelImpl model = null;
- private NodeImpl nextNode = null;
- private NodeImpl parentNode = null;
-
- protected XMLModelUpdater(DOMModelImpl model) {
- super();
-
- if (model != null) {
- this.model = model;
- this.generator = model.getGenerator();
- }
- }
-
- /**
- * changeAttrValue method
- *
- * @param attrNode
- * org.w3c.dom.Attr
- */
- private void changeAttrName(Attr attrNode) {
- if (attrNode == null)
- return;
-
- AttrImpl attr = (AttrImpl) attrNode;
- ElementImpl element = (ElementImpl) attr.getOwnerElement();
- if (element == null)
- return;
-
- if (element.isCommentTag()) {
- changeStartTag(element);
- return;
- }
-
- int offset = element.getStartOffset();
- int start = offset;
- int end = offset;
-
- String name = attr.getName();
- if (name == null)
- name = NodeImpl.EMPTY_STRING;
- ITextRegion nameRegion = attr.getNameRegion();
- if (nameRegion == null)
- return; // error
- start += nameRegion.getStart();
- // use getTextEnd() because getEnd() may include the tailing spaces
- end += nameRegion.getTextEnd();
-
- replaceSource(name, start, end);
- }
-
- /**
- * changeAttrValue method
- *
- * @param attrNode
- * org.w3c.dom.Attr
- */
- private void changeAttrValue(Attr attrNode) {
- if (attrNode == null)
- return;
-
- AttrImpl attr = (AttrImpl) attrNode;
- ElementImpl element = (ElementImpl) attr.getOwnerElement();
- if (element == null)
- return;
-
- if (element.isCommentTag()) {
- changeStartTag(element);
- return;
- }
-
- int offset = element.getStartOffset();
- int start = offset;
- int end = offset;
-
- String value = null;
- ITextRegion valueRegion = attr.getValueRegion();
- if (valueRegion != null) {
- char quote = 0; // no quote preference
- // DW: 4/16/2003 due to change in structuredDocument ... we need a
- // flatnode to
- // get at region values. For now I'll assume this is always the
- // first
- // flatnode .. may need to make smarter later (e.g. to search for
- // the flatnode that this.valueRegion belongs to.
- IStructuredDocumentRegion documentRegion = element.getFirstStructuredDocumentRegion();
- String oldValue = documentRegion.getText(valueRegion);
- if (oldValue != null && oldValue.length() > 0) {
- char firstChar = oldValue.charAt(0);
- if (firstChar == '"' || firstChar == '\'') {
- quote = firstChar;
- }
- }
-
- ITextRegion startRegion = valueRegion;
-
- value = this.generator.generateAttrValue(attr, quote);
- if (value == null) {
- value = NodeImpl.EMPTY_STRING;
- // remove equal too
- ITextRegion equalRegion = attr.getEqualRegion();
- if (equalRegion != null)
- startRegion = equalRegion;
- }
- attr.setValueRegion(valueRegion); // reset value
-
- start += startRegion.getStart();
- // use getTextEnd() because getEnd() may include the tailing
- // spaces
- end += valueRegion.getTextEnd();
- }
- else {
- ITextRegion equalRegion = attr.getEqualRegion();
-
- value = this.generator.generateAttrValue(attr);
- if (value == null) {
- if (equalRegion == null)
- return; // nothng to do
- value = NodeImpl.EMPTY_STRING;
- // remove equal
- start += equalRegion.getStart();
- end += equalRegion.getTextEnd();
- }
- else {
- if (equalRegion != null) {
- // use getTextEnd() because getEnd() may include the
- // tailing spaces
- start += equalRegion.getTextEnd();
- }
- else {
- ITextRegion nameRegion = attr.getNameRegion();
- if (nameRegion == null)
- return; // must never happen
- // use getTextEnd() because getEnd() may include the
- // tailing spaces
- start += nameRegion.getTextEnd();
- value = '=' + value;
- }
- end = start;
- }
- }
-
- replaceSource(value, start, end);
- }
-
- /**
- */
- void changeEndTag(Element element) {
- String source = this.generator.generateEndTag(element);
- if (source == null)
- return;
- int length = source.length();
- if (length == 0)
- return;
-
- ElementImpl impl = (ElementImpl) element;
- int offset = impl.getEndStartOffset();
- int start = offset;
- int end = offset;
- if (impl.hasEndTag()) {
- end = impl.getEndOffset();
- this.gapStructuredDocumentRegion = impl.getEndStructuredDocumentRegion();
- impl.setEndStructuredDocumentRegion(new StructuredDocumentRegionProxy(offset, length));
- }
-
- replaceSource(source, start, end);
- }
-
- /**
- * changeName method
- *
- * @param node
- * org.w3c.dom.Node
- */
- void changeName(Node node) {
- if (node == null)
- return;
- if (getStructuredDocument() == null)
- return;
-
- // support changing name of attribute for setPrefix()
- short nodeType = node.getNodeType();
- if (nodeType == Node.ATTRIBUTE_NODE) {
- changeAttrName((Attr) node);
- return;
- }
-
- // not supported
- return;
- }
-
- void changeRegion(RegionChangedEvent change, IStructuredDocumentRegion flatNode, ITextRegion region) {
- if (change.getOffset() >= flatNode.getStartOffset() + region.getTextEnd()) {
- // change is entirely in white-space
- return;
- }
-
- NodeImpl root = (NodeImpl) this.model.getDocument();
- this.parentNode = root;
- this.nextNode = (NodeImpl) root.getFirstChild();
-
- removeGapStructuredDocumentRegion(flatNode);
- insertGapStructuredDocumentRegionBefore(flatNode.getStart());
- changeStructuredDocumentRegion(flatNode);
- insertGapStructuredDocumentRegionAfter(flatNode.getEnd());
- }
-
- /**
- * This is a fallback method to regenerate the start tag.
- */
- void changeStartTag(Element element) {
- if (element == null)
- return;
- ElementImpl impl = (ElementImpl) element;
-
- if (!impl.hasStartTag() && !impl.hasEndTag()) {
- // need to generate the start and the end tags
- Node parent = element.getParentNode();
- if (parent != null) {
- replaceChild(parent, element, element);
- return;
- }
- // else error
- }
-
- String source = this.generator.generateStartTag(element);
- if (source == null)
- return;
- int length = source.length();
- if (length == 0)
- return;
-
- int offset = impl.getStartOffset();
- int start = offset;
- int end = offset;
- if (impl.hasStartTag()) {
- end = impl.getStartEndOffset();
- this.gapStructuredDocumentRegion = impl.getStartStructuredDocumentRegion();
- }
- impl.setStartStructuredDocumentRegion(new StructuredDocumentRegionProxy(offset, length));
-
- replaceSource(source, start, end);
- }
-
- private void changeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (oldStructuredDocumentRegion == null)
- return; // error
- if (this.parentNode == null)
- return; // error
-
- int oldOffset = oldStructuredDocumentRegion.getStart();
- int oldEnd = oldStructuredDocumentRegion.getEnd();
- boolean isEndTag = false;
-
- // find owner node
- NodeImpl ownerNode = null;
- while (this.parentNode != null) {
- if (this.nextNode != null) {
- IStructuredDocumentRegion nextStructuredDocumentRegion = this.nextNode.getStructuredDocumentRegion();
- if (nextStructuredDocumentRegion != null) {
- if (nextStructuredDocumentRegion == oldStructuredDocumentRegion) {
- ownerNode = this.nextNode;
- break;
- }
- int nextOffset = nextStructuredDocumentRegion.getStart();
- if (nextOffset == oldOffset) { // found
- ownerNode = this.nextNode;
- break;
- }
- if (this.nextNode.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) this.nextNode;
- if (text.hasStructuredDocumentRegion(oldStructuredDocumentRegion)) {
- ownerNode = this.nextNode;
- break;
- }
- int nextEnd = nextStructuredDocumentRegion.getEnd();
- if (nextOffset < oldEnd && nextEnd > oldOffset) {
- ownerNode = this.nextNode;
- break;
- }
- }
- }
-
- Node child = this.nextNode.getFirstChild();
- if (child != null) {
- this.parentNode = this.nextNode;
- this.nextNode = (NodeImpl) child;
- continue;
- }
-
- if (this.nextNode.getNodeType() == Node.ELEMENT_NODE) {
- this.parentNode = this.nextNode;
- this.nextNode = null;
- continue;
- }
-
- this.nextNode = (NodeImpl) this.nextNode.getNextSibling();
- if (this.nextNode != null)
- continue;
- }
-
- if (this.parentNode.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) this.parentNode;
- IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- if (endStructuredDocumentRegion == oldStructuredDocumentRegion) {
- ownerNode = this.parentNode;
- isEndTag = true;
- break;
- }
- int endOffset = endStructuredDocumentRegion.getStart();
- if (endOffset == oldOffset) { // found
- ownerNode = this.parentNode;
- isEndTag = true;
- break;
- }
- }
- }
-
- this.nextNode = (NodeImpl) this.parentNode.getNextSibling();
- this.parentNode = (NodeImpl) this.parentNode.getParentNode();
- }
- if (ownerNode == null)
- throw new StructuredDocumentRegionManagementException();
-
- short nodeType = ownerNode.getNodeType();
- if (nodeType == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) ownerNode;
- if (isEndTag) {
- element.setEndStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- else {
- element.setStartStructuredDocumentRegion(oldStructuredDocumentRegion);
- updateAttrRegions(element, oldStructuredDocumentRegion);
- }
- }
- else if (nodeType == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) ownerNode;
-
- IStructuredDocumentRegion flatNode = text.getStructuredDocumentRegion();
- if (flatNode == oldStructuredDocumentRegion) {
- int newOffset = oldOffset;
- int newEnd = oldEnd;
- if (oldOffset == this.gapOffset) {
- newOffset += this.diff;
- }
- else {
- newEnd = this.gapOffset;
- }
- int newLength = newEnd - newOffset;
- IStructuredDocumentRegion newStructuredDocumentRegion = new StructuredDocumentRegionProxy(newOffset, newLength, oldStructuredDocumentRegion);
- text.setStructuredDocumentRegion(newStructuredDocumentRegion);
-
- if (oldEnd > newEnd) {
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- return;
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- int offset = proxy.getOffset();
- int end = offset + proxy.getLength();
- if (proxy.getStructuredDocumentRegion() == null) {
- if (offset == oldOffset && end == oldEnd) {
- text.setStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- else {
- if (end > oldEnd) {
- StructuredDocumentRegionContainer container = new StructuredDocumentRegionContainer();
- container.appendStructuredDocumentRegion(oldStructuredDocumentRegion);
- proxy.setOffset(oldEnd);
- proxy.setLength(end - oldEnd);
- container.appendStructuredDocumentRegion(proxy);
- text.setStructuredDocumentRegion(container);
- }
- else {
- proxy.setStructuredDocumentRegion(oldStructuredDocumentRegion);
-
- if (end < oldEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- }
- }
- return;
- }
-
- if (offset >= this.gapOffset) {
- proxy.setOffset(offset + this.diff);
- end += this.diff;
- }
- if (end < oldEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- }
- else if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue; // error
- if (content == oldStructuredDocumentRegion) {
- int newOffset = oldOffset;
- int newEnd = oldEnd;
- if (oldOffset == this.gapOffset) {
- newOffset += this.diff;
- }
- else {
- newEnd = this.gapOffset;
- }
- int newLength = newEnd - newOffset;
- IStructuredDocumentRegion newStructuredDocumentRegion = new StructuredDocumentRegionProxy(newOffset, newLength, oldStructuredDocumentRegion);
- container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
-
- if (oldEnd > newEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- return;
- }
-
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- int offset = proxy.getOffset();
- int end = offset + proxy.getLength();
- if (end <= oldOffset)
- continue;
- if (proxy.getStructuredDocumentRegion() == null) {
- if (offset == oldOffset && end == oldEnd) {
- container.replaceStructuredDocumentRegion(oldStructuredDocumentRegion, i);
- }
- else {
- if (end > oldEnd) {
- container.insertStructuredDocumentRegion(oldStructuredDocumentRegion, i);
- proxy.setOffset(oldEnd);
- proxy.setLength(end - oldEnd);
- }
- else {
- proxy.setStructuredDocumentRegion(oldStructuredDocumentRegion);
-
- if (end < oldEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- }
- }
- return;
- }
-
- if (offset >= this.gapOffset) {
- proxy.setOffset(offset + this.diff);
- end += this.diff;
- }
- if (end < oldEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- changeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- }
- }
- }
- else {
- throw new StructuredDocumentRegionManagementException();
- }
- }
- else {
- ownerNode.setStructuredDocumentRegion(oldStructuredDocumentRegion);
- }
- }
-
- /**
- */
- private void changeTextData(Text text) {
- if (text == null)
- return;
-
- String source = this.generator.generateSource(text);
- if (source == null)
- source = NodeImpl.EMPTY_STRING;
- int length = source.length();
-
- TextImpl impl = (TextImpl) text;
- int start = impl.getStartOffset();
- int end = impl.getEndOffset();
- int offset = start;
-
- // make sure previous tag is closed
- Node prev = text.getPreviousSibling();
- if (prev != null) {
- String preTag = getCloseTag((IDOMNode) prev);
- if (preTag != null && preTag.length() > 0) {
- offset += preTag.length();
- source = preTag + source;
- }
- }
- else {
- Node parent = text.getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- String preTag = getStartCloseTag(element);
- if (preTag != null && preTag.length() > 0) {
- offset += preTag.length();
- StringBuffer buffer = new StringBuffer();
- buffer.append(preTag);
- buffer.append(source);
- if (text.getNextSibling() == null && !element.hasEndTag() && (element.isJSPContainer() || element.isCDATAContainer())) {
- // need to generate the end tag
- String postTag = this.generator.generateEndTag(element);
- if (postTag != null) {
- int postLength = postTag.length();
- if (postLength > 0) {
- buffer.append(postTag);
- int postOffset = offset + length;
- IStructuredDocumentRegion flatNode = new StructuredDocumentRegionProxy(postOffset, postLength);
- element.setEndStructuredDocumentRegion(flatNode);
- }
- }
- }
- source = buffer.toString();
- }
- }
- }
-
- this.gapStructuredDocumentRegion = impl.getStructuredDocumentRegion();
- IStructuredDocumentRegion newStructuredDocumentRegion = null;
- if (length > 0)
- newStructuredDocumentRegion = new StructuredDocumentRegionProxy(offset, length);
- impl.setStructuredDocumentRegion(newStructuredDocumentRegion);
-
- replaceSource(source, start, end);
- }
-
- /**
- * changeValue method
- *
- * @param node
- * org.w3c.dom.Node
- */
- void changeValue(Node node) {
- if (node == null)
- return;
- if (getStructuredDocument() == null)
- return;
-
- short nodeType = node.getNodeType();
- if (nodeType == Node.TEXT_NODE) {
- changeTextData((Text) node);
- return;
- }
- if (nodeType == Node.ATTRIBUTE_NODE) {
- changeAttrValue((Attr) node);
- return;
- }
- if (nodeType == Node.ELEMENT_NODE) {
- changeStartTag((Element) node);
- return;
- }
-
- String source = this.generator.generateSource(node);
- if (source == null)
- source = NodeImpl.EMPTY_STRING;
- int length = source.length();
-
- NodeImpl impl = (NodeImpl) node;
- int start = impl.getStartOffset();
- int end = impl.getEndOffset();
-
- this.gapStructuredDocumentRegion = impl.getStructuredDocumentRegion();
- IStructuredDocumentRegion flatNode = null;
- if (length > 0)
- flatNode = new StructuredDocumentRegionProxy(start, length);
- impl.setStructuredDocumentRegion(flatNode);
-
- replaceSource(source, start, end);
- }
-
- /**
- */
- private String getAttrValueClose(IDOMElement element) {
- if (element == null)
- return null;
-
- IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- ITextRegion region = StructuredDocumentRegionUtil.getLastRegion(flatNode);
- if (region == null || region.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- return null;
- String value = flatNode.getText(region);
- if (value == null)
- return null;
- int length = value.length();
- if (length == 0)
- return null;
-
- // check open JSP tag
- boolean closeJSPTag = false;
- int offset = value.indexOf(JSPTag.TAG_OPEN);
- while (offset >= 0) {
- offset = value.indexOf(JSPTag.TAG_CLOSE, offset + 2);
- if (offset < 0) {
- closeJSPTag = true;
- break;
- }
- offset = value.indexOf(JSPTag.TAG_OPEN, offset + 2);
- }
-
- // check quote
- boolean closeQuote = false;
- char firstChar = value.charAt(0);
- if (firstChar == '"' || firstChar == '\'') {
- if (closeJSPTag || length == 1 || value.charAt(length - 1) != firstChar) {
- closeQuote = true;
- }
- }
-
- if (!closeJSPTag && !closeQuote)
- return null;
-
- StringBuffer buffer = new StringBuffer();
- if (closeJSPTag)
- buffer.append(JSPTag.TAG_CLOSE);
- if (closeQuote)
- buffer.append(firstChar);
- return buffer.toString();
- }
-
- /**
- * Gather close tags recursively.
- */
- private String getCloseTag(IDOMNode node) {
- if (node == null || node.isClosed())
- return null;
-
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- return this.generator.generateCloseTag(node);
- }
-
- ElementImpl element = (ElementImpl) node;
- if (element.hasEndTag()) {
- // end tag is not closed
- return this.generator.generateCloseTag(element);
- }
-
- // no end tag
- int offset = element.getEndOffset();
- StringBuffer buffer = new StringBuffer();
-
- IDOMNode lastChild = (IDOMNode) element.getLastChild();
- if (lastChild == null) {
- if (!element.isStartTagClosed()) {
- if (element.preferEmptyTag())
- element.setEmptyTag(true);
- String closeTag = getStartCloseTag(element);
- if (closeTag != null) {
- int length = closeTag.length();
- if (length > 0) {
- buffer.append(closeTag);
- offset += length;
- }
- }
- }
- }
- else {
- String closeTag = getCloseTag(lastChild);
- if (closeTag != null) {
- int length = closeTag.length();
- if (length > 0) {
- buffer.append(closeTag);
- offset += length;
- }
- }
- }
-
- String endTag = this.generator.generateEndTag(element);
- if (endTag != null) {
- int length = endTag.length();
- if (length > 0) {
- buffer.append(endTag);
- IStructuredDocumentRegion flatNode = new StructuredDocumentRegionProxy(offset, length);
- element.setEndStructuredDocumentRegion(flatNode);
- }
- }
-
- return buffer.toString();
- }
-
- /**
- */
- private String getStartCloseTag(IDOMElement element) {
- if (element == null || element.isStartTagClosed())
- return null;
-
- StringBuffer buffer = new StringBuffer();
- String attrValueClose = getAttrValueClose(element);
- if (attrValueClose != null)
- buffer.append(attrValueClose);
- String closeTag = this.generator.generateCloseTag(element);
- if (closeTag != null)
- buffer.append(closeTag);
- return buffer.toString();
- }
-
- private IStructuredDocument getStructuredDocument() {
- if (model == null)
- return null;
- return model.getStructuredDocument();
- }
-
- /**
- */
- void initialize() {
- this.gapStructuredDocumentRegion = null;
- this.gapOffset = 0;
- this.gapLength = 0;
- this.diff = 0;
- this.parentNode = null;
- this.nextNode = null;
- }
-
- private void insertGapStructuredDocumentRegionAfter(int endOffset) {
- if (this.gapStructuredDocumentRegion == null)
- return;
-
- if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) this.gapStructuredDocumentRegion;
- IStructuredDocumentRegion flatNode = proxy.getStructuredDocumentRegion();
- if (flatNode != null)
- insertStructuredDocumentRegion(flatNode);
- }
- else if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) this.gapStructuredDocumentRegion;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue;
- if (content.getStart() < endOffset)
- continue;
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- IStructuredDocumentRegion flatNode = proxy.getStructuredDocumentRegion();
- if (flatNode != null)
- insertStructuredDocumentRegion(flatNode);
- }
- else {
- insertStructuredDocumentRegion(content);
- }
- }
- }
- else {
- insertStructuredDocumentRegion(this.gapStructuredDocumentRegion);
- }
- }
-
- private void insertGapStructuredDocumentRegionBefore(int startOffset) {
- if (this.gapStructuredDocumentRegion == null)
- return;
-
- if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) this.gapStructuredDocumentRegion;
- IStructuredDocumentRegion flatNode = proxy.getStructuredDocumentRegion();
- if (flatNode != null)
- insertStructuredDocumentRegion(flatNode);
- }
- else if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) this.gapStructuredDocumentRegion;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue;
- if (content.getStart() >= startOffset)
- return;
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- IStructuredDocumentRegion flatNode = proxy.getStructuredDocumentRegion();
- if (flatNode != null)
- insertStructuredDocumentRegion(flatNode);
- }
- else {
- insertStructuredDocumentRegion(content);
- }
- }
- }
- else {
- insertStructuredDocumentRegion(this.gapStructuredDocumentRegion);
- }
- }
-
- /**
- */
- private void insertStructuredDocumentRegion(IStructuredDocumentRegion newStructuredDocumentRegion) {
- if (newStructuredDocumentRegion == null)
- return; // error
- if (this.parentNode == null)
- return; // error
-
- int newOffset = newStructuredDocumentRegion.getStart();
- int newEnd = newStructuredDocumentRegion.getEnd();
- boolean isEndTag = false;
-
- // find owner node
- NodeImpl ownerNode = null;
- while (this.parentNode != null) {
- if (this.nextNode != null) {
- IStructuredDocumentRegion nextStructuredDocumentRegion = this.nextNode.getStructuredDocumentRegion();
- if (nextStructuredDocumentRegion != null) {
- int nextOffset = nextStructuredDocumentRegion.getStart();
- if (nextOffset == newOffset) { // found
- ownerNode = this.nextNode;
- break;
- }
- if (this.nextNode.getNodeType() == Node.TEXT_NODE) {
- int nextEnd = nextStructuredDocumentRegion.getEnd();
- if (nextOffset < newEnd && nextEnd > newOffset) {
- ownerNode = this.nextNode;
- break;
- }
- }
- }
-
- Node child = this.nextNode.getFirstChild();
- if (child != null) {
- this.parentNode = this.nextNode;
- this.nextNode = (NodeImpl) child;
- continue;
- }
-
- if (this.nextNode.getNodeType() == Node.ELEMENT_NODE) {
- this.parentNode = this.nextNode;
- this.nextNode = null;
- continue;
- }
-
- this.nextNode = (NodeImpl) this.nextNode.getNextSibling();
- if (this.nextNode != null)
- continue;
- }
-
- if (this.parentNode.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) this.parentNode;
- IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- int endOffset = endStructuredDocumentRegion.getStart();
- if (endOffset == newOffset) { // found
- ownerNode = this.parentNode;
- isEndTag = true;
- break;
- }
- }
- }
-
- this.nextNode = (NodeImpl) this.parentNode.getNextSibling();
- this.parentNode = (NodeImpl) this.parentNode.getParentNode();
- }
- if (ownerNode == null)
- throw new StructuredDocumentRegionManagementException();
-
- short nodeType = ownerNode.getNodeType();
- if (nodeType == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) ownerNode;
- if (isEndTag) {
- element.setEndStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- else {
- element.setStartStructuredDocumentRegion(newStructuredDocumentRegion);
- updateAttrRegions(element, newStructuredDocumentRegion);
- }
- }
- else if (nodeType == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) ownerNode;
- IStructuredDocumentRegion oldStructuredDocumentRegion = text.getStructuredDocumentRegion();
- if (oldStructuredDocumentRegion == null) {
- throw new StructuredDocumentRegionManagementException();
- }
- int oldOffset = oldStructuredDocumentRegion.getStart();
- int oldEnd = oldStructuredDocumentRegion.getEnd();
- if (oldOffset == newOffset && oldEnd == newEnd) {
- text.setStructuredDocumentRegion(newStructuredDocumentRegion);
- return;
- }
-
- if (oldStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) oldStructuredDocumentRegion;
- if (oldEnd > newEnd) {
- StructuredDocumentRegionContainer container = new StructuredDocumentRegionContainer();
- if (oldOffset == newOffset) {
- container.appendStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- else {
- StructuredDocumentRegionProxy newProxy = new StructuredDocumentRegionProxy();
- newProxy.setOffset(oldOffset);
- newProxy.setLength(newEnd - oldOffset);
- newProxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
- container.appendStructuredDocumentRegion(newProxy);
- }
- proxy.setOffset(newEnd);
- proxy.setLength(oldEnd - newEnd);
- container.appendStructuredDocumentRegion(proxy);
- text.setStructuredDocumentRegion(container);
- }
- else {
- proxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
-
- if (oldEnd < newEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- insertStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- }
- return;
- }
-
- if (oldStructuredDocumentRegion instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) oldStructuredDocumentRegion;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue; // error
- int offset = content.getStart();
- int end = content.getEnd();
- if (end <= newOffset)
- continue;
- if (offset == newOffset && end == newEnd) {
- container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
- return;
- }
-
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (end > newEnd) {
- if (offset == newOffset) {
- container.insertStructuredDocumentRegion(newStructuredDocumentRegion, i);
- }
- else {
- StructuredDocumentRegionProxy newProxy = new StructuredDocumentRegionProxy();
- newProxy.setOffset(offset);
- newProxy.setLength(newEnd - offset);
- newProxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
- container.insertStructuredDocumentRegion(newProxy, i);
- }
- proxy.setOffset(newEnd);
- proxy.setLength(end - newEnd);
- return;
- }
- else {
- proxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
- if (end == newEnd)
- return;
- }
- }
- }
-
- if (oldEnd < newEnd) { // to be shared
- this.nextNode = (NodeImpl) text.getNextSibling();
- insertStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- return;
- }
- else {
- throw new StructuredDocumentRegionManagementException();
- }
- }
- else {
- ownerNode.setStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- }
-
- private void removeGapStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (this.gapStructuredDocumentRegion == null)
- return;
-
- if (this.gapStructuredDocumentRegion == oldStructuredDocumentRegion) {
- this.gapStructuredDocumentRegion = null;
- return;
- }
-
- if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) this.gapStructuredDocumentRegion;
- IStructuredDocumentRegion flatNode = proxy.getStructuredDocumentRegion();
- if (flatNode == oldStructuredDocumentRegion)
- this.gapStructuredDocumentRegion = null;
- }
- else if (this.gapStructuredDocumentRegion instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) this.gapStructuredDocumentRegion;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue;
- if (content == oldStructuredDocumentRegion) {
- if (count > 1)
- container.removeStructuredDocumentRegion(i);
- else
- this.gapStructuredDocumentRegion = null;
- return;
- }
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- if (count > 1)
- container.removeStructuredDocumentRegion(i);
- else
- this.gapStructuredDocumentRegion = null;
- return;
- }
- }
- }
- }
- }
-
- private void removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
- if (oldStructuredDocumentRegion == null)
- return; // error
- if (this.parentNode == null)
- return; // error
-
- int gapEnd = this.gapOffset + this.gapLength;
- int oldOffset = oldStructuredDocumentRegion.getStart();
- int oldEnd = oldStructuredDocumentRegion.getEnd();
- if (oldOffset >= this.gapOffset && oldEnd <= gapEnd)
- return; // do nothing
- int oldLength = oldEnd - oldOffset;
- if (oldOffset >= gapEnd)
- oldOffset += this.diff;
-
- // find owner node
- NodeImpl ownerNode = null;
- ElementImpl ownerEndTag = null;
- TextImpl ownerText = null;
- while (this.parentNode != null) {
- if (this.nextNode != null) {
- if (this.nextNode.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- ownerNode = this.nextNode;
- break;
- }
- if (this.nextNode.getNodeType() == Node.TEXT_NODE) {
- TextImpl text = (TextImpl) this.nextNode;
- if (text.hasStructuredDocumentRegion(oldStructuredDocumentRegion)) {
- ownerNode = this.nextNode;
- ownerText = text;
- break;
- }
- }
-
- Node child = this.nextNode.getFirstChild();
- if (child != null) {
- this.parentNode = this.nextNode;
- this.nextNode = (NodeImpl) child;
- continue;
- }
-
- if (this.nextNode.getNodeType() == Node.ELEMENT_NODE) {
- this.parentNode = this.nextNode;
- this.nextNode = null;
- continue;
- }
-
- this.nextNode = (NodeImpl) this.nextNode.getNextSibling();
- if (this.nextNode != null)
- continue;
- }
-
- if (this.parentNode.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) this.parentNode;
- if (element.getEndStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- ownerNode = this.parentNode;
- ownerEndTag = element;
- break;
- }
- }
-
- this.nextNode = (NodeImpl) this.parentNode.getNextSibling();
- this.parentNode = (NodeImpl) this.parentNode.getParentNode();
- }
- if (ownerNode == null)
- throw new StructuredDocumentRegionManagementException();
-
- if (ownerText != null) {
- IStructuredDocumentRegion flatNode = ownerText.getStructuredDocumentRegion();
- if (flatNode == oldStructuredDocumentRegion) {
- IStructuredDocumentRegion newStructuredDocumentRegion = new StructuredDocumentRegionProxy(oldOffset, oldLength);
- ownerText.setStructuredDocumentRegion(newStructuredDocumentRegion);
- return;
- }
-
- if (flatNode instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
- if (proxy.getStructuredDocumentRegion() != oldStructuredDocumentRegion) {
- throw new StructuredDocumentRegionManagementException();
- }
- int offset = proxy.getOffset();
- int end = offset + proxy.getLength();
- if (offset >= this.gapOffset) {
- proxy.setOffset(offset + this.diff);
- }
- proxy.setStructuredDocumentRegion(null);
- if (end < oldEnd && (end < this.gapOffset || oldEnd > gapEnd)) { // has
- // shared
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- }
- else if (flatNode instanceof StructuredDocumentRegionContainer) {
- StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
- int count = container.getStructuredDocumentRegionCount();
- for (int i = 0; i < count; i++) {
- IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
- if (content == null)
- continue; // error
- if (content == oldStructuredDocumentRegion) {
- IStructuredDocumentRegion newStructuredDocumentRegion = new StructuredDocumentRegionProxy(oldOffset, oldLength);
- container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
- return;
- }
-
- if (content instanceof StructuredDocumentRegionProxy) {
- StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) content;
- if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
- int offset = proxy.getOffset();
- int end = offset + proxy.getLength();
- if (offset >= this.gapOffset) {
- proxy.setOffset(offset + this.diff);
- }
- proxy.setStructuredDocumentRegion(null);
- if (end < oldEnd && (end < this.gapOffset || oldEnd > gapEnd)) { // has
- // shared
- removeStructuredDocumentRegion(oldStructuredDocumentRegion);
- return;
- }
- }
- }
- }
- }
- else {
- throw new StructuredDocumentRegionManagementException();
- }
- }
- else {
- IStructuredDocumentRegion newStructuredDocumentRegion = new StructuredDocumentRegionProxy(oldOffset, oldLength);
- if (ownerEndTag != null) {
- ownerEndTag.setEndStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- else {
- ownerNode.setStructuredDocumentRegion(newStructuredDocumentRegion);
- }
- }
- }
-
- /**
- * replaceAttr method
- *
- * @param ownerElement
- * org.w3c.dom.Element
- * @param newAttr
- * org.w3c.dom.Attr
- * @param oldAttr
- * org.w3c.dom.Attr
- */
- void replaceAttr(Element ownerElement, Attr newAttr, Attr oldAttr) {
- if (ownerElement == null)
- return;
- if (getStructuredDocument() == null)
- return;
-
- ElementImpl element = (ElementImpl) ownerElement;
- if (!element.hasStartTag()) {
- changeStartTag(element);
- return;
- }
- if (element.isCommentTag()) {
- changeStartTag(element);
- return;
- }
-
- int offset = element.getStartOffset();
- int start = offset;
- int end = offset;
-
- boolean insertSpace = false;
- String attrValueClose = null;
- if (oldAttr != null) {
- AttrImpl impl = (AttrImpl) oldAttr;
- ITextRegion nameRegion = impl.getNameRegion();
- if (nameRegion == null)
- return; // must never happen
- ITextRegion lastRegion = impl.getValueRegion();
- if (lastRegion != null) {
- end += lastRegion.getEnd();
- }
- else {
- lastRegion = impl.getEqualRegion();
- if (lastRegion != null) {
- end += lastRegion.getEnd();
- }
- else {
- end += nameRegion.getEnd();
- lastRegion = nameRegion;
- }
- }
- // check there are extra space before the last attribute
- IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion();
- if (flatNode == null)
- return; // must never happen
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return; // must never happen
- ITextRegion prevRegion = null;
- ITextRegion nextRegion = null;
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (region == nameRegion) {
- if (i > 0) {
- prevRegion = regions.get(i - 1);
- }
- }
- if (region == lastRegion) {
- if (i + 1 < regions.size()) {
- nextRegion = regions.get(i + 1);
- }
- break;
- }
- }
- boolean isLastAttr = false;
- if (nextRegion != null) {
- String regionType = nextRegion.getType();
- if (regionType == DOMRegionContext.XML_TAG_CLOSE || regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE || isNestedTagClose(regionType)) {
- isLastAttr = true;
- }
- }
- if (isLastAttr && prevRegion != null) {
- start += prevRegion.getTextEnd();
- }
- else {
- start += nameRegion.getStart();
- }
-
- // impl.resetRegions(ownerElement);
- impl.resetRegions(element);
- }
- else { // append attribute
- IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion();
- if (flatNode == null)
- return; // must never happen
-
- attrValueClose = getAttrValueClose(element);
- if (attrValueClose != null && attrValueClose.length() > 0) {
- insertSpace = true;
- start = flatNode.getEndOffset();
- end = start;
- }
- else {
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return; // must never happen
- int attrStart = 0;
- for (int i = regions.size() - 1; i >= 0; i--) {
- ITextRegion region = regions.get(i);
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_CLOSE || regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE || isNestedTagClose(regionType))
- continue;
- int regionEnd = region.getEnd();
- if (regionEnd == region.getTextEnd())
- insertSpace = true;
- attrStart = regionEnd;
- break;
- }
- if (attrStart == 0)
- return; // not found, must never happen
- start += attrStart;
- end = start;
- }
- }
-
- String source = null;
- if (newAttr != null) {
- int size = 2;
- if (attrValueClose != null)
- size += attrValueClose.length();
- String name = this.generator.generateAttrName(newAttr);
- if (name != null)
- size += name.length();
- String value = this.generator.generateAttrValue(newAttr);
- if (value != null)
- size += value.length();
- StringBuffer buffer = new StringBuffer(size);
- if (attrValueClose != null)
- buffer.append(attrValueClose);
- if (insertSpace)
- buffer.append(' ');
- buffer.append(name);
- if (value != null) {
- buffer.append('=');
- buffer.append(value);
- }
- source = buffer.toString();
- }
-
- replaceSource(source, start, end);
- }
-
- protected boolean isNestedTagClose(String regionType) {
- boolean result = false;
- return result;
- }
-
- /**
- * replaceChild method
- *
- * @param parentNode
- * org.w3c.dom.Node
- * @param newChild
- * org.w3c.dom.Node
- * @param oldChild
- * org.w3c.dom.Node
- */
- void replaceChild(Node parentNode, Node newChild, Node oldChild) {
- if (parentNode == null)
- return;
- if (newChild == null && oldChild == null)
- return;
- if (getStructuredDocument() == null)
- return;
-
- int start = 0;
- int end = 0;
- String preTag = null;
- String postTag = null;
- ElementImpl postElement = null;
- if (oldChild != null) {
- NodeImpl node = (NodeImpl) oldChild;
- start = node.getStartOffset();
- end = node.getEndOffset();
- if (oldChild.getNodeType() == Node.TEXT_NODE) {
- this.gapStructuredDocumentRegion = node.getStructuredDocumentRegion();
- }
- node.resetStructuredDocumentRegions(); // reset values from
- // IStructuredDocumentRegion
- }
- else {
- NodeImpl prev = (NodeImpl) newChild.getPreviousSibling();
- if (prev != null) {
- start = prev.getEndOffset();
- end = start;
- preTag = getCloseTag(prev);
- }
- else {
- // first child
- NodeImpl next = (NodeImpl) newChild.getNextSibling();
- if (next != null) {
- start = next.getStartOffset();
- end = start;
- if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
- preTag = getStartCloseTag((IDOMElement) parentNode);
- }
- }
- else {
- // newly having a child
- if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parentNode;
- if (element.isEmptyTag()) { // empty tag format
- // need to generate the start and the end tags
- end = element.getEndOffset();
- start = end - 2; // for "/>"
- element.setEmptyTag(false);
- preTag = this.generator.generateCloseTag(element);
- postTag = this.generator.generateEndTag(element);
- postElement = element;
- }
- else if (!element.hasStartTag()) {
- start = element.getStartOffset();
- end = start;
- // invalid end tag or implicit tag
- // need to generate the start tag
- preTag = this.generator.generateStartTag(element);
- if (preTag != null) {
- int length = preTag.length();
- if (length > 0) {
- IStructuredDocumentRegion flatNode = new StructuredDocumentRegionProxy(start, length);
- element.setStartStructuredDocumentRegion(flatNode);
- }
- }
- if (!element.hasEndTag()) {
- // implicit tag
- // need to generate the end tags
- postTag = this.generator.generateEndTag(element);
- postElement = element;
- }
- }
- else {
- start = element.getStartEndOffset();
- end = start;
- preTag = getStartCloseTag(element);
- if (preTag != null && preTag.length() > 0) {
- if (!element.hasEndTag() && (element.isJSPContainer() || element.isCDATAContainer())) {
- // need to generate the end tag
- postTag = this.generator.generateEndTag(element);
- postElement = element;
- }
- }
- }
- }
- // else might DOCUMENT_NODE, start and end are 0
- }
- }
- }
-
- String source = null;
- if (newChild != null) {
- StringBuffer buffer = new StringBuffer();
- int offset = start;
- if (preTag != null) {
- int length = preTag.length();
- if (length > 0) {
- offset += length;
- buffer.append(preTag);
- }
- }
-
- NodeImpl node = (NodeImpl) newChild;
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) node;
- if (element.preferEmptyTag())
- element.setEmptyTag(true);
- IStructuredDocumentRegion flatNode = null;
- String startTag = this.generator.generateStartTag(element);
- if (startTag != null) {
- int length = startTag.length();
- if (length > 0) {
- buffer.append(startTag);
- flatNode = new StructuredDocumentRegionProxy(offset, length);
- offset += length;
- }
- }
- element.setStartStructuredDocumentRegion(flatNode);
- }
- else {
- String content = this.generator.generateSource(node);
- if (content == null)
- content = NodeImpl.EMPTY_STRING;
- int length = content.length();
- IStructuredDocumentRegion flatNode = null;
- if (length > 0) {
- buffer.append(content);
- flatNode = new StructuredDocumentRegionProxy(offset, length);
- offset += length;
- }
- node.setStructuredDocumentRegion(flatNode);
- }
-
- NodeImpl child = (NodeImpl) node.getFirstChild();
- if (child != null) {
- node = child;
- continue;
- }
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) node;
- IStructuredDocumentRegion flatNode = null;
- String endTag = this.generator.generateEndTag(element);
- if (endTag != null) {
- int length = endTag.length();
- if (length > 0) {
- buffer.append(endTag);
- flatNode = new StructuredDocumentRegionProxy(offset, length);
- offset += length;
- }
- }
- element.setEndStructuredDocumentRegion(flatNode);
- }
-
- while (node != null) {
- if (node == newChild) {
- node = null;
- break;
- }
- NodeImpl next = (NodeImpl) node.getNextSibling();
- if (next != null) {
- node = next;
- break;
- }
-
- node = (NodeImpl) node.getParentNode();
- if (node.getNodeType() != Node.ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- IStructuredDocumentRegion flatNode = null;
- String endTag = this.generator.generateEndTag(element);
- if (endTag != null) {
- int length = endTag.length();
- if (length > 0) {
- buffer.append(endTag);
- flatNode = new StructuredDocumentRegionProxy(offset, length);
- offset += length;
- }
- }
- element.setEndStructuredDocumentRegion(flatNode);
- }
- }
-
- if (postTag != null) {
- int length = postTag.length();
- if (length > 0) {
- buffer.append(postTag);
- if (postElement != null) {
- IStructuredDocumentRegion flatNode = new StructuredDocumentRegionProxy(offset, length);
- postElement.setEndStructuredDocumentRegion(flatNode);
- }
- }
- }
- source = buffer.toString();
- }
-
- if (start == end && (source == null || source.length() == 0)) {
- // no thing changed
- return;
- }
-
- replaceSource(source, start, end);
- }
-
- void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) {
- // future_TODO: optimize
-
- NodeImpl root = (NodeImpl) this.model.getDocument();
- this.parentNode = root;
- this.nextNode = (NodeImpl) root.getFirstChild();
-
- removeGapStructuredDocumentRegion(flatNode);
- insertGapStructuredDocumentRegionBefore(flatNode.getStart());
- changeStructuredDocumentRegion(flatNode);
- insertGapStructuredDocumentRegionAfter(flatNode.getEnd());
- }
-
- /**
- * Wraps IStructuredDocumentRegion.replaceText() and sets contextual
- * information.
- */
- private void replaceSource(String source, int start, int end) {
- int inserted = 0;
- if (source == null)
- source = NodeImpl.EMPTY_STRING;
- else
- inserted = source.length();
- int removed = end - start;
- if (inserted == 0 && removed == 0)
- return;
-
- this.gapOffset = start;
- this.gapLength = removed;
- this.diff = inserted - removed;
- // Note: due to bug
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3619
- // for now assume "ignore readonly" region is ok -- assume DOM itself
- // checks if
- // ok to insert or not. In reality, we may have to make or "contains"
- // method more
- // better. Or, we may have to "perculate up" the parameter for clients
- // to tell us programatically
- // that its ok to insert/format in a read-only region.
- getStructuredDocument().replaceText(this.model, this.gapOffset, this.gapLength, source, true);
- }
-
- void replaceStructuredDocumentRegions(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
- NodeImpl root = (NodeImpl) this.model.getDocument();
-
- if (oldStructuredDocumentRegions != null) {
- this.parentNode = root;
- this.nextNode = (NodeImpl) root.getFirstChild();
-
- Enumeration e = oldStructuredDocumentRegions.elements();
- while (e.hasMoreElements()) {
- IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement();
- if (flatNode == null)
- continue;
- removeStructuredDocumentRegion(flatNode);
- removeGapStructuredDocumentRegion(flatNode);
- }
- }
-
- if (newStructuredDocumentRegions != null) {
- this.parentNode = root;
- this.nextNode = (NodeImpl) root.getFirstChild();
-
- IStructuredDocumentRegion lastStructuredDocumentRegion = null;
- Enumeration e = newStructuredDocumentRegions.elements();
- while (e.hasMoreElements()) {
- IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement();
- if (flatNode == null)
- continue;
- if (lastStructuredDocumentRegion == null)
- insertGapStructuredDocumentRegionBefore(flatNode.getStart());
- insertStructuredDocumentRegion(flatNode);
- lastStructuredDocumentRegion = flatNode;
- }
- if (lastStructuredDocumentRegion != null) {
- insertGapStructuredDocumentRegionAfter(lastStructuredDocumentRegion.getEnd());
- }
- else {
- insertGapStructuredDocumentRegionBefore(this.gapOffset);
- // make sure to restore all backuped StructuredDocumentRegions
- insertGapStructuredDocumentRegionAfter(this.gapOffset);
- }
- }
- else {
- this.parentNode = root;
- this.nextNode = (NodeImpl) root.getFirstChild();
-
- insertGapStructuredDocumentRegionBefore(this.gapOffset);
- // make sure to restore all backuped StructuredDocumentRegions
- insertGapStructuredDocumentRegionAfter(this.gapOffset);
- }
- }
-
- /**
- */
- private void updateAttrRegions(Element element, IStructuredDocumentRegion flatNode) {
-
- // update attributes
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return;
- NamedNodeMap attributes = element.getAttributes();
- if (attributes == null)
- return;
- int index = -1;
- AttrImpl attr = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- attr = (AttrImpl) attributes.item(++index);
- if (attr != null) {
- attr.setNameRegion(region);
- // reset other regions
- attr.setEqualRegion(null);
- attr.setValueRegion(null);
- }
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- if (attr != null)
- attr.setEqualRegion(region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- if (attr != null) {
- attr.setValueRegion(region);
- attr = null;
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentCharsetDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentCharsetDetector.java
deleted file mode 100644
index 697f649ebe..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentCharsetDetector.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.encoding;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.internal.document.DocumentReader;
-import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
-import org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector;
-
-
-/**
- * This class reads and parses first of XML file to get encoding.
- *
- */
-public class XMLDocumentCharsetDetector extends XMLResourceEncodingDetector implements IDocumentCharsetDetector {
-
- /**
- * XMLLoader constructor comment.
- */
- public XMLDocumentCharsetDetector() {
- super();
- }
-
- public void set(IDocument document) {
- set(new DocumentReader(document, 0));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentLoader.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentLoader.java
deleted file mode 100644
index 2316b34c44..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/encoding/XMLDocumentLoader.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.encoding;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.document.AbstractDocumentLoader;
-import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory;
-import org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
-import org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.internal.parser.XMLStructuredDocumentReParser;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
-
-
-/**
- * This class reads an XML file and creates an XML Structured Model.
- *
- */
-public class XMLDocumentLoader extends AbstractDocumentLoader {
-
- public XMLDocumentLoader() {
- super();
- }
-
- public IDocumentPartitioner getDefaultDocumentPartitioner() {
- return new StructuredTextPartitionerForXML();
- }
-
- public IDocumentCharsetDetector getDocumentEncodingDetector() {
- if (fDocumentEncodingDetector == null) {
- fDocumentEncodingDetector = new XMLDocumentCharsetDetector();
- }
- return fDocumentEncodingDetector;
- }
-
- public RegionParser getParser() {
- return new XMLSourceParser();
- }
-
- protected String getPreferredNewLineDelimiter(IFile file) {
- String delimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(ContentTypeIdForXML.ContentTypeID_XML);
- if (delimiter == null)
- delimiter = super.getPreferredNewLineDelimiter(file);
- return delimiter;
- }
-
- protected String getSpecDefaultEncoding() {
- // by default, UTF-8 as per XML spec
- final String enc = "UTF-8"; //$NON-NLS-1$
- return enc;
- }
-
- protected IEncodedDocument newEncodedDocument() {
- IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser());
- if (structuredDocument instanceof BasicStructuredDocument) {
- ((BasicStructuredDocument) structuredDocument).setReParser(new XMLStructuredDocumentReParser());
- }
- return structuredDocument;
- }
-
- public IDocumentLoader newInstance() {
- return new XMLDocumentLoader();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java
deleted file mode 100644
index 9537d42fc7..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java
+++ /dev/null
@@ -1,1713 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 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
- * David Carver (STAR) - bug 297006 - String Comparison
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.formatter;
-
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class DefaultXMLPartitionFormatter {
- /**
- * Just a small container class that holds a DOMNode & documentRegion that
- * should represent each other.
- */
- protected class DOMRegion {
- public IDOMNode domNode;
- public IStructuredDocumentRegion documentRegion;
- }
-
- static private final String PRESERVE = "preserve";//$NON-NLS-1$
- static private final String COLLAPSE = "collapse";//$NON-NLS-1$
- static private final String REPLACE = "replace";//$NON-NLS-1$
- static private final String PRESERVE_QUOTED = "\"preserve\"";//$NON-NLS-1$
- static private final String XML_SPACE = "xml:space";//$NON-NLS-1$
- static private final String XSL_NAMESPACE = "http://www.w3.org/1999/XSL/Transform"; //$NON-NLS-1$
- static private final String XSL_ATTRIBUTE = "attribute"; //$NON-NLS-1$
- static private final String XSL_TEXT = "text"; //$NON-NLS-1$
- static private final String SPACE = " "; //$NON-NLS-1$
- static private final String EMPTY = ""; //$NON-NLS-1$
- static private final String PROPERTY_WHITESPACE_FACET = "org.eclipse.wst.xsd.cm.properties/whitespace"; //$NON-NLS-1$
-
- private XMLFormattingPreferences fPreferences = null;
- private IProgressMonitor fProgressMonitor;
-
- private int replaceSpaces(TextEdit textEdit, int spaceStartOffset, int availableLineWidth, String whitespaceRun) {
- StringBuffer buff = new StringBuffer(whitespaceRun);
- for(int i = 0; i < buff.length(); i++) {
- buff.setCharAt(i, ' '); //$NON-NLS-1$
- }
- String replacementString = buff.toString();
- if (!replacementString.equals(whitespaceRun)) {
- ReplaceEdit replaceEdit = new ReplaceEdit(spaceStartOffset, whitespaceRun.length(), replacementString);
- textEdit.addChild(replaceEdit);
- }
- return availableLineWidth;
- }
-
- private int collapseSpaces(TextEdit textEdit, int spaceStartOffset, int availableLineWidth, String whitespaceRun) {
- // prefer to use use existing whitespace
- int existingWhitespaceOffset = whitespaceRun.indexOf(' ');
- if (existingWhitespaceOffset > -1) {
- // delete whitespaces before and after existing whitespace
- if (existingWhitespaceOffset > 0) {
- DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset, existingWhitespaceOffset);
- textEdit.addChild(deleteEdit);
- }
- if (existingWhitespaceOffset < whitespaceRun.length() - 1) {
- int nextOffset = existingWhitespaceOffset + 1;
- DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset + nextOffset, whitespaceRun.length() - nextOffset);
- textEdit.addChild(deleteEdit);
- }
- }
- else {
- // delete all whitespace and insert new one
- // collapse whitespace by deleting whitespace
- DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset, whitespaceRun.length());
- textEdit.addChild(deleteEdit);
- // then insert one space
- InsertEdit insertEdit = new InsertEdit(spaceStartOffset, SPACE);
- textEdit.addChild(insertEdit);
- }
- // remember to account for space added
- --availableLineWidth;
- return availableLineWidth;
- }
-
- private int collapseAndIndent(TextEdit textEdit, int spaceStartOffset, int availableLineWidth, int indentLevel, String whitespaceRun, IStructuredDocumentRegion currentRegion) {
- // Need to keep blank lines, but still collapse the whitespace
- String lineDelimiters = null;
- if (!getFormattingPreferences().getClearAllBlankLines()) {
- lineDelimiters = extractLineDelimiters(whitespaceRun, currentRegion);
- String formattedLine = lineDelimiters + getIndentString(indentLevel);
- if(lineDelimiters.length() > 0 && !formattedLine.equals(whitespaceRun)) {
- textEdit.addChild(new ReplaceEdit(spaceStartOffset, whitespaceRun.length(), formattedLine));
- availableLineWidth = getFormattingPreferences().getMaxLineWidth() - indentLevel;
- }
- }
- if (lineDelimiters == null || lineDelimiters.length() == 0) {
- availableLineWidth = collapseSpaces(textEdit, spaceStartOffset, availableLineWidth, whitespaceRun);
- }
- return availableLineWidth;
- }
-
- private void deleteTrailingSpaces(TextEdit textEdit, ITextRegion currentTextRegion, IStructuredDocumentRegion currentDocumentRegion) {
- int textEnd = currentTextRegion.getTextEnd();
- int textEndOffset = currentDocumentRegion.getStartOffset() + textEnd;
- int difference = currentTextRegion.getEnd() - textEnd;
- DeleteEdit deleteEdit = new DeleteEdit(textEndOffset, difference);
- textEdit.addChild(deleteEdit);
- }
-
- public TextEdit format(IDocument document, int start, int length) {
- return format(document, start, length, new XMLFormattingPreferences());
- }
-
- public TextEdit format(IDocument document, int start, int length, XMLFormattingPreferences preferences) {
- TextEdit edit = null;
- if (document instanceof IStructuredDocument) {
- IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) document);
- if (model != null) {
- try {
- edit = format(model, start, length, preferences);
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
- return edit;
- }
-
- public TextEdit format(IStructuredModel model, int start, int length) {
- return format(model, start, length, new XMLFormattingPreferences());
- }
-
- public TextEdit format(IStructuredModel model, int start, int length, XMLFormattingPreferences preferences) {
- setFormattingPreferences(preferences);
-
- TextEdit edit = new MultiTextEdit();
- IStructuredDocument document = model.getStructuredDocument();
- // get initial document region
- IStructuredDocumentRegion currentRegion = document.getRegionAtCharacterOffset(start);
- if (currentRegion != null) {
- int startOffset = currentRegion.getStartOffset();
-
- // get initial dom node
- IndexedRegion currentIndexedRegion = model.getIndexedRegion(startOffset);
- if (currentIndexedRegion instanceof IDOMNode) {
- // set up domRegion which will contain current region to be
- // formatted
- IDOMNode currentDOMNode = (IDOMNode) currentIndexedRegion;
- DOMRegion domRegion = new DOMRegion();
- domRegion.documentRegion = currentRegion;
- domRegion.domNode = currentDOMNode;
-
- XMLFormattingConstraints parentConstraints = getRegionConstraints(currentDOMNode);
-
- /* if the whitespace strategy is declared as default, get it from the preferences */
- if(XMLFormattingConstraints.DEFAULT.equals(parentConstraints.getWhitespaceStrategy()))
- parentConstraints.setWhitespaceStrategy(preferences.getElementWhitespaceStrategy());
-
- // TODO: initialize indentLevel
- // initialize available line width
- int lineWidth = getFormattingPreferences().getMaxLineWidth();
- try {
- IRegion lineInfo = document.getLineInformationOfOffset(startOffset);
- lineWidth = lineWidth - (startOffset - lineInfo.getOffset());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- parentConstraints.setAvailableLineWidth(lineWidth);
-
- // format all siblings (and their children) as long they
- // overlap with start/length
- Position formatRange = new Position(start, length);
- formatSiblings(edit, domRegion, parentConstraints, formatRange);
- }
- }
- return edit;
- }
-
- /**
- * Determines the formatting constraints for a specified node based on
- * its ancestors' formatting. In particular, if any ancestor node either
- * explicitly defines whitespace preservation or ignorance, that
- * whitespace strategy should be used for <code>currentNode</code> and
- * all of its descendants.
- *
- * @param currentNode the node to investigate the ancestry of to determine
- * formatting constraints
- *
- * @return formatting constraints defined by an ancestor
- */
- private XMLFormattingConstraints getRegionConstraints(IDOMNode currentNode) {
- IDOMNode iterator = currentNode;
- XMLFormattingConstraints result = new XMLFormattingConstraints();
- DOMRegion region = new DOMRegion();
- XMLFormattingConstraints parentConstraints = new XMLFormattingConstraints();
- boolean parent = true;
-
- /* Iterate through the ancestry to find if any explicit whitespace strategy has
- * been defined
- */
- while(iterator != null && iterator.getNodeType() != Node.DOCUMENT_NODE) {
- iterator = (IDOMNode) iterator.getParentNode();
- region.domNode = iterator;
- region.documentRegion = iterator.getFirstStructuredDocumentRegion();
-
- updateFormattingConstraints(null, null, result, region);
-
- /* If this is the parent of the current node, keep the constraints
- * in case no other constraints are identified
- */
- if(parent) {
- parentConstraints.copyConstraints(result);
- parent = false;
- }
-
- /* A parent who has defined a specific whitespace strategy was found */
- if(XMLFormattingConstraints.PRESERVE.equals(result.getWhitespaceStrategy()) || XMLFormattingConstraints.DEFAULT.equals(result.getWhitespaceStrategy()))
- return result;
- }
-
- return parentConstraints;
- }
-// private XMLFormattingConstraints getRegionConstraints(IDOMNode currentNode) {
-// IDOMNode iterator = (IDOMNode) currentNode.getParentNode();
-// XMLFormattingConstraints result = new XMLFormattingConstraints();
-// DOMRegion region = new DOMRegion();
-//
-// /* Iterate through the ancestry to find if any explicit whitespace strategy has
-// * been defined
-// */
-// while(iterator != null && iterator.getNodeType() != Node.DOCUMENT_NODE) {
-
-// region.domNode = iterator;
-// region.documentRegion = iterator.getFirstStructuredDocumentRegion();
-//
-// updateFormattingConstraints(null, null, result, region);
-//
-// /* A parent who has defined a specific whitespace strategy was found */
-// if(XMLFormattingConstraints.PRESERVE == result.getWhitespaceStrategy() || XMLFormattingConstraints.DEFAULT == result.getWhitespaceStrategy())
-// return result;
-//
-// iterator = (IDOMNode) iterator.getParentNode();
-// }
-//
-// return null;
-// }
-
- /**
- * Formats the given xml content region
- *
- * @param textEdit
- * @param formatRange
- * @param parentConstraints
- * @param currentDOMRegion
- * @param previousRegion
- */
- private void formatContent(TextEdit textEdit, Position formatRange, XMLFormattingConstraints parentConstraints, DOMRegion currentDOMRegion, IStructuredDocumentRegion previousRegion) {
- IStructuredDocumentRegion currentRegion = currentDOMRegion.documentRegion;
- String fullText = currentDOMRegion.domNode.getSource();
-
- // check if in preserve space mode, if so, don't touch anything but
- // make sure to update available line width
- String whitespaceMode = parentConstraints.getWhitespaceStrategy();
- if (XMLFormattingConstraints.PRESERVE.equals(whitespaceMode)) {
- int availableLineWidth = parentConstraints.getAvailableLineWidth();
- availableLineWidth = updateLineWidthWithLastLine(fullText, availableLineWidth);
-
- // update available line width in constraints
- parentConstraints.setAvailableLineWidth(availableLineWidth);
- // A text node can contain multiple structured document regions - sync the documentRegion
- // with the last region of the node since the text from all regions was formatted
- currentDOMRegion.documentRegion = currentDOMRegion.domNode.getLastStructuredDocumentRegion();
- return;
- }
-
- // if content is just whitespace and there's something after it
- // just skip over this region because region will take care of it
- boolean isAllWhitespace = ((IDOMText) currentDOMRegion.domNode).isElementContentWhitespace();
- IStructuredDocumentRegion nextDocumentRegion = null;
- if (isAllWhitespace) {
- parentConstraints.setAvailableLineWidth(fPreferences.getMaxLineWidth());
- nextDocumentRegion = currentRegion.getNext();
- if (nextDocumentRegion != null)
- return;
- }
-
- // special handling if text follows an entity or cdata region
- if (!XMLFormattingConstraints.COLLAPSE.equals(whitespaceMode) && previousRegion != null) {
- String previouRegionType = previousRegion.getType();
- if (DOMRegionContext.XML_ENTITY_REFERENCE.equals(previouRegionType) || DOMRegionContext.XML_CDATA_TEXT.equals(previouRegionType))
- whitespaceMode = XMLFormattingConstraints.COLLAPSE;
- }
- // also, special handling if text is before an entity or cdata region
- if (!XMLFormattingConstraints.COLLAPSE.equals(whitespaceMode)) {
- // get next document region if dont already have it
- if (nextDocumentRegion == null)
- nextDocumentRegion = currentRegion.getNext();
- if (nextDocumentRegion != null) {
- String nextRegionType = nextDocumentRegion.getType();
- if (DOMRegionContext.XML_ENTITY_REFERENCE.equals(nextRegionType) || DOMRegionContext.XML_CDATA_TEXT.equals(nextRegionType))
- whitespaceMode = XMLFormattingConstraints.COLLAPSE;
- }
- }
- final IStructuredDocumentRegion lastRegion = currentDOMRegion.domNode.getLastStructuredDocumentRegion();
- formatTextInContent(textEdit, parentConstraints, currentRegion, lastRegion != null ? lastRegion.getNext(): null, fullText, whitespaceMode);
- // A text node can contain multiple structured document regions - sync the documentRegion
- // with the last region of the node since the text from all regions was formatted
- currentDOMRegion.documentRegion = lastRegion;
- }
-
- private void formatEmptyStartTagWithNoAttr(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion, int availableLineWidth, String indentStrategy, String whitespaceStrategy, ITextRegion currentTextRegion) {
- // get preference if there should be a space or not between tag
- // name and empty tag close
- // <tagName />
- boolean oneSpaceInTagName = getFormattingPreferences().getSpaceBeforeEmptyCloseTag();
-
- // calculate available line width
- int tagNameLineWidth = currentTextRegion.getTextLength() + 3;
- if (oneSpaceInTagName) {
- // add one more to account for space before empty tag close
- ++tagNameLineWidth;
- }
- availableLineWidth -= tagNameLineWidth;
-
- if (XMLFormattingConstraints.INLINE.equals(indentStrategy)) {
- // if was inlining, need to check if out of available line
- // width
- if (availableLineWidth < 0) {
- // need to indent if possible
- int lineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, true);
- // update available line width
- if (lineWidth > 0)
- availableLineWidth = lineWidth - tagNameLineWidth;
- else
- availableLineWidth -= tagNameLineWidth;
- }
- else {
- // no need to indent
- // just make sure to delete previous whitespace if
- // needed
- if ((DOMRegionContext.XML_CONTENT.equals(previousDocumentRegion.getType())) && (previousDocumentRegion.getFullText().trim().length() == 0)) {
- availableLineWidth = collapseSpaces(textEdit, previousDocumentRegion.getStartOffset(), availableLineWidth, previousDocumentRegion.getFullText());
- }
- }
- }
-
- // delete any trail spaces after tag name
- int textLength = currentTextRegion.getTextLength();
- int regionLength = currentTextRegion.getLength();
-
- boolean thereAreSpaces = textLength < regionLength;
- if (!oneSpaceInTagName && thereAreSpaces) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- }
- else if(oneSpaceInTagName) {
- insertSpaceAndCollapse(textEdit, currentDocumentRegion, availableLineWidth, currentTextRegion);
- }
- constraints.setAvailableLineWidth(availableLineWidth);
- }
-
- /**
- * Formats an end tag
- *
- * @param textEdit
- * @param currentRegion
- * @param textRegions
- */
- private void formatEndTag(TextEdit textEdit, Position formatRange, XMLFormattingConstraints constraints, DOMRegion currentDOMRegion, IStructuredDocumentRegion previousDocumentRegion) {
- IStructuredDocumentRegion currentDocumentRegion = currentDOMRegion.documentRegion;
-
- String whitespaceStrategy = constraints.getWhitespaceStrategy();
- String indentStrategy = constraints.getIndentStrategy();
-
- // do not format space before start tag if preserving spaces
- if (whitespaceStrategy != XMLFormattingConstraints.PRESERVE) {
- // format like indent strategy says
- if (XMLFormattingConstraints.INDENT.equals(indentStrategy) || XMLFormattingConstraints.NEW_LINE.equals(indentStrategy)) {
- int availableLineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, false);
- constraints.setAvailableLineWidth(availableLineWidth);
- }
- else if ( XMLFormattingConstraints.INLINE.equals(indentStrategy)){
- IStructuredDocument doc = currentDocumentRegion.getParentDocument();
- int currentLine = doc.getLineOfOffset(currentDocumentRegion.getStartOffset());
- int prevLine = doc.getLineOfOffset(previousDocumentRegion.getStartOffset());
- if ( currentLine != prevLine){
- int availableLineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, false);
- constraints.setAvailableLineWidth(availableLineWidth);
- }
- }
- }
- // format the end tag itself
- formatWithinEndTag(textEdit, constraints, currentDocumentRegion, previousDocumentRegion);
- }
-
- /**
- * Formats the given region (and all its children) contained in domRegion.
- *
- * @param edit
- * edits required to format
- * @param formatRange
- * document range to format (only format content within this
- * range)
- * @param parentConstraints
- * @param domRegion
- * assumes dom node & region are not null
- * @param previousRegion
- * could be null
- * @return Returns the last region formatted
- */
- private DOMRegion formatRegion(TextEdit edit, Position formatRange, XMLFormattingConstraints parentConstraints, DOMRegion domRegion, IStructuredDocumentRegion previousRegion) {
- IStructuredDocumentRegion currentRegion = domRegion.documentRegion;
- String regionType = currentRegion.getType();
- if (DOMRegionContext.XML_TAG_NAME.equals(regionType)) {
- ITextRegion textRegion = currentRegion.getFirstRegion();
- String textRegionType = textRegion.getType();
- if (DOMRegionContext.XML_TAG_OPEN.equals(textRegionType)) {
- domRegion = formatStartTag(edit, formatRange, parentConstraints, domRegion, previousRegion);
- }
- else if (DOMRegionContext.XML_END_TAG_OPEN.equals(textRegionType)) {
- formatEndTag(edit, formatRange, parentConstraints, domRegion, previousRegion);
- }
- }
- else if (DOMRegionContext.XML_CONTENT.equals(regionType) || domRegion.domNode.getNodeType() == Node.TEXT_NODE) {
- formatContent(edit, formatRange, parentConstraints, domRegion, previousRegion);
- }
- else if (DOMRegionContext.XML_COMMENT_TEXT.equals(regionType)) {
- formatComment(edit, formatRange, parentConstraints, domRegion, previousRegion);
- }
- else {
- // unknown, so just leave alone for now but make sure to update
- // available line width
- String fullText = currentRegion.getFullText();
- int width = updateLineWidthWithLastLine(fullText, parentConstraints.getAvailableLineWidth());
- parentConstraints.setAvailableLineWidth(width);
- }
- return domRegion;
- }
-
- /**
- * Formats the domRegion and all of its children and siblings
- *
- * @param edit
- * @param domRegion
- * @param parentConstraints
- * @param formatRange
- */
- private void formatSiblings(TextEdit edit, DOMRegion domRegion, XMLFormattingConstraints parentConstraints, Position formatRange) {
- IStructuredDocumentRegion previousRegion = null;
- IStructuredDocumentRegion currentRegion = domRegion.documentRegion;
- IDOMNode currentDOMNode = domRegion.domNode;
- while (currentDOMNode != null && currentRegion != null && formatRange.overlapsWith(currentRegion.getStartOffset(), currentRegion.getLength()) && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- domRegion.documentRegion = currentRegion;
- domRegion.domNode = currentDOMNode;
-
- // need to make sure current document region and current
- // dom node match up
- if (currentDOMNode.getFirstStructuredDocumentRegion().equals(currentRegion)) {
- // format this document region/node, formatRegion will
- // return the last node/region formatted
- domRegion = formatRegion(edit, formatRange, parentConstraints, domRegion, previousRegion);
- }
- else {
- // TODO: need to figure out what to do if they don't
- // match up
- }
- previousRegion = domRegion.documentRegion;
- // get the next sibling information
- if (domRegion.domNode != null)
- currentDOMNode = (IDOMNode) domRegion.domNode.getNextSibling();
- else
- currentDOMNode = null;
- currentRegion = previousRegion.getNext();
- }
- }
-
- /**
- * Formats a start tag
- *
- * @param textEdit
- * @param currentRegion
- * @param textRegions
- */
- private DOMRegion formatStartTag(TextEdit textEdit, Position formatRange, XMLFormattingConstraints parentConstraints, DOMRegion currentDOMRegion, IStructuredDocumentRegion previousDocumentRegion) {
- // determine proper indent by referring to parent constraints,
- // previous node, and current node
- IStructuredDocumentRegion currentDocumentRegion = currentDOMRegion.documentRegion;
- IDOMNode currentDOMNode = currentDOMRegion.domNode;
-
- // create a constraint for this tag
- XMLFormattingConstraints thisConstraints = new XMLFormattingConstraints();
- XMLFormattingConstraints childrenConstraints = new XMLFormattingConstraints();
- updateFormattingConstraints(parentConstraints, thisConstraints, childrenConstraints, currentDOMRegion);
-
- if(XMLFormattingConstraints.DEFAULT.equals(childrenConstraints.getWhitespaceStrategy()))
- childrenConstraints.setWhitespaceStrategy((new XMLFormattingPreferences()).getElementWhitespaceStrategy());
-
- String whitespaceStrategy = thisConstraints.getWhitespaceStrategy();
- String indentStrategy = thisConstraints.getIndentStrategy();
- int availableLineWidth = thisConstraints.getAvailableLineWidth();
-
- // format space before start tag
- // do not format space before start tag if preserving spaces
- if (!XMLFormattingConstraints.PRESERVE.equals(whitespaceStrategy)) {
- // format like indent strategy says
- if (XMLFormattingConstraints.INDENT.equals(indentStrategy) || XMLFormattingConstraints.NEW_LINE.equals(indentStrategy)) {
- availableLineWidth = indentIfPossible(textEdit, thisConstraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, true, true);
- if (availableLineWidth > 0)
- thisConstraints.setAvailableLineWidth(availableLineWidth);
- }
- }
- // format the start tag itself
- boolean tagEnded = formatWithinTag(textEdit, thisConstraints, currentDocumentRegion, previousDocumentRegion);
-
- // format children
- if (!tagEnded) {
- // update childConstraints with thisConstraint's indentLevel &
- // availableLineWidth
- childrenConstraints.setIndentLevel(thisConstraints.getIndentLevel());
- childrenConstraints.setAvailableLineWidth(thisConstraints.getAvailableLineWidth());
-
- previousDocumentRegion = currentDocumentRegion;
- IDOMNode childDOMNode = (IDOMNode) currentDOMNode.getFirstChild();
- IStructuredDocumentRegion nextRegion = currentDocumentRegion.getNext();
- boolean passedFormatRange = false;
- // as long as there is one child
- if (childDOMNode != null && nextRegion != null) {
- while (childDOMNode != null && nextRegion != null && !passedFormatRange && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- DOMRegion childDOMRegion = new DOMRegion();
- childDOMRegion.documentRegion = nextRegion;
- childDOMRegion.domNode = childDOMNode;
- if (nextRegion.equals(childDOMNode.getFirstStructuredDocumentRegion())) {
- // format children. pass in child constraints
- childDOMRegion = formatRegion(textEdit, formatRange, childrenConstraints, childDOMRegion, previousDocumentRegion);
- }
- else {
- // TODO: what happens if they dont match up?
- }
-
- // update childDOMRegion with next dom/region node
- if (childDOMRegion.domNode != null) {
- childDOMNode = (IDOMNode) childDOMRegion.domNode.getNextSibling();
- }
- else {
- childDOMNode = null;
- }
- previousDocumentRegion = childDOMRegion.documentRegion;
- nextRegion = previousDocumentRegion.getNext();
- if (nextRegion != null)
- passedFormatRange = !formatRange.overlapsWith(nextRegion.getStartOffset(), nextRegion.getLength());
- }
- }
- else {
- // there were no children, so keep end tag inlined
- childrenConstraints.setWhitespaceStrategy(XMLFormattingConstraints.COLLAPSE);
- childrenConstraints.setIndentStrategy(XMLFormattingConstraints.INLINE);
- }
-
- if (!passedFormatRange) {
- // update the dom region with the last formatted region/dom
- // node should be end tag and this tag's DOMNode
- currentDOMRegion.documentRegion = nextRegion;
- currentDOMRegion.domNode = currentDOMNode;
-
- // end tag's indent level should be same as start tag's
- childrenConstraints.setIndentLevel(thisConstraints.getIndentLevel());
- // format end tag
- boolean formatEndTag = false;
- if (nextRegion != null && currentDOMNode != null) {
- ITextRegionList rs = nextRegion.getRegions();
- if (rs.size() > 1) {
- ITextRegion r = rs.get(0);
- if (r != null && DOMRegionContext.XML_END_TAG_OPEN.equals(r.getType())) {
- r = rs.get(1);
- if (r != null && DOMRegionContext.XML_TAG_NAME.equals(r.getType())) {
- String tagName = nextRegion.getText(r);
- if (tagName != null && tagName.equals(currentDOMNode.getNodeName()))
- formatEndTag = true;
- }
- }
-
- }
- }
- if (formatEndTag)
- formatEndTag(textEdit, formatRange, childrenConstraints, currentDOMRegion, previousDocumentRegion);
- else {
- // missing end tag so return last formatted document
- // region
- currentDOMRegion.documentRegion = previousDocumentRegion;
- }
- }
- else {
- // passed format range before could finish, so update dom
- // region to last known formatted region
- currentDOMRegion.documentRegion = nextRegion;
- currentDOMRegion.domNode = childDOMNode;
- }
-
- // update parent constraint since this is what is passed back
- parentConstraints.setAvailableLineWidth(childrenConstraints.getAvailableLineWidth());
- }
- else {
- // update available line width
- parentConstraints.setAvailableLineWidth(thisConstraints.getAvailableLineWidth());
- }
- return currentDOMRegion;
- }
-
- private void formatStartTagWithNoAttr(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion, int availableLineWidth, String indentStrategy, String whitespaceStrategy, ITextRegion currentTextRegion) {
- // calculate available line width
- int tagNameLineWidth = currentTextRegion.getTextLength() + 2;
- availableLineWidth -= tagNameLineWidth;
-
- if (XMLFormattingConstraints.INLINE.equals(indentStrategy)) {
- // if was inlining, need to check if out of available line
- // width
- if (availableLineWidth < 0) {
- // need to indent if possible
- int lineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, true);
- // update available line width
- if (lineWidth > 0)
- availableLineWidth = lineWidth - tagNameLineWidth;
- else
- availableLineWidth -= tagNameLineWidth;
- }
- else {
- // no need to indent
- // just make sure to delete previous whitespace if
- // needed
- if (previousDocumentRegion != null) {
- if (DOMRegionContext.XML_CONTENT.equals(previousDocumentRegion.getType())) {
- String previousDocumentRegionText = previousDocumentRegion.getFullText();
- if (previousDocumentRegionText.trim().length() == 0) {
- availableLineWidth = collapseSpaces(textEdit, previousDocumentRegion.getStartOffset(), availableLineWidth, previousDocumentRegionText);
- }
- }
- }
- }
- }
-
- // delete any trail spaces after tag name
- if (currentTextRegion.getTextLength() < currentTextRegion.getLength()) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- }
- constraints.setAvailableLineWidth(availableLineWidth);
- }
-
- /**
- * Format the text in xml content
- *
- * @param textEdit
- * @param parentConstraints
- * @param currentRegion
- * @param fullText
- * @param whitespaceMode
- */
- private void formatTextInContent(TextEdit textEdit, XMLFormattingConstraints parentConstraints, IStructuredDocumentRegion currentRegion, IStructuredDocumentRegion nextRegion, String fullText, String whitespaceMode) {
- int availableLineWidth = parentConstraints.getAvailableLineWidth();
-
- // determine indentation
- boolean forceInitialIndent = false;
- int indentLevel = parentConstraints.getIndentLevel() + 1;
- String indentMode = parentConstraints.getIndentStrategy();
- if (XMLFormattingConstraints.INDENT.equals(indentMode)) {
- forceInitialIndent = true;
- }
- if (XMLFormattingConstraints.NEW_LINE.equals(indentMode)) {
- indentLevel = parentConstraints.getIndentLevel();
- forceInitialIndent = true;
- }
-
- int fullTextOffset = 0;
- char[] fullTextArray = fullText.toCharArray();
- while (fullTextOffset < fullTextArray.length) {
- // gather all whitespaces
- String whitespaceRun = getCharacterRun(fullTextArray, fullTextOffset, true);
- if (whitespaceRun.length() > 0) {
- // offset where whitespace starts
- int whitespaceStart = fullTextOffset;
- // update current offset in fullText
- fullTextOffset += whitespaceRun.length();
-
- // gather following word
- String characterRun = getCharacterRun(fullTextArray, fullTextOffset, false);
- int characterRunLength = characterRun.length();
- if (characterRunLength > 0) {
- // indent if word is too long or forcing initial
- // indent
- availableLineWidth -= characterRunLength;
- // offset where indent/collapse will happen
- int startOffset = currentRegion.getStartOffset() + whitespaceStart;
- if (forceInitialIndent || (availableLineWidth <= 0)) {
- // indent if not already indented
- availableLineWidth = indentIfNotAlreadyIndented(textEdit, currentRegion, indentLevel, startOffset, whitespaceRun);
- // remember to subtract word length
- availableLineWidth -= characterRunLength;
- forceInitialIndent = false; // initial indent done
- }
- else {
- // just collapse spaces, but adjust for any indenting that may result from preserving line delimiters
- if (whitespaceStart == 0 && XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
- // if ignore, trim
- DeleteEdit deleteTrailing = new DeleteEdit(startOffset, whitespaceRun.length());
- textEdit.addChild(deleteTrailing);
- }
- else if(XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
- availableLineWidth = replaceSpaces(textEdit, startOffset, availableLineWidth, whitespaceRun);
- else
- availableLineWidth = collapseAndIndent(textEdit, startOffset, availableLineWidth, indentLevel, whitespaceRun, currentRegion);
- }
-
- fullTextOffset += characterRunLength;
- }
- else {
- // handle trailing whitespace
- int whitespaceOffset = currentRegion.getStartOffset() + whitespaceStart;
- if (XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
- availableLineWidth = replaceSpaces(textEdit, whitespaceOffset, availableLineWidth, whitespaceRun);
- else if (XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
- // always trim
- DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
- textEdit.addChild(deleteTrailing);
- }
- else if(getFormattingPreferences().getClearAllBlankLines()) {
- if (!nextRegionHandlesTrailingWhitespace(nextRegion)) {
- if (XMLFormattingConstraints.IGNORE.equals(whitespaceMode)) {
- // if ignore, trim
- DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
- textEdit.addChild(deleteTrailing);
- }
- else {
- // if collapse, leave a space. but what if end up
- // wanting to add indent? then need to delete space
- // added and add indent instead
- availableLineWidth = collapseSpaces(textEdit, whitespaceOffset, availableLineWidth, whitespaceRun);
- }
- }
- }
- }
- }
- else {
- // gather word
- String characterRun = getCharacterRun(fullTextArray, fullTextOffset, false);
- int characterRunLength = characterRun.length();
- if (characterRunLength > 0) {
- // indent if word is too long or forcing initial
- // indent
- // [243091] - characterRunLength should only be subtracted once or text formatting wraps prematurely
- // availableLineWidth = availableLineWidth - characterRunLength;
- if ((XMLFormattingConstraints.IGNORE.equals(whitespaceMode) || XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) && (forceInitialIndent || (availableLineWidth <= 0))) {
- // indent if not already indented
- availableLineWidth = indentIfNotAlreadyIndented(textEdit, currentRegion, indentLevel, currentRegion.getStartOffset(), whitespaceRun);
- // remember to subtract word length
- availableLineWidth -= characterRunLength;
- forceInitialIndent = false; // initial indent done
- }
- else {
- // just collapse spaces
- availableLineWidth -= characterRunLength;
- }
-
- fullTextOffset += characterRunLength;
- }
- }
- }
- // update available line width
- parentConstraints.setAvailableLineWidth(availableLineWidth);
- }
-
- private boolean nextRegionHandlesTrailingWhitespace(IStructuredDocumentRegion region) {
- if (region == null)
- return false;
- final String type = region.getType();
- if (type.equals(DOMRegionContext.XML_TAG_NAME)) {
- return DOMRegionContext.XML_TAG_OPEN.equals(region.getFirstRegion().getType());
- }
- return DOMRegionContext.XML_COMMENT_TEXT.equals(type);
- }
-
- private void formatWithinEndTag(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion) {
- String indentStrategy = constraints.getIndentStrategy();
- String whitespaceStrategy = constraints.getWhitespaceStrategy();
- int availableLineWidth = constraints.getAvailableLineWidth();
- ITextRegionList textRegions = currentDocumentRegion.getRegions();
- int currentNumberOfRegions = currentDocumentRegion.getNumberOfRegions();
- int currentTextRegionIndex = 1;
-
- ITextRegion currentTextRegion = textRegions.get(currentTextRegionIndex);
- String currentType = currentTextRegion.getType();
- // tag name should always be the first text region
- if (DOMRegionContext.XML_TAG_NAME.equals(currentType) && currentTextRegionIndex < currentNumberOfRegions - 1) {
- ITextRegion nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
- // Bug 221279 - Some non well-formed documents will not contribute a next region
- if (nextTextRegion != null && DOMRegionContext.XML_TAG_CLOSE.equals(nextTextRegion.getType())) {
- // calculate available line width
- int tagNameLineWidth = currentTextRegion.getTextLength() + 3;
- availableLineWidth -= tagNameLineWidth;
-
- if (XMLFormattingConstraints.INLINE.equals(indentStrategy)) {
- // if was inlining, need to check if out of available line
- // width - Whitespace may have been corrected in the text content
- if (availableLineWidth < 0 && XMLFormattingConstraints.IGNORE.equals(whitespaceStrategy)) {
- // need to deindent if possible
- int lineWidth = indentIfPossible(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, false);
- // update available line width
- if (lineWidth > 0)
- availableLineWidth = lineWidth - tagNameLineWidth;
- }
- else {
- // no need to indent
- // just make sure to delete previous whitespace if
- // needed
- if (previousDocumentRegion != null) {
- if (DOMRegionContext.XML_CONTENT.equals(previousDocumentRegion.getType())) {
- String previousDocumentRegionText = previousDocumentRegion.getFullText();
- if (previousDocumentRegionText.trim().length() == 0) {
- availableLineWidth = collapseSpaces(textEdit, previousDocumentRegion.getStartOffset(), availableLineWidth, previousDocumentRegionText);
- }
- }
- }
- }
- }
- // delete any trail spaces after tag name
- if (currentTextRegion.getTextLength() < currentTextRegion.getLength()) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- }
- }
- }
- else {
- // end tag has unexpected stuff, so just leave it alone
- }
- constraints.setAvailableLineWidth(availableLineWidth);
- }
-
- /**
- * Formats the contents within a tag like tag name and attributes
- *
- * @param textEdit
- * @param currentDocumentRegion
- * @param textRegions
- * contains at least 3 regions
- * @return true if tag was ended, false otherwise
- */
- private boolean formatWithinTag(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion) {
- int availableLineWidth = constraints.getAvailableLineWidth();
- String indentStrategy = constraints.getIndentStrategy();
- String whitespaceStrategy = constraints.getWhitespaceStrategy();
- int indentLevel = constraints.getIndentLevel();
- ITextRegionList textRegions = currentDocumentRegion.getRegions();
- int currentTextRegionIndex = 1;
-
- ITextRegion currentTextRegion = textRegions.get(currentTextRegionIndex);
- String currentType = currentTextRegion.getType();
- // tag name should always be the first text region
- if (DOMRegionContext.XML_TAG_NAME.equals(currentType)) {
- ITextRegion nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
- String nextType = (nextTextRegion != null) ? nextTextRegion.getType() : null;
- if (DOMRegionContext.XML_TAG_CLOSE.equals(nextType)) {
- // already at tag close
- formatStartTagWithNoAttr(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, availableLineWidth, indentStrategy, whitespaceStrategy, currentTextRegion);
- return false;
- }
- else if (DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(nextType)) {
- // already at empty tag close
- formatEmptyStartTagWithNoAttr(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, availableLineWidth, indentStrategy, whitespaceStrategy, currentTextRegion);
- return true;
- }
- else {
- availableLineWidth -= (currentTextRegion.getTextLength() + 2);
- boolean alignFinalBracket = getFormattingPreferences().getAlignFinalBracket();
- boolean oneSpaceInTagName = getFormattingPreferences().getSpaceBeforeEmptyCloseTag();
- boolean indentMultipleAttribute = getFormattingPreferences().getIndentMultipleAttributes();
- // indicates if tag spanned more than one line
- boolean spanMoreThan1Line = false;
- // indicates if all attributes should be indented
- boolean indentAllAttributes = false;
- if (indentMultipleAttribute) {
- int attributesCount = 0;
- int i = 2;
- final int size = textRegions.size();
- while (i < size && attributesCount < 2) {
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(textRegions.get(i).getType())) {
- ++attributesCount;
- }
- i++;
- }
- indentAllAttributes = (attributesCount > 1);
- }
-
- while ((currentTextRegionIndex + 1) < textRegions.size()) {
- nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
- nextType = nextTextRegion.getType();
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(nextType)) {
- boolean indentAttribute = indentAllAttributes;
- if (!indentAttribute)
- indentAttribute = shouldIndentBeforeAttribute(constraints, textRegions, availableLineWidth, currentTextRegionIndex, currentTextRegion, nextTextRegion);
- if (indentAttribute) {
- availableLineWidth = indentIfNotAlreadyIndented(textEdit, indentLevel + 1, currentDocumentRegion, currentTextRegion);
- spanMoreThan1Line = true;
- }
- else {
- // otherwise, insertSpaceAndCollapse
- insertSpaceAndCollapse(textEdit, currentDocumentRegion, availableLineWidth, currentTextRegion);
- // update available line width
- availableLineWidth -= (currentTextRegion.getTextLength() + 1);
- }
- }
- else if (DOMRegionContext.XML_TAG_CLOSE.equals(nextType)) {
- // if need to align bracket on next line, indent
- if (alignFinalBracket && spanMoreThan1Line) {
- availableLineWidth = indentIfNotAlreadyIndented(textEdit, indentLevel, currentDocumentRegion, currentTextRegion);
- --availableLineWidth; // for tag close itself
- }
- else {
- // otherwise, just delete space before tag close
- if (currentTextRegion.getTextLength() < currentTextRegion.getLength()) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- availableLineWidth -= (currentTextRegion.getTextLength() + 1);
- }
- }
- // update line width
- constraints.setAvailableLineWidth(availableLineWidth);
- return false;
- }
- else if (DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(nextType)) {
- int textLength = currentTextRegion.getTextLength();
- int regionLength = currentTextRegion.getLength();
-
- boolean thereAreSpaces = textLength < regionLength;
- if (!oneSpaceInTagName && thereAreSpaces) {
- // delete any trail spaces after tag name
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- availableLineWidth -= (currentTextRegion.getTextLength() + 2);
- }
- // insert a space and collapse ONLY IF it's specified
- else if (oneSpaceInTagName) {
- insertSpaceAndCollapse(textEdit, currentDocumentRegion, availableLineWidth, currentTextRegion);
- availableLineWidth -= (currentTextRegion.getTextLength() + 3);
- }
- // update line width
- constraints.setAvailableLineWidth(availableLineWidth);
- return true;
- }
- else {
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(currentType) && DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS.equals(nextType)) {
- if (currentTextRegion.getTextLength() < currentTextRegion.getLength()) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- }
- // update available width
- availableLineWidth -= currentTextRegion.getTextLength();
- }
- else if (DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS.equals(currentType) && DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(nextType)) {
- if (currentTextRegion.getTextLength() < currentTextRegion.getLength()) {
- deleteTrailingSpaces(textEdit, currentTextRegion, currentDocumentRegion);
- }
- // update available width
- availableLineWidth -= currentTextRegion.getTextLength();
- }
- else {
- // otherwise, insertSpaceAndCollapse
- insertSpaceAndCollapse(textEdit, currentDocumentRegion, availableLineWidth, currentTextRegion);
- // update available line width
- availableLineWidth -= (currentTextRegion.getTextLength() + 1);
- }
- }
- currentTextRegion = nextTextRegion;
- currentType = nextType;
- ++currentTextRegionIndex;
- }
- }
- }
- // update line width
- constraints.setAvailableLineWidth(availableLineWidth);
- return false;
- }
-
- /**
- * Format an XML comment structured document region.
- */
- private void formatComment(TextEdit textEdit, Position formatRange, XMLFormattingConstraints parentConstraints, DOMRegion currentDOMRegion, IStructuredDocumentRegion previousRegion) {
- IStructuredDocumentRegion currentRegion = currentDOMRegion.documentRegion;
- int lineWidth = parentConstraints.getAvailableLineWidth() - currentRegion.getFullText().length();
- // Don't format if we're not exceeding the available line width, or if the whitespace
- // strategy is to preserve whitespace - But update line width.
- if(currentRegion == null || XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy()) || !fPreferences.getFormatCommentText()) {
- parentConstraints.setAvailableLineWidth(lineWidth);
- return;
- }
-
- Iterator it = currentRegion.getRegions().iterator();
- ITextRegion previous = null;
- if (previousRegion == null)
- previousRegion = currentRegion.getPrevious();
- // Iterate over each text region of the comment
- Node parent = currentDOMRegion.domNode.getParentNode();
- while(it.hasNext()) {
- ITextRegion text = (ITextRegion) it.next();
- String type = text.getType();
- if (type == DOMRegionContext.XML_COMMENT_OPEN) {
- int indentLevel = (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE) ? 0 : 1;
- int width = formatCommentStart(textEdit, parentConstraints, indentLevel, currentRegion, previousRegion, text);
- parentConstraints.setAvailableLineWidth(width);
- }
- else if (type == DOMRegionContext.XML_COMMENT_TEXT) {
- int indentLevel = (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE) ? -1 : parentConstraints.getIndentLevel();
- formatCommentContent(textEdit, parentConstraints, indentLevel, currentRegion, previous, text);
- }
- previous = text;
- }
- }
-
- private void formatCommentContent(TextEdit textEdit, XMLFormattingConstraints parentConstraints, int indentLevel, IStructuredDocumentRegion currentRegion, ITextRegion previous, ITextRegion region) {
- int lineWidth = parentConstraints.getAvailableLineWidth() - currentRegion.getFullText(previous).length();
- // If there's more text than line width available, format
- String text = currentRegion.getFullText(region);
- compressContent(textEdit, currentRegion, currentRegion.getStartOffset(region), indentLevel + 1, lineWidth, text);
- }
-
- private void compressContent(TextEdit textEdit, IStructuredDocumentRegion region, int startOffset, int indentLevel, int lineWidth, String text) {
- int length = text.length();
- int start = 0, end = 0;
- char c = 0;
- int resultLength = 0;
- boolean joinLines = fPreferences.getJoinCommentLines();
- boolean onOwnLine = false;
-
- String indent = getIndentString(indentLevel + 1);
-
- for (int i = 0; i < length; i++) {
- c = text.charAt(i);
- // Compress whitespace unless its a line delimiter and formatting does not permit joining lines
- if (Character.isWhitespace(c)) {
- if ((c != '\r' && c!= '\n') || joinLines) {
- // Just came off of a word
- if (start == end) {
- start = end = i;
- }
- end++;
- resultLength++;
- }
- else {
- // correct the indent of this line
- lineWidth = fPreferences.getMaxLineWidth();
- resultLength = 0;
- onOwnLine = true;
-
- // Compress any whitespace before the line delimiter
- if (start != end) {
- int replaceLength = end - start;
- textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, EMPTY));
- start = end = i;
- }
- }
- }
- else {
- // Transitioned to a new word
- if (start != end) {
- int replaceLength = end - start;
- if (onOwnLine) {
- // If content is on its own line, replace leading whitespace with proper indent
- textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, indent));
- resultLength -= (replaceLength - indent.length());
- onOwnLine = false;
- }
- else if (!(replaceLength == 1 && text.charAt(start) == ' ')) {
- textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, SPACE));
- resultLength -= (replaceLength - 1);
- }
- start = end = i;
- // Make sure the word starts on a new line
- if (resultLength > lineWidth) {
- lineWidth = fPreferences.getMaxLineWidth();
- resultLength = 0;
- textEdit.addChild(new InsertEdit(start + startOffset, getLineDelimiter(region) + indent));
- }
- }
- // Word is immediately after line delimiters, indent appropriately
- if (onOwnLine) {
- textEdit.addChild(new InsertEdit(i + startOffset, indent));
- onOwnLine = false;
- }
- resultLength++;
- }
- }
-
- // Clean up any dangling whitespace
- int replaceLength = end - start;
- indent = getIndentString(indentLevel);
- if (replaceLength == 0) { // No trailing whitespace
- textEdit.addChild(new InsertEdit(length + startOffset, (onOwnLine) ? indent : SPACE));
- }
- else {
- String whitespace = text.substring(start);
- String replacement = (onOwnLine) ? indent : SPACE;
- if (!whitespace.equals(replacement)) {
- textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, replacement));
- }
- }
- }
-
- private int formatCommentStart(TextEdit textEdit, XMLFormattingConstraints parentConstraints, int indentLevel, IStructuredDocumentRegion currentRegion, IStructuredDocumentRegion previousRegion, ITextRegion region) {
- int lineWidth = parentConstraints.getAvailableLineWidth();
- if (previousRegion!=null&&(DOMRegionContext.XML_CONTENT.equals(previousRegion.getType()))) {
- String previousText = previousRegion.getFullText();
- String trailingWhitespace = getTrailingWhitespace(previousText);
- String delimiters = extractLineDelimiters(trailingWhitespace, previousRegion);
- if (delimiters != null && delimiters.length() > 0){// && previousText.length() == trailingWhitespace.length()) {
- // Format the comment if it's on a new line
- int offset = previousRegion.getEnd() - trailingWhitespace.length();
- lineWidth = indentIfNotAlreadyIndented(textEdit, currentRegion, parentConstraints.getIndentLevel() + indentLevel, offset, trailingWhitespace);
- }
- }
- return lineWidth;
- }
-
- /**
- * Returns either a String of whitespace or characters depending on
- * forWhitespace
- *
- * @param fullTextArray
- * the text array to look in
- * @param textOffset
- * the start offset to start searching
- * @param forWhitespace
- * true if should return whitespaces, false otherwise
- * @return a String of either all whitespace or all characters. Never
- * returns null
- */
- private String getCharacterRun(char[] fullTextArray, int textOffset, boolean forWhitespace) {
- StringBuffer characterRun = new StringBuffer();
- boolean nonCharacterFound = false;
- while (textOffset < fullTextArray.length && !nonCharacterFound) {
- char c = fullTextArray[textOffset];
- boolean isWhitespace = Character.isWhitespace(c);
- if ((forWhitespace && isWhitespace) || (!forWhitespace && !isWhitespace))
- characterRun.append(c);
- else
- nonCharacterFound = true;
- ++textOffset;
- }
- return characterRun.toString();
- }
-
- private String getTrailingWhitespace(String text) {
- StringBuffer whitespaceRun = new StringBuffer();
- int index = text.length() - 1;
- while(index >= 0) {
- char c = text.charAt(index--);
- if (Character.isWhitespace(c))
- whitespaceRun.insert(0, c);
- else
- break;
- }
- return whitespaceRun.toString();
- }
-
- private String getIndentString(int indentLevel) {
- StringBuffer indentString = new StringBuffer();
- String indent = getFormattingPreferences().getOneIndent();
- for (int i = 0; i < indentLevel; ++i) {
- indentString.append(indent);
- }
- return indentString.toString();
- }
-
- protected XMLFormattingPreferences getFormattingPreferences() {
- if (fPreferences == null)
- fPreferences = new XMLFormattingPreferences();
- return fPreferences;
- }
-
- protected void setFormattingPreferences(XMLFormattingPreferences preferences) {
- fPreferences = preferences;
- }
-
- /**
- * Indent if whitespaceRun does not already contain an indent
- *
- * @param textEdit
- * @param indentLevel
- * @param indentStartOffset
- * @param maxAvailableLineWidth
- * @param whitespaceRun
- * @return new available line width up to where indented
- */
- private int indentIfNotAlreadyIndented(TextEdit textEdit, IStructuredDocumentRegion currentRegion, int indentLevel, int indentStartOffset, String whitespaceRun) {
- int maxAvailableLineWidth = getFormattingPreferences().getMaxLineWidth();
-
- int availableLineWidth;
- String indentString = getIndentString(indentLevel);
- String lineDelimiter = getLineDelimiter(currentRegion);
- String newLineAndIndent = lineDelimiter + indentString;
-
- TextEdit indentation = null;
-
- // if not already correctly indented
- if (!newLineAndIndent.equals(whitespaceRun)) {
- if (getFormattingPreferences().getClearAllBlankLines()) {
- if (whitespaceRun != null) {
- // replace existing whitespace run
- indentation = new ReplaceEdit(indentStartOffset, whitespaceRun.length(), newLineAndIndent);
- }
- else {
- // just insert correct indent
- indentation = new InsertEdit(indentStartOffset, newLineAndIndent);
- }
- }
- // Keep the empty lines
- else {
- // just insert correct indent
- if(whitespaceRun == null)
- indentation = new InsertEdit(indentStartOffset, newLineAndIndent);
- // Need to preserve the number of empty lines, but still indent on the current line properly
- else {
- String existingDelimiters = extractLineDelimiters(whitespaceRun, currentRegion);
- if(existingDelimiters != null && existingDelimiters.length() > 0) {
- String formatted = existingDelimiters + indentString;
- // Don't perform a replace if the formatted string is the same as the existing whitespaceRun
- if(!formatted.equals(whitespaceRun))
- indentation = new ReplaceEdit(indentStartOffset, whitespaceRun.length(), formatted);
- }
- // No blank lines to preserve - correct the indent
- else
- indentation = new ReplaceEdit(indentStartOffset, whitespaceRun.length(), newLineAndIndent);
- }
- }
- }
-
- if(indentation != null)
- textEdit.addChild(indentation);
- // update line width
- availableLineWidth = maxAvailableLineWidth - indentString.length();
- return availableLineWidth;
- }
-
- private int indentIfNotAlreadyIndented(TextEdit textEdit, int indentLevel, IStructuredDocumentRegion currentDocumentRegion, ITextRegion currentTextRegion) {
- // indent if not already indented
- int textLength = currentTextRegion.getTextLength();
- int regionLength = currentTextRegion.getLength();
- int indentStartOffset = currentDocumentRegion.getTextEndOffset(currentTextRegion);
- String fullText = currentDocumentRegion.getFullText(currentTextRegion);
- String whitespaceRun = fullText.substring(textLength, regionLength);
-
- // update line width
- int availableLineWidth = indentIfNotAlreadyIndented(textEdit, currentDocumentRegion, indentLevel, indentStartOffset, whitespaceRun);
- return availableLineWidth;
- }
-
- private int indentIfPossible(TextEdit textEdit, XMLFormattingConstraints thisConstraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion, String whitespaceStrategy, String indentStrategy, boolean addIndent) {
- return indentIfPossible(textEdit, thisConstraints, currentDocumentRegion, previousDocumentRegion, whitespaceStrategy, indentStrategy, addIndent, !getFormattingPreferences().getClearAllBlankLines());
- }
-
- private int indentIfPossible(TextEdit textEdit, XMLFormattingConstraints thisConstraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion, String whitespaceStrategy, String indentStrategy, boolean addIndent, boolean handlePreviousWhitespace) {
- int availableLineWidth = -1;
- // if there is no previous document region, there is no need to indent
- // because we're at beginning of document
- if (previousDocumentRegion == null)
- return availableLineWidth;
-
- // only indent if ignoring whitespace or if collapsing and
- // there was a whitespace character before this region
- boolean canIndent = false;
- String previousRegionFullText = null;
- String previousRegionType = null;
-
- if ((XMLFormattingConstraints.IGNORE.equals(whitespaceStrategy)) || XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceStrategy)) {
- // if ignoring, need to check if previous region was cdata
- previousRegionType = previousDocumentRegion.getType();
- if (DOMRegionContext.XML_CDATA_TEXT.equals(previousRegionType))
- canIndent = false;
- else
- canIndent = true;
- }
- else if (XMLFormattingConstraints.COLLAPSE.equals(whitespaceStrategy)) {
- // if collapsing, need to check if previous region ended in a
- // whitespace
- previousRegionType = previousDocumentRegion.getType();
- if (DOMRegionContext.XML_CONTENT.equals(previousRegionType)) {
- previousRegionFullText = previousDocumentRegion.getFullText();
- int length = previousRegionFullText.length();
- if (length > 1)
- canIndent = Character.isWhitespace(previousRegionFullText.charAt(length - 1));
- }
- }
- if (canIndent) {
- int indentStartOffset = currentDocumentRegion.getStartOffset();
- String whitespaceRun = null;
-
- // get previous region type if it was not previously retrieved
- if (previousRegionType == null)
- previousRegionType = previousDocumentRegion.getType();
-
- // get previous region's text if it was not previously retrieved
- if (previousRegionFullText == null && DOMRegionContext.XML_CONTENT.equals(previousRegionType))
- previousRegionFullText = previousDocumentRegion.getFullText();
-
- // if previous region was only whitespace, this may
- // already be indented, so need to make sure
- if ((previousRegionFullText != null) && (previousRegionFullText.trim().length() == 0)) {
- indentStartOffset = previousDocumentRegion.getStartOffset();
- whitespaceRun = previousRegionFullText;
- }
- if ((previousRegionFullText != null) && (whitespaceRun == null) && handlePreviousWhitespace) {
- whitespaceRun = getTrailingWhitespace(previousRegionFullText);
- indentStartOffset = previousDocumentRegion.getEndOffset() - whitespaceRun.length();
- }
-
- int indentLevel = thisConstraints.getIndentLevel();
- if (addIndent && XMLFormattingConstraints.INDENT.equals(indentStrategy)) {
- ++indentLevel;
- thisConstraints.setIndentLevel(indentLevel);
- }
-
- // indent if not already indented
- availableLineWidth = indentIfNotAlreadyIndented(textEdit, currentDocumentRegion, indentLevel, indentStartOffset, whitespaceRun);
- }
- return availableLineWidth;
- }
-
- /**
- * Allow exactly one whitespace in currentTextRegion. If there are more,
- * collapse to one. If there are none, insert one.
- *
- * @param textEdit
- * @param currentDocumentRegion
- * @param availableLineWidth
- * @param currentTextRegion
- */
- private void insertSpaceAndCollapse(TextEdit textEdit, IStructuredDocumentRegion currentDocumentRegion, int availableLineWidth, ITextRegion currentTextRegion) {
- int textLength = currentTextRegion.getTextLength();
- int regionLength = currentTextRegion.getLength();
- boolean thereAreSpaces = textLength < regionLength;
- int spacesStartOffset = currentDocumentRegion.getStartOffset(currentTextRegion) + textLength;
-
- if (thereAreSpaces) {
- String fullTagName = currentDocumentRegion.getFullText(currentTextRegion);
- String whitespaceRun = fullTagName.substring(textLength, regionLength);
- collapseSpaces(textEdit, spacesStartOffset, availableLineWidth, whitespaceRun);
- }
- else {
- // insert a space
- InsertEdit insertEdit = new InsertEdit(spacesStartOffset, SPACE);
- textEdit.addChild(insertEdit);
- }
- }
-
- private boolean shouldIndentBeforeAttribute(XMLFormattingConstraints constraints, ITextRegionList textRegions, int availableLineWidth, int currentTextRegionIndex, ITextRegion currentTextRegion, ITextRegion nextTextRegion) {
- boolean indentAttribute = false;
-
- // look ahead to see if going to hit max line width
- // something attrName
- int currentWidth = currentTextRegion.getTextLength() + nextTextRegion.getTextLength() + 1;
- if (currentWidth > availableLineWidth)
- indentAttribute = true;
- else {
- if ((currentTextRegionIndex + 2) < textRegions.size()) {
- // still okay, so try next region
- // something attrName=
- ITextRegion textRegion = textRegions.get(currentTextRegionIndex + 2);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS.equals(textRegion.getType())) {
- ++currentWidth;
- if (currentWidth > availableLineWidth)
- indentAttribute = true;
- else {
- if ((currentTextRegionIndex + 3) < textRegions.size()) {
- // still okay, so try next region
- // something attrName=attrValue
- textRegion = textRegions.get(currentTextRegionIndex + 3);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(textRegion.getType())) {
- currentWidth = +textRegion.getTextLength();
- if (currentWidth > availableLineWidth)
- indentAttribute = true;
- }
- }
- }
- }
- }
- }
- return indentAttribute;
- }
-
- /**
- * Given the provided information (parentConstraints & currentDOMRegion),
- * update the formatting constraints (for this & child)
- *
- * @param parentConstraints
- * can be null
- * @param thisConstraints
- * can be null
- * @param childConstraints
- * can be null
- * @param currentDOMRegion
- * cannot be null
- */
- protected void updateFormattingConstraints(XMLFormattingConstraints parentConstraints, XMLFormattingConstraints thisConstraints, XMLFormattingConstraints childConstraints, DOMRegion currentDOMRegion) {
- IStructuredDocumentRegion currentRegion = currentDOMRegion.documentRegion;
- IDOMNode currentNode = currentDOMRegion.domNode;
-
- // default to whatever parent's constraint said to do
- if (parentConstraints != null) {
- if (thisConstraints != null) {
- thisConstraints.copyConstraints(parentConstraints);
- }
- if (childConstraints != null) {
- childConstraints.copyConstraints(parentConstraints);
- // if whitespace strategy was only a hint, null it out so
- // defaults are taken instead
- if (parentConstraints.isWhitespaceStrategyAHint())
- childConstraints.setWhitespaceStrategy(null);
- }
- }
-
- // set up constraints for direct children of document root
- Node parentNode = currentNode.getParentNode();
- if (parentNode != null && parentNode.getNodeType() == Node.DOCUMENT_NODE) {
- if (thisConstraints != null) {
- thisConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNORE);
- thisConstraints.setIndentStrategy(XMLFormattingConstraints.NEW_LINE);
- thisConstraints.setIndentLevel(0);
- }
- if (childConstraints != null) {
- childConstraints.setWhitespaceStrategy(null);
- childConstraints.setIndentStrategy(null);
- childConstraints.setIndentLevel(0);
- }
- }
-
- // other conditions to check when setting up child constraints
- if (childConstraints != null) {
- XMLFormattingPreferences preferences = getFormattingPreferences();
-
- // if we're at document root, child tags should always just start
- // on a new line and have an indent level of 0
- if (currentNode.getNodeType() == Node.DOCUMENT_NODE) {
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNORE);
- childConstraints.setIndentStrategy(XMLFormattingConstraints.NEW_LINE);
- childConstraints.setIndentLevel(0);
- }
- else {
- // BUG108074 & BUG84688 - preserve whitespace in xsl:text &
- // xsl:attribute
- String nodeNamespaceURI = currentNode.getNamespaceURI();
- if (XSL_NAMESPACE.equals(nodeNamespaceURI)) {
- String nodeName = ((Element) currentNode).getLocalName();
- if (XSL_ATTRIBUTE.equals(nodeName) || XSL_TEXT.equals(nodeName)) {
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
- }
- }
- else {
- // search within current tag for xml:space attribute
- ITextRegionList textRegions = currentRegion.getRegions();
- int i = 0;
- boolean xmlSpaceFound = false;
- boolean preserveFound = false;
- while (i < textRegions.size() && !xmlSpaceFound) {
- ITextRegion textRegion = textRegions.get(i);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(textRegion.getType())) {
- String regionText = currentRegion.getText(textRegion);
- if (XML_SPACE.equals(regionText)) {
- if ((i + 1) < textRegions.size()) {
- ++i;
- textRegion = textRegions.get(i);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS.equals(textRegion.getType()) && ((i + 1) < textRegions.size())) {
- ++i;
- textRegion = textRegions.get(i);
- regionText = currentRegion.getText(textRegion);
- if (PRESERVE.equals(regionText) || PRESERVE_QUOTED.equals(regionText)) {
- preserveFound = true;
- }
- }
- }
- xmlSpaceFound = true;
- }
- }
- ++i;
- }
- if (xmlSpaceFound) {
- if (preserveFound) {
- // preserve was found so set the strategy
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
- }
- else {
- // xml:space was found but it was not collapse, so
- // use default whitespace strategy
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.DEFAULT);
- }
- }
- else {
- // how to hande nodes that have nonwhitespace text
- // content
- NodeList nodeList = currentNode.getChildNodes();
- int length = nodeList.getLength();
- int index = 0;
- boolean textNodeFound = false;
- // BUG214516 - If the parent constraint is to preserve whitespace, child constraints should
- // still reflect the parent constraints
- while (index < length && !textNodeFound && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
- Node childNode = nodeList.item(index);
- if (childNode.getNodeType() == Node.TEXT_NODE) {
- textNodeFound = !((IDOMText) childNode).isElementContentWhitespace();
- }
- ++index;
- }
- if (textNodeFound) {
- if (length > 1) {
- // more in here than just text, so consider
- // this mixed content
- childConstraints.setWhitespaceStrategy(preferences.getMixedWhitespaceStrategy());
- childConstraints.setIndentStrategy(preferences.getMixedIndentStrategy());
- }
- else {
- // there's only text
- childConstraints.setWhitespaceStrategy(preferences.getTextWhitespaceStrategy());
- childConstraints.setIndentStrategy(preferences.getTextIndentStrategy());
- }
- childConstraints.setIsWhitespaceStrategyAHint(true);
- childConstraints.setIsIndentStrategyAHint(true);
- }
-
- // try referring to content model for information on
- // whitespace & indent strategy
- ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) currentNode.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
- CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(currentNode);
- if (elementDeclaration != null) {
- // follow whitespace strategy preference for
- // pcdata content
- int contentType = elementDeclaration.getContentType();
-
- String facetValue = null;
- if(elementDeclaration.getDataType() != null)
- facetValue = (String) elementDeclaration.getDataType().getProperty(PROPERTY_WHITESPACE_FACET);
- if(facetValue != null) {
- if(PRESERVE.equals(facetValue))
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
- // For XSD types, "collapse" corresponds to the IGNOREANDTRIM strategy
- else if(COLLAPSE.equals(facetValue))
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNOREANDTRIM);
- else if(REPLACE.equals(facetValue))
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.REPLACE);
- }
- else if (contentType == CMElementDeclaration.PCDATA && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
- childConstraints.setWhitespaceStrategy(preferences.getPCDataWhitespaceStrategy());
- }
- else if (contentType == CMElementDeclaration.ELEMENT && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNORE);
- childConstraints.setIndentStrategy(XMLFormattingConstraints.INDENT);
- childConstraints.setIsWhitespaceStrategyAHint(true);
- childConstraints.setIsIndentStrategyAHint(true);
- }
- else {
- // look for xml:space in content model
- CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes();
-
- // Not needed - we're looking for xml:space
- //CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmAttributes);
- //List nodes = ModelQueryUtil.getModelQuery(currentNode.getOwnerDocument()).getAvailableContent((Element) currentNode, elementDeclaration, ModelQuery.INCLUDE_ATTRIBUTES);
- //for (int k = 0; k < nodes.size(); k++) {
- // CMNode cmnode = (CMNode) nodes.get(k);
- // if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- // allAttributes.put(cmnode);
- // }
- //}
- //cmAttributes = allAttributes;
-
- // Check implied values from the DTD way.
- CMAttributeDeclaration attributeDeclaration = (CMAttributeDeclaration) cmAttributes.getNamedItem(XML_SPACE);
- if (attributeDeclaration != null) {
- // CMAttributeDeclaration found, check
- // it
- // out.
-
- //BUG214516/196544 - Fixed NPE that was caused by an attr having
- // a null attr type
- String defaultValue = null;
- CMDataType attrType = attributeDeclaration.getAttrType();
- if (attrType != null) {
- if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && attrType.getImpliedValue() != null)
- defaultValue = attrType.getImpliedValue();
- else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
- defaultValue = attrType.getEnumeratedValues()[0];
- }
- }
-
- // xml:space="preserve" means preserve
- // space,
- // everything else means back to
- // default.
- if (PRESERVE.equals(defaultValue))
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
- else
- childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.DEFAULT);
- }
- // If the node has no attributes, inherit the parents whitespace strategy
- else {
- if (parentConstraints != null)
- childConstraints.setWhitespaceStrategy(parentConstraints.getWhitespaceStrategy());
- else
- childConstraints.setWhitespaceStrategy(null);
- }
- }
- }
- }
- }
- }
- // set default values according to preferences
- if (childConstraints.getWhitespaceStrategy() == null) {
- childConstraints.setWhitespaceStrategy(preferences.getElementWhitespaceStrategy());
- }
- if (childConstraints.getIndentStrategy() == null) {
- childConstraints.setIndentStrategy(preferences.getElementIndentStrategy());
- }
- }
- }
-
- /**
- * Calculates the current available line width given fullText.
- *
- * @param fullText
- * @param availableLineWidth
- * @param maxAvailableLineWidth
- * @return
- */
- private int updateLineWidthWithLastLine(String fullText, int availableLineWidth) {
- int maxAvailableLineWidth = getFormattingPreferences().getMaxLineWidth();
- int lineWidth = availableLineWidth;
- if (fullText != null) {
- int textLength = fullText.length();
- // update available line width
- // find last newline
- int lastLFOffset = fullText.lastIndexOf('\n');
- int lastCROffset = fullText.lastIndexOf('\r');
- // all text was on 1 line
- if (lastLFOffset == -1 && lastCROffset == -1) {
- // just subtract text length from current
- // available line width
- lineWidth -= fullText.length();
- }
- else {
- // calculate available line width of last line
- int lastNewLine = Math.max(lastLFOffset, lastCROffset);
- lineWidth = maxAvailableLineWidth - (textLength - lastNewLine);
- }
- }
- return lineWidth;
- }
-
- private String getLineDelimiter(IStructuredDocumentRegion currentRegion) {
- IStructuredDocument doc = currentRegion.getParentDocument();
- int line = doc.getLineOfOffset(currentRegion.getStartOffset());
- String lineDelimiter = doc.getLineDelimiter();
- try {
- if (line > 0) {
- lineDelimiter = doc.getLineDelimiter(line - 1);
- }
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- // BUG115716: if cannot get line delimiter from current line, just
- // use default line delimiter
- if (lineDelimiter == null)
- lineDelimiter = doc.getLineDelimiter();
- return lineDelimiter;
- }
-
- private String extractLineDelimiters(String base, IStructuredDocumentRegion currentRegion) {
- String lineDelimiter = getLineDelimiter(currentRegion);
- StringBuffer sb = new StringBuffer();
- for(int index = 0; index < base.length();) {
- index = base.indexOf(lineDelimiter, index);
- if(index++ >= 0)
- sb.append(lineDelimiter);
- else
- break;
- }
- return sb.toString();
- }
-
- void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormatterFormatProcessor.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormatterFormatProcessor.java
deleted file mode 100644
index e02ee7e4cb..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormatterFormatProcessor.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.formatter;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.text.DocumentRewriteSession;
-import org.eclipse.jface.text.DocumentRewriteSessionType;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension4;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-
-/**
- * This is a wrapper for the new xml formatter so that it can be still
- * considered an IStruturedFormatProcessor
- */
-public class XMLFormatterFormatProcessor implements IStructuredFormatProcessor {
- private DefaultXMLPartitionFormatter fFormatter = null;
- private IProgressMonitor fProgressMonitor = null;
-
- public void formatDocument(IDocument document, int start, int length) throws IOException, CoreException {
- if (document instanceof IStructuredDocument) {
- IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) document);
- if (model != null) {
- try {
- formatModel(model, start, length);
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
- }
-
- public void formatFile(IFile file) throws IOException, CoreException {
- if (file == null)
- return;
-
- IStructuredModel structuredModel = null;
- // OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- // ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null) {
- structuredModel.releaseFromEdit();
- }
-
- }
- }
-
- public void formatModel(IStructuredModel structuredModel) {
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
-
- formatModel(structuredModel, start, length);
- }
-
- public void formatModel(IStructuredModel structuredModel, int start, int length) {
- if(fProgressMonitor != null)
- fProgressMonitor.beginTask("", 2);
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- DocumentRewriteSession activeRewriteSession = ((IDocumentExtension4) structuredDocument).getActiveRewriteSession();
- boolean startedRewriteSession = false;
- if (activeRewriteSession == null) {
- activeRewriteSession = ((IDocumentExtension4) structuredDocument).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
- startedRewriteSession = true;
- }
- getFormatter().setProgressMonitor(new NullProgressMonitor() {
- public boolean isCanceled() {
- return fProgressMonitor != null && fProgressMonitor.isCanceled();
- }
- });
- TextEdit edit = getFormatter().format(structuredModel, start, length);
- if(fProgressMonitor != null)
- fProgressMonitor.worked(1);
-
- try {
- structuredModel.aboutToChangeModel();
- edit.apply(structuredDocument);
- if(fProgressMonitor != null)
- fProgressMonitor.worked(1);
- }
- catch (Exception e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- if (startedRewriteSession && activeRewriteSession != null) {
- ((IDocumentExtension4) structuredDocument).stopRewriteSession(activeRewriteSession);
- }
- structuredModel.changedModel();
- if(fProgressMonitor != null)
- fProgressMonitor.done();
- }
- }
-
- public void formatNode(Node node) {
- if (node instanceof IDOMNode) {
- IDOMNode domNode = (IDOMNode) node;
- formatModel(domNode.getModel(), domNode.getStartOffset(), domNode.getLength());
- }
- }
-
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-
- private DefaultXMLPartitionFormatter getFormatter() {
- if (fFormatter == null) {
- fFormatter = new DefaultXMLPartitionFormatter();
- }
- return fFormatter;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingConstraints.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingConstraints.java
deleted file mode 100644
index fa2a53b45c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingConstraints.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.formatter;
-
-
-public class XMLFormattingConstraints {
- public final static String PRESERVE = "PRESERVE"; //$NON-NLS-1$
- public final static String COLLAPSE = "COLLAPSE"; //$NON-NLS-1$
- public final static String IGNORE = "IGNORE"; //$NON-NLS-1$
- public final static String IGNOREANDTRIM = "IGNOREANDTRIM"; //$NON-NLS-1$
- public final static String DEFAULT = "DEFAULT"; //$NON-NLS-1$
- public final static String REPLACE = "REPLACE"; //$NON-NLS-1$
-
- public final static String INDENT = "INDENT"; //$NON-NLS-1$
- public final static String NEW_LINE = "NEW_LINE"; //$NON-NLS-1$
- public final static String INLINE = "INLINE"; //$NON-NLS-1$
-
- private int fAvailableLineWidth = 0;
- private int fIndentLevel = 0;
- private String fIndentStrategy;
- private String fWhitespaceStrategy;
- private boolean fIsIndentStrategyAHint = false;
- private boolean fIsWhitespaceStrategyAHint = false;
-
- /**
- * Initializes the values in this formatting constraint with values from
- * constraints
- *
- * @param constraints
- * cannot be null
- */
- public void copyConstraints(XMLFormattingConstraints constraints) {
- setAvailableLineWidth(constraints.getAvailableLineWidth());
- setIndentLevel(constraints.getIndentLevel());
- setIndentStrategy(constraints.getIndentStrategy());
- setWhitespaceStrategy(constraints.getWhitespaceStrategy());
- }
-
- public int getAvailableLineWidth() {
- return fAvailableLineWidth;
- }
-
- public void setAvailableLineWidth(int lineWidth) {
- fAvailableLineWidth = lineWidth;
- }
-
- public int getIndentLevel() {
- return fIndentLevel;
- }
-
- public void setIndentLevel(int indentLevel) {
- fIndentLevel = indentLevel;
- }
-
- public String getIndentStrategy() {
- return fIndentStrategy;
- }
-
- public void setIndentStrategy(String indentStrategy) {
- fIndentStrategy = indentStrategy;
- }
-
- public String getWhitespaceStrategy() {
- return fWhitespaceStrategy;
- }
-
- public void setWhitespaceStrategy(String whitespaceStrategy) {
- fWhitespaceStrategy = whitespaceStrategy;
- }
-
- public boolean isIndentStrategyAHint() {
- return fIsIndentStrategyAHint;
- }
-
- public void setIsIndentStrategyAHint(boolean isIndentStrategyAHint) {
- fIsIndentStrategyAHint = isIndentStrategyAHint;
- }
-
- public boolean isWhitespaceStrategyAHint() {
- return fIsWhitespaceStrategyAHint;
- }
-
- public void setIsWhitespaceStrategyAHint(boolean isWhitespaceStrategyAHint) {
- fIsWhitespaceStrategyAHint = isWhitespaceStrategyAHint;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingPreferences.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingPreferences.java
deleted file mode 100644
index 61c1b46fb0..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/XMLFormattingPreferences.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.formatter;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-
-public class XMLFormattingPreferences {
- public final static String PRESERVE = XMLFormattingConstraints.PRESERVE;
- public final static String COLLAPSE = XMLFormattingConstraints.COLLAPSE;
- public final static String IGNORE = XMLFormattingConstraints.IGNORE;
-
- public final static String INDENT = XMLFormattingConstraints.INDENT;
- public final static String NEW_LINE = XMLFormattingConstraints.NEW_LINE;
- public final static String INLINE = XMLFormattingConstraints.INLINE;
-
- private int fMaxLineWidth = 72;
- private boolean fAlignFinalBracket = false;
- private boolean fSpaceBeforeEmptyCloseTag = true;
- private boolean fIndentMultipleAttributes = false;
- private boolean fFormatCommentText = true;
- private boolean fJoinCommentLines = false;
-
- private String fPCDataWhitespaceStrategy = XMLFormattingConstraints.PRESERVE;
- private String fTextIndentStrategy = XMLFormattingConstraints.INLINE;
- private String fTextWhitespaceStrategy = XMLFormattingConstraints.COLLAPSE;
- private String fElementIndentStrategy = XMLFormattingConstraints.INDENT;
- private String fElementWhitespaceStrategy = XMLFormattingConstraints.IGNORE;
- private String fMixedIndentStrategy = XMLFormattingConstraints.INDENT;
- private String fMixedWhitespaceStrategy = XMLFormattingConstraints.IGNORE;
- private String fOneIndent = "\t"; //$NON-NLS-1$
- private boolean fClearAllBlankLines = false;
-
- public XMLFormattingPreferences() {
- Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
- if (preferences != null) {
- setFormatCommentText(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_TEXT));
- setJoinCommentLines(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_JOIN_LINES));
-
- setMaxLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
- setIndentMultipleAttributes(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
- setAlignFinalBracket(preferences.getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
- setSpaceBeforeEmptyCloseTag(preferences.getBoolean(XMLCorePreferenceNames.SPACE_BEFORE_EMPTY_CLOSE_TAG));
-
- boolean preservepcdata = preferences.getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT);
- if (preservepcdata)
- fPCDataWhitespaceStrategy = XMLFormattingPreferences.PRESERVE;
- else
- fPCDataWhitespaceStrategy = XMLFormattingPreferences.COLLAPSE;
-
- char indentChar = ' ';
- String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
- if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
- indentChar = '\t';
- }
- int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
-
- StringBuffer indent = new StringBuffer();
- for (int i = 0; i < indentationWidth; i++) {
- indent.append(indentChar);
- }
- setOneIndent(indent.toString());
- setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
- }
- }
-
- public int getMaxLineWidth() {
- return fMaxLineWidth;
- }
-
- public boolean getFormatCommentText() {
- return fFormatCommentText;
- }
-
- public boolean getAlignFinalBracket() {
- return fAlignFinalBracket;
- }
-
- public boolean getSpaceBeforeEmptyCloseTag() {
- return fSpaceBeforeEmptyCloseTag;
- }
-
- public boolean getIndentMultipleAttributes() {
- return fIndentMultipleAttributes;
- }
-
- public String getPCDataWhitespaceStrategy() {
- return fPCDataWhitespaceStrategy;
- }
-
- public String getTextIndentStrategy() {
- return fTextIndentStrategy;
- }
-
- public String getTextWhitespaceStrategy() {
- return fTextWhitespaceStrategy;
- }
-
- public String getElementIndentStrategy() {
- return fElementIndentStrategy;
- }
-
- public String getElementWhitespaceStrategy() {
- return fElementWhitespaceStrategy;
- }
-
- public boolean getJoinCommentLines() {
- return fJoinCommentLines;
- }
-
- public void setJoinCommentLines(boolean joinCommentLines) {
- fJoinCommentLines = joinCommentLines;
- }
-
- public void setFormatCommentText(boolean formatCommentText) {
- fFormatCommentText = formatCommentText;
- }
-
- public void setSpaceBeforeEmptyCloseTag(boolean spaceBeforeEmptyCloseTag) {
- fSpaceBeforeEmptyCloseTag = spaceBeforeEmptyCloseTag;
- }
-
- public void setIndentMultipleAttributes(boolean indentMultipleAttributes) {
- fIndentMultipleAttributes = indentMultipleAttributes;
- }
-
- public void setPCDataWhitespaceStrategy(String dataWhitespaceStrategy) {
- fPCDataWhitespaceStrategy = dataWhitespaceStrategy;
- }
-
- public void setAlignFinalBracket(boolean alignFinalBracket) {
- fAlignFinalBracket = alignFinalBracket;
- }
-
- public String getMixedIndentStrategy() {
- return fMixedIndentStrategy;
- }
-
- public void setMixedIndentStrategy(String mixedIndentStrategy) {
- fMixedIndentStrategy = mixedIndentStrategy;
- }
-
- public String getMixedWhitespaceStrategy() {
- return fMixedWhitespaceStrategy;
- }
-
- public void setMixedWhitespaceStrategy(String mixedWhitespaceStrategy) {
- fMixedWhitespaceStrategy = mixedWhitespaceStrategy;
- }
-
- public String getOneIndent() {
- return fOneIndent;
- }
-
- protected void setMaxLineWidth(int maxLineWidth) {
- fMaxLineWidth = maxLineWidth;
- }
-
- protected void setOneIndent(String oneIndent) {
- fOneIndent = oneIndent;
- }
-
- public boolean getClearAllBlankLines() {
- return fClearAllBlankLines;
- }
-
- public void setClearAllBlankLines(boolean clearAllBlankLines) {
- fClearAllBlankLines = clearAllBlankLines;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java
deleted file mode 100644
index abff1a4b8a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.modelhandler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
-import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryAdapterFactoryForEmbeddedXML;
-
-
-public class EmbeddedXML implements EmbeddedTypeHandler {
-
- private static List supportedMimeTypes;
- public String ContentTypeID_EmbeddedXML = "org.eclipse.wst.xml.core.contenttype.EmbeddedXML"; //$NON-NLS-1$
-
- /**
- * Constructor for EmbeddedXML.
- */
- public EmbeddedXML() {
- super();
- }
-
- /*
- * @see EmbeddedContentType#getAdapterFactories()
- */
- public List getAdapterFactories() {
- List factories = new ArrayList();
- factories.add(new ModelQueryAdapterFactoryForEmbeddedXML());
- // factories.addAll(PluginContributedFactoryReader.getInstance().getFactories(this));
- return factories;
- }
-
- /**
- * @see EmbeddedContentType#getFamilyId()
- */
- public String getFamilyId() {
- return ModelHandlerForXML.AssociatedContentTypeID;
- }
-
- public List getSupportedMimeTypes() {
- if (supportedMimeTypes == null) {
- supportedMimeTypes = new ArrayList();
- supportedMimeTypes.add("application/xml"); //$NON-NLS-1$
- supportedMimeTypes.add("text/xml"); //$NON-NLS-1$
- }
- return supportedMimeTypes;
- }
-
- public void initializeFactoryRegistry(FactoryRegistry registry) {
- //TODO: initialize
- }
-
- public void initializeParser(RegionParser parser) {
- // nothing to initialize for "pure" XML
- // compare with XHTML
- }
-
- public boolean isDefault() {
- return false;
- }
-
- public EmbeddedTypeHandler newInstance() {
- return new EmbeddedXML();
- }
-
- public void uninitializeFactoryRegistry(FactoryRegistry registry) {
- // TODO: need to undo anything we did in initialize
-
- }
-
- public void uninitializeParser(RegionParser parser) {
- // need to undo anything we did in initialize
- }
-
- public boolean canHandleMimeType(String mimeType) {
- boolean canHandle = getSupportedMimeTypes().contains(mimeType);
- if(!canHandle) {
- canHandle = mimeType.endsWith("+xml"); //$NON-NLS-1$
- }
- return canHandle;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/ModelHandlerForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/ModelHandlerForXML.java
deleted file mode 100644
index f4bdf3c8be..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/ModelHandlerForXML.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.modelhandler;
-
-import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.AbstractModelHandler;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.internal.provisional.IModelLoader;
-import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentCharsetDetector;
-import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentLoader;
-
-
-/**
- * Provides generic XML model handling. It is also marked as the default
- * content type handler. There should be only one implementation of the
- * default.
- */
-public class ModelHandlerForXML extends AbstractModelHandler implements IModelHandler {
- /**
- * Needs to match what's in plugin registry. In fact, can be overwritten
- * at run time with what's in registry! (so should never be 'final')
- */
- static String AssociatedContentTypeID = "org.eclipse.core.runtime.xml"; //$NON-NLS-1$
- /**
- * Needs to match what's in plugin registry. In fact, can be overwritten
- * at run time with what's in registry! (so should never be 'final')
- */
- private static String ModelHandlerID = "org.eclipse.wst.xml.core.modelhandler"; //$NON-NLS-1$
-
- public ModelHandlerForXML() {
- super();
- setId(ModelHandlerID);
- setAssociatedContentTypeId(AssociatedContentTypeID);
- }
-
- public IDocumentLoader getDocumentLoader() {
- return new XMLDocumentLoader();
- }
-
- public IDocumentCharsetDetector getEncodingDetector() {
- return new XMLDocumentCharsetDetector();
- }
-
- public IModelLoader getModelLoader() {
- return new XMLModelLoader();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/XMLModelLoader.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/XMLModelLoader.java
deleted file mode 100644
index ecf9223690..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/XMLModelLoader.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.modelhandler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.PropagatingAdapter;
-import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.internal.model.AbstractModelLoader;
-import org.eclipse.wst.sse.core.internal.provisional.IModelLoader;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.xml.core.internal.DebugAdapterFactory;
-import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
-import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentLoader;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryAdapterFactoryForXML;
-import org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-
-
-/**
- * This class reads an XML file and creates an XML Structured Model.
- *
- */
-public class XMLModelLoader extends AbstractModelLoader {
-
- // private static final String STR_ENCODING = "encoding"; //$NON-NLS-1$
-
- /**
- * XMLLoader constructor comment.
- */
- public XMLModelLoader() {
- super();
- }
-
- public List getAdapterFactories() {
- List result = new ArrayList();
- INodeAdapterFactory factory = null;
- factory = new ModelQueryAdapterFactoryForXML();
- result.add(factory);
- // Does XML need propagating adapter? Or just JSP?
- factory = new PropagatingAdapterFactoryImpl();
- result.add(factory);
- return result;
- }
-
- public IDocumentLoader getDocumentLoader() {
- if (documentLoaderInstance == null) {
- documentLoaderInstance = new XMLDocumentLoader();
- }
- return documentLoaderInstance;
- }
-
- public IModelLoader newInstance() {
- return new XMLModelLoader();
- }
-
- public IStructuredModel newModel() {
- return new DOMModelImpl();
- }
-
- protected void preLoadAdapt(IStructuredModel structuredModel) {
- super.preLoadAdapt(structuredModel);
- IDOMModel domModel = (IDOMModel) structuredModel;
- // if there is a model in the adapter, this will adapt it to
- // first node. After that the PropagatingAdater spreads over the
- // children being
- // created. Each time that happends, a side effect is to
- // also "spread" sprecific registered adapters,
- // they two can propigate is needed.
- ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
-
- if (Debug.debugNotificationAndEvents) {
- PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
- propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory());
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForEmbeddedXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForEmbeddedXML.java
deleted file mode 100644
index 805a9c1a23..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForEmbeddedXML.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.modelquery;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-
-
-public class ModelQueryAdapterFactoryForEmbeddedXML extends ModelQueryAdapterFactoryForXML {
-
-
- /**
- * Constructor for ModelQueryAdapterFactoryForEmbeddedXML.
- */
- public ModelQueryAdapterFactoryForEmbeddedXML() {
- super(ModelQueryAdapter.class, false);
- }
-
- protected void configureDocumentManager(CMDocumentManager mgr) {
- super.configureDocumentManager(mgr);
- mgr.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
- }
-
- /**
- * ISSUE: this "forces" a new one to always be created/returned,
- * not "cached" on the node. That seems incorrect.
- * Simply using shouldRegisterFalse should work, except,
- * there might have been one there that someone else already
- * explicitly put there, so this is only way I know to
- * override that. Especially complicated here since a number
- * of adapters are for ModelQueryAdapter.class.
- */
- public INodeAdapter adapt(INodeNotifier object) {
- return adaptNew(object);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
deleted file mode 100644
index cbb4add74b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.modelquery;
-
-
-
-import java.io.File;
-import java.net.URI;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.IModelStateListener;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapterImpl;
-
-
-public class ModelQueryAdapterFactoryForXML extends AbstractAdapterFactory {
-
- protected ModelQueryAdapterImpl modelQueryAdapterImpl;
- IStructuredModel stateNotifier = null;
- private InternalModelStateListener internalModelStateListener;
-
- /**
- * ModelQueryAdapterFactoryForXML constructor comment.
- */
- public ModelQueryAdapterFactoryForXML() {
- this(ModelQueryAdapter.class, true);
- }
-
- /**
- * ModelQueryAdapterFactoryForXML constructor comment.
- *
- * @param adapterKey
- * java.lang.Object
- * @param registerAdapters
- * boolean
- */
- protected ModelQueryAdapterFactoryForXML(Object adapterKey, boolean registerAdapters) {
- super(adapterKey, registerAdapters);
- }
-
- class InternalModelStateListener implements IModelStateListener {
-
- /**
- * @see IModelStateListener#modelAboutToBeChanged(IStructuredModel)
- */
- public void modelAboutToBeChanged(IStructuredModel model) {
- }
-
- /**
- * @see IModelStateListener#modelChanged(IStructuredModel)
- */
- public void modelChanged(IStructuredModel model) {
- }
-
- /**
- * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel,
- * boolean)
- */
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- }
-
- /**
- * @see IModelStateListener#modelResourceDeleted(IStructuredModel)
- */
- public void modelResourceDeleted(IStructuredModel model) {
- }
-
- /**
- * @see IModelStateListener#modelResourceMoved(IStructuredModel,
- * IStructuredModel)
- */
- public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
- stateNotifier.removeModelStateListener(this);
- stateNotifier = newModel;
- updateResolver(stateNotifier);
- stateNotifier.addModelStateListener(this);
- }
-
- public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
- // TODO Auto-generated method stub
-
- }
-
- public void modelReinitialized(IStructuredModel structuredModel) {
- updateResolver(structuredModel);
-
- }
-
-
- }
-
- protected boolean autoLoadCM() {
- // until the existence of a CMDocumentRequesterFactory to create the
- // load requests,
- // return true
- return true;
- }
-
- protected void configureDocumentManager(CMDocumentManager mgr) {
- // this depends on there being a CMDocumentRequesterFactory installed
- mgr.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, autoLoadCM());
- }
-
- public INodeAdapterFactory copy() {
-
- return new ModelQueryAdapterFactoryForXML(getAdapterKey(), isShouldRegisterAdapter());
- }
-
- /**
- * createAdapter method comment.
- */
- protected INodeAdapter createAdapter(INodeNotifier target) {
-
- if (org.eclipse.wst.sse.core.internal.util.Debug.displayInfo)
- System.out.println("-----------------------ModelQueryAdapterFactoryForXML.createAdapter" + target); //$NON-NLS-1$
- if (modelQueryAdapterImpl == null) {
- if (target instanceof IDOMNode) {
- IDOMNode xmlNode = (IDOMNode) target;
- IStructuredModel model = xmlNode.getModel();
- stateNotifier = xmlNode.getModel();
- stateNotifier.addModelStateListener(getInternalModelStateListener());
-
- org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
- if (Debug.displayInfo)
- System.out.println("----------------ModelQueryAdapterFactoryForXML... baseLocation : " + resolver.getFileBaseLocation()); //$NON-NLS-1$
-
- /**
- * XMLCatalogIdResolver currently requires a filesystem
- * location string. Customarily this will be what is in the
- * deprecated SSE URIResolver and required by the Common URI
- * Resolver.
- */
- URIResolver idResolver = null;
- if (resolver != null) {
- idResolver = new XMLCatalogIdResolver(resolver.getFileBaseLocation(), resolver);
- }
- else {
- /*
- * 203649 - this block may be necessary due to ordering of
- * setting the resolver into the model
- */
- String baseLocation = null;
- String modelsBaseLocation = model.getBaseLocation();
- if (modelsBaseLocation != null) {
- File file = new Path(modelsBaseLocation).toFile();
- if (file.exists()) {
- baseLocation = file.getAbsolutePath();
- }
- else {
- IPath basePath = new Path(model.getBaseLocation());
- IResource derivedResource = null;
- if (basePath.segmentCount() > 1)
- derivedResource = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
- else
- derivedResource = ResourcesPlugin.getWorkspace().getRoot().getProject(basePath.segment(0));
- IPath derivedPath = derivedResource.getLocation();
- if (derivedPath != null) {
- baseLocation = derivedPath.toString();
- }
- else {
- URI uri = derivedResource.getLocationURI();
- if (uri != null) {
- baseLocation = uri.toString();
- }
- }
- }
- if(baseLocation == null) {
- baseLocation = modelsBaseLocation;
- }
- }
- idResolver = new XMLCatalogIdResolver(baseLocation, null);
- }
-
- CMDocumentCache cmDocumentCache = new CMDocumentCache();
- ModelQuery modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);
-
- // cs todo...
- // for now we create a CMDocumentCache on a 'per editor' basis
- // in the future we need to support a CMDocumentCache that is
- // shared between editors
- // nsd comment: may not be appropriate depending on
- CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
- if (documentManager != null) {
- configureDocumentManager(documentManager);
- }
- modelQueryAdapterImpl = new ModelQueryAdapterImpl(cmDocumentCache, modelQuery, idResolver);
- }
- }
- return modelQueryAdapterImpl;
- }
-
- public void release() {
- super.release();
- if (stateNotifier != null)
- stateNotifier.removeModelStateListener(getInternalModelStateListener());
- stateNotifier = null;
- if (modelQueryAdapterImpl != null)
- modelQueryAdapterImpl.release();
- }
-
- protected void updateResolver(IStructuredModel model) {
-
- String baseLocation = model.getBaseLocation();
- IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
- if (baseFile != null) {
- if (baseFile.getLocation() != null) {
- baseLocation = baseFile.getLocation().toString();
- }
- if (baseLocation == null && baseFile.getLocationURI() != null) {
- baseLocation = baseFile.getLocationURI().toString();
- }
- if (baseLocation == null) {
- baseLocation = baseFile.getFullPath().toString();
- }
- }
- else {
- baseLocation = model.getBaseLocation();
- }
- modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver()));
- }
-
- private final InternalModelStateListener getInternalModelStateListener() {
- if (internalModelStateListener == null) {
- internalModelStateListener = new InternalModelStateListener();
- }
- return internalModelStateListener;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryUtil.java
deleted file mode 100644
index eae3e89082..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.modelquery;
-
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.w3c.dom.Document;
-
-
-/**
- * This class is used to associate ModelQuery (and related data) with a
- * Document (or IStructuredModel).
- */
-public class ModelQueryUtil {
-
- public static CMDocumentCache getCMDocumentCache(Document node) {
- ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(node);
- return modelQueryAdapter != null ? modelQueryAdapter.getCMDocumentCache() : null;
- }
-
- public static URIResolver getIdResolver(Document node) {
- ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(node);
- return modelQueryAdapter != null ? modelQueryAdapter.getIdResolver() : null;
- }
-
- public static ModelQuery getModelQuery(Document node) {
- ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(node);
- return modelQueryAdapter != null ? modelQueryAdapter.getModelQuery() : null;
- }
-
- public static ModelQuery getModelQuery(IStructuredModel model) {
- if ((!(model instanceof IDOMModel)) || model == null)
- return null;
- return getModelQuery(((IDOMModel) model).getDocument());
- }
-
- public static ModelQueryAdapter getModelQueryAdapter(Document node) {
- ModelQueryAdapter result = null;
-
- if (node instanceof INodeNotifier) {
- INodeNotifier notifier = (INodeNotifier) node;
- result = (ModelQueryAdapter) notifier.getAdapterFor(ModelQueryAdapter.class);
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java
deleted file mode 100644
index 61852f9ab6..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.modelquery;
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.sse.core.internal.util.URIResolver;
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-// TODO cs : remove this class and utilize the common URIResolver directly
-// We need to update some of the ModelQuery related code to pass the
-// 'baseLocation' thru
-// and then there'll be node need for this class.
-//
-public class XMLCatalogIdResolver implements org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver {
- protected String resourceLocation;
-
- protected URIResolver uriresolver;
-
- private XMLCatalogIdResolver() {
- super();
- }
-
- private XMLCatalogIdResolver(String resourceLocation) {
- this();
- this.resourceLocation = resourceLocation;
- }
-
- public XMLCatalogIdResolver(String resourceLocation, URIResolver uriresolver) {
- this(resourceLocation);
-// this constructor should not be called with two null arguments.
-// If so, an assert will occur later when resolve is called.
-// See 118371 XMLCatalogIdResolver#resolve throws AssertionFailedException
-//
-// but, I'm not enabling this check now due to lateness in cycle.
-// if (resourceLocation == null && uriresolver == null) {
-// throw new IllegalArgumentException("both location and resolver can not be null");
-// }
- this.uriresolver = uriresolver;
- }
-
-
- /**
- * Gets the resourceLocation.
- *
- * @return Returns a String
- */
- private String getResourceLocation() {
- String location = resourceLocation;
- if (location == null) {
- if (uriresolver != null)
- location = uriresolver.getFileBaseLocation();
- }
- return location;
- }
-
-
- public String resolve(String base, String publicId, String systemId) {
-
- String result = systemId;
- if (base == null) {
- base = getResourceLocation();
- // bug 117320, ensure base URI is 'protocal' qualified before
- // passing it thru to URIResolver
- // bug 117424, we should be able to assume that the base location
- // is non-null
-
- /**
- * We shouldn't assert a failure because the catalog does not
- * require a base location to operate and it will be called from
- * non-file-based scenarios.
- *
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=206176
- */
- // Assert.isNotNull(base, "Base location is expected to be non null."); //$NON-NLS-1$
- if (base != null) {
- base = URIHelper.addImpliedFileProtocol(base);
- }
- }
- result = URIResolverPlugin.createResolver().resolve(base, publicId, systemId);
- return result;
- }
-
- public String resolvePhysicalLocation(String baseLocation, String publicId, String logicalLocation) {
- // This class should never be called to perform physical resolution!
- // If it does we should log it as an error
- Logger.log(Logger.ERROR_DEBUG, "XMLCatalogIDResolver.resolvePhysicalLocation() called unexpectedly"); //$NON-NLS-1$
- return logicalLocation;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java
deleted file mode 100644
index 74d14abb92..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.modelquery;
-
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.XMLAssociationProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.w3c.dom.Document;
-
-/**
- * XMLModelQueryAssociationProvider
- *
- * This added and/or made public specifically for experimentation. It will
- * change as this functionality becomes API. See
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=119084
- *
- */
-public class XMLModelQueryAssociationProvider extends XMLAssociationProvider {
-
- protected URIResolver idResolver;
-
- public XMLModelQueryAssociationProvider(CMDocumentCache cache, URIResolver idResolver) {
- super(cache);
- this.idResolver = idResolver;
- }
-
- protected String resolveGrammarURI(Document document, String publicId, String systemId) {
-
- // CS : spooky code alert!
- // this look really strange because we're passing null in as the first
- // argument
- // however we're assuming the use of a 'fudged' URIResolver that knows
- // the
- // correct baseLocation and will call to the URIResolver framework
- // properly
-
- // CS : note that we should never call resolvePhysical at this point.
- // Physical resolution should only occur when we're interesting to
- // opening the actual stream.
- // The CMDocumentFactory implementation would be responsible for
- // calling resolvePhysical.
- // All we need to do here is return a 'logical' URI
-
- if (idResolver == null)
- return null;
- return idResolver.resolve(null, publicId, systemId);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryImpl.java
deleted file mode 100644
index 7bfa0014f0..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.modelquery;
-
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.MovableModelQuery;
-
-
-public class XMLModelQueryImpl extends ModelQueryImpl implements MovableModelQuery {
-
- protected CMDocumentCache fCache = null;
-
- public XMLModelQueryImpl(CMDocumentCache cache, URIResolver idResolver) {
- super(new XMLModelQueryAssociationProvider(cache, idResolver));
- fCache = cache;
- }
-
- /**
- * @see MovableModelQuery#setIdResolver(URIResolver)
- */
- public void setIdResolver(URIResolver newIdResolver) {
- modelQueryAssociationProvider = new XMLModelQueryAssociationProvider(fCache, newIdResolver);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java
deleted file mode 100644
index 7754a80622..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser;
-
-
-
-import org.eclipse.wst.sse.core.internal.ltk.parser.IBlockedStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion;
-
-
-public class BlockStructuredDocumentRegion extends BasicStructuredDocumentRegion implements IBlockedStructuredDocumentRegion {
-
- private String partitionType;
-
- /**
- * A BlockStructuredDocumentRegion is like a IStructuredDocumentRegion,
- * but is the result of a "block scan".
- */
- public BlockStructuredDocumentRegion() {
- super();
- }
-
- public String getPartitionType() {
- if (partitionType == null) {
- // eventually can look up surroundingTag name
- // but this field is primarily entended for future
- // extensibility. This may change.
- //partitionType = "org.eclipse.wst.sse.core." + tagname;
- }
- return partitionType;
- }
-
- public void setPartitionType(String partitionType) {
- this.partitionType = partitionType;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java
deleted file mode 100644
index 0de33025b0..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.parser;
-
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl;
-import org.eclipse.wst.xml.core.internal.Logger;
-
-
-public class ContextRegionContainer implements ITextRegionContainer {
- protected int length;
- protected ITextRegionCollection parent;
- protected ITextRegionList regions;
- protected int start;
- protected int textLength;
- protected String type;
-
- public ContextRegionContainer() {
- super();
- regions = new TextRegionListImpl();
-
- }
-
- /**
- * these "deep" parenting is not normal, but just in case.
- */
- private IStructuredDocument _getParentDocument() {
- // go up enough parents to get to document
- ITextRegionCollection parent = getParent();
- while (!(parent instanceof IStructuredDocumentRegion)) {
- // would be an error not to be container, but
- // won't check for it now
- parent = ((ITextRegionContainer) parent).getParent();
- }
- return ((IStructuredDocumentRegion) parent).getParentDocument();
- }
-
-
- public void adjust(int i) {
-
- start += i;
- // I erroneously added length and textLength
- // TODO: may want to rename this method to adjustStart
- //length += i;
- //textLength += i;
-
- }
-
- public void adjustLength(int i) {
- length += i;
- }
-
- public void adjustStart(int i) {
- start += i;
- }
-
-
- public void adjustTextLength(int i) {
- textLength += i;
-
- }
-
- public boolean containsOffset(int i) {
-
- return getStartOffset() <= i && i < getEndOffset();
- }
-
- public boolean containsOffset(ITextRegion containedRegion, int offset) {
- return getStartOffset(containedRegion) <= offset && offset < getEndOffset(containedRegion);
- }
-
- /**
- * This method is just to equate positions. clients may (will probably)
- * still need to make calls to equate regions, parent, etc.
- */
- public void equatePositions(ITextRegion region) {
- start = region.getStart();
- length = region.getLength();
- textLength = region.getTextLength();
- }
-
- public int getEnd() {
- return start + length;
- }
-
- public int getEndOffset() {
- // our startOffset take into account our parent, and our start
- return getStartOffset() + getLength();
- }
-
- public int getEndOffset(ITextRegion containedRegion) {
- return getStartOffset(containedRegion) + containedRegion.getLength();
- }
-
- public ITextRegion getFirstRegion() {
- return getRegions().get(0);
- }
-
- public String getFullText() {
- return getParent().getFullText(this);
- }
-
- public String getFullText(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion aRegion) {
- // Must be proxied here since aRegion should always be a child of
- // *this* container and indexed from
- // this container's offset
- return parent.getFullText().substring(start + aRegion.getStart(), start + aRegion.getEnd());
- }
-
- public ITextRegion getLastRegion() {
- return getRegions().get(getRegions().size() - 1);
- }
-
- public int getLength() {
- return length;
- }
-
-
- public int getNumberOfRegions() {
- return getRegions().size();
- }
-
- public ITextRegionCollection getParent() {
- return parent;
- }
-
- /**
- * The parameter offset refers to the overall offset in the document.
- */
- public ITextRegion getRegionAtCharacterOffset(int offset) {
- ITextRegion result = null;
- if (regions != null) {
- int thisStartOffset = getStartOffset();
- if (offset < thisStartOffset)
- return null;
- int thisEndOffset = getStartOffset() + getLength();
- if (offset > thisEndOffset)
- return null;
- // transform the requested offset to the "scale" that
- // regions are stored in, which are all relative to the
- // start point.
- //int transformedOffset = offset - getStartOffset();
- //
- ITextRegionList regions = getRegions();
- int length = regions.size();
- int low = 0;
- int high = length;
- int mid = 0;
- // Binary search for the region
- while (low < high) {
- mid = low + ((high - low) >> 1);
- ITextRegion region = regions.get(mid);
- if (org.eclipse.wst.sse.core.internal.util.Debug.debugStructuredDocument) {
- System.out.println("region(s) in IStructuredDocumentRegion::getRegionAtCharacterOffset: " + region); //$NON-NLS-1$
- System.out.println(" midpoint of search:" + mid); //$NON-NLS-1$
- System.out.println(" requested offset: " + offset); //$NON-NLS-1$
- //System.out.println(" transformedOffset: " +
- // transformedOffset); //$NON-NLS-1$
- System.out.println(" region start: " + region.getStart()); //$NON-NLS-1$
- System.out.println(" region end: " + region.getEnd()); //$NON-NLS-1$
- System.out.println(" region type: " + region.getType()); //$NON-NLS-1$
- System.out.println(" region class: " + region.getClass()); //$NON-NLS-1$
-
- }
- // Region is before this one
- if (offset < region.getStart() + thisStartOffset)
- high = mid;
- else if (offset > (region.getEnd() + thisStartOffset - 1))
- low = mid + 1;
- else
- return region;
- }
- return null;
- }
- return result;
- }
-
- public ITextRegionList getRegions() {
- return regions;
- }
-
- public int getStart() {
- return start;
- }
-
- public int getStartOffset() {
- return getParent().getStartOffset() + getStart();
- }
-
- public int getStartOffset(ITextRegion containedRegion) {
- // it is an error to pass null to this method
- // ISSUE: need better "spec" on error behavior:
- // for now will return zero as this will roughly
- // work for some cases (and avoid NPE).
- if (containedRegion == null) {
- return getStartOffset();
- }
- return getStartOffset() + containedRegion.getStart();
- }
-
- /**
- * same as getFullText for this region type ... do we need to take white
- * space off?
- */
-
- public String getText() {
- String result = null;
- try {
- IStructuredDocument parentDocument = _getParentDocument();
- result = parentDocument.get(start, length);
- } catch (BadLocationException e) {
- Logger.logException("program error: unreachable exception", e); //$NON-NLS-1$
- }
- return result;
- }
-
- public String getText(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion aRegion) {
- // Must be proxied here since aRegion should always be a child of
- // *this* container and indexed from
- // this container's offset
- return parent.getText().substring(start + aRegion.getStart(), start + aRegion.getTextEnd());
- }
-
- public int getTextEnd() {
- return start + textLength;
- }
-
- public int getTextEndOffset() {
- ITextRegion region = regions.get(regions.size() - 1);
- // our startOffset take into account our parent, and our start
- // (pa) 10/4 changed to be based on text end
- // it used to return incorrect value for embedded region containers
- //
-
- // TODO CRITICAL -- need to re-work this work around, so doesn't
- // depend on XMLRegionContext
- // // this is a workaround for 226823///////////
- // for (int i = regions.size() - 1; i >= 0 && region.getType() ==
- // XMLRegionContext.WHITE_SPACE; i--)
- // region = (ITextRegion) regions.get(i);
- // /////////////////////////////////////////////
-
- return getStartOffset() + region.getTextEnd();
- }
-
- public int getTextEndOffset(ITextRegion containedRegion) {
- int result = 0;
- if (regions != null) {
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- ITextRegion region = getRegions().get(i);
- if (region == containedRegion) {
- result = getStartOffset(region) + region.getTextEnd();
- break;
- }
- }
- }
- return result;
- }
-
- public int getTextLength() {
- return textLength;
- }
-
- public String getType() {
- return type;
- }
-
- public void setLength(int i) {
- length = i;
- }
-
- public void setParent(ITextRegionCollection parentRegion) {
- parent = parentRegion;
- }
-
- public void setRegions(ITextRegionList containedRegions) {
- regions = containedRegions;
- }
-
- public void setStart(int i) {
- start = i;
- }
-
- public void setTextLength(int i) {
- textLength = i;
- }
-
- public void setType(String string) {
- type = string;
- }
-
- public String toString() {
- String className = getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- String result = "Container!!! " + shortClassName + "--> " + getType() + ": " + getStart() + "-" + getTextEnd() + (getTextEnd() != getEnd() ? ("/" + getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- return result;
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent result = null;
- // FUTURE_TO_DO: need to implement region level parsing in
- // ITextRegionContainer::updateModel
- // never being called?
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java
deleted file mode 100644
index 5cb8d5a6f8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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.parser;
-
-
-
-/*
- *
- * A non-resizable class implementing the behavior of java.util.Stack, but
- * directly for the <code> integer </code> primitive.
- */
-import java.util.EmptyStackException;
-
-public class IntStack {
- private int[] list = null;
-
- private int size = 0;
-
- public IntStack() {
- this(100);
- }
-
- public IntStack(int maxdepth) {
- super();
- list = new int[maxdepth];
- initialize();
- }
-
- public boolean empty() {
- return size == 0;
- }
-
- public int get(int slot) {
- return list[slot];
- }
-
- void initialize() {
- for (int i = 0; i < list.length; i++)
- list[i] = -1;
- }
-
- /**
- * Returns the int at the top of the stack without removing it
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int peek() {
- if (size == 0)
- throw new EmptyStackException();
- return list[size - 1];
- }
-
- /**
- * Removes and returns the int at the top of the stack
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int pop() {
- int value = peek();
- list[size - 1] = -1;
- size--;
- return value;
- }
-
- /**
- * Pushes an item onto the top of this stack.
- *
- * @param newValue -
- * the int to be pushed onto this stack.
- * @return the <code>newValue</code> argument.
- */
- public int push(int newValue) {
- if (size == list.length) {
- throw new StackOverflowError();
- }
- list[size++] = newValue;
- return newValue;
- }
-
- public int size() {
- return size;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer s = new StringBuffer(getClass().getName() + ":" +size + " [");
- for (int i = 0; i < size; i++) {
- s.append(list[i]);
- if(i < size - 1) {
- s.append(", ");
- }
- }
- s.append("]");
- return s.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java
deleted file mode 100644
index 1315a77980..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser;
-
-
-
-import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-
-
-public class RegionFactory {
-
- public RegionFactory() {
- super();
- }
-
- public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length) {
- return this.createToken(parent, context, start, textLength, length, null, null);
- }
-
- public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length, String lang, String surroundingTag) {
- ITextRegion newRegion = createToken(context, start, textLength, length);
- // DW, 4/16/2003 token regions no longer have parents
- //newRegion.setParent(parent);
- return newRegion;
- }
-
- public ITextRegion createToken(String context, int start, int textLength, int length) {
- return this.createToken(context, start, textLength, length, null, null);
- }
-
- public ITextRegion createToken(String context, int start, int textLength, int length, String lang, String surroundingTag) {
- ITextRegion newRegion = new ContextRegion(context, start, textLength, length);
- return newRegion;
-
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java
deleted file mode 100644
index 34faaec6ef..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java
+++ /dev/null
@@ -1,595 +0,0 @@
-/* The following code was generated by JFlex 1.4 on 2/25/08 10:25 AM */
-
-/*******************************************************************************
- * Copyright (c) 2004,2008 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
- * kb.huang - Bug 214416 Dot char is not escaped in XML10Names.jFlex
- *******************************************************************************/
-/*nlsXXX*/
-package org.eclipse.wst.xml.core.internal.parser;
-
-
-
-
-/**
- * This class is a scanner generated by
- * <a href="http://www.jflex.de/">JFlex</a> 1.4
- * on 2/25/08 10:25 AM from the specification file
- * <tt>XML10Names.jflex</tt>
- */
-public final class XML10Names {
-
- /** This character denotes the end of file */
- private static final int YYEOF = -1;
-
- /** initial size of the lookahead buffer */
- private static final int ZZ_BUFFERSIZE = 2048;
-
- /** lexical states */
- private static final int YYINITIAL = 0;
-
- /**
- * Translates characters to character classes
- */
- private static final String ZZ_CMAP_PACKED =
- "\12\0\1\3\42\0\1\2\1\2\1\0\12\2\1\1\6\0\32\1"+
- "\4\0\1\1\1\0\32\1\74\0\1\2\10\0\27\1\1\0\37\1"+
- "\1\0\72\1\2\0\13\1\2\0\10\1\1\0\65\1\1\0\104\1"+
- "\11\0\44\1\3\0\2\1\4\0\36\1\70\0\131\1\22\0\7\1"+
- "\16\0\2\2\56\0\106\2\32\0\2\2\44\0\1\1\1\2\3\1"+
- "\1\0\1\1\1\0\24\1\1\0\54\1\1\0\7\1\3\0\1\1"+
- "\1\0\1\1\1\0\1\1\1\0\1\1\1\0\22\1\15\0\14\1"+
- "\1\0\102\1\1\0\14\1\1\0\44\1\1\0\4\2\11\0\65\1"+
- "\2\0\2\1\2\0\2\1\3\0\34\1\2\0\10\1\2\0\2\1"+
- "\67\0\46\1\2\0\1\1\7\0\46\1\12\0\21\2\1\0\27\2"+
- "\1\0\3\2\1\0\1\2\1\0\2\2\1\0\1\2\13\0\33\1"+
- "\5\0\3\1\56\0\32\1\5\0\1\2\12\1\10\2\15\0\12\2"+
- "\6\0\1\2\107\1\2\0\5\1\1\0\17\1\1\0\4\1\1\0"+
- "\1\1\17\2\2\1\2\2\1\0\4\2\2\0\12\2\u0207\0\3\2"+
- "\1\0\65\1\2\0\1\2\1\1\20\2\3\0\4\2\3\0\12\1"+
- "\2\2\2\0\12\2\21\0\3\2\1\0\10\1\2\0\2\1\2\0"+
- "\26\1\1\0\7\1\1\0\1\1\3\0\4\1\2\0\1\2\1\0"+
- "\7\2\2\0\2\2\2\0\3\2\11\0\1\2\4\0\2\1\1\0"+
- "\3\1\2\2\2\0\12\2\2\1\20\0\1\2\2\0\6\1\4\0"+
- "\2\1\2\0\26\1\1\0\7\1\1\0\2\1\1\0\2\1\1\0"+
- "\2\1\2\0\1\2\1\0\5\2\4\0\2\2\2\0\3\2\13\0"+
- "\4\1\1\0\1\1\7\0\12\2\2\2\3\1\14\0\3\2\1\0"+
- "\7\1\1\0\1\1\1\0\3\1\1\0\26\1\1\0\7\1\1\0"+
- "\2\1\1\0\5\1\2\0\1\2\1\1\10\2\1\0\3\2\1\0"+
- "\3\2\22\0\1\1\5\0\12\2\21\0\3\2\1\0\10\1\2\0"+
- "\2\1\2\0\26\1\1\0\7\1\1\0\2\1\2\0\4\1\2\0"+
- "\1\2\1\1\6\2\3\0\2\2\2\0\3\2\10\0\2\2\4\0"+
- "\2\1\1\0\3\1\4\0\12\2\22\0\2\2\1\0\6\1\3\0"+
- "\3\1\1\0\4\1\3\0\2\1\1\0\1\1\1\0\2\1\3\0"+
- "\2\1\3\0\3\1\3\0\10\1\1\0\3\1\4\0\5\2\3\0"+
- "\3\2\1\0\4\2\11\0\1\2\17\0\11\2\21\0\3\2\1\0"+
- "\10\1\1\0\3\1\1\0\27\1\1\0\12\1\1\0\5\1\4\0"+
- "\7\2\1\0\3\2\1\0\4\2\7\0\2\2\11\0\2\1\4\0"+
- "\12\2\22\0\2\2\1\0\10\1\1\0\3\1\1\0\27\1\1\0"+
- "\12\1\1\0\5\1\4\0\7\2\1\0\3\2\1\0\4\2\7\0"+
- "\2\2\7\0\1\1\1\0\2\1\4\0\12\2\22\0\2\2\1\0"+
- "\10\1\1\0\3\1\1\0\27\1\1\0\20\1\4\0\6\2\2\0"+
- "\3\2\1\0\4\2\11\0\1\2\10\0\2\1\4\0\12\2\221\0"+
- "\56\1\1\0\1\1\1\2\2\1\7\2\5\0\6\1\1\2\10\2"+
- "\1\0\12\2\47\0\2\1\1\0\1\1\2\0\2\1\1\0\1\1"+
- "\2\0\1\1\6\0\4\1\1\0\7\1\1\0\3\1\1\0\1\1"+
- "\1\0\1\1\2\0\2\1\1\0\2\1\1\0\1\1\1\2\2\1"+
- "\6\2\1\0\2\2\1\1\2\0\5\1\1\0\1\2\1\0\6\2"+
- "\2\0\12\2\76\0\2\2\6\0\12\2\13\0\1\2\1\0\1\2"+
- "\1\0\1\2\4\0\2\2\10\1\1\0\41\1\7\0\24\2\1\0"+
- "\6\2\4\0\6\2\1\0\1\2\1\0\25\2\3\0\7\2\1\0"+
- "\1\2\346\0\46\1\12\0\47\1\11\0\1\1\1\0\2\1\1\0"+
- "\3\1\1\0\1\1\1\0\2\1\1\0\5\1\51\0\1\1\1\0"+
- "\1\1\1\0\1\1\13\0\1\1\1\0\1\1\1\0\1\1\3\0"+
- "\2\1\3\0\1\1\5\0\3\1\1\0\1\1\1\0\1\1\1\0"+
- "\1\1\1\0\1\1\3\0\2\1\3\0\2\1\1\0\1\1\50\0"+
- "\1\1\11\0\1\1\2\0\1\1\2\0\2\1\7\0\2\1\1\0"+
- "\1\1\1\0\7\1\50\0\1\1\4\0\1\1\10\0\1\1\u0c06\0"+
- "\234\1\4\0\132\1\6\0\26\1\2\0\6\1\2\0\46\1\2\0"+
- "\6\1\2\0\10\1\1\0\1\1\1\0\1\1\1\0\1\1\1\0"+
- "\37\1\2\0\65\1\1\0\7\1\1\0\1\1\3\0\3\1\1\0"+
- "\7\1\3\0\4\1\2\0\6\1\4\0\15\1\5\0\3\1\1\0"+
- "\7\1\323\0\15\2\4\0\1\2\104\0\1\1\3\0\2\1\2\0"+
- "\1\1\121\0\3\1\u0e82\0\1\2\1\0\1\1\31\0\11\1\6\2"+
- "\1\0\5\2\13\0\124\1\4\0\2\2\2\0\2\2\2\0\132\1"+
- "\1\0\3\2\6\0\50\1\u1cd3\0\u51a6\1\u0c5a\0\u2ba4\1\u285c\0";
-
- /**
- * Translates characters to character classes
- */
- private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
-
- /**
- * Translates DFA states to action switch labels.
- */
- private static final int [] ZZ_ACTION = zzUnpackAction();
-
- private static final String ZZ_ACTION_PACKED_0 =
- "\1\0\1\1\1\2\1\3";
-
- private static int [] zzUnpackAction() {
- int [] result = new int[4];
- int offset = 0;
- offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
- return result;
- }
-
- private static int zzUnpackAction(String packed, int offset, int [] result) {
- int i = 0; /* index in packed string */
- int j = offset; /* index in unpacked array */
- int l = packed.length();
- while (i < l) {
- int count = packed.charAt(i++);
- int value = packed.charAt(i++);
- do result[j++] = value; while (--count > 0);
- }
- return j;
- }
-
-
- /**
- * Translates a state to a row index in the transition table
- */
- private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
-
- private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\4\0\10\0\14";
-
- private static int [] zzUnpackRowMap() {
- int [] result = new int[4];
- int offset = 0;
- offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
- return result;
- }
-
- private static int zzUnpackRowMap(String packed, int offset, int [] result) {
- int i = 0; /* index in packed string */
- int j = offset; /* index in unpacked array */
- int l = packed.length();
- while (i < l) {
- int high = packed.charAt(i++) << 16;
- result[j++] = high | packed.charAt(i++);
- }
- return j;
- }
-
- /**
- * The transition table of the DFA
- */
- private static final int ZZ_TRANS [] = {
- 1, 2, 1, -1, -1, -1, -1, -1, 3, 2,
- 2, -1, 3, 3, 3, -1
- };
-
- /* error codes */
- private static final int ZZ_UNKNOWN_ERROR = 0;
- private static final int ZZ_NO_MATCH = 1;
-// private static final int ZZ_PUSHBACK_2BIG = 2;
-
- /* error messages for the codes above */
- private static final String ZZ_ERROR_MSG[] = {
- "Unkown internal scanner error",
- "Error: could not match input",
- "Error: pushback value was too large"
- };
-
- /**
- * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
- */
- private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
-
- private static final String ZZ_ATTRIBUTE_PACKED_0 =
- "\1\0\1\11\2\1";
-
- private static int [] zzUnpackAttribute() {
- int [] result = new int[4];
- int offset = 0;
- offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
- return result;
- }
-
- private static int zzUnpackAttribute(String packed, int offset, int [] result) {
- int i = 0; /* index in packed string */
- int j = offset; /* index in unpacked array */
- int l = packed.length();
- while (i < l) {
- int count = packed.charAt(i++);
- int value = packed.charAt(i++);
- do result[j++] = value; while (--count > 0);
- }
- return j;
- }
-
- /** the input device */
- private java.io.Reader zzReader;
-
- /** the current state of the DFA */
- private int zzState;
-
- /** the current lexical state */
- private int zzLexicalState = YYINITIAL;
-
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
-
- /** the textposition at the last accepting state */
- private int zzMarkedPos;
-
- /** the textposition at the last state to be included in yytext */
- //private int zzPushbackPos;
-
- /** the current text position in the buffer */
- private int zzCurrentPos;
-
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int zzStartRead;
-
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int zzEndRead;
-
- /** number of newlines encountered up to the start of the matched text */
-// private int yyline;
-
- /** the number of characters up to the start of the matched text */
-// private int yychar;
-
- /**
- * the number of characters from the last newline up to the start of the
- * matched text
- */
-// private int yycolumn;
-
- /**
- * zzAtBOL == true <=> the scanner is currently at the beginning of a line
- */
-// private boolean zzAtBOL = true;
-
- /** zzAtEOF == true <=> the scanner is at the EOF */
- private boolean zzAtEOF;
-
- /* user code: */
- boolean result;
- /**
- * Creates a new scanner
- */
- public XML10Names() {
- this.zzReader = null;
- }
-
- public boolean isValidXML10Name(String stringToCheck) {
- boolean result = false;
- yyreset(new java.io.StringReader(stringToCheck));
- try {
- result = isValidXML10Name();
- }
- catch (java.io.IOException e) {
- // should be impossible with strings, but if occurs, just means
- // "not"
- result = false;
- }
- return result;
- }
-
-
-
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- public XML10Names(java.io.Reader in) {
- this.zzReader = in;
- }
-
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- public XML10Names(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
-
- /**
- * Unpacks the compressed character translation table.
- *
- * @param packed the packed character translation table
- * @return the unpacked character translation table
- */
- private static char [] zzUnpackCMap(String packed) {
- char [] map = new char[0x10000];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 1218) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do map[j++] = value; while (--count > 0);
- }
- return map;
- }
-
-
- /**
- * Refills the input buffer.
- *
- * @return <code>false</code>, iff there was new input.
- *
- * @exception java.io.IOException if any I/O-Error occurs
- */
- private boolean zzRefill() throws java.io.IOException {
-
- /* first: make room (if you can) */
- if (zzStartRead > 0) {
- System.arraycopy(zzBuffer, zzStartRead,
- zzBuffer, 0,
- zzEndRead-zzStartRead);
-
- /* translate stored positions */
- zzEndRead-= zzStartRead;
- zzCurrentPos-= zzStartRead;
- zzMarkedPos-= zzStartRead;
- //zzPushbackPos-= zzStartRead;
- zzStartRead = 0;
- }
-
- /* is the buffer big enough? */
- if (zzCurrentPos >= zzBuffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[zzCurrentPos*2];
- System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
- zzBuffer = newBuffer;
- }
-
- /* finally: fill the buffer with new input */
- int numRead = zzReader.read(zzBuffer, zzEndRead,
- zzBuffer.length-zzEndRead);
-
- if (numRead < 0) {
- return true;
- }
- else {
- zzEndRead+= numRead;
- return false;
- }
- }
-
-
- /**
- * Closes the input stream.
- */
-// private final void yyclose() throws java.io.IOException {
-// zzAtEOF = true; /* indicate end of file */
-// zzEndRead = zzStartRead; /* invalidate buffer */
-//
-// if (zzReader != null)
-// zzReader.close();
-// }
-
-
- /**
- * Resets the scanner to read from a new input stream.
- * Does not close the old reader.
- *
- * All internal variables are reset, the old input stream
- * <b>cannot</b> be reused (internal buffer is discarded and lost).
- * Lexical state is set to <tt>ZZ_INITIAL</tt>.
- *
- * @param reader the new input stream
- */
- private final void yyreset(java.io.Reader reader) {
- zzReader = reader;
-// zzAtBOL = true;
- zzAtEOF = false;
- zzEndRead = zzStartRead = 0;
- zzCurrentPos = zzMarkedPos = 0;//zzPushbackPos = 0;
-// yyline = yychar = yycolumn = 0;
- zzLexicalState = YYINITIAL;
- }
-
-
- /**
- * Returns the current lexical state.
- */
-// private final int yystate() {
-// return zzLexicalState;
-// }
-
-
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
-// private final void yybegin(int newState) {
-// zzLexicalState = newState;
-// }
-
-
- /**
- * Returns the text matched by the current regular expression.
- */
-// private final String yytext() {
-// return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
-// }
-
-
- /**
- * Returns the character at position <tt>pos</tt> from the
- * matched text.
- *
- * It is equivalent to yytext().charAt(pos), but faster
- *
- * @param pos the position of the character to fetch.
- * A value from 0 to yylength()-1.
- *
- * @return the character at position pos
- */
-// private final char yycharat(int pos) {
-// return zzBuffer[zzStartRead+pos];
-// }
-
-
- /**
- * Returns the length of the matched text region.
- */
-// private final int yylength() {
-// return zzMarkedPos-zzStartRead;
-// }
-
-
- /**
- * Reports an error that occured while scanning.
- *
- * In a wellformed scanner (no or only correct usage of
- * yypushback(int) and a match-all fallback rule) this method
- * will only be called with things that "Can't Possibly Happen".
- * If this method is called, something is seriously wrong
- * (e.g. a JFlex bug producing a faulty scanner etc.).
- *
- * Usual syntax/scanner level error handling should be done
- * in error fallback rules.
- *
- * @param errorCode the code of the errormessage to display
- */
- private void zzScanError(int errorCode) {
- String message;
- try {
- message = ZZ_ERROR_MSG[errorCode];
- }
- catch (ArrayIndexOutOfBoundsException e) {
- message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
- }
-
- throw new Error(message);
- }
-
-
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
-// private void yypushback(int number) {
-// if ( number > yylength() )
-// zzScanError(ZZ_PUSHBACK_2BIG);
-//
-// zzMarkedPos -= number;
-// }
-
-
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception java.io.IOException if any I/O-Error occurs
- */
- private boolean isValidXML10Name() throws java.io.IOException {
- int zzInput;
- int zzAction;
-
- // cached fields:
- int zzCurrentPosL;
- int zzMarkedPosL;
- int zzEndReadL = zzEndRead;
- char [] zzBufferL = zzBuffer;
- char [] zzCMapL = ZZ_CMAP;
-
- int [] zzTransL = ZZ_TRANS;
- int [] zzRowMapL = ZZ_ROWMAP;
- int [] zzAttrL = ZZ_ATTRIBUTE;
-
- while (true) {
- zzMarkedPosL = zzMarkedPos;
-
- zzAction = -1;
-
- zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
-
- zzState = zzLexicalState;
-
-
- zzForAction: {
- while (true) {
-
- if (zzCurrentPosL < zzEndReadL)
- zzInput = zzBufferL[zzCurrentPosL++];
- else if (zzAtEOF) {
- zzInput = YYEOF;
- break zzForAction;
- }
- else {
- // store back cached positions
- zzCurrentPos = zzCurrentPosL;
- zzMarkedPos = zzMarkedPosL;
- boolean eof = zzRefill();
- // get translated positions and possibly new buffer
- zzCurrentPosL = zzCurrentPos;
- zzMarkedPosL = zzMarkedPos;
- zzBufferL = zzBuffer;
- zzEndReadL = zzEndRead;
- if (eof) {
- zzInput = YYEOF;
- break zzForAction;
- }
- else {
- zzInput = zzBufferL[zzCurrentPosL++];
- }
- }
- int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
- if (zzNext == -1) break zzForAction;
- zzState = zzNext;
-
- int zzAttributes = zzAttrL[zzState];
- if ( (zzAttributes & 1) == 1 ) {
- zzAction = zzState;
- zzMarkedPosL = zzCurrentPosL;
- if ( (zzAttributes & 8) == 8 ) break zzForAction;
- }
-
- }
- }
-
- // store back cached position
- zzMarkedPos = zzMarkedPosL;
-
- switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 1:
- { return false; /* matched wild */
- }
- case 4: break;
- case 2:
- { return true; /* exact name */
- }
- case 5: break;
- case 3:
- { return false; /* more than name */
- }
- case 6: break;
- default:
- if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
- zzAtEOF = true;
- { {return false; /* hit end with no match */} }
- }
- else {
- zzScanError(ZZ_NO_MATCH);
- }
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
deleted file mode 100644
index 4a8791c4f7..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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.parser;
-
-
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.internal.document.DocumentReader;
-import org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker;
-import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser;
-import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTokenizer;
-import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
-import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandler;
-import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParser;
-import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParserExtension;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.text.CharSequenceReader;
-import org.eclipse.wst.sse.core.internal.text.IRegionComparible;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- * Takes input from the HTMLTokenizer and creates a tag list
- */
-
-public class XMLSourceParser implements RegionParser, BlockTagParser, StructuredDocumentRegionParser, IRegionComparible, StructuredDocumentRegionParserExtension {
- // made public to aid access from inner classes in hierarchy.
- // TODO: in future, figure out how to solve without exposing data.
- public CharSequence fCharSequenceSource = null;
- private IDocument fDocumentInput;
- protected int fOffset = 0;
- // DMW: 2/12/03. Removed some state data, since not really needed,
- // and since it added a lot to overhead (since so many regions are
- // created.
- // protected IStructuredDocumentRegion fCurrentNode = null;
- // protected IStructuredDocumentRegion fNodes = null;
- // protected List fRegions = null;
- // protected Object fInput = null;
- protected String fStringInput = null;
- protected List fStructuredDocumentRegionHandlers;
-
- protected BlockTokenizer fTokenizer = null;
- protected long startTime;
- protected long stopTime;
-
- /**
- * HTMLSourceParser constructor comment.
- */
- public XMLSourceParser() {
- super();
- fStructuredDocumentRegionHandlers = new ArrayList();
- }
-
- /**
- * This is a simple utility to count nodes. Used only for debug
- * statements.
- */
- protected int _countNodes(IStructuredDocumentRegion nodes) {
- int result = 0;
- IStructuredDocumentRegion countNode = nodes;
- while (countNode != null) {
- result++;
- countNode = countNode.getNext();
- }
- return result;
- }
-
- public void addBlockMarker(BlockMarker marker) {
- getTokenizer().addBlockMarker(marker);
- }
-
- public synchronized void addStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler) {
- if (fStructuredDocumentRegionHandlers == null)
- fStructuredDocumentRegionHandlers = new ArrayList();
- synchronized (fStructuredDocumentRegionHandlers) {
- fStructuredDocumentRegionHandlers.add(handler);
- }
- }
-
- public void beginBlockScan(String newTagName) {
- getTokenizer().beginBlockTagScan(newTagName);
- }
-
- /**
- * @return IStructuredDocumentRegion
- */
- protected IStructuredDocumentRegion createStructuredDocumentRegion(String type) {
- IStructuredDocumentRegion newNode = null;
- if (type == DOMRegionContext.BLOCK_TEXT)
- newNode = XMLStructuredRegionFactory.createRegion(XMLStructuredRegionFactory.XML_BLOCK);
- else
- newNode = XMLStructuredRegionFactory.createRegion(XMLStructuredRegionFactory.XML);
- return newNode;
- }
-
- protected void fireNodeParsed(IStructuredDocumentRegion fCurrentNode) {
- /*
- * Never let an Exceptions from foreign code interfere with completion
- * of parsing. To get an exception here is definitely a program error
- * somewhere, but we can't afford to interrupt the flow of control. or
- * backwards typing can result!
- *
- * Protect the user's data above everything.
- */
- Object[] handlers = null;
- synchronized (fStructuredDocumentRegionHandlers) {
- if (fStructuredDocumentRegionHandlers == null)
- return;
-
- handlers = fStructuredDocumentRegionHandlers.toArray();
- }
- if (fCurrentNode != null && handlers != null) {
- for (int i = 0; i < handlers.length; i++) {
- try {
- ((StructuredDocumentRegionHandler) handlers[i]).nodeParsed(fCurrentNode);
- }
- catch (Exception e) {
- Logger.log(Logger.ERROR, "Error occurred while firing Node Parsed event", e); //$NON-NLS-1$
- }
- }
- }
- }
-
- public BlockMarker getBlockMarker(String tagName) {
- List markers = getTokenizer().getBlockMarkers();
- for (int i = 0; i < markers.size(); i++) {
- BlockMarker marker = (BlockMarker) markers.get(i);
- if (marker.isCaseSensitive()) {
- if (marker.getTagName().equals(tagName))
- return marker;
- }
- else {
- if (marker.getTagName().equalsIgnoreCase(tagName))
- return marker;
- }
- }
- return null;
- }
-
- public List getBlockMarkers() {
- return getTokenizer().getBlockMarkers();
- }
-
- /**
- * @return IStructuredDocumentRegion
- */
- public IStructuredDocumentRegion getDocumentRegions() {
- IStructuredDocumentRegion headnode = null;
- if (headnode == null) {
- if (Debug.perfTest) {
- startTime = System.currentTimeMillis();
- }
- headnode = parseNodes();
- if (Debug.perfTest) {
- stopTime = System.currentTimeMillis();
- System.out.println(" -- creating nodes of IStructuredDocument -- "); //$NON-NLS-1$
- System.out.println(" Time parse and init all regions: " + (stopTime - startTime) + " (msecs)"); //$NON-NLS-2$//$NON-NLS-1$
- // System.out.println(" for " + fRegions.size() + "
- // Regions");//$NON-NLS-2$//$NON-NLS-1$
- System.out.println(" and " + _countNodes(headnode) + " Nodes"); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- return headnode;
- }
-
- protected ITextRegion getNextRegion() {
- ITextRegion region = null;
- try {
- region = getTokenizer().getNextToken();
- // DMW: 2/12/03 Removed state
- // if (region != null) {
- // fRegions.add(region);
- // }
- return region;
- }
- catch (StackOverflowError e) {
- Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset(), e); //$NON-NLS-1$
- throw e;
- }
- catch (Exception e) {
- Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset() + " (" + e.getLocalizedMessage() + ")", e); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Return the full list of known regions. Typically getNodes should be
- * used instead of this method.
- */
- public List getRegions() {
- IStructuredDocumentRegion headNode = null;
- if (!getTokenizer().isEOF()) {
- headNode = getDocumentRegions();
- // throw new IllegalStateException("parsing has not finished");
- }
- // for memory recovery, we assume if someone
- // requests all regions, we can reset our big
- // memory consuming objects
- // but the new "getRegions" method is then more expensive.
- // I don't think its used much, though.
- List localRegionsList = getRegions(headNode);
- primReset();
- return localRegionsList;
- }
-
- /**
- * Method getRegions.
- *
- * @param headNode
- * @return List
- */
- protected List getRegions(IStructuredDocumentRegion headNode) {
- List allRegions = new ArrayList();
- IStructuredDocumentRegion currentNode = headNode;
- while (currentNode != null) {
- ITextRegionList nodeRegions = currentNode.getRegions();
- for (int i = 0; i < nodeRegions.size(); i++) {
- allRegions.add(nodeRegions.get(i));
- }
- currentNode = currentNode.getNext();
- }
- return allRegions;
- }
-
- /**
- * @deprecated - use the add/remove methods instead
- * @return java.util.List
- */
- public List getStructuredDocumentRegionHandlers() {
- if (fStructuredDocumentRegionHandlers == null) {
- fStructuredDocumentRegionHandlers = new ArrayList(0);
- }
- return fStructuredDocumentRegionHandlers;
- }
-
- /**
- * Returns text from the current input. Text is only valid before
- * getNodes() has been called and only when a raw String or DocumentReader
- * is given as the input.
- */
- public String getText(int offset, int length) {
- String text = null;
- if (fCharSequenceSource != null) {
- int start = fOffset + offset;
- int end = start + length;
- text = fCharSequenceSource.subSequence(start, end).toString();
- }
- else if (fDocumentInput != null) {
- try {
- text = fDocumentInput.get(offset, length);
- }
- catch (BadLocationException e) {
- text = ""; //$NON-NLS-1$
- }
- }
- else {
- if (fStringInput == null || fStringInput.length() == 0 || offset + length > fStringInput.length() || offset < 0) {
- text = ""; //$NON-NLS-1$
- }
- else {
- // offset is entirely valid during parsing as the parse
- // numbers haven't been adjusted.
- text = fStringInput.substring(offset, offset + length);
- }
- }
- return text;
- }
-
- protected BlockTokenizer getTokenizer() {
- if (fTokenizer == null) {
- fTokenizer = new XMLTokenizer();
- }
- return fTokenizer;
- }
-
-
- public RegionParser newInstance() {
- XMLSourceParser newInstance = new XMLSourceParser();
- newInstance.setTokenizer(getTokenizer().newInstance());
- return newInstance;
- }
-
- protected IStructuredDocumentRegion parseNodes() {
- // regions are initially reported as complete offsets within the
- // scanned input
- // they are adjusted here to be indexes from the currentNode's start
- // offset
- IStructuredDocumentRegion headNode = null;
- IStructuredDocumentRegion lastNode = null;
- ITextRegion region = null;
- IStructuredDocumentRegion currentNode = null;
- String type = null;
-
- while ((region = getNextRegion()) != null) {
- type = region.getType();
- // these types (might) demand a IStructuredDocumentRegion for each
- // of them
- if (type == DOMRegionContext.BLOCK_TEXT) {
- if (currentNode != null && currentNode.getLastRegion().getType() == DOMRegionContext.BLOCK_TEXT) {
- // multiple block texts indicated embedded containers; no
- // new IStructuredDocumentRegion
- currentNode.addRegion(region);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- region.adjustStart(-currentNode.getStart());
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- }
- else {
- // not continuing a IStructuredDocumentRegion
- if (currentNode != null) {
- // ensure that any existing node is at least
- // terminated
- if (!currentNode.isEnded()) {
- currentNode.setLength(region.getStart() - currentNode.getStart());
- // fCurrentNode.setTextLength(region.getStart() -
- // fCurrentNode.getStart());
- }
- lastNode = currentNode;
- }
- fireNodeParsed(currentNode);
- currentNode = createStructuredDocumentRegion(type);
- if (lastNode != null) {
- lastNode.setNext(currentNode);
- }
- currentNode.setPrevious(lastNode);
- currentNode.setStart(region.getStart());
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- currentNode.setEnded(true);
- region.adjustStart(-currentNode.getStart());
- currentNode.addRegion(region);
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- }
- }
- // the following contexts OPEN new StructuredDocumentRegions
- else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_DECLARATION_OPEN)) {
- if (currentNode != null) {
- // ensure that any existing node is at least terminated
- if (!currentNode.isEnded()) {
- currentNode.setLength(region.getStart() - currentNode.getStart());
- // fCurrentNode.setTextLength(region.getStart() -
- // fCurrentNode.getStart());
- }
- lastNode = currentNode;
- }
- fireNodeParsed(currentNode);
- currentNode = createStructuredDocumentRegion(type);
- if (lastNode != null) {
- lastNode.setNext(currentNode);
- }
- currentNode.setPrevious(lastNode);
- currentNode.setStart(region.getStart());
- currentNode.addRegion(region);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- region.adjustStart(-currentNode.getStart());
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- }
- // the following contexts neither open nor close
- // StructuredDocumentRegions; just add to them
- else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) || (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) {
- currentNode.addRegion(region);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- region.adjustStart(-currentNode.getStart());
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- }
- // the following contexts close off StructuredDocumentRegions
- // cleanly
- else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE)) {
- currentNode.setEnded(true);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- currentNode.addRegion(region);
- region.adjustStart(-currentNode.getStart());
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- }
- // this is extremely rare, but valid
- else if (type == DOMRegionContext.WHITE_SPACE) {
- ITextRegion lastRegion = currentNode.getLastRegion();
- // pack the embedded container with this region
- if (lastRegion instanceof ITextRegionContainer) {
- ITextRegionContainer container = (ITextRegionContainer) lastRegion;
- container.getRegions().add(region);
- // containers must have parent set ...
- // setting for EACH subregion is redundent, but not sure
- // where else to do, so will do here for now.
- container.setParent(currentNode);
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(container);
- region.adjustStart(container.getLength() - region.getStart());
- }
- currentNode.getLastRegion().adjustLength(region.getLength());
- currentNode.adjustLength(region.getLength());
- }
- else if (type == DOMRegionContext.UNDEFINED && currentNode != null) {
- // skip on a very-first region situation as the default
- // behavior is good enough
- // combine with previous if also undefined
- if (currentNode.getLastRegion() != null && currentNode.getLastRegion().getType() == DOMRegionContext.UNDEFINED) {
- currentNode.getLastRegion().adjustLength(region.getLength());
- currentNode.adjustLength(region.getLength());
- }
- // previous wasn't undefined
- else {
- currentNode.addRegion(region);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- region.adjustStart(-currentNode.getStart());
- }
- }
- else {
- // if an unknown type is the first region in the document,
- // ensure that a node exists
- if (currentNode == null) {
- currentNode = createStructuredDocumentRegion(type);
- currentNode.setStart(region.getStart());
- }
- currentNode.addRegion(region);
- currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
- region.adjustStart(-currentNode.getStart());
- // DW 4/16/2003 regions no longer have parents
- // region.setParent(currentNode);
- if (Debug.debugTokenizer)
- System.out.println(getClass().getName() + " found region of not specifically handled type " + region.getType() + " @ " + region.getStart() + "[" + region.getLength() + "]"); //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
-
- // these regions also get their own node, so close them cleanly
- // NOTE: these regions have new StructuredDocumentRegions created
- // for them above; it may
- // be more readable if that is handled here as well, but the
- // current layout
- // ensures that they open StructuredDocumentRegions the same way
- if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE)) {
- currentNode.setEnded(true);
- }
- if (headNode == null && currentNode != null) {
- headNode = currentNode;
- }
- }
- if (currentNode != null) {
- fireNodeParsed(currentNode);
- currentNode.setPrevious(lastNode);
- }
- // fStringInput = null;
- primReset();
- return headNode;
- }
-
- protected void primReset() {
- // fNodes = null;
- // fRegions = null;
- // fInput = null;
- fStringInput = null;
- fCharSequenceSource = null;
- fDocumentInput = null;
- fOffset = 0;
- // fCurrentNode = null;
- // DMW: also reset tokenizer so it doesn't hold on
- // to large arrays
- getTokenizer().reset(new char[0]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.internal.text.IRegionComparible#regionMatches(int,
- * int, java.lang.String)
- */
- public boolean regionMatches(int offset, int length, String stringToCompare) {
- // by definition
- if (stringToCompare == null)
- return false;
-
- int ajustedOffset = fOffset + offset;
- boolean result = false;
- if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) {
- result = ((IRegionComparible) fCharSequenceSource).regionMatches(ajustedOffset, length, stringToCompare);
- }
- else {
- // old fashioned ways
- String test = null;
- if (fCharSequenceSource != null) {
- test = fCharSequenceSource.subSequence(ajustedOffset, ajustedOffset + length).toString();
- }
- else if (fStringInput != null) {
- test = fStringInput.substring(ajustedOffset, ajustedOffset + length);
- }
- result = stringToCompare.equals(test);
- }
- return result;
- }
-
- public boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare) {
- // by definition
- if (stringToCompare == null)
- return false;
-
- int ajustedOffset = fOffset + offset;
- boolean result = false;
- if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) {
- result = ((IRegionComparible) fCharSequenceSource).regionMatchesIgnoreCase(ajustedOffset, length, stringToCompare);
- }
- else {
- // old fashioned ways
- String test = null;
- if (fCharSequenceSource != null) {
- test = fCharSequenceSource.subSequence(ajustedOffset, ajustedOffset + length).toString();
- }
- else if (fStringInput != null) {
- test = fStringInput.substring(ajustedOffset, ajustedOffset + length);
- }
- result = stringToCompare.equalsIgnoreCase(test);
- }
- return result;
- }
-
- public void removeBlockMarker(BlockMarker marker) {
- getTokenizer().removeBlockMarker(marker);
- }
-
- public void removeBlockMarker(String tagName) {
- getTokenizer().removeBlockMarker(tagName);
- }
-
- public void removeStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler) {
- if (fStructuredDocumentRegionHandlers == null)
- return;
- synchronized (fStructuredDocumentRegionHandlers) {
- fStructuredDocumentRegionHandlers.remove(handler);
- }
- }
-
- /**
- * Resets the input.
- */
- public void reset(java.io.FileInputStream instream) {
- primReset();
- // fInput = instream;
- getTokenizer().reset(instream);
- }
-
- /**
- * Resets the input.
- */
- public void reset(java.io.Reader reader) {
- reset(reader, 0);
- }
-
- /**
- * Resets the input.
- */
- public void reset(java.io.Reader reader, int position) {
- primReset();
- fOffset = position;
- getTokenizer().reset(reader, position);
- if (reader instanceof DocumentReader) {
- IDocument doc = ((DocumentReader) reader).getDocument();
- if (doc instanceof CharSequence) {
- fCharSequenceSource = (CharSequence) doc;
- }
- else {
- // old fashioned IDocument
- fDocumentInput = ((DocumentReader) reader).getDocument();
- }
-
- }
- else if (reader instanceof CharSequenceReader) {
- fCharSequenceSource = ((CharSequenceReader) reader).getOriginalSource();
- }
- }
-
- /**
- * Resets the input. Use this version to allow text to be retrieved
- * <em>during</em> parsing, such as by the
- * StructuredDocumentRegionHandler.
- */
- public void reset(String sourceString) {
- reset(new StringReader(sourceString));
- fStringInput = sourceString;
- }
-
- /**
- * Resets the input. Use this version to allow text to be retrieved
- * <em>during</em> parsing, such as by the
- * StructuredDocumentRegionHandler.
- */
- public void reset(String sourceString, int position) {
- StringReader reader = new StringReader(sourceString);
- reset(reader, position);
- fStringInput = sourceString;
- }
-
- public void resetHandlers() {
- Object[] handlers = null;
- synchronized (fStructuredDocumentRegionHandlers) {
- if (fStructuredDocumentRegionHandlers == null)
- return;
-
- handlers = fStructuredDocumentRegionHandlers.toArray();
- }
- for (int i = 0; i < handlers.length; i++) {
- try {
- ((StructuredDocumentRegionHandler) handlers[i]).resetNodes();
- }
- catch (Exception e) {
- Logger.log(Logger.ERROR, "Error occurred while resetting handlers", e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- *
- * @param List
- */
- public void setStructuredDocumentRegionHandlers(List newStructuredDocumentRegionHandlers) {
- fStructuredDocumentRegionHandlers = newStructuredDocumentRegionHandlers;
- }
-
- protected void setTokenizer(BlockTokenizer newTokenizer) {
- // DMW: changed from private to protected, so subclass could use in
- // creation of 'newInstance'.
- fTokenizer = newTokenizer;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java
deleted file mode 100644
index c185520fa7..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class XMLStructuredDocumentReParser extends StructuredDocumentReParser {
-
- public XMLStructuredDocumentReParser() {
- super();
- }
-
- protected IStructuredDocumentRegion findDirtyEnd(int end) {
- // Caution: here's one place we have to cast
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end);
- // if not well formed, get one past, if there is something there
- if ((result != null) && (!result.isEnded())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
- // also, get one past if exactly equal to the end (this was needed
- // as a simple fix to when a whole exact region is deleted.
- // there's probably a better way.
- if ((result != null) && (end == result.getEnd())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
-
- // 12/6/2001 - Since we've changed the parser/scanner to allow a lone
- // '<' without
- // always interpretting it as start of a tag name, we need to be a
- // little fancier, in order
- // to "skip" over any plain 'ol content between the lone '<' and any
- // potential meating
- // regions past plain 'ol content.
- if (isLoneOpenFollowedByContent(result) && (result.getNext() != null)) {
- result = result.getNext();
- }
-
- if (result != null)
- fStructuredDocument.setCachedDocumentRegion(result);
- dirtyEnd = result;
-
- return dirtyEnd;
- }
-
- protected void findDirtyStart(int start) {
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start);
- // heuristic: if the postion is exactly equal to the start, then
- // go back one more, if it exists. This prevents problems with
- // insertions
- // of text that should be merged with the previous node instead of
- // simply hung
- // off of it as a separate node (ex.: XML content inserted right
- // before an open
- // bracket should become part of the previous content node)
- if (result != null) {
- IStructuredDocumentRegion previous = result.getPrevious();
- if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) {
- result = previous;
- }
- // If we are now at the end of a "tag dependent" content area (or
- // JSP area)
- // then we need to back up all the way to the beginning of that.
- IStructuredDocumentRegion potential = result;
- while (isPartOfBlockRegion(potential)) {
- potential = potential.getPrevious();
- }
- if (potential != null) {
- result = potential;
- fStructuredDocument.setCachedDocumentRegion(result);
- }
- }
- dirtyStart = result;
- }
-
- /**
- * The rule is, that is we are content, preceded by lone <, then we need
- * to advance one more for dirty end.
- */
- protected boolean isLoneOpenFollowedByContent(IStructuredDocumentRegion flatNode) {
- boolean result = false;
- String type = flatNode.getType();
- if (type == DOMRegionContext.XML_CONTENT) {
- IStructuredDocumentRegion previous = flatNode.getPrevious();
- String previousType = null;
- if (previous != null) {
- previousType = previous.getType();
- }
- if (previousType != null) {
- result = (previousType == DOMRegionContext.XML_TAG_OPEN);
- }
- }
- return result;
- }
-
- protected boolean isPartOfBlockRegion(IStructuredDocumentRegion flatNode) {
- boolean result = false;
- String type = flatNode.getType();
- result = (type == DOMRegionContext.BLOCK_TEXT);
- return result;
- }
-
- public IStructuredTextReParser newInstance() {
- return new XMLStructuredDocumentReParser();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java
deleted file mode 100644
index 8a98dc2d9b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.text.XMLStructuredDocumentRegion;
-
-
-/**
- * A simple class to generate instances of StructuredRegions.
- */
-public class XMLStructuredRegionFactory {
- public final static int JSP_DIRECTIVE = 1003;
- public final static int XML = 1001;
- public final static int XML_BLOCK = 1002;
-
- public static IStructuredDocumentRegion createRegion(int type) {
- IStructuredDocumentRegion instance = null;
- switch (type) {
- case XML :
- instance = new XMLStructuredDocumentRegion();
- break;
- case XML_BLOCK :
- instance = new BlockStructuredDocumentRegion();
- break;
- default :
- throw new IllegalArgumentException("AbstractRegion::createRegion. Invalid type."); //$NON-NLS-1$
- }
- return instance;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java
deleted file mode 100644
index be32479132..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java
+++ /dev/null
@@ -1,1913 +0,0 @@
-/* The following code was generated by JFlex 1.2.2 on 3/7/11 4:17 PM */
-
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.parser;
-
-import java.io.CharArrayReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker;
-import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTokenizer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.parser.regions.XMLParserRegionFactory;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- * This class is a scanner generated by
- * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2
- * on 3/7/11 4:17 PM from the specification file
- * <tt>file:/C:/dev/workspaces/indigo/org.eclipse.wst.sse.core/DevTimeSupport/SedModel/HTMLTokenizer/devel/XMLTokenizer.jflex</tt>
- */
-public class XMLTokenizer implements BlockTokenizer, DOMRegionContext {
-
- /** this character denotes the end of file */
- final public static int YYEOF = -1;
-
- /** lexical states */
- final public static int ST_XML_DOCTYPE_EXTERNAL_ID = 23;
- final public static int ST_XML_ELEMENT_DECLARATION_CONTENT = 27;
- final public static int ST_DHTML_ATTRIBUTE_NAME = 12;
- final public static int ST_XML_PI_TAG_CLOSE = 11;
- final public static int ST_XML_DECLARATION_CLOSE = 21;
- final public static int ST_XML_PI_ATTRIBUTE_VALUE = 10;
- final public static int ST_DHTML_EQUALS = 13;
- final public static int ST_XML_TAG_NAME = 16;
- final public static int ST_XML_ATTRIBUTE_VALUE = 19;
- final public static int ST_DHTML_ATTRIBUTE_VALUE = 14;
- final public static int ST_XML_DOCTYPE_ID_SYSTEM = 25;
- final public static int ST_XML_ATTRIBUTE_NAME = 17;
- final public static int ST_XML_ELEMENT_DECLARATION = 26;
- final public static int ST_XML_DOCTYPE_DECLARATION = 22;
- final public static int ST_XML_ATTLIST_DECLARATION = 28;
- final public static int ST_XML_COMMENT_END = 4;
- final public static int ST_CDATA_TEXT = 1;
- final public static int ST_DHTML_TAG_CLOSE = 15;
- final public static int ST_XML_COMMENT = 3;
- final public static int ST_PI_CONTENT = 7;
- final public static int ST_PI_WS = 6;
- final public static int ST_CDATA_END = 2;
- final public static int ST_XML_ATTLIST_DECLARATION_CONTENT = 29;
- final public static int ST_BLOCK_TAG_SCAN = 30;
- final public static int ST_XML_PI_EQUALS = 9;
- final public static int ST_XML_DECLARATION = 20;
- final public static int YYINITIAL = 0;
- final public static int ST_XML_DOCTYPE_ID_PUBLIC = 24;
- final public static int ST_XML_EQUALS = 18;
- final public static int ST_PI = 5;
- final public static int ST_XML_PI_ATTRIBUTE_NAME = 8;
-
- /**
- * Translates characters to character classes
- */
- final private static String yycmap_packed =
- "\11\0\1\5\1\22\2\0\1\14\22\0\1\14\1\21\1\11\1\55"+
- "\1\16\1\17\1\12\1\13\1\16\1\16\1\16\1\16\1\16\1\7"+
- "\1\6\1\3\12\15\1\10\1\61\1\1\1\45\1\2\1\4\1\16"+
- "\1\34\1\62\1\32\1\33\1\50\1\57\1\36\1\36\1\42\1\36"+
- "\1\36\1\27\1\25\1\44\1\43\1\47\1\36\1\40\1\56\1\35"+
- "\1\60\2\36\1\23\1\46\1\36\1\31\1\0\1\20\1\0\1\10"+
- "\1\0\1\52\1\62\1\63\1\53\1\37\1\57\1\36\1\66\1\42"+
- "\2\36\1\30\1\26\1\44\1\43\1\47\1\36\1\40\1\41\1\51"+
- "\1\60\1\36\1\36\1\24\1\54\1\36\1\0\1\0\72\0\1\65"+
- "\10\0\27\64\1\0\37\64\1\0\72\64\2\0\13\64\2\0\10\64"+
- "\1\0\65\64\1\0\104\64\11\0\44\64\3\0\2\64\4\0\36\64"+
- "\70\0\131\64\22\0\7\64\16\0\2\65\56\0\106\65\32\0\2\65"+
- "\44\0\1\64\1\65\3\64\1\0\1\64\1\0\24\64\1\0\54\64"+
- "\1\0\7\64\3\0\1\64\1\0\1\64\1\0\1\64\1\0\1\64"+
- "\1\0\22\64\15\0\14\64\1\0\102\64\1\0\14\64\1\0\44\64"+
- "\1\0\4\65\11\0\65\64\2\0\2\64\2\0\2\64\3\0\34\64"+
- "\2\0\10\64\2\0\2\64\67\0\46\64\2\0\1\64\7\0\46\64"+
- "\12\0\21\65\1\0\27\65\1\0\3\65\1\0\1\65\1\0\2\65"+
- "\1\0\1\65\13\0\33\64\5\0\3\64\56\0\32\64\5\0\1\65"+
- "\12\64\10\65\15\0\12\65\6\0\1\65\107\64\2\0\5\64\1\0"+
- "\17\64\1\0\4\64\1\0\1\64\17\65\2\64\2\65\1\0\4\65"+
- "\2\0\12\65\u0207\0\3\65\1\0\65\64\2\0\1\65\1\64\20\65"+
- "\3\0\4\65\3\0\12\64\2\65\2\0\12\65\21\0\3\65\1\0"+
- "\10\64\2\0\2\64\2\0\26\64\1\0\7\64\1\0\1\64\3\0"+
- "\4\64\2\0\1\65\1\0\7\65\2\0\2\65\2\0\3\65\11\0"+
- "\1\65\4\0\2\64\1\0\3\64\2\65\2\0\12\65\2\64\20\0"+
- "\1\65\2\0\6\64\4\0\2\64\2\0\26\64\1\0\7\64\1\0"+
- "\2\64\1\0\2\64\1\0\2\64\2\0\1\65\1\0\5\65\4\0"+
- "\2\65\2\0\3\65\13\0\4\64\1\0\1\64\7\0\12\65\2\65"+
- "\3\64\14\0\3\65\1\0\7\64\1\0\1\64\1\0\3\64\1\0"+
- "\26\64\1\0\7\64\1\0\2\64\1\0\5\64\2\0\1\65\1\64"+
- "\10\65\1\0\3\65\1\0\3\65\22\0\1\64\5\0\12\65\21\0"+
- "\3\65\1\0\10\64\2\0\2\64\2\0\26\64\1\0\7\64\1\0"+
- "\2\64\2\0\4\64\2\0\1\65\1\64\6\65\3\0\2\65\2\0"+
- "\3\65\10\0\2\65\4\0\2\64\1\0\3\64\4\0\12\65\22\0"+
- "\2\65\1\0\6\64\3\0\3\64\1\0\4\64\3\0\2\64\1\0"+
- "\1\64\1\0\2\64\3\0\2\64\3\0\3\64\3\0\10\64\1\0"+
- "\3\64\4\0\5\65\3\0\3\65\1\0\4\65\11\0\1\65\17\0"+
- "\11\65\21\0\3\65\1\0\10\64\1\0\3\64\1\0\27\64\1\0"+
- "\12\64\1\0\5\64\4\0\7\65\1\0\3\65\1\0\4\65\7\0"+
- "\2\65\11\0\2\64\4\0\12\65\22\0\2\65\1\0\10\64\1\0"+
- "\3\64\1\0\27\64\1\0\12\64\1\0\5\64\4\0\7\65\1\0"+
- "\3\65\1\0\4\65\7\0\2\65\7\0\1\64\1\0\2\64\4\0"+
- "\12\65\22\0\2\65\1\0\10\64\1\0\3\64\1\0\27\64\1\0"+
- "\20\64\4\0\6\65\2\0\3\65\1\0\4\65\11\0\1\65\10\0"+
- "\2\64\4\0\12\65\221\0\56\64\1\0\1\64\1\65\2\64\7\65"+
- "\5\0\6\64\1\65\10\65\1\0\12\65\47\0\2\64\1\0\1\64"+
- "\2\0\2\64\1\0\1\64\2\0\1\64\6\0\4\64\1\0\7\64"+
- "\1\0\3\64\1\0\1\64\1\0\1\64\2\0\2\64\1\0\2\64"+
- "\1\0\1\64\1\65\2\64\6\65\1\0\2\65\1\64\2\0\5\64"+
- "\1\0\1\65\1\0\6\65\2\0\12\65\76\0\2\65\6\0\12\65"+
- "\13\0\1\65\1\0\1\65\1\0\1\65\4\0\2\65\10\64\1\0"+
- "\41\64\7\0\24\65\1\0\6\65\4\0\6\65\1\0\1\65\1\0"+
- "\25\65\3\0\7\65\1\0\1\65\346\0\46\64\12\0\47\64\11\0"+
- "\1\64\1\0\2\64\1\0\3\64\1\0\1\64\1\0\2\64\1\0"+
- "\5\64\51\0\1\64\1\0\1\64\1\0\1\64\13\0\1\64\1\0"+
- "\1\64\1\0\1\64\3\0\2\64\3\0\1\64\5\0\3\64\1\0"+
- "\1\64\1\0\1\64\1\0\1\64\1\0\1\64\3\0\2\64\3\0"+
- "\2\64\1\0\1\64\50\0\1\64\11\0\1\64\2\0\1\64\2\0"+
- "\2\64\7\0\2\64\1\0\1\64\1\0\7\64\50\0\1\64\4\0"+
- "\1\64\10\0\1\64\u0c06\0\234\64\4\0\132\64\6\0\26\64\2\0"+
- "\6\64\2\0\46\64\2\0\6\64\2\0\10\64\1\0\1\64\1\0"+
- "\1\64\1\0\1\64\1\0\37\64\2\0\65\64\1\0\7\64\1\0"+
- "\1\64\3\0\3\64\1\0\7\64\3\0\4\64\2\0\6\64\4\0"+
- "\15\64\5\0\3\64\1\0\7\64\323\0\15\65\4\0\1\65\104\0"+
- "\1\64\3\0\2\64\2\0\1\64\121\0\3\64\u0e82\0\1\65\1\0"+
- "\1\64\31\0\11\64\6\65\1\0\5\65\13\0\124\64\4\0\2\65"+
- "\2\0\2\65\2\0\132\64\1\0\3\65\6\0\50\64\u1cd3\0\u51a6\64"+
- "\u0c5a\0\u2ba4\64\134\0\u0800\0\u1ffe\0\2\0";
-
- /**
- * Translates characters to character classes
- */
- final private static char [] yycmap = yy_unpack_cmap(yycmap_packed);
-
- /**
- * Translates a state to a row index in the transition table
- */
- final private static int yy_rowMap [] = {
- 0, 55, 110, 165, 220, 275, 330, 385, 440, 495,
- 550, 605, 660, 715, 770, 825, 880, 935, 990, 1045,
- 1100, 1155, 1210, 1265, 1320, 1375, 1430, 1485, 1540, 1595,
- 1650, 1705, 1760, 1815, 1870, 1925, 1980, 1925, 1980, 2035,
- 1925, 1925, 1980, 2090, 2145, 2200, 2255, 2310, 2365, 2420,
- 2475, 1925, 1980, 2530, 2585, 2640, 1925, 2695, 2695, 2750,
- 2805, 2860, 2530, 1925, 2915, 2970, 1925, 3025, 3080, 3135,
- 3190, 3245, 3300, 1925, 3355, 3410, 3465, 3520, 1925, 3575,
- 3630, 3685, 3740, 3795, 1925, 3850, 3905, 3960, 4015, 4070,
- 4125, 4180, 4235, 4235, 4290, 4345, 4400, 4455, 4455, 4510,
- 4565, 4620, 4675, 4675, 4730, 4785, 4840, 4895, 1925, 4950,
- 4950, 5005, 5060, 5115, 5170, 1925, 1925, 1980, 1925, 1925,
- 5225, 5280, 5335, 5390, 5445, 5500, 5555, 5610, 5665, 1925,
- 5720, 5775, 5830, 1925, 1925, 2695, 5885, 2805, 1925, 5940,
- 2860, 2915, 3025, 3080, 5995, 3135, 1925, 6050, 3190, 1925,
- 3575, 6105, 3685, 1925, 6160, 3740, 5225, 6215, 6270, 6325,
- 4015, 1925, 6380, 6435, 4235, 6490, 4290, 1925, 6545, 6600,
- 6655, 6655, 6710, 6765, 4400, 4235, 4455, 6820, 4510, 1925,
- 6875, 4565, 4620, 4455, 4675, 6930, 4730, 1925, 6985, 7040,
- 7095, 7095, 7150, 7205, 7260, 4950, 7315, 5005, 1925, 7370,
- 7425, 7480, 7480, 7535, 7590, 7645, 7700, 7755, 7810, 7865,
- 1925, 7920, 7975, 1925, 1925, 1925, 2255, 8030, 8085, 8140,
- 8195, 8250, 8305, 8360, 6545, 8415, 8415, 6985, 8470, 8470,
- 8525, 7370, 8580, 8580, 8635, 1925, 8690, 8745, 1925, 8800,
- 8855, 8910, 8965, 9020, 9075, 9130, 9185, 6710, 7150, 9240,
- 7535, 9295, 9350, 9405, 9460, 9515, 9570, 9625, 9680, 9735,
- 9790, 9845, 9900, 9955, 10010, 10065, 10120, 10175, 1925, 1925,
- 10230, 10285, 10340, 10395, 10450, 1925, 1925, 1925, 10505, 10560,
- 10615, 10670, 10725, 10780, 1925, 10835, 4840, 5115, 10890, 10945,
- 11000, 11055, 2255
- };
-
- /**
- * The packed transition table of the DFA
- */
- final private static String yy_packed =
- "\1\40\1\41\10\40\1\42\4\40\1\43\47\40\1\44"+
- "\1\45\65\44\1\46\1\47\16\46\1\50\1\46\1\51"+
- "\44\46\1\52\1\53\65\52\1\46\1\47\5\46\1\54"+
- "\12\46\1\51\45\46\1\47\2\46\1\55\1\56\2\46"+
- "\1\57\3\46\1\56\5\46\1\56\1\60\1\61\4\57"+
- "\1\46\10\57\1\62\2\57\1\46\7\57\1\46\3\57"+
- "\1\46\3\57\1\46\1\57\1\46\1\47\2\46\1\55"+
- "\1\63\6\46\1\63\5\46\1\63\44\46\1\64\1\65"+
- "\2\64\1\66\15\64\1\51\44\64\1\46\1\47\2\46"+
- "\1\67\1\56\2\46\1\70\3\46\1\56\5\46\1\56"+
- "\6\70\1\46\13\70\1\46\7\70\1\46\3\70\1\46"+
- "\3\70\1\46\1\70\1\46\1\47\2\46\1\67\1\56"+
- "\2\46\1\70\3\46\1\56\5\46\1\56\6\70\1\46"+
- "\13\70\1\71\7\70\1\46\3\70\1\46\3\70\1\46"+
- "\1\70\1\72\1\47\1\46\1\73\1\74\1\56\3\72"+
- "\1\75\1\72\1\76\1\56\5\72\1\56\44\72\1\46"+
- "\1\47\2\46\1\77\15\46\1\51\45\46\1\47\1\100"+
- "\1\101\1\46\1\56\2\46\1\102\3\46\1\56\5\46"+
- "\1\56\6\102\1\46\13\102\1\46\7\102\1\46\3\102"+
- "\1\46\3\102\1\46\1\102\1\46\1\47\1\100\1\101"+
- "\1\46\1\56\2\46\1\102\3\46\1\56\5\46\1\56"+
- "\6\102\1\46\13\102\1\103\7\102\1\46\3\102\1\46"+
- "\3\102\1\46\1\102\1\104\1\47\1\100\1\105\1\104"+
- "\1\56\3\104\1\106\1\104\1\107\1\56\5\104\1\56"+
- "\44\104\1\46\1\47\3\46\1\56\6\46\1\56\5\46"+
- "\1\56\44\46\1\110\1\111\1\112\1\113\4\110\1\114"+
- "\12\110\6\115\1\110\13\115\1\110\7\115\1\110\3\115"+
- "\1\110\3\115\1\110\1\115\1\46\1\111\1\112\1\113"+
- "\1\46\1\56\2\46\1\116\3\46\1\56\5\46\1\56"+
- "\6\116\1\46\13\116\1\46\7\116\1\46\3\116\1\46"+
- "\3\116\1\46\1\116\1\46\1\111\1\112\1\113\1\46"+
- "\1\56\2\46\1\116\3\46\1\56\5\46\1\56\6\116"+
- "\1\46\13\116\1\117\7\116\1\46\3\116\1\46\3\116"+
- "\1\46\1\116\1\120\1\111\1\112\1\121\1\120\1\56"+
- "\3\120\1\122\1\120\1\123\1\56\5\120\1\56\44\120"+
- "\1\46\1\124\1\125\2\46\1\56\6\46\1\56\5\46"+
- "\1\56\10\46\1\126\1\127\2\46\1\130\10\46\1\130"+
- "\1\46\1\127\1\126\14\46\1\47\1\125\2\46\1\56"+
- "\6\46\1\56\5\46\1\56\6\46\1\131\36\46\1\47"+
- "\1\125\2\46\1\56\2\46\1\132\3\46\1\56\5\46"+
- "\1\56\6\132\1\131\13\132\1\46\7\132\1\46\3\132"+
- "\1\46\3\132\1\46\1\132\1\46\1\47\1\125\2\46"+
- "\1\56\6\46\1\56\5\46\1\56\6\46\1\131\7\46"+
- "\1\133\5\46\1\134\6\46\1\133\10\46\1\135\1\47"+
- "\1\125\1\136\1\135\1\56\3\135\1\137\1\135\1\140"+
- "\1\56\5\135\1\56\6\135\1\141\35\135\1\142\1\47"+
- "\1\125\1\143\1\142\1\56\3\142\1\144\1\142\1\145"+
- "\1\56\5\142\1\56\6\142\1\146\35\142\1\147\1\47"+
- "\1\125\1\150\1\147\1\56\3\147\1\151\1\147\1\152"+
- "\1\56\5\147\1\56\44\147\1\153\1\154\1\155\64\153"+
- "\1\156\1\47\1\125\1\157\1\156\1\56\3\156\1\160"+
- "\1\156\1\161\1\56\5\156\1\56\44\156\1\162\1\163"+
- "\1\164\64\162\1\165\1\166\65\165\1\40\1\0\10\40"+
- "\1\0\4\40\1\0\47\40\3\0\1\167\1\170\14\0"+
- "\1\171\52\0\1\172\2\0\1\173\3\0\1\172\5\0"+
- "\1\172\6\173\1\0\13\173\1\0\7\173\1\174\3\173"+
- "\1\0\3\173\1\0\1\173\5\0\1\172\2\0\1\175"+
- "\3\0\1\172\2\0\1\176\2\0\1\172\6\175\1\0"+
- "\13\175\1\0\7\175\1\0\3\175\1\0\3\175\1\0"+
- "\1\175\110\0\1\177\65\0\1\200\55\0\1\201\61\0"+
- "\1\202\71\0\1\56\6\0\1\56\5\0\1\56\52\0"+
- "\3\57\4\0\1\57\5\0\6\57\1\0\13\57\1\0"+
- "\7\57\1\0\3\57\1\0\5\57\6\0\3\57\4\0"+
- "\1\57\5\0\2\57\2\203\2\57\1\0\13\57\1\0"+
- "\7\57\1\0\3\57\1\0\5\57\6\0\3\57\4\0"+
- "\1\57\5\0\2\57\1\203\1\204\2\57\1\0\13\57"+
- "\1\0\7\57\1\0\3\57\1\0\5\57\6\0\3\57"+
- "\4\0\1\57\5\0\2\57\2\205\2\57\1\0\13\57"+
- "\1\0\7\57\1\0\3\57\1\0\5\57\5\0\1\63"+
- "\6\0\1\63\5\0\1\63\46\0\1\206\66\0\1\207"+
- "\72\0\3\70\4\0\1\70\5\0\6\70\1\0\13\70"+
- "\1\0\7\70\1\0\3\70\1\0\5\70\1\72\2\0"+
- "\1\210\1\72\1\0\3\72\1\0\1\72\2\0\5\72"+
- "\1\0\45\72\1\0\1\207\1\210\1\72\1\0\3\72"+
- "\1\0\1\72\2\0\5\72\1\0\44\72\1\75\2\211"+
- "\1\212\1\75\1\211\3\75\1\213\1\75\2\211\5\75"+
- "\1\211\44\75\1\76\2\214\1\215\1\76\1\214\3\76"+
- "\1\214\1\76\1\213\1\214\5\76\1\214\44\76\2\0"+
- "\1\100\1\216\71\0\3\102\4\0\1\102\5\0\6\102"+
- "\1\0\13\102\1\0\7\102\1\0\3\102\1\0\5\102"+
- "\1\104\2\0\1\217\1\104\1\0\3\104\1\0\1\104"+
- "\2\0\5\104\1\0\45\104\1\0\1\100\1\220\1\104"+
- "\1\0\3\104\1\0\1\104\2\0\5\104\1\0\44\104"+
- "\1\106\2\221\1\222\1\106\1\221\3\106\1\223\1\106"+
- "\2\221\5\106\1\221\44\106\1\107\2\224\1\225\1\107"+
- "\1\224\3\107\1\224\1\107\1\223\1\224\5\107\1\224"+
- "\44\107\1\110\3\0\17\110\6\0\1\110\13\0\1\110"+
- "\7\0\1\110\3\0\1\110\3\0\1\110\4\0\1\167"+
- "\15\0\1\171\47\0\1\226\64\0\1\110\3\0\2\110"+
- "\3\114\4\110\1\114\5\110\6\115\1\110\13\115\1\110"+
- "\7\115\1\110\3\115\1\110\3\115\1\114\1\115\6\0"+
- "\3\115\4\0\1\115\5\0\6\115\1\0\13\115\1\0"+
- "\7\115\1\0\3\115\1\0\5\115\6\0\3\116\4\0"+
- "\1\116\5\0\6\116\1\0\13\116\1\0\7\116\1\0"+
- "\3\116\1\0\5\116\1\120\2\0\1\227\1\120\1\0"+
- "\3\120\1\0\1\120\2\0\5\120\1\0\45\120\1\0"+
- "\1\226\1\227\1\120\1\0\3\120\1\0\1\120\2\0"+
- "\5\120\1\0\44\120\1\122\2\230\1\231\1\122\1\230"+
- "\3\122\1\232\1\122\2\230\5\122\1\230\44\122\1\123"+
- "\2\233\1\234\1\123\1\233\3\123\1\233\1\123\1\232"+
- "\1\233\5\123\1\233\44\123\3\0\1\167\15\0\1\235"+
- "\110\0\1\236\60\0\1\237\13\0\1\237\44\0\2\240"+
- "\36\0\20\241\1\242\46\241\6\0\3\132\4\0\1\132"+
- "\5\0\6\132\1\0\13\132\1\0\7\132\1\0\3\132"+
- "\1\0\5\132\46\0\1\243\5\0\1\243\72\0\1\244"+
- "\6\0\1\135\2\0\1\245\1\135\1\0\3\135\1\0"+
- "\1\135\2\0\5\135\1\0\44\135\1\137\2\246\1\247"+
- "\1\137\1\246\3\137\1\250\1\137\2\246\5\137\1\246"+
- "\44\137\1\251\2\252\1\253\1\254\1\252\3\254\1\252"+
- "\1\251\1\255\1\256\3\254\1\251\1\254\1\256\6\254"+
- "\1\251\32\254\2\251\1\254\1\141\2\241\1\257\1\141"+
- "\1\241\3\141\1\241\1\141\2\241\3\141\1\260\1\141"+
- "\1\241\44\141\1\142\2\0\1\261\1\142\1\0\3\142"+
- "\1\0\1\142\2\0\5\142\1\0\44\142\1\144\2\262"+
- "\1\263\1\144\1\262\3\144\1\264\1\144\2\262\5\144"+
- "\1\262\44\144\1\145\2\265\1\266\1\145\1\265\3\145"+
- "\1\265\1\145\1\264\1\265\5\145\1\265\44\145\1\146"+
- "\2\241\1\267\1\146\1\241\3\146\1\241\1\146\2\241"+
- "\3\146\1\270\1\146\1\241\44\146\1\147\2\0\1\271"+
- "\1\147\1\0\3\147\1\0\1\147\2\0\5\147\1\0"+
- "\44\147\1\151\2\272\1\273\1\151\1\272\3\151\1\274"+
- "\1\151\2\272\5\151\1\272\44\151\1\275\2\276\1\277"+
- "\1\300\1\276\3\300\1\276\1\275\1\301\1\302\3\300"+
- "\1\275\1\300\1\302\6\300\1\275\32\300\2\275\1\300"+
- "\2\153\1\0\66\153\1\0\16\153\1\303\45\153\1\156"+
- "\2\0\1\304\1\156\1\0\3\156\1\0\1\156\2\0"+
- "\5\156\1\0\44\156\1\160\2\305\1\306\1\160\1\305"+
- "\3\160\1\307\1\160\2\305\5\160\1\305\44\160\1\310"+
- "\2\311\1\312\1\313\1\311\3\313\1\311\1\310\1\314"+
- "\1\315\3\313\1\310\1\313\1\315\6\313\1\310\32\313"+
- "\2\310\1\313\2\162\1\0\66\162\1\0\16\162\1\316"+
- "\45\162\7\0\1\317\21\0\1\320\42\0\1\172\2\0"+
- "\1\40\3\0\1\172\5\0\1\172\6\40\1\0\13\40"+
- "\1\0\7\40\1\0\3\40\1\0\3\40\1\0\1\40"+
- "\1\321\1\0\3\321\1\322\3\173\1\321\1\0\1\321"+
- "\1\322\1\173\1\321\1\0\2\321\1\322\6\173\1\321"+
- "\13\173\1\321\7\173\1\321\3\173\1\323\5\173\15\0"+
- "\1\324\6\0\1\325\42\0\1\321\1\0\3\321\1\322"+
- "\3\175\1\321\1\0\1\321\1\322\1\175\1\321\1\0"+
- "\2\321\1\322\6\175\1\321\13\175\1\321\7\175\1\321"+
- "\3\175\1\326\5\175\17\0\1\176\100\0\1\320\37\0"+
- "\1\327\66\0\1\330\72\0\3\57\4\0\1\57\5\0"+
- "\4\57\2\331\1\0\13\57\1\0\7\57\1\0\3\57"+
- "\1\0\5\57\6\0\3\57\4\0\1\57\5\0\4\57"+
- "\1\331\1\332\1\0\13\57\1\0\7\57\1\0\3\57"+
- "\1\0\5\57\6\0\3\57\4\0\1\57\5\0\6\57"+
- "\1\0\13\57\1\0\1\57\1\333\5\57\1\0\3\57"+
- "\1\0\5\57\11\211\1\213\55\211\13\214\1\213\53\214"+
- "\11\221\1\223\55\221\13\224\1\223\53\224\11\230\1\232"+
- "\55\230\13\233\1\232\53\233\32\0\1\334\30\0\1\334"+
- "\40\0\1\335\13\0\1\335\54\0\1\336\10\0\1\336"+
- "\57\0\1\337\14\0\1\337\72\0\1\340\4\0\11\246"+
- "\1\250\55\246\1\251\2\252\1\341\1\251\1\252\3\251"+
- "\1\252\1\251\1\250\1\252\5\251\1\252\44\251\13\252"+
- "\1\250\53\252\1\251\2\252\1\341\1\251\1\252\3\251"+
- "\1\252\1\251\1\342\1\252\5\251\1\252\44\251\13\0"+
- "\1\343\53\0\13\252\1\342\53\252\11\262\1\264\55\262"+
- "\13\265\1\264\53\265\11\272\1\274\55\272\1\275\2\276"+
- "\1\344\1\275\1\276\3\275\1\276\1\275\1\274\1\276"+
- "\5\275\1\276\44\275\13\276\1\274\53\276\1\275\2\276"+
- "\1\344\1\275\1\276\3\275\1\276\1\275\1\345\1\276"+
- "\5\275\1\276\44\275\13\0\1\346\53\0\13\276\1\345"+
- "\53\276\2\153\1\0\26\153\1\347\35\153\11\305\1\307"+
- "\55\305\1\310\2\311\1\350\1\310\1\311\3\310\1\311"+
- "\1\310\1\307\1\311\5\310\1\311\44\310\13\311\1\307"+
- "\53\311\1\310\2\311\1\350\1\310\1\311\3\310\1\311"+
- "\1\310\1\351\1\311\5\310\1\311\44\310\13\0\1\352"+
- "\53\0\13\311\1\351\53\311\2\162\1\0\26\162\1\353"+
- "\35\162\7\0\1\354\111\0\1\355\34\0\1\321\1\0"+
- "\10\321\1\0\4\321\1\0\41\321\1\0\6\321\1\0"+
- "\3\321\1\322\4\321\1\0\1\321\1\322\2\321\1\0"+
- "\2\321\1\322\36\321\1\356\5\321\15\0\1\324\43\0"+
- "\1\357\22\0\1\360\14\0\3\360\2\0\1\360\10\0"+
- "\1\360\1\0\2\360\3\0\1\360\2\0\2\360\11\0"+
- "\1\57\1\361\1\57\4\0\1\57\5\0\6\57\1\0"+
- "\13\57\1\0\7\57\1\0\3\57\1\0\5\57\6\0"+
- "\3\57\4\0\1\57\5\0\6\57\1\0\11\57\1\362"+
- "\1\57\1\0\7\57\1\0\3\57\1\0\5\57\35\0"+
- "\1\363\13\0\1\363\44\0\2\364\63\0\2\365\75\0"+
- "\1\366\13\0\1\366\44\0\2\367\41\0\2\370\1\0"+
- "\3\370\2\0\1\255\4\370\1\0\10\370\1\0\32\370"+
- "\2\0\1\370\3\0\2\371\1\0\3\371\2\0\1\301"+
- "\4\371\1\0\10\371\1\0\32\371\2\0\1\371\2\153"+
- "\1\0\27\153\1\372\34\153\3\0\2\373\1\0\3\373"+
- "\2\0\1\314\4\373\1\0\10\373\1\0\32\373\2\0"+
- "\1\373\2\162\1\0\27\162\1\374\34\162\33\0\1\375"+
- "\114\0\1\356\22\0\1\360\14\0\3\360\2\0\1\360"+
- "\10\0\1\360\1\0\2\360\3\0\1\360\1\0\1\357"+
- "\2\360\11\0\3\57\4\0\1\57\5\0\6\57\1\0"+
- "\7\57\1\376\3\57\1\0\7\57\1\0\3\57\1\0"+
- "\5\57\6\0\3\57\4\0\1\57\5\0\6\57\1\0"+
- "\6\57\1\377\4\57\1\0\7\57\1\0\3\57\1\0"+
- "\5\57\46\0\1\u0100\5\0\1\u0100\54\0\1\u0101\63\0"+
- "\1\u0102\10\0\1\u0102\55\0\1\u0103\10\0\1\u0103\60\0"+
- "\1\u0104\24\0\2\153\1\0\30\153\1\u0105\33\153\2\162"+
- "\1\0\30\162\1\u0106\33\162\34\0\1\u0107\40\0\3\57"+
- "\4\0\1\57\5\0\6\57\1\0\13\57\1\0\3\57"+
- "\1\u0108\3\57\1\0\3\57\1\0\5\57\6\0\3\57"+
- "\4\0\1\57\5\0\6\57\1\0\3\57\1\u0109\7\57"+
- "\1\0\3\57\1\u0109\3\57\1\0\3\57\1\0\5\57"+
- "\47\0\1\u010a\60\0\1\u010b\14\0\1\u010b\54\0\1\u010c"+
- "\47\0\2\u010d\72\0\1\u010e\30\0\1\u010e\3\0\2\153"+
- "\1\0\31\153\1\u010f\32\153\2\162\1\0\31\162\1\u0110"+
- "\32\162\35\0\1\u0111\37\0\3\57\4\0\1\57\5\0"+
- "\6\57\1\0\13\57\1\0\6\57\1\u0112\1\0\3\57"+
- "\1\0\5\57\5\0\1\u0113\3\57\3\0\1\u0113\1\57"+
- "\4\0\1\u0113\6\57\1\0\13\57\1\0\7\57\1\0"+
- "\3\57\1\0\5\57\37\0\1\u0114\10\0\1\u0114\53\0"+
- "\1\u0115\13\0\1\u0115\52\0\1\u0116\13\0\1\u0116\15\0"+
- "\2\153\1\0\32\153\1\u0117\31\153\2\162\1\0\32\162"+
- "\1\u0118\31\162\34\0\1\u0119\40\0\3\57\4\0\1\57"+
- "\5\0\5\57\1\u011a\1\0\13\57\1\0\7\57\1\0"+
- "\3\57\1\0\5\57\5\0\1\u0113\6\0\1\u0113\5\0"+
- "\1\u0113\44\0\2\153\1\0\31\153\1\u011b\32\153\2\162"+
- "\1\0\31\162\1\u011c\32\162\31\0\1\u011d\43\0\3\57"+
- "\4\0\1\57\5\0\6\57\1\0\5\57\1\u011e\5\57"+
- "\1\0\7\57\1\0\3\57\1\0\5\57\2\153\1\0"+
- "\26\153\1\u011f\35\153\2\162\1\0\26\162\1\u0120\35\162"+
- "\6\0\3\57\4\0\1\57\5\0\6\57\1\0\7\57"+
- "\1\u0121\3\57\1\0\7\57\1\0\3\57\1\0\5\57"+
- "\6\0\3\57\4\0\1\57\5\0\6\57\1\0\13\57"+
- "\1\0\7\57\1\0\3\57\1\0\4\57\1\u0122\6\0"+
- "\3\57\4\0\1\57\5\0\6\57\1\0\5\57\1\u0123"+
- "\5\57\1\0\7\57\1\0\3\57\1\0\5\57\6\0"+
- "\3\57\4\0\1\57\5\0\6\57\1\0\5\57\1\u0124"+
- "\5\57\1\0\7\57\1\0\3\57\1\0\5\57\6\0"+
- "\3\57\4\0\1\57\5\0\6\57\1\0\13\57\1\0"+
- "\3\57\1\u0125\3\57\1\0\3\57\1\0\5\57";
-
- /**
- * The transition table of the DFA
- */
- final private static int yytrans [] = yy_unpack(yy_packed);
-
-
- /* error codes */
- final private static int YY_UNKNOWN_ERROR = 0;
- // final private static int YY_ILLEGAL_STATE = 1;
- final private static int YY_NO_MATCH = 2;
- final private static int YY_PUSHBACK_2BIG = 3;
-
- /* error messages for the codes above */
- final private static String YY_ERROR_MSG[] = {
- "Unkown internal scanner error", //$NON-NLS-1$
- "Internal error: unknown state", //$NON-NLS-1$
- "Error: could not match input", //$NON-NLS-1$
- "Error: pushback value was too large" //$NON-NLS-1$
- };
-
- /**
- * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
- */
- private final static byte YY_ATTRIBUTE[] = {
- 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
- 1, 1, 1, 9, 1, 9, 1, 1, 9, 9, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 9, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9,
- 1, 1, 9, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 9, 1,
- 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1,
- 1, 1, 1, 9, 9, 1, 9, 9, 1, 0, 1, 0, 1, 1, 0, 0,
- 0, 9, 1, 1, 1, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0,
- 0, 0, 9, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0,
- 0, 9, 0, 0, 0, 0, 0, 9, 1, 0, 0, 1, 1, 0, 0, 1,
- 0, 0, 0, 9, 0, 0, 0, 1, 0, 0, 0, 9, 1, 0, 0, 1,
- 1, 0, 1, 0, 0, 0, 9, 1, 0, 0, 1, 1, 0, 1, 0, 0,
- 1, 1, 9, 0, 0, 9, 9, 9, 1, 1, 1, 0, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 9, 0, 1, 9, 0,
- 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0,
- 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 9, 9, 1, 1,
- 0, 1, 1, 9, 9, 9, 1, 1, 0, 1, 1, 1, 9, 1, 1, 1,
- 1, 1, 1, 1, 1
- };
-
- /** the input device */
- private java.io.Reader yy_reader;
-
- /** the current state of the DFA */
- private int yy_state;
-
- /** the current lexical state */
- private int yy_lexical_state = YYINITIAL;
-
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char yy_buffer[] = new char[16384];
-
- /** the textposition at the last accepting state */
- private int yy_markedPos;
-
- /** the textposition at the last state to be included in yytext */
- //private int yy_pushbackPos;
-
- /** the current text position in the buffer */
- private int yy_currentPos;
-
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int yy_startRead;
-
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int yy_endRead;
-
- /** number of newlines encountered up to the start of the matched text */
- // private int yyline;
-
- /** the number of characters up to the start of the matched text */
- private int yychar;
-
- /**
- * the number of characters from the last newline up to the start of the
- * matched text
- */
- // private int yycolumn;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning of a line
- */
- // private boolean yy_atBOL;
-
- /** yy_atEOF == true <=> the scanner has returned a value for EOF */
- private boolean yy_atEOF;
-
- /** denotes if the user-EOF-code has already been executed */
- private boolean yy_eof_done;
-
- /* user code: */
- private int fTokenCount = 0;
-
- // required holders for white-space compacting
- private boolean fShouldLoadBuffered = false;
- private String fBufferedContext = null;
- private int fBufferedStart = 1;
- private int fBufferedLength = 0;
- private String f_context = null;
-
- // state stack for handling embedded regions
- private IntStack fStateStack = new IntStack();
-
- private String context = null;
- private int start = 0;
- private int textLength = 0;
- private int length = 0;
-
- // offset for tracking position specific block tags
- private int fOffset = 0;
-
- // the name of the current tag being opened
- private String fCurrentTagName = null;
-
- // the list of tag name BlockMarkers
- private List fBlockMarkers = new ArrayList();
-
- // required to not seek text blocks on an end tag
- private boolean fIsBlockingEnabled = false;
- private boolean fIsCaseSensitiveBlocking = true;
-
- private XMLParserRegionFactory fRegionFactory = new XMLParserRegionFactory();
-/**
- * user method
- */
-public final void addBlockMarker(BlockMarker marker) {
- if(containsTagName(marker.getTagName()))
- return;
- fBlockMarkers.add(marker);
-}
-/**
- * user method
- */
-public final void removeBlockMarker(BlockMarker marker) {
- fBlockMarkers.remove(marker);
-}
-/**
- * user method
- */
-public final void removeBlockMarker(String tagname) {
- if (fBlockMarkers != null) {
- Iterator blocks = fBlockMarkers.iterator();
- while (blocks.hasNext()) {
- if (((BlockMarker) blocks.next()).getTagName().equals(tagname))
- blocks.remove();
- }
- }
-}
-/* user method */
-public final boolean isCaseSensitiveBlocking() {
- return fIsCaseSensitiveBlocking;
-}
-/* user method */
-public final void setCaseSensitiveBlocking(boolean newValue) {
- fIsCaseSensitiveBlocking = newValue;
-}
-/* user method */
-public boolean getBlockMarkerCaseSensitivity() {
- return getBlockMarkerCaseSensitivity(fCurrentTagName);
-}
-/* user method */
-public boolean getBlockMarkerCaseSensitivity(String name) {
- Iterator iterator = fBlockMarkers.iterator();
- while(iterator.hasNext()) {
- BlockMarker marker = (BlockMarker)iterator.next();
- boolean casesensitive = marker.isCaseSensitive();
- if(casesensitive && marker.getTagName().equals(name))
- return casesensitive;
- else if(!casesensitive && marker.getTagName().equalsIgnoreCase(name))
- return casesensitive;
- }
- return true;
-}
-/* user method */
-public String getBlockMarkerContext() {
- return getBlockMarkerContext(fCurrentTagName);
-}
-/* user method */
-public String getBlockMarkerContext(String name) {
- Iterator iterator = fBlockMarkers.iterator();
- while(iterator.hasNext()) {
- BlockMarker marker = (BlockMarker)iterator.next();
- if(marker.getTagName().equals(name))
- return marker.getContext();
- }
- return BLOCK_TEXT;
-}
-/* user method */
-public List getBlockMarkers() {
- return fBlockMarkers;
-}
-/* user method */
-public final int getOffset() {
- return fOffset + yychar;
-}
-private final boolean isBlockMarker() {
- return isBlockMarker(fCurrentTagName);
-}
-private final boolean isBlockMarker(String tagName) {
- if (!fIsBlockingEnabled)
- return false;
- return containsTagName(tagName);
-}
-/**
- * user method
- */
-public final void beginBlockTagScan(String newTagName) {
- beginBlockMarkerScan(newTagName, BLOCK_TEXT);
-}
-/**
- * user method
- *
- * Special tokenizer setup. Allows tokenization to be initiated at the
- * start of a text block within a "newTagName" tag.
- *
- * Example:
- * Tokenizer toker = new Tokenizer();
- * toker.setCaseSensitiveBlocking(false);
- * toker.reset(new java.io.StringReader("afiuhqwkejhtasihgalkwhtq</scripter></scr></script>asgdasga"));
- * toker.beginBlockMarkerScan("script", BLOCK_TEXT);
- * toker.getRegions();
- *
- * Returns:
- * BLOCK_TEXT: 0-40
- * XML_END_TAG_OPEN: 41-42
- * XML_TAG_NAME: 43-48
- * XML_TAG_CLOSE: 49-49
- * XML_CONTENT: 50-57
- *
- */
-public final void beginBlockMarkerScan(String newTagName, String blockcontext) {
- yybegin(ST_BLOCK_TAG_SCAN);
- fCurrentTagName = newTagName;
-}
-/**
- * Method doScan.
- *
- * Returns a context region for all of the text from the current position upto the end of input or
- * to right *before* the first occurence of searchString
- *
- * @param searchString - target string to search for ex.: "-->", "</tagname"
- * @param requireTailSeparator - whether the target must be immediately followed by whitespace or '>'
- * @param context - the context of the scanned region if non-zero length
- * @param exitState - the state to go to if the region was of non-zero length
- * @param abortState - the state to go to if the searchString was found immediately
- * @return String - the context found: the desired context on a non-zero length match, the abortContext on immediate success
- * @throws IOException
- */
-private final String doScan(String searchString, boolean requireTailSeparator, String searchContext, int exitState, int immediateFallbackState) throws IOException {
- boolean stillSearching = true;
- // Disable further block (probably)
- fIsBlockingEnabled = false;
- int searchStringLength = searchString.length();
- int n = 0;
- char lastCheckChar;
- int i;
- boolean same = false;
- while (stillSearching) {
- n = 0;
- // Ensure that enough data from the input exists to compare against the search String.
- n = yy_advance();
- while(n != YYEOF && yy_currentPos < searchStringLength)
- n = yy_advance();
- // If the input was too short or we've exhausted the input, stop immediately.
- if (n == YYEOF) {
- stillSearching = false;
- }
- else {
- same = true;
- // Ensure that we've not encountered a complete block (<%%>) that was *shorter* than the closeTagString and
- // thus found twice at current-targetLength [since the first scan would have come out this far anyway].
- // Check the characters in the target versus the last targetLength characters read from the buffer
- // and see if it matches
-
- // safety check for array accesses (yy_currentPos is the *last* character we can check against)
- if(yy_currentPos >= searchStringLength && yy_currentPos <= yy_buffer.length) {
- for(i = 0; i < searchStringLength; i++) {
- if(same && fIsCaseSensitiveBlocking)
- same = yy_buffer[i + yy_currentPos - searchStringLength] == searchString.charAt(i);
- else if(same && !fIsCaseSensitiveBlocking)
- same = Character.toLowerCase(yy_buffer[i + yy_currentPos - searchStringLength]) == Character.toLowerCase(searchString.charAt(i));
- }
- }
- // safety check failed; no match is possible right now
- else {
- same = false;
- }
- if (same && requireTailSeparator && yy_currentPos < yy_buffer.length) {
- // Additional check for close tags to ensure that targetString="</script" doesn't match
- // "</scriptS"
- lastCheckChar = yy_buffer[yy_currentPos];
- // Succeed on "</script>" and "</script "
- if(lastCheckChar == '>' || Character.isWhitespace(lastCheckChar))
- stillSearching = false;
- }
- else {
- stillSearching = !same || (yy_currentPos < yy_startRead + searchStringLength);
- }
- }
- }
- if (n != YYEOF || same) {
- // We've stopped short of the end or definitely found a match
- yy_markedPos = yy_currentPos - searchStringLength;
- yy_currentPos = yy_markedPos + 1;
- // If the searchString occurs at the very beginning of what would have
- // been a Block, resume scanning normally immediately
- if (yy_markedPos == yy_startRead) {
- yybegin(immediateFallbackState);
- return primGetNextToken();
- }
- }
- else {
- // We ran through the rest of the input
- yy_markedPos = yy_currentPos;
- yy_currentPos++;
- }
- yybegin(exitState);
- // If the ending occurs at the very beginning of what would have
- // been a Block, resume scanning normally immediately
- if(yy_markedPos == yy_startRead)
- return primGetNextToken();
- return searchContext;
-}
-/**
- * user method
- *
- * A generic lookahead-like operation
- */
-private final String doBlockScan(String target, String targetContext, int immediateFallbackState) throws IOException {
- return doScan(target, false, targetContext, immediateFallbackState, immediateFallbackState);
-}
-/**
- * user method
- * does a lookahead for the current tag name
- */
-private final String doBlockTagScan() throws IOException {
- fIsCaseSensitiveBlocking = getBlockMarkerCaseSensitivity();
- return doScan("</" + fCurrentTagName, true, getBlockMarkerContext(fCurrentTagName), YYINITIAL, YYINITIAL);
-}
-/**
- * user method
- *
- * Converts the raw context String returned by the primGetNextToken()
- * method into a full ITextRegion by pulling in values for the
- * current offset within the scanning text.
- *
- * Returns null when EOF is encountered and attaches intermittently
- * discovered whitespace onto the end of useful regions.
- *
- * Note that this algorithm caches the token following the one being returned
- * so that whitespace can be collapsed.
- */
-public final ITextRegion getNextToken() throws IOException {
- // load the starting non-whitespace token (assume that it is so)
- if (fShouldLoadBuffered) {
- context = fBufferedContext;
- start = fBufferedStart;
- textLength = length = fBufferedLength;
- fShouldLoadBuffered = false;
- }
- else {
- context = primGetNextToken();
- if (context == XML_TAG_NAME) {
- if(containsTagName(yy_buffer, yy_startRead, yy_markedPos-yy_startRead))
- fCurrentTagName = yytext();
- else
- fCurrentTagName = null;
- }
- else if (context == XML_TAG_OPEN) {
- fIsBlockingEnabled = true;
- }
- else if (context == XML_END_TAG_OPEN) {
- fIsBlockingEnabled = false;
- }
- start = yychar;
- textLength = length = yylength();
- if (yy_atEOF) {
- fTokenCount++;
- return null;
- }
- }
- // store the next token
- f_context = primGetNextToken();
- if (f_context == XML_TAG_NAME) {
- if(containsTagName(yy_buffer, yy_startRead, yy_markedPos-yy_startRead))
- fCurrentTagName = yytext();
- else
- fCurrentTagName = null;
- }
- else if (f_context == XML_TAG_OPEN) {
- fIsBlockingEnabled = true;
- }
- else if (f_context == XML_END_TAG_OPEN) {
- fIsBlockingEnabled = false;
- }
- fBufferedContext = f_context;
- fBufferedStart = yychar;
- fBufferedLength = yylength();
- fShouldLoadBuffered = true;
- if (fBufferedContext == WHITE_SPACE) {
- fShouldLoadBuffered = false;
- length += fBufferedLength;
- }
- if (context == null) {
- // EOF
- if (Debug.debugTokenizer) {
- System.out.println(getClass().getName() + " discovered " + fTokenCount + " tokens."); //$NON-NLS-2$//$NON-NLS-1$
- }
- return null;
- }
- fTokenCount++;
- return fRegionFactory.createToken(context, start, textLength, length, null, fCurrentTagName);
-}
-/* user method */
-public XMLTokenizer(){
- super();
-}
-/* user method */
-public XMLTokenizer(char[] charArray){
- this(new CharArrayReader(charArray));
-}
-/* user method */
-public void reset(char[] charArray) {
- reset(new CharArrayReader(charArray), 0);
-}
-/* user method */
-public void reset(char[] charArray, int newOffset) {
- reset(new CharArrayReader(charArray), newOffset);
-}
-/* user method */
-public void reset(java.io.InputStream in) {
- reset(new java.io.InputStreamReader(in), 0);
-}
-/* user method */
-public void reset(java.io.InputStream in, int newOffset) {
- reset(new java.io.InputStreamReader(in), newOffset);
-}
-/* user method */
-public void reset(java.io.Reader in) {
- reset(in, 0);
-}
-/**
- * user method *
- *
- * Reset internal counters and vars to "newly created" values, in the hopes
- * that resetting a pre-existing tokenizer is faster than creating a new one.
- *
- * This method contains code blocks that were essentially duplicated from the
- * <em>generated</em> output of this specification before this method was
- * added. Those code blocks were under the above copyright.
- */
-public void reset(java.io.Reader in, int newOffset) {
- if (Debug.debugTokenizer) {
- System.out.println("resetting tokenizer");//$NON-NLS-1$
- }
- fOffset = newOffset;
-
- /* the input device */
- yy_reader = in;
-
- /* the current state of the DFA */
- yy_state = 0;
-
- /* the current lexical state */
- yy_lexical_state = YYINITIAL;
-
- /* this buffer contains the current text to be matched and is
- the source of the yytext() string */
- java.util.Arrays.fill(yy_buffer, (char)0);
-
- /* the textposition at the last accepting state */
- yy_markedPos = 0;
-
- /* the textposition at the last state to be included in yytext */
- //yy_pushbackPos = 0;
-
- /* the current text position in the buffer */
- yy_currentPos = 0;
-
- /* startRead marks the beginning of the yytext() string in the buffer */
- yy_startRead = 0;
-
- /**
- * endRead marks the last character in the buffer, that has been read
- * from input
- */
- yy_endRead = 0;
-
- /* number of newlines encountered up to the start of the matched text */
- //yyline = 0;
-
- /* the number of characters up to the start of the matched text */
- yychar = 0;
-
- /* yy_atEOF == true <=> the scanner has returned a value for EOF */
- yy_atEOF = false;
-
- /* denotes if the user-EOF-code has already been executed */
- yy_eof_done = false;
-
-
- /* user vars: */
- fTokenCount = 0;
-
- fShouldLoadBuffered = false;
- fBufferedContext = null;
- fBufferedStart = 1;
- fBufferedLength = 0;
- fStateStack = new IntStack();
-
- context = null;
- start = 0;
- textLength = 0;
- length = 0;
-}
-
- /**
- * user method
- *
- */
- public BlockTokenizer newInstance() {
- XMLTokenizer newInstance = new XMLTokenizer();
- // global tagmarkers can be shared; they have no state and
- // are never destroyed (e.g. 'release')
- for(int i = 0; i < fBlockMarkers.size(); i++) {
- BlockMarker blockMarker = (BlockMarker) fBlockMarkers.get(i);
- if(blockMarker.isGlobal())
- newInstance.addBlockMarker(blockMarker);
- }
- return newInstance;
- }
-/* user method */
-private final String scanXMLCommentText() throws IOException {
- // Scan for '-->' and return the text up to that point as
- // XML_COMMENT_TEXT unless the string occurs IMMEDIATELY, in which
- // case change to the ST_XML_COMMENT_END state and return the next
- // context as usual.
- return doScan("-->", false, XML_COMMENT_TEXT, ST_XML_COMMENT_END, ST_XML_COMMENT_END);
-}
-
-
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- public XMLTokenizer(java.io.Reader in) {
- this.yy_reader = in;
- }
-
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- public XMLTokenizer(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
-
- /**
- * Unpacks the compressed DFA transition table.
- *
- * @param packed the packed transition table
- * @return the unpacked transition table
- */
- private static int [] yy_unpack(String packed) {
- int [] trans = new int[11110];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 3646) {
- int count = packed.charAt(i++);
- int value = packed.charAt(i++);
- value--;
- do trans[j++] = value; while (--count > 0);
- }
- return trans;
- }
-
- /**
- * Unpacks the compressed character translation table.
- *
- * @param packed the packed character translation table
- * @return the unpacked character translation table
- */
- private static char [] yy_unpack_cmap(String packed) {
- char [] map = new char[0x10000];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 1372) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do map[j++] = value; while (--count > 0);
- }
- return map;
- }
-
-
- /**
- * Gets the next input character.
- *
- * @return the next character of the input stream, EOF if the
- * end of the stream is reached.
- * @exception IOException if any I/O-Error occurs
- */
- private int yy_advance() throws java.io.IOException {
-
- /* standard case */
- if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++];
-
- /* if the eof is reached, we don't need to work hard */
- if (yy_atEOF) return YYEOF;
-
- /* otherwise: need to refill the buffer */
-
- /* first: make room (if you can) */
- if (yy_startRead > 0) {
- System.arraycopy(yy_buffer, yy_startRead,
- yy_buffer, 0,
- yy_endRead-yy_startRead);
-
- /* translate stored positions */
- yy_endRead-= yy_startRead;
- yy_currentPos-= yy_startRead;
- yy_markedPos-= yy_startRead;
- //yy_pushbackPos-= yy_startRead;
- yy_startRead = 0;
- }
-
- /* is the buffer big enough? */
- if (yy_currentPos >= yy_buffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[yy_currentPos*2];
- System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
- yy_buffer = newBuffer;
- }
-
- /* finally: fill the buffer with new input */
- int numRead = yy_reader.read(yy_buffer, yy_endRead,
- yy_buffer.length-yy_endRead);
-
- if ( numRead == -1 ) return YYEOF;
-
- yy_endRead+= numRead;
-
- return yy_buffer[yy_currentPos++];
- }
-
-
- /**
- * Closes the input stream.
- */
- final public void yyclose() throws java.io.IOException {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yy_reader.close();
- }
-
-
- /**
- * Returns the current lexical state.
- */
- final public int yystate() {
- return yy_lexical_state;
- }
-
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
- final public void yybegin(int newState) {
- yy_lexical_state = newState;
- }
-
-
- /**
- * Returns the text matched by the current regular expression.
- */
- final public String yytext() {
- return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead );
- }
-
- /**
- * Returns the length of the matched text region.
- */
- final public int yylength() {
- return yy_markedPos-yy_startRead;
- }
-
-
- /**
- * Reports an error that occured while scanning - from the SED JFlex skeleton
- *
- * @param errorCode the code of the errormessage to display
- */
- private void yy_ScanError(int errorCode) {
- try {
- Logger.log(Logger.ERROR, YY_ERROR_MSG[errorCode]);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- Logger.log(Logger.ERROR, YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
- }
- // DO NOT EXIT the VM on an error
- // System.exit(1);
- }
-
-
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
- void yypushback(int number) {
- if ( number > yylength() )
- yy_ScanError(YY_PUSHBACK_2BIG);
-
- yy_markedPos -= number;
- }
-
- /**
- * user method - skeleton.sed
- */
- protected final boolean containsTagName(char[] markerTagName, int offset, int tagnameLength) {
- for(int j = 0; j < fBlockMarkers.size(); j++) {
- BlockMarker marker = (BlockMarker)fBlockMarkers.get(j);
- if(marker.getTagName().length() == tagnameLength) {
- boolean matchesSoFar = true;
- for(int i = 0; i < tagnameLength && matchesSoFar; i++) {
- if(marker.isCaseSensitive()) {
- if(marker.getTagName().charAt(i) != markerTagName[i + offset])
- matchesSoFar = false;
- }
- else {
- if(Character.toLowerCase(marker.getTagName().charAt(i)) != Character.toLowerCase(markerTagName[i + offset]))
- matchesSoFar = false;
- }
- }
- if(matchesSoFar)
- return true;
- }
- }
- return false;
- }
-
- /**
- * user method - skeleton.sed
- *
- * Return ALL of the regions scannable within the remaining text
- * Note: for verification use
- */
- public final List getRegions() {
- List tokens = new ArrayList();
- ITextRegion region = null;
- try {
- region = getNextToken();
- while(region != null) {
- if (region != null) {
- tokens.add(region);
- }
- region = getNextToken();
- }
- }
- catch (StackOverflowError e) {
- Logger.logException(getClass().getName()+": input could not be tokenized correctly at position " + getOffset(), e);//$NON-NLS-1$
- throw e;
- }
- catch (Exception e) {
- // Since this is convenience method and NOT the recommended
- // way of getting tokens, many errors are simply hidden
- Logger.logException("Exception not handled retrieving regions: " + e.getLocalizedMessage(), e);//$NON-NLS-1$
- }
- return tokens;
- }
- /**
- * user method - skeleton.sed
- */
- private final void dump(String s) {
- if (Debug.debugTokenizer) {
- System.out.println(s + " (" + yychar + "-" + //$NON-NLS-2$//$NON-NLS-1$
- (yylength() + yychar) + "):\'" +//$NON-NLS-1$
- StringUtils.escape(yytext()) + "\'");//$NON-NLS-1$
- }
- }
- /* user method - skeleton.sed */
- public final boolean isEOF() {
- return yy_atEOF;
- }
-/* user method - skeleton.sed */
-protected final boolean containsTagName(String markerTagName) {
- Iterator blocks = fBlockMarkers.iterator();
- while(blocks.hasNext()) {
- BlockMarker marker = (BlockMarker)blocks.next();
- if(marker.isCaseSensitive()) {
- if(marker.getTagName().equals(markerTagName))
- return true;
- }
- else {
- if(marker.getTagName().equalsIgnoreCase(markerTagName))
- return true;
- }
- }
- return false;
-}
-
- /**
- * Contains user EOF-code, which will be executed exactly once,
- * when the end of file is reached
- */
- private void yy_do_eof() {
- if (!yy_eof_done) {
- yy_eof_done = true;
- // do nothing, this is the downstream parser's job
-
- }
- }
-
-
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception IOException if any I/O-Error occurs
- */
- public String primGetNextToken() throws java.io.IOException {
- int yy_input;
- int yy_action;
-
-
- while (true) {
-
- yychar+= yylength();
-
- yy_action = -1;
-
- yy_currentPos = yy_startRead = yy_markedPos;
-
- yy_state = yy_lexical_state;
-
-
- yy_forAction: {
- while (true) {
-
- yy_input = yy_advance();
-
- if ( yy_input == YYEOF ) break yy_forAction;
-
- int yy_next = yytrans[ yy_rowMap[yy_state] + yycmap[yy_input] ];
- if (yy_next == -1) break yy_forAction;
- yy_state = yy_next;
-
- int yy_attributes = YY_ATTRIBUTE[yy_state];
- if ( (yy_attributes & 1) > 0 ) {
- yy_action = yy_state;
- yy_markedPos = yy_currentPos;
- if ( (yy_attributes & 8) > 0 ) break yy_forAction;
- }
-
- }
- }
-
-
- switch (yy_action) {
-
- case 292:
- {
- if(Debug.debugTokenizer)
- dump("XSL processing instruction target");//$NON-NLS-1$
- yybegin(ST_XML_PI_ATTRIBUTE_NAME);
- return XML_TAG_NAME;
- }
- case 294: break;
- case 284:
- case 286:
- case 287:
- {
- if(Debug.debugTokenizer)
- dump("\nCDATA start");//$NON-NLS-1$
- fStateStack.push(yystate());
- yybegin(ST_CDATA_TEXT);
- return XML_CDATA_OPEN;
- }
- case 295: break;
- case 277:
- {
- if(Debug.debugTokenizer)
- dump("element");//$NON-NLS-1$
- yybegin(ST_XML_ELEMENT_DECLARATION);
- return XML_ELEMENT_DECLARATION;
- }
- case 296: break;
- case 276:
- {
- if(Debug.debugTokenizer)
- dump("attlist");//$NON-NLS-1$
- yybegin(ST_XML_ATTLIST_DECLARATION);
- return XML_ATTLIST_DECLARATION;
- }
- case 297: break;
- case 275:
- {
- if(Debug.debugTokenizer)
- dump("doctype");//$NON-NLS-1$
- yybegin(ST_XML_DOCTYPE_DECLARATION);
- return XML_DOCTYPE_DECLARATION;
- }
- case 298: break;
- case 269:
- {
- if(Debug.debugTokenizer)
- dump("doctype external id");//$NON-NLS-1$
- yybegin(ST_XML_DOCTYPE_ID_PUBLIC);
- return XML_DOCTYPE_EXTERNAL_ID_PUBLIC;
- }
- case 299: break;
- case 268:
- {
- if(Debug.debugTokenizer)
- dump("doctype external id");//$NON-NLS-1$
- yybegin(ST_XML_DOCTYPE_ID_SYSTEM);
- return XML_DOCTYPE_EXTERNAL_ID_SYSTEM;
- }
- case 300: break;
- case 264:
- case 274:
- {
- if(Debug.debugTokenizer)
- dump("DHTML processing instruction target");//$NON-NLS-1$
- yybegin(ST_DHTML_ATTRIBUTE_NAME);
- return XML_TAG_NAME;
- }
- case 301: break;
- case 238:
- {
- if(Debug.debugTokenizer)
- dump("\nCharRef");//$NON-NLS-1$
- return XML_CHAR_REFERENCE;
- }
- case 302: break;
- case 235:
- {
- if(Debug.debugTokenizer)
- dump("\ncomment start");//$NON-NLS-1$
- yybegin(ST_XML_COMMENT);
- return XML_COMMENT_OPEN;
- }
- case 303: break;
- case 216:
- case 217:
- {
- if(Debug.debugTokenizer)
- dump("XML processing instruction target");//$NON-NLS-1$
- yybegin(ST_XML_PI_ATTRIBUTE_NAME);
- return XML_TAG_NAME;
- }
- case 304: break;
- case 215:
- {
- if(Debug.debugTokenizer)
- dump("comment end");//$NON-NLS-1$
- yybegin(YYINITIAL);
- return XML_COMMENT_CLOSE;
- }
- case 305: break;
- case 214:
- {
- if(Debug.debugTokenizer)
- dump("CDATA end");//$NON-NLS-1$
- yybegin(fStateStack.pop());
- return XML_CDATA_CLOSE;
- }
- case 306: break;
- case 213:
- {
- if(Debug.debugTokenizer)
- dump("\nPEReference");//$NON-NLS-1$
- return XML_PE_REFERENCE;
- }
- case 307: break;
- case 210:
- {
- if(Debug.debugTokenizer)
- dump("\nEntityRef");//$NON-NLS-1$
- return XML_ENTITY_REFERENCE;
- }
- case 308: break;
- case 161:
- case 175:
- case 183:
- {
- return XML_DOCTYPE_INTERNAL_SUBSET;
- }
- case 309: break;
- case 149:
- {
- yybegin(YYINITIAL);
- if(Debug.debugTokenizer)
- dump("empty tag close");//$NON-NLS-1$
- return XML_EMPTY_TAG_CLOSE;
- }
- case 310: break;
- case 134:
- {
- if(Debug.debugTokenizer)
- dump("XML processing instruction end");//$NON-NLS-1$
- yybegin(YYINITIAL);
- return XML_PI_CLOSE;
- }
- case 311: break;
- case 133:
- {
- // ended with nothing inside
- yybegin(YYINITIAL);
- return XML_PI_CLOSE;
- }
- case 312: break;
- case 129:
- {
- if(Debug.debugTokenizer)
- dump("processing instruction end");//$NON-NLS-1$
- yybegin(YYINITIAL);
- return XML_PI_CLOSE;
- }
- case 313: break;
- case 120:
- {
- fStateStack.push(yystate());
- if(Debug.debugTokenizer)
- dump("\ndeclaration start");//$NON-NLS-1$
- yybegin(ST_XML_DECLARATION);
- return XML_DECLARATION_OPEN;
- }
- case 314: break;
- case 119:
- {
- if(Debug.debugTokenizer)
- dump("\nprocessing instruction start");//$NON-NLS-1$
- yybegin(ST_PI);
- return XML_PI_OPEN;
- }
- case 315: break;
- case 118:
- {
- if(Debug.debugTokenizer)
- dump("\nend tag open");//$NON-NLS-1$
- yybegin(ST_XML_TAG_NAME);
- return XML_END_TAG_OPEN;
- }
- case 316: break;
- case 57:
- case 59:
- case 60:
- case 61:
- case 138:
- {
- if(Debug.debugTokenizer)
- dump("XML processing instruction attribute value");//$NON-NLS-1$
- yybegin(ST_XML_PI_ATTRIBUTE_NAME);
- return XML_TAG_ATTRIBUTE_VALUE;
- }
- case 317: break;
- case 56:
- {
- if(Debug.debugTokenizer)
- dump("XML processing instruction '='");//$NON-NLS-1$
- yybegin(ST_XML_PI_ATTRIBUTE_VALUE);
- return XML_TAG_ATTRIBUTE_EQUALS;
- }
- case 318: break;
- case 55:
- {
- if(Debug.debugTokenizer)
- dump("XML processing instruction attribute name");//$NON-NLS-1$
- yybegin(ST_XML_PI_EQUALS);
- return XML_TAG_ATTRIBUTE_NAME;
- }
- case 319: break;
- case 51:
- case 52:
- case 53:
- {
- // block scan until close is found
- return doScan("?>", false, XML_PI_CONTENT, ST_XML_PI_TAG_CLOSE, ST_XML_PI_TAG_CLOSE);
- }
- case 320: break;
- case 50:
- {
- yybegin(ST_PI_CONTENT);
- return WHITE_SPACE;
- }
- case 321: break;
- case 46:
- case 47:
- case 48:
- case 49:
- case 130:
- case 131:
- case 132:
- case 218:
- case 240:
- case 241:
- case 253:
- case 254:
- case 263:
- case 273:
- case 281:
- case 285:
- case 288:
- case 289:
- case 290:
- case 291:
- {
- if(Debug.debugTokenizer)
- dump("processing instruction target");//$NON-NLS-1$
- yybegin(ST_PI_WS);
- return XML_TAG_NAME;
- }
- case 322: break;
- case 41:
- case 42:
- {
- if(Debug.debugTokenizer)
- dump("comment content");//$NON-NLS-1$
- return scanXMLCommentText();
- }
- case 323: break;
- case 40:
- {
- if(Debug.debugTokenizer)
- dump("LINE FEED");//$NON-NLS-1$
- return WHITE_SPACE;
- }
- case 324: break;
- case 35:
- case 36:
- {
- if(Debug.debugTokenizer)
- dump("CDATA text");//$NON-NLS-1$
- String blockContext = doBlockScan("]]>", XML_CDATA_TEXT, ST_CDATA_END);//$NON-NLS-1$
- if(blockContext == XML_CDATA_TEXT)
- yybegin(ST_CDATA_END);
- return blockContext;
- }
- case 325: break;
- case 0:
- case 31:
- case 122:
- case 124:
- case 208:
- case 209:
- case 237:
- {
- if(Debug.debugTokenizer)
- dump("\nXML content");//$NON-NLS-1$
- return XML_CONTENT;
- }
- case 326: break;
- case 5:
- case 8:
- case 9:
- case 10:
- case 12:
- case 13:
- case 14:
- case 15:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 28:
- case 45:
- {
- if(Debug.debugTokenizer)
- dump("white space");//$NON-NLS-1$
- return WHITE_SPACE;
- }
- case 327: break;
- case 16:
- case 71:
- {
- if(Debug.debugTokenizer)
- dump("inappropriate tag name");//$NON-NLS-1$
- yybegin(YYINITIAL);
- return XML_CONTENT;
- }
- case 328: break;
- case 27:
- case 106:
- case 107:
- case 194:
- case 230:
- case 249:
- case 260:
- case 270:
- case 278:
- case 282:
- {
- if(Debug.debugTokenizer)
- dump("elementdecl contentspec");//$NON-NLS-1$
- return XML_ELEMENT_DECL_CONTENT;
- }
- case 329: break;
- case 29:
- case 113:
- case 114:
- case 205:
- case 234:
- case 251:
- case 261:
- case 271:
- case 279:
- case 283:
- {
- if(Debug.debugTokenizer)
- dump("attlist contentspec");//$NON-NLS-1$
- return XML_ATTLIST_DECL_CONTENT;
- }
- case 330: break;
- case 32:
- case 72:
- case 83:
- {
- if(Debug.debugTokenizer)
- dump("\nstart tag open");//$NON-NLS-1$
- yybegin(ST_XML_TAG_NAME);
- return XML_TAG_OPEN;
- }
- case 331: break;
- case 33:
- case 37:
- case 38:
- case 39:
- case 43:
- case 44:
- case 54:
- case 58:
- case 62:
- case 64:
- case 68:
- case 74:
- case 80:
- case 85:
- case 86:
- case 87:
- case 88:
- case 90:
- case 91:
- case 93:
- case 98:
- case 103:
- case 110:
- {
- if (Debug.debugTokenizer)
- System.out.println("!!!unexpected!!!: \"" + yytext() + "\":" + //$NON-NLS-2$//$NON-NLS-1$
- yychar + "-" + (yychar + yylength()));//$NON-NLS-1$
- return UNDEFINED;
- }
- case 332: break;
- case 34:
- case 125:
- {
- if(Debug.debugTokenizer)
- dump("non-reference %");//$NON-NLS-1$
- return XML_CONTENT;
- }
- case 333: break;
- case 63:
- {
- if(Debug.debugTokenizer)
- dump("DHTML processing instruction end");//$NON-NLS-1$
- yybegin(YYINITIAL);
- return XML_PI_CLOSE;
- }
- case 334: break;
- case 65:
- {
- if(Debug.debugTokenizer)
- dump("DHTML processing instruction attribute name");//$NON-NLS-1$
- yybegin(ST_DHTML_EQUALS);
- return XML_TAG_ATTRIBUTE_NAME;
- }
- case 335: break;
- case 66:
- {
- if(Debug.debugTokenizer)
- dump("DHTML processing instruction '='");//$NON-NLS-1$
- yybegin(ST_DHTML_ATTRIBUTE_VALUE);
- return XML_TAG_ATTRIBUTE_EQUALS;
- }
- case 336: break;
- case 67:
- case 69:
- case 70:
- case 146:
- {
- if(Debug.debugTokenizer)
- dump("DHTML processing instruction attribute value");//$NON-NLS-1$
- yybegin(ST_DHTML_ATTRIBUTE_NAME);
- return XML_TAG_ATTRIBUTE_VALUE;
- }
- case 337: break;
- case 73:
- {
- if(Debug.debugTokenizer)
- dump("tag close");//$NON-NLS-1$
- if(isBlockMarker()) {
- yybegin(ST_BLOCK_TAG_SCAN);
- }
- else
- yybegin(YYINITIAL);
- return XML_TAG_CLOSE;
- }
- case 338: break;
- case 75:
- case 76:
- {
- if(Debug.debugTokenizer)
- dump("tag name");//$NON-NLS-1$
- yybegin(ST_XML_ATTRIBUTE_NAME);
- return XML_TAG_NAME;
- }
- case 339: break;
- case 77:
- {
- if(Debug.debugTokenizer)
- dump("attr name");//$NON-NLS-1$
- yybegin(ST_XML_EQUALS);
- return XML_TAG_ATTRIBUTE_NAME;
- }
- case 340: break;
- case 78:
- {
- if(Debug.debugTokenizer)
- dump("equals");//$NON-NLS-1$
- yybegin(ST_XML_ATTRIBUTE_VALUE);
- return XML_TAG_ATTRIBUTE_EQUALS;
- }
- case 341: break;
- case 79:
- case 81:
- case 82:
- case 153:
- {
- if(Debug.debugTokenizer)
- dump("attr value");//$NON-NLS-1$
- yybegin(ST_XML_ATTRIBUTE_NAME);
- return XML_TAG_ATTRIBUTE_VALUE;
- }
- case 342: break;
- case 84:
- {
- if(Debug.debugTokenizer)
- dump("declaration end");//$NON-NLS-1$
- if (Debug.debugTokenizer) {
- if(fStateStack.peek()!=YYINITIAL)
- System.out.println("end embedded region");//$NON-NLS-1$
- }
- yybegin(fStateStack.pop());
- return XML_DECLARATION_CLOSE;
- }
- case 343: break;
- case 89:
- {
- if(Debug.debugTokenizer)
- dump("doctype type");//$NON-NLS-1$
- yybegin(ST_XML_DOCTYPE_EXTERNAL_ID);
- return XML_DOCTYPE_NAME;
- }
- case 344: break;
- case 92:
- case 94:
- case 95:
- case 96:
- case 167:
- case 168:
- case 171:
- case 172:
- case 225:
- {
- if(Debug.debugTokenizer)
- dump("doctype public reference");//$NON-NLS-1$
- yybegin(ST_XML_DOCTYPE_ID_SYSTEM);
- return XML_DOCTYPE_EXTERNAL_ID_PUBREF;
- }
- case 345: break;
- case 97:
- case 99:
- case 100:
- case 101:
- case 179:
- {
- if(Debug.debugTokenizer)
- dump("doctype system reference");//$NON-NLS-1$
- yybegin(ST_XML_DECLARATION_CLOSE);
- return XML_DOCTYPE_EXTERNAL_ID_SYSREF;
- }
- case 346: break;
- case 102:
- case 104:
- case 105:
- case 187:
- case 188:
- case 191:
- case 192:
- case 228:
- {
- if(Debug.debugTokenizer)
- dump("elementdecl name");//$NON-NLS-1$
- yybegin(ST_XML_ELEMENT_DECLARATION_CONTENT);
- return XML_ELEMENT_DECL_NAME;
- }
- case 347: break;
- case 108:
- {
- if(Debug.debugTokenizer)
- dump("elementdecl close");//$NON-NLS-1$
- if (Debug.debugTokenizer) {
- if(fStateStack.peek()!=YYINITIAL)
- System.out.println("end embedded region");//$NON-NLS-1$
- }
- yybegin(fStateStack.pop());
- return XML_DECLARATION_CLOSE;
- }
- case 348: break;
- case 109:
- case 111:
- case 112:
- case 198:
- case 199:
- case 202:
- case 203:
- case 232:
- {
- if(Debug.debugTokenizer)
- dump("attlist name");//$NON-NLS-1$
- yybegin(ST_XML_ATTLIST_DECLARATION_CONTENT);
- return XML_ATTLIST_DECL_NAME;
- }
- case 349: break;
- case 115:
- {
- if(Debug.debugTokenizer)
- dump("attlist close");//$NON-NLS-1$
- if (Debug.debugTokenizer) {
- if(fStateStack.peek()!=YYINITIAL)
- System.out.println("end embedded region");//$NON-NLS-1$
- }
- yybegin(fStateStack.pop());
- return XML_DECLARATION_CLOSE;
- }
- case 350: break;
- case 116:
- case 117:
- {
- return doBlockTagScan();
- }
- case 351: break;
- default:
- if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
- yy_atEOF = true;
- yy_do_eof();
- return null;
- }
- else {
- yy_ScanError(YY_NO_MATCH);
- }
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java
deleted file mode 100644
index 836dd41f5c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-
-public class AttributeEqualsRegion implements ITextRegion {
- static private final byte fTextLength = 1;
- static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS;
- private short fLength;
- private int fStart;
-
-
- public AttributeEqualsRegion() {
- super();
- }
-
- public AttributeEqualsRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fLength = (short) length;
- }
-
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = (short) region.getLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java
deleted file mode 100644
index a2c4158f80..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class AttributeNameRegion implements ITextRegion {
- // specify correct type
- static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_NAME;
- private int fLength;
- private int fStart;
- private int fTextLength;
-
- public AttributeNameRegion() {
- super();
- }
-
- public AttributeNameRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fTextLength = textLength;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
- public void adjustTextLength(int i) {
- fTextLength += 1;
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- RegionChangedEvent result = null;
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
- canHandle = false;
- } else {
- canHandle = true;
- }
- } else {
- if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- } else {
- canHandle = false;
- }
-
- }
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
- // If we are handling as whitespace, there is no need to increase
- // the text length, only
- // the total length is changing.
- if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
- fTextLength += lengthDifference;
- }
- fLength += lengthDifference;
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
- }
-
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java
deleted file mode 100644
index 7fbbbbf353..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class AttributeValueRegion implements ITextRegion {
- // specify correct type
- static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE;
- private int fLength;
- private int fStart;
- private int fTextLength;
-
- public AttributeValueRegion() {
- super();
- }
-
- public AttributeValueRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fTextLength = textLength;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
- }
-
- public void adjustStart(int i) {
- fStart += i;
- }
-
- public void adjustTextLength(int i) {
- fTextLength += 1;
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- RegionChangedEvent result = null;
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
- canHandle = false;
- } else {
- canHandle = true;
- }
- } else {
- if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- } else {
- canHandle = false;
- }
- }
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
- // If we are handling as whitespace, there is no need to increase
- // the text length, only
- // the total length is changing.
- if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
- fTextLength += lengthDifference;
- }
- // update length (and end) after above check for white space,
- // since
- // it looks to determine if at end of region.
- fLength += lengthDifference;
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java
deleted file mode 100644
index 339d692f4a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class EmptyTagCloseRegion implements ITextRegion {
- private int fLength = 2;
- static private final byte fTextLength = 2;
- static private final String fType = DOMRegionContext.XML_EMPTY_TAG_CLOSE;
- private int fStart;
-
-
- public EmptyTagCloseRegion() {
- super();
- }
-
- public EmptyTagCloseRegion(int start, int textLength, int length) {
- super();
- fStart = start;
- fLength = length;
- if (fTextLength != textLength)
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- }
-
- public void adjustLength(int i) {
- fLength += i;
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
- public void adjustTextLength(int i) {
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java
deleted file mode 100644
index 1ad5549d0d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class EndTagOpenRegion implements ITextRegion {
- static private final String fType = DOMRegionContext.XML_END_TAG_OPEN;
- private int fLength;
- private int fStart;
- static private final byte fTextLength = 2;
-
-
- public EndTagOpenRegion() {
- super();
- }
-
- public EndTagOpenRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- if (fTextLength != textLength)
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- fLength = length;
- }
-
- public EndTagOpenRegion(int start, int length) {
- this();
- fStart = start;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
-// fTextLength += 1;
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
-// fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java
deleted file mode 100644
index e6064beb1d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- *
- * This class is not intended to be used, its just present to server as a
- * generic starting point for adding new specific region types.
- *
- */
-
-public class GenericTemplateRegion implements ITextRegion {
- // specify correct type
- static private final String fType = DOMRegionContext.UNDEFINED;
- private int fLength;
- private int fStart;
- private int fTextLength;
-
-
- public GenericTemplateRegion() {
- super();
- }
-
- public GenericTemplateRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fTextLength = textLength;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
- fTextLength += i;
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java
deleted file mode 100644
index af783f63b0..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-
-
-public class RegionToStringUtil {
- static public String toString(ITextRegion region) {
- String className = region.getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- String result = shortClassName + "--> " + region.getType() + ": " + region.getStart() + "-" + region.getTextEnd() + (region.getTextEnd() != region.getEnd() ? ("/" + region.getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- // NOTE: if the document held by any region has been updated and the
- // region offsets have not
- // yet been updated, the output from this method invalid.
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java
deleted file mode 100644
index 567d0937bc..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-
-
-/**
- *
- * This is a utility class to centralize 'region' update. Note: care must be
- * taken that is is not used for StructuredDocumentRegions, or container
- * regions, its only for "token regions"
- *
- */
-public class RegionUpdateRule {
-
- static public boolean allLetterOrDigit(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- // TO_DO_FUTURE: check that a Java Letter or Digit is
- // the same thing as an XML letter or digit
- if (!(Character.isLetterOrDigit(changes.charAt(i)))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- static public boolean allWhiteSpace(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- if (!Character.isWhitespace(changes.charAt(i))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- static public boolean canHandleAsLetterOrDigit(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- if (parent == null)
- return canHandleAsLetterOrDigit(region, changes, requestStart, lengthToReplace);
- boolean result = false;
- // Make sure we are in a non-white space area
- if ((requestStart <= (parent.getTextEndOffset(region))) && (allLetterOrDigit(changes))) {
- result = true;
- }
- return result;
- }
-
- static public boolean canHandleAsLetterOrDigit(ITextRegion region, String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // Make sure we are in a non-white space area
- if ((requestStart <= (region.getTextEnd())) && (allLetterOrDigit(changes))) {
- result = true;
- }
- return result;
- }
-
- static public boolean canHandleAsWhiteSpace(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // we don't explect a null parent, but just in case!
- // (in which case, we must be dealing with regions that are
- // structuredDocumentRegions).
- if (parent == null)
- return canHandleAsWhiteSpace(region, changes, requestStart, lengthToReplace);
- boolean result = false;
- // if we are in the "white space" area of a region, then
- // we don't want to handle, a reparse is needed.
- // the white space region is consider anywhere that would
- // leave whitespace between this character and the text part.
- // and of course, we can insert whitespace in whitespace region
- //
- // if there is no whitespace in this region, no need to look further
- if (region.getEnd() > region.getTextEnd()) {
- // no need to add one to end of text, as we used to, since we
- // change definition of length to equate to offset plus one.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866
- // watch out for whitespace at end of text
- if (requestStart >= parent.getTextEndOffset(region)) {
- // ok, we are in the whitespace region, so we can't handle,
- // unless
- // we are just inserting whitespace.
- if (allWhiteSpace(changes)) {
- result = true;
- } else {
- result = false;
- }
- }
- }
- return result;
- }
-
- static public boolean canHandleAsWhiteSpace(ITextRegion region, String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // if we are in the "white space" area of a region, then
- // we don't want to handle, a reparse is needed.
- // the white space region is consider anywhere that would
- // leave whitespace between this character and the text part.
- // and of course, we can insert whitespace in whitespace region
- //
- // if there is no whitespace in this region, no need to look further
- if (region.getEnd() > region.getTextEnd()) {
- // no need to add one to end of text, as we used to, since we
- // change definition of length to equate to offset plus one.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866
- // watch out for whitespace at end of text
- if (requestStart >= region.getTextEnd()) {
- // ok, we are in the whitespace region, so we can't handle,
- // unless
- // we are just inserting whitespace.
- if (allWhiteSpace(changes)) {
- result = true;
- } else {
- result = false;
- }
- }
- }
- return result;
- }
-
- // need an adjust text length API before this can be used
- static public StructuredDocumentEvent updateModel(ITextRegion region, Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- RegionChangedEvent result = null;
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + region.getType()); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((region.getStart() >= region.getTextEnd()) || (Math.abs(lengthToReplace) >= region.getTextEnd() - region.getStart())) {
- canHandle = false;
- } else {
- canHandle = true;
- }
- } else {
- if ((RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(region, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- } else {
- canHandle = false;
- }
- }
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- region.adjustLength(lengthDifference);
- // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
- // If we are handling as whitespace, there is no need to increase
- // the text length, only
- // the total length is changing.
- if (!RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, region.getStart(), lengthToReplace)) {
- // region.adjustTextLength(lengthDifference);
- }
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, region, changes, requestStart, lengthToReplace);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java
deleted file mode 100644
index 027ae4d992..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class TagCloseRegion implements ITextRegion {
- static private final byte fLength = 1;
- static private final byte fTextLength = 1;
- static private final String fType = DOMRegionContext.XML_TAG_CLOSE;
- private int fStart;
-
-
- public TagCloseRegion() {
- super();
- }
-
- public TagCloseRegion(int start) {
- this();
- fStart = start;
- }
-
- public void adjustLength(int i) {
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java
deleted file mode 100644
index 38b59c4233..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class TagNameRegion implements ITextRegion {
- static private final String fType = DOMRegionContext.XML_TAG_NAME;
- private short fLength;
- private int fStart;
- private short fTextLength;
-
-
- public TagNameRegion() {
- super();
- }
-
- public TagNameRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fTextLength = (short) textLength;
- fLength = (short) length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
- fTextLength += i;
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = (short) region.getLength();
- fTextLength = (short) region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java
deleted file mode 100644
index e8cb85e928..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class TagOpenRegion implements ITextRegion {
- static private final String fType = DOMRegionContext.XML_TAG_OPEN;
- private int fLength;
- private int fStart;
- static private final byte fTextLength = 1;
-
-
- public TagOpenRegion() {
- super();
- }
-
- public TagOpenRegion(int start, int textLength, int length) {
- this(start, length);
- if (fTextLength != textLength)
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- }
-
- public TagOpenRegion(int start, int length) {
- this();
- fStart = start;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
-// fTextLength += 1;
- throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java
deleted file mode 100644
index bc0bcc197b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class WhiteSpaceOnlyRegion implements ITextRegion {
- static private final byte fTextLength = 0;
-
- static private final String fType = DOMRegionContext.WHITE_SPACE;
- protected int fLength;
- protected int fStart;
-
- public WhiteSpaceOnlyRegion(int start, int length) {
- super();
- fStart = start;
- fLength = length;
- }
-
- public void adjust(int i) {
- fStart += i;
- }
-
- public void adjustLength(int i) {
- fLength += i;
- }
-
- public void adjustStart(int i) {
- fStart += i;
- }
-
-
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
- public boolean contains(int position) {
-
- return fStart <= position && position < fStart + fLength;
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public void setLength(int i) {
- fLength = i;
- }
-
- public void setStart(int i) {
- fStart = i;
- }
-
- public void setTextLength(short i) {
- throw new RuntimeException("invalid call"); //$NON-NLS-1$
- }
-
- public void setType(String string) {
- throw new RuntimeException("invalid call"); //$NON-NLS-1$
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- /**
- * For this ITextRegion type, the start must in terms of what the region
- * expects ... that is, its not document offset, but start relative to
- * what ever contains it.
- */
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
- canHandle = false;
- }
- else {
- canHandle = true;
- }
- }
- else {
- if (RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- }
- else {
- canHandle = false;
- }
-
- }
- RegionChangedEvent result = null;
-
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- fLength += lengthDifference;
-
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
- }
-
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java
deleted file mode 100644
index 23da980cde..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class XMLCDataTextRegion implements ITextRegion {
- static private final String fType = DOMRegionContext.XML_CDATA_TEXT;
- private int fLength;
- private int fStart;
- private int fTextLength;
-
-
- public XMLCDataTextRegion() {
- super();
- }
-
- public XMLCDataTextRegion(int start, int textLength, int length) {
- this();
- fStart = start;
- fTextLength = textLength;
- fLength = length;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
- fTextLength += i;
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- // TODO: shouldn't cdata be like XML Content ... length and text
- // length
- // always be the same, regardless of whitespace?
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // TODO: this is a pretty lame method, since XML CData region can have
- // a much
- // better rule for region update, but this is what previous
- // (unfactored)
- // version had, so I'll carry it over, of now.
- RegionChangedEvent result = null;
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
- canHandle = false;
- } else {
- canHandle = true;
- }
- } else {
- if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- } else {
- canHandle = false;
- }
-
- }
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
- // If we are handling as whitespace, there is no need to increase
- // the text length, only
- // the total length is changing.
- if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
- fTextLength += lengthDifference;
- }
- fLength += lengthDifference;
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
- }
-
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java
deleted file mode 100644
index e9088dbb0c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-
-public class XMLContentRegion implements ITextRegion {
- static private final String fType = DOMRegionContext.XML_CONTENT;
- // length and textLength are always the same for content region
- //private int fTextLength;
- private int fLength;
- private int fStart;
-
-
- public XMLContentRegion() {
- super();
- }
-
- public XMLContentRegion(int start, int length) {
- this();
- fStart = start;
- fLength = length;
- }
-
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextEnd() {
- return fStart + fLength;
- }
-
- public int getTextLength() {
- return fLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // TODO: this is a pretty lame method, since XML Content can have a
- // much
- // better rule for region update, but this is what previous
- // (unfactored)
- // version had, so I'll carry it over, of now.
- RegionChangedEvent result = null;
- // if the region is an easy type (e.g. attribute value),
- // and the requested changes are all
- // alphanumeric, then make the change here locally.
- // (This can obviously be made more sophisticated as the need arises,
- // but should
- // always follow this pattern.)
- if (Debug.debugStructuredDocument) {
- System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
- System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
- }
- boolean canHandle = false;
- // note: we'll always handle deletes from these
- // regions ... if its already that region,
- // deleting something from it won't change its
- // type. (remember, the calling program needs
- // to insure we are not called, if not all contained
- // on one region.
- if ((changes == null) || (changes.length() == 0)) {
- // delete case
- // We can not do the quick delete, if
- // if all the text in a region is to be deleted.
- // Or, if the delete starts in the white space region.
- // In these cases, a reparse is needed.
- // Minor note, we use textEnd-start since it always
- // less than or equal to end-start. This might
- // cause us to miss a few cases we could have handled,
- // but will prevent us from trying to handle funning cases
- // involving whitespace.
- if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
- canHandle = false;
- } else {
- canHandle = true;
- }
- } else {
- if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
- canHandle = true;
- } else {
- canHandle = false;
- }
-
- }
- if (canHandle) {
- // at this point, we still have the old region. We won't create a
- // new instance, we'll just update the one we have, by changing
- // its end postion,
- // The parent flatnode, upon return, has responsibility
- // for updating sibling regions.
- // and in turn, the structuredDocument itself has responsibility
- // for
- // updating the text store and down stream flatnodes.
- if (Debug.debugStructuredDocument) {
- System.out.println("change handled by region"); //$NON-NLS-1$
- }
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Note: we adjust both end and text end, because for any change
- // that is in only the trailing whitespace region, we should not
- // do a quick change,
- // so 'canHandle' should have been false for those case.
- fLength += lengthDifference;
- // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
- // If we are handling as whitespace, there is no need to increase
- // the text length, only
- // the total length is changing.
- // don't need for content region
- // if (!RegionUpdateRule.canHandleAsWhiteSpace(this, changes,
- // fStart, lengthToReplace)) {
- // fTextLength += lengthDifference;
- // }
- result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
- }
-
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java
deleted file mode 100644
index 38df3ea165..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-
-public class XMLHeadParserFactory {
- public ITextRegion createToken(String context, int start, int textLength, int length, String text) {
- ITextRegion newRegion = null;
- // if (context == XMLRegionContext.XML_CDATA_TEXT) {
- newRegion = new XMLHeadParserRegion(context, start, textLength, length, text);
- // }
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java
deleted file mode 100644
index f3917b6338..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- *
- * This class is not intended to be used, its just present to server as a
- * generic starting point for adding new specific region types.
- */
-
-public class XMLHeadParserRegion implements ITextRegion {
- private int fLength;
- private int fStart;
- private String fText;
- private int fTextLength;
- // specify correct type
- private String fType = DOMRegionContext.UNDEFINED;
-
- public XMLHeadParserRegion() {
- super();
- }
-
- public XMLHeadParserRegion(String context, int start, int textLength, int length, String text) {
- this();
- fType = context;
- fStart = start;
- fTextLength = textLength;
- fLength = length;
- fText = text;
- }
-
- public void adjustLength(int i) {
- fLength += i;
-
- }
-
- public void adjustStart(int i) {
- fStart += i;
-
- }
-
-
- public void adjustTextLength(int i) {
- fTextLength += 1;
-
- }
-
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public String getText() {
- return fText;
- }
-
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public String toString() {
- return RegionToStringUtil.toString(this);
- }
-
- public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // can never be updated
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java
deleted file mode 100644
index 581f44780e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.parser.regions;
-
-
-
-import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
-import org.eclipse.wst.sse.core.internal.parser.ForeignRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- *
- * This region factory is very specific to the parser output, and the specific
- * implementation classes for various regions.
- */
-
-public class XMLParserRegionFactory {
-
- public XMLParserRegionFactory() {
- super();
- }
-
- public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length) {
- return this.createToken(parent, context, start, textLength, length, null, null);
- }
-
- public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length, String lang, String surroundingTag) {
- ITextRegion newRegion = createToken(context, start, textLength, length);
- // DW, 4/16/2003 token regions no longer have parents
- // newRegion.setParent(parent);
- return newRegion;
- }
-
- public ITextRegion createToken(String context, int start, int textLength, int length) {
- return this.createToken(context, start, textLength, length, null, null);
- }
-
- public ITextRegion createToken(String context, int start, int textLength, int length, String lang, String surroundingTag) {
- ITextRegion newRegion = null;
- if (context == DOMRegionContext.XML_CDATA_TEXT) {
- newRegion = new XMLCDataTextRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_CONTENT) {
- newRegion = new XMLContentRegion(start, length);
- }
- else if (context == DOMRegionContext.XML_TAG_NAME) {
- newRegion = new TagNameRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- newRegion = new AttributeNameRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- newRegion = new AttributeEqualsRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- newRegion = new AttributeValueRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_TAG_OPEN) {
- newRegion = new TagOpenRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_END_TAG_OPEN) {
- newRegion = new EndTagOpenRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.XML_TAG_CLOSE) {
- newRegion = new TagCloseRegion(start);
- }
- else if (context == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- newRegion = new EmptyTagCloseRegion(start, textLength, length);
- }
- else if (context == DOMRegionContext.WHITE_SPACE) {
- newRegion = new WhiteSpaceOnlyRegion(start, length);
- }
- else
- // removed this condition during transition, and implemented in
- // subclass
- // if (context == XMLJSPRegionContexts.JSP_CONTENT) {
- // newRegion = new JSPCodeRegion(context, start, textLength, length);
- // } else
- if (context == DOMRegionContext.BLOCK_TEXT) {
- newRegion = new ForeignRegion(context, start, textLength, length);
- ((ForeignRegion) newRegion).setSurroundingTag(surroundingTag);
- }
- else {
- newRegion = new ContextRegion(context, start, textLength, length);
- }
- return newRegion;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java
deleted file mode 100644
index 4fad19bf9f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-
-/**
- * Sets default values for XML Core preferences
- */
-public class XMLCorePreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- IEclipsePreferences node = new DefaultScope().getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName());
-
- // formatting preferences
- node.putInt(XMLCorePreferenceNames.LINE_WIDTH, 72);
- node.putBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, false);
- node.put(XMLCorePreferenceNames.INDENTATION_CHAR, XMLCorePreferenceNames.TAB);
- node.putInt(XMLCorePreferenceNames.INDENTATION_SIZE, 1);
- node.putBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS, false);
- node.putBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET, false);
- node.putBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT, false);
- node.putBoolean(XMLCorePreferenceNames.SPACE_BEFORE_EMPTY_CLOSE_TAG, true);
- node.putBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_TEXT, true);
- node.putBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_JOIN_LINES, true);
- // cleanup preferences
- node.putBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
- node.putBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS, true);
- node.putBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS, true);
- node.putBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES, true);
- node.putBoolean(XMLCorePreferenceNames.FORMAT_SOURCE, true);
- node.putBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES, false);
- node.putBoolean(XMLCorePreferenceNames.FIX_XML_DECLARATION, true);
-
- node.put(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
- node.put(CommonEncodingPreferenceNames.OUTPUT_CODESET, "UTF-8");//$NON-NLS-1$
- node.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
-
- // this could be made smarter by actually looking up the content
- // type's valid extensions
- node.put(XMLCorePreferenceNames.DEFAULT_EXTENSION, "xml"); //$NON-NLS-1$
-
- node.putBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR, true);
- // 1 = IMarker.SEVERITY_WARNING
- node.putInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, 1);
- node.putInt(XMLCorePreferenceNames.INDICATE_NO_DOCUMENT_ELEMENT, -1); // ignore
- node.putBoolean(XMLCorePreferenceNames.USE_XINCLUDE, false);
- node.putBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true);
- node.putBoolean(XMLCorePreferenceNames.CMDOCUMENT_GLOBAL_CACHE_ENABLED, true);
-
- node.putBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION, false);
- node.putInt(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE, 2);
- node.putInt(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_START_TAG, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_END_TAG, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_TAG_NAME, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_QUOTES, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET, 2);
- node.putInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE, 2);
- node.putInt(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET, 2);
- node.putInt(XMLCorePreferenceNames.WHITESPACE_AT_START, 2);
- node.putInt(XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME, 2);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
deleted file mode 100644
index 4da44ce825..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.preferences;
-
-
-/**
- * Common preference keys used by XML core
- *
- * @plannedfor 1.0
- */
-public class XMLCorePreferenceNames {
- private XMLCorePreferenceNames() {
- // empty private constructor so users cannot instantiate class
- }
-
- /**
- * The default extension to use when none is specified in the New File
- * Wizard.
- * <p>
- * Value is of type <code>String</code>.
- * </p>
- */
- public static final String DEFAULT_EXTENSION = "defaultExtension"; //$NON-NLS-1$
-
-
- /**
- * The maximum width of a line before a line split is needed.
- * <p>
- * Value is of type <code>Integer</code>.
- * </p>
- */
- public static final String LINE_WIDTH = "lineWidth";//$NON-NLS-1$
-
- /**
- * Indicates if all blanks lines should be cleared during formatting.
- * Blank lines will be kept when false.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String CLEAR_ALL_BLANK_LINES = "clearAllBlankLines";//$NON-NLS-1$
-
- /**
- * The number of #INDENTATION_CHAR for 1 indentation.
- * <p>
- * Value is of type <code>Integer</code>.
- * </p>
- */
- public static final String INDENTATION_SIZE = "indentationSize";//$NON-NLS-1$
-
- /**
- * The character used for indentation.
- * <p>
- * Value is of type <code>String</code>.<br />
- * Possible values: {TAB, SPACE}
- * </p>
- */
- public static final String INDENTATION_CHAR = "indentationChar";//$NON-NLS-1$
-
- /**
- * Possible value for the preference #INDENTATION_CHAR. Indicates to use
- * tab character when formatting.
- *
- * @see #SPACE
- * @see #INDENTATION_CHAR
- */
- public static final String TAB = "tab"; //$NON-NLS-1$
-
- /**
- * Possible value for the preference #INDENTATION_CHAR. Indicates to use
- * space character when formatting.
- *
- * @see #TAB
- * @see #INDENTATION_CHAR
- */
- public static final String SPACE = "space"; //$NON-NLS-1$
-
- /**
- * Indicates if tags with multiple attributes should be formatted
- * (splitting each attr on a new line).
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String SPLIT_MULTI_ATTRS = "splitMultiAttrs";//$NON-NLS-1$
-
- /**
- * Indicates whether or not cleanup processor should format source.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
-
- /**
- * Indicates whether or not empty elements should be compressed during
- * cleanup.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String COMPRESS_EMPTY_ELEMENT_TAGS = "compressEmptyElementTags";//$NON-NLS-1$
-
- /**
- * Indicates whether or not to insert required attributes during cleanup.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String INSERT_REQUIRED_ATTRS = "insertRequiredAttrs";//$NON-NLS-1$
-
- /**
- * Indicates whether or not to insert missing tags during cleanup.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
-
- /**
- * Indicates whether or not to quote all attribute values during cleanup.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
-
- /**
- * Indicates whether or not to insert missing XML declarations during cleanup.
- * <p>
- * Value is of type <code>Boolean</code>
- * </p>
- */
- public static final String FIX_XML_DECLARATION = "fixXMLDeclaration"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not to convert all line delimiters during cleanup.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- * @deprecated - no longer used
- */
- public static final String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
-
- /**
- * Indicates the line delimiter to use during cleanup if converting line
- * delimiters.
- * <p>
- * Value is of type <code>String</code>.<br />
- * Possible values: {CR, CRLF, LF, NO_TRANSLATION}
- * </p>
- *
- */
- public static final String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
-
- /**
- * Indicates whether or not a warning should be produced when validating a
- * file that specifies not grammar.
- * <p>
- * Value is of type <code>boolean</code>.<br />
- * Possible values: {TRUE, FALSE}
- * </p>
- * @deprecated
- */
- public static final String WARN_NO_GRAMMAR = "warnNoGrammar";//$NON-NLS-1$
-
- /**
- * Indicates whether or not a message should be produced when validating a
- * file that specifies not grammar.
- * <p>
- * Value is of type <code>integer</code>.<br />
- * Possible values: {0, 1, 2} (none, warning, error)
- * </p>
- */
- public static final String INDICATE_NO_GRAMMAR = "indicateNoGrammar";//$NON-NLS-1$
-
- /**
- * Indicates whether or not a message should be produced when validating a file that does not contain
- * a document element
- * <p>
- * Value is of type <code>integer</code>.<br/>
- * Possible values: {-1, 1, 2} (none, warning, error)
- * </p>
- */
- public static final String INDICATE_NO_DOCUMENT_ELEMENT = "indiciateNoDocumentElement"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not xincludes should be processed before
- * validation.
- * <p>
- * Value is of type <code>boolean</code>.<br />
- * Possible values: {TRUE, FALSE}
- * </p>
- *
- */
- public static final String USE_XINCLUDE = "xinclude";//$NON-NLS-1$
-
- /**
- * Indicates if all whitespace in tags with CDATA content should be
- * preserved.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String PRESERVE_CDATACONTENT = "preserveCDATAContent";//$NON-NLS-1$
-
- /**
- * Indicates if end brackets of start tags should be placed on a new line
- * if the start tag spans more than one line.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String ALIGN_END_BRACKET = "alignEndBracket";//$NON-NLS-1$
-
- /**
- * Indicates if an empty close tag should have a space inserted before
- * closing.
- * <p>
- * Value is of type <code>Boolean</code>
- * </p>
- */
- public static final String SPACE_BEFORE_EMPTY_CLOSE_TAG = "spaceBeforeEmptyCloseTag";//$NON-NLS-1$
-
- /**
- * Indicates whether or not all schema locations for XSD should be honoured
- * during XSD validation of XML.
- * <p>
- * Value is of type <code>boolean</code>.<br />
- * Possible values: {TRUE, FALSE}
- * </p>
- *
- */
- public static final String HONOUR_ALL_SCHEMA_LOCATIONS = "honourAllSchemaLocations";//$NON-NLS-1$
-
- /**
- * Indicates whether or not the content of comments should be formatted
- * <p>
- * Value is of type <code>boolean</code><br />
- * Possible values: {TRUE, FALSE}
- * </p>
- */
- public static final String FORMAT_COMMENT_TEXT = "formatCommentText"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not the lines of comments should be joined when formatting
- * <p>
- * Value is of type <code>boolean</code>
- */
- public static final String FORMAT_COMMENT_JOIN_LINES = "formatCommentJoinLines"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not CMDocuments should be globally cached
- * <p>
- * Value is of type <code>boolean</code>
- */
- public static final String CMDOCUMENT_GLOBAL_CACHE_ENABLED = "cmDocumentGlobalCacheEnabled"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not MarkUpValidator should run as part of XMl Validation.
- * <p>
- * Value is of type <code>boolean</code>.<br />
- * Possible values: {TRUE, FALSE}
- * </p>
- */
- public static final String MARKUP_VALIDATION = "markupValidation"; //$NON-NLS-1$
-
- /**
- * Indicates whether or not a message should be produced when validating a
- * file that specifies following condition.
- * <p>
- * Value is of type <code>integer</code>.<br />
- * Possible values: {0, 1, 2} (none, warning, error)
- * </p>
- */
- public static final String ATTRIBUTE_HAS_NO_VALUE = "attributeHasNoValue"; //$NON-NLS-1$
- public static final String END_TAG_WITH_ATTRIBUTES = "endTagWithAttributes"; //$NON-NLS-1$
- public static final String WHITESPACE_BEFORE_TAGNAME = "whitespaceBeforeTagName"; //$NON-NLS-1$
- public static final String MISSING_CLOSING_BRACKET = "missingClosingBracket"; //$NON-NLS-1$
- public static final String MISSING_CLOSING_QUOTE = "missingClosingQuote"; //$NON-NLS-1$
- public static final String MISSING_END_TAG = "missingEndTag"; //$NON-NLS-1$
- public static final String MISSING_START_TAG = "missingStartTag"; //$NON-NLS-1$
- public static final String MISSING_QUOTES = "missingQuotes"; //$NON-NLS-1$
- public static final String NAMESPACE_IN_PI_TARGET = "namespaceInPITarget"; //$NON-NLS-1$
- public static final String MISSING_TAG_NAME = "missingTagName"; //$NON-NLS-1$
- public static final String WHITESPACE_AT_START = "whitespaceAtStart"; //$NON-NLS-1$
- public static final String USE_PROJECT_SETTINGS = "use-project-settings";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterFactoryImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterFactoryImpl.java
deleted file mode 100644
index 7376d4ee46..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterFactoryImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.propagate;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.PropagatingAdapter;
-import org.eclipse.wst.sse.core.internal.PropagatingAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-
-
-/**
- * The PropagatingAdapterFactory is part of the "adapt on create" mechanism. A
- * PropagatingAdapter, once added to a node, will cause proagating adapters to
- * be created for all child nodes. A side effect of creating a
- * PropagatingAdapter for a node is that is is also creates adapters for and
- * adapts the Node for all other registered 'create on adapt' Adapters. This
- * other adapters are registered by registering their factories via plugin
- * extension point.
- */
-public class PropagatingAdapterFactoryImpl extends AbstractAdapterFactory implements PropagatingAdapterFactory {
-
- private PropagatingAdapter fAdapterInstance;
- private List fContributedFactories = null;
-
- /**
- * PropagatingAdapterFactory constructor comment.
- */
- public PropagatingAdapterFactoryImpl() {
- this(PropagatingAdapter.class, true);
- }
-
- protected PropagatingAdapterFactoryImpl(Object adapterKey, boolean registerAdapters) { // ,
- super(adapterKey, registerAdapters);
- }
-
- public void addContributedFactories(INodeAdapterFactory factory) {
- if (fContributedFactories != null) {
- fContributedFactories.add(factory);
- }
-
- }
-
- /**
- * createAdapter method comment.
- */
- protected INodeAdapter createAdapter(INodeNotifier target) {
- // every notifier get's one of these
- // (and the same instance of it)
- return getAdapterInstance();
- }
-
- /**
- * Gets the adapterInstance.
- *
- * @return Returns a PropagatingAdapter
- */
- private PropagatingAdapter getAdapterInstance() {
- if (fAdapterInstance == null) {
- fAdapterInstance = new PropagatingAdapterImpl();
- if (fContributedFactories != null) {
- for (int i = 0; i < fContributedFactories.size(); i++)
- fAdapterInstance.addAdaptOnCreateFactory((PropagatingAdapterFactory) fContributedFactories.get(i));
- }
- }
- return fAdapterInstance;
- }
-
- public void release() {
- // give the adapter instance a chance to release its factories
- getAdapterInstance().release();
-
- }
-
- public void setContributedFactories(ArrayList list) {
- fContributedFactories = list;
-
- }
-
- public INodeAdapterFactory copy() {
- PropagatingAdapterFactory clonedInstance = new PropagatingAdapterFactoryImpl(getAdapterKey(), isShouldRegisterAdapter());
- // clone this adapters specific list of adapter factories too
- if (fContributedFactories != null) {
-
- Iterator iterator = fContributedFactories.iterator();
- clonedInstance.setContributedFactories(new ArrayList());
- while (iterator.hasNext()) {
- INodeAdapterFactory existingFactory = (INodeAdapterFactory) iterator.next();
- clonedInstance.addContributedFactories(existingFactory.copy());
- }
- }
- return clonedInstance;
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterImpl.java
deleted file mode 100644
index f581590c35..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/propagate/PropagatingAdapterImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.propagate;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.PropagatingAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class PropagatingAdapterImpl implements PropagatingAdapter {
-
- private List adaptOnCreateFactories = null;
-
- /**
- * AbstractPropagatingAdapterImpl constructor comment.
- */
- public PropagatingAdapterImpl() {
- super();
- }
-
- private void adaptOnCreate(IDOMNode node) {
- // give each of the factories a chance to adapt the node, if it
- // chooses to
- if (adaptOnCreateFactories != null) {
-
-
- synchronized (adaptOnCreateFactories) {
- int length = adaptOnCreateFactories.size();
- for (int i = 0; i < length; i++) {
- INodeAdapterFactory factory = (INodeAdapterFactory) adaptOnCreateFactories.get(i);
- factory.adapt(node);
- }
- }
-
- }
-
- }
-
- /**
- * This mechanism can be made "easier to use" later.
- */
- public void addAdaptOnCreateFactory(INodeAdapterFactory factory) {
- getAdaptOnCreateFactories().add(factory);
- }
-
- /**
- * Gets the adaptOnCreateFactories.
- *
- * @return Returns a List
- */
- public List getAdaptOnCreateFactories() {
- if (adaptOnCreateFactories == null)
- adaptOnCreateFactories = new ArrayList();
- return adaptOnCreateFactories;
- }
-
-
- /**
- * @see PropagatingAdapter#initializeForFactory(INodeAdapterFactory,
- * INodeNotifier)
- */
- public void initializeForFactory(INodeAdapterFactory factory, INodeNotifier node) {
- // ISSUE: we are a DOM specific implimentation,
- // we should not be.
- if (node instanceof IDOMNode) {
- IDOMNode xmlNode = (IDOMNode) node;
- propagateTo(xmlNode);
- }
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(PropagatingAdapter.class);
- }
-
- private boolean isInteresting(Object newValue) {
- return (newValue != null && (newValue instanceof Element || newValue instanceof Document || newValue instanceof DocumentType));
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // Issue: We only propagate to Elements ...
- // not attributes too! We should careful consider doning all when
- // when we improve "adapt on create" design.
- if (eventType == INodeNotifier.ADD && isInteresting(newValue)) {
- propagateTo((IDOMNode) newValue);
- }
- }
-
- private void propagateTo(IDOMNode node) {
- // get adapter to ensure its created
- node.getAdapterFor(PropagatingAdapter.class);
- adaptOnCreate(node);
- propagateToChildren(node);
- }
-
- private void propagateToChildren(IDOMNode parent) {
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- propagateTo((IDOMNode) child);
- }
- }
-
- /**
- * @see PropagatingAdapter#release()
- */
- public void release() {
- if (adaptOnCreateFactories != null) {
-
- synchronized (adaptOnCreateFactories) {
- int length = adaptOnCreateFactories.size();
- for (int i = 0; i < length; i++) {
- INodeAdapterFactory factory = (INodeAdapterFactory) adaptOnCreateFactories.get(i);
- factory.release();
- }
- }
-
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLCharEntity.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLCharEntity.java
deleted file mode 100644
index b1fb483b99..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLCharEntity.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional;
-
-
-
-/**
- * XML Namespace constants
- *
- * @plannedfor 1.0
- */
-public interface IXMLCharEntity {
- static final String AMP_NAME = "amp";//$NON-NLS-1$
- static final String AMP_REF = "&amp;";//$NON-NLS-1$
- static final String AMP_VALUE = "&";//$NON-NLS-1$
- static final String APOS_NAME = "apos";//$NON-NLS-1$
- static final String APOS_REF = "&apos;";//$NON-NLS-1$
- static final String APOS_VALUE = "'";//$NON-NLS-1$
- static final String GT_NAME = "gt";//$NON-NLS-1$
- static final String GT_REF = "&gt;";//$NON-NLS-1$
- static final String GT_VALUE = ">";//$NON-NLS-1$
-
- static final String LT_NAME = "lt";//$NON-NLS-1$
- static final String LT_REF = "&lt;";//$NON-NLS-1$
- static final String LT_VALUE = "<";//$NON-NLS-1$
- static final String QUOT_NAME = "quot";//$NON-NLS-1$
- static final String QUOT_REF = "&quot;";//$NON-NLS-1$
- static final String QUOT_VALUE = "\"";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLNamespace.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLNamespace.java
deleted file mode 100644
index 10847db83c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLNamespace.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 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
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional;
-
-
-
-/**
- * XML Namespace constants
- *
- * @plannedfor 1.0
- */
-public interface IXMLNamespace {
-
- String XMLNS = "xmlns";//$NON-NLS-1$
- String XMLNS_PREFIX = "xmlns:";//$NON-NLS-1$
- String XMLNS_URI = "http://www.w3.org/2000/xmlns/";//$NON-NLS-1$
- String XML = "xml";//$NON-NLS-1$
- String XML_PREFIX = "xml:";//$NON-NLS-1$
- String XML_URI = "http://www.w3.org/XML/1998/namespace";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLPreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLPreferenceNames.java
deleted file mode 100644
index df49d48e1b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/IXMLPreferenceNames.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional;
-
-/**
- * Keys to use for preference settings.
- *
- * @plannedfor 1.0
- */
-
-public interface IXMLPreferenceNames {
- String CLEANUP_ATTR_NAME_CASE = "cleanupAttrNameCase";//$NON-NLS-1$
- String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
- // cleanup preference names
- String CLEANUP_TAG_NAME_CASE = "cleanupTagNameCase";//$NON-NLS-1$
- String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
- String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
- String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
-
- // others
- String LAST_ACTIVE_PAGE = "lastActivePage";//$NON-NLS-1$
- String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
-
- /*
- * not used for now // highlighting types String COMMENT_BORDER =
- * "commentBorder";//$NON-NLS-1$ String COMMENT_TEXT =
- * "commentText";//$NON-NLS-1$ String CDATA_BORDER =
- * "cdataBorder";//$NON-NLS-1$ String CDATA_TEXT =
- * "cdataText";//$NON-NLS-1$ String PI_BORDER = "piBorder";//$NON-NLS-1$
- * String PI_CONTENT = "piContent";//$NON-NLS-1$ String TAG_BORDER =
- * "tagBorder";//$NON-NLS-1$ String TAG_NAME = "tagName";//$NON-NLS-1$
- * String TAG_ATTRIBUTE_NAME = "tagAttributeName";//$NON-NLS-1$ String
- * TAG_ATTRIBUTE_VALUE = "tagAttributeValue";//$NON-NLS-1$ String
- * DECL_BORDER = "declBoder";//$NON-NLS-1$ String DOCTYPE_NAME =
- * "doctypeName";//$NON-NLS-1$ String DOCTYPE_EXTERNAL_ID =
- * "doctypeExternalId";//$NON-NLS-1$ String DOCTYPE_EXTERNAL_ID_PUBREF =
- * "doctypeExternalPubref";//$NON-NLS-1$ String DOCTYPE_EXTERNAL_ID_SYSREF =
- * "doctypeExtrenalSysref";//$NON-NLS-1$ String XML_CONTENT =
- * "xmlContent";//$NON-NLS-1$ // highlighting preferences String COMMA =
- * ",";//$NON-NLS-1$ String COLOR = "color";//$NON-NLS-1$ String NAME =
- * "name";//$NON-NLS-1$ String FOREGROUND = "foreground";//$NON-NLS-1$
- * String BACKGROUND = "background";//$NON-NLS-1$ String BOLD =
- * "bold";//$NON-NLS-1$ String ITALIC = "italic";//$NON-NLS-1$
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/NameValidator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/NameValidator.java
deleted file mode 100644
index 496beb7234..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/NameValidator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.provisional;
-
-import java.io.Reader;
-
-import org.eclipse.wst.xml.core.internal.parser.XML10Names;
-
-/**
- * This class provides consistent way to pre-check if a string is a valid XML
- * name, before, for example, trying to actually create an Element with it.
- * Attempting to create an Element with an invalid name will throw the appropriate
- * DOM Exception, but often clients want to check the validiting of a name
- * such as based on some user input, long in advance of actually making
- * the DOM call. And, natually, want to give the user feedback in a more
- * timely fashion.
- *
- * ISSUE: is "endns:" really valid xml name? I think not, but this method
- * (currently) says it is.
- *
- * @plannedfor 1.0
- */
-public final class NameValidator {
-
- private static XML10Names xml10charChecker = null;
-
- /**
- * Returns true if <code>name</code> is valid XML name according to XML
- * 1.0 rules, false otherwise.
- *
- * @param name
- * name is the string to test
- * @return true if valid name according to XML 1.0 rules, false otherwise.
- */
- public synchronized static final boolean isValid(String name) {
-
- if (xml10charChecker == null) {
- xml10charChecker = inititailizeXML10Names();
- }
- return xml10charChecker.isValidXML10Name(name);
- }
-
- private static XML10Names inititailizeXML10Names() {
- return new XML10Names((Reader) null);
- }
-
- /**
- * Not intenteded to be instantiated.
- */
- private NameValidator() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocType.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocType.java
deleted file mode 100644
index 3e6ff39c35..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 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.provisional.contentmodel;
-
-
-public interface CMDocType {
- /**
- * CHTML files
- */
- public final static String CHTML_DOC_TYPE = "CHTML";//$NON-NLS-1$
- /**
- * HTML files
- */
- public final static String HTML_DOC_TYPE = "HTML";//$NON-NLS-1$
- /**
- * HTML5 files
- */
- public final static String HTML5_DOC_TYPE = "HTML5";//$NON-NLS-1$
- /**
- * JSP 1.1 files (currently includes 1.2 elements for backward behavioral compatibility)
- */
- public final static String JSP11_DOC_TYPE = "JSP11";//$NON-NLS-1$
- /**
- * JSP 1.2 files
- */
- public final static String JSP12_DOC_TYPE = "JSP12";//$NON-NLS-1$
- /**
- * JSP 2.0 JSP files
- */
- public final static String JSP20_DOC_TYPE = "JSP20";//$NON-NLS-1$
- /**
- * JSP 2.0 Tag files
- */
- public final static String TAG20_DOC_TYPE = "JSP20.TAG";//$NON-NLS-1$
- /**
- * JSP 2.1 Tag files
- */
- public final static String TAG21_DOC_TYPE = "JSP21.TAG";//$NON-NLS-1$
- /**
- * JSP 2.1 JSP files
- */
- public final static String JSP21_DOC_TYPE = "JSP21";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocumentTracker.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocumentTracker.java
deleted file mode 100644
index 19baa552e9..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMDocumentTracker.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.contentmodel;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-
-
-/**
- * Position dependent CMDocument tracker. A tracker matches a
- * IStructuredDocumentRegion with a CMDocument that it enables allowing for
- * position-dependent content models
- */
-public interface CMDocumentTracker {
-
- CMDocument getDocument();
-
- IStructuredDocumentRegion getStructuredDocumentRegion();
-}
-
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMNodeWrapper.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMNodeWrapper.java
deleted file mode 100644
index dbe75d6799..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/CMNodeWrapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.contentmodel;
-
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-public interface CMNodeWrapper extends CMNode {
- CMNode getOriginNode();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/ContentModelAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/ContentModelAdapter.java
deleted file mode 100644
index a66811ee42..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/ContentModelAdapter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.contentmodel;
-
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-/**
- * ContentModelAdapter interface
- */
-public interface ContentModelAdapter extends org.eclipse.wst.sse.core.internal.provisional.INodeAdapter {
-
- /**
- * getCMDocument method
- *
- * @return CMDocument
- * @param notifer
- *
- * Returns CMDocument associated to the adapting node. For exampl : HTML
- * CMDocument is associated to HTML Document node, DTD CMDocument is
- * associated to DocumentType node, DTD/Schema CMDocument is associated to
- * Element node (sometime with namespace), and taglib CMDocument is
- * associated to taglib directive Element node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter
- * implementation.
- */
- CMDocument getCMDocument(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier notifier);
-
- /**
- * getDeclaration method
- *
- * @return CMNode
- * @param notifer
- *
- * Returns ElementDefinition or AttributeDefinition for the adapting node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter
- * implementation.
- */
- CMNode getDeclaration(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier notifier);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/NullContentModel.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/NullContentModel.java
deleted file mode 100644
index 0b2ee6ba9b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contentmodel/NullContentModel.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.contentmodel;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamespace;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-
-/**
- * This class can be used to intialize specific variables that need a content
- * model, until the true content model is available. This prevents having to
- * do lots of null checks.
- */
-public class NullContentModel implements CMDocument {
-
- private static class NullCMNamedNodeMap implements CMNamedNodeMap {
- public int getLength() {
- return 0;
- }
-
- public CMNode getNamedItem(String name) {
- return null;
- }
-
- public CMNode item(int index) {
- return null;
- }
-
- public Iterator iterator() {
- return new NullIterator();
- }
-
- }
-
- private static class NullIterator implements Iterator {
- public NullIterator() {
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- public NullContentModel() {
- super();
- }
-
- public CMNamedNodeMap getElements() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamedNodeMap getEntities() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamespace getNamespace() {
- return null;
- }
-
- public String getNodeName() {
- return null;
- }
-
- public int getNodeType() {
- return 0;
- }
-
- public Object getProperty(String propertyName) {
- return null;
- }
-
- public boolean supports(String propertyName) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contenttype/ContentTypeIdForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contenttype/ContentTypeIdForXML.java
deleted file mode 100644
index 67c3a90b03..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/contenttype/ContentTypeIdForXML.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.provisional.contenttype;
-
-/**
- * This class, with its few field, is a convience to provide compile-time
- * safety when refering to a contentType ID. The value of the contenttype id
- * field must match what is specified in plugin.xml file.
- *
- * @plannedfor 1.0
- */
-final public class ContentTypeIdForXML {
- /**
- * This content type is actually supplied by base Eclipse. Its given here
- * just as documentation for WTP based clients. Typically, clients should
- * use the values/constants supplied by base Eclipse.
- */
- public final static String ContentTypeID_XML = getConstantString2();
- /**
- * This value is public only for testing and special infrastructure. The
- * constant nor is value should not be referenced by clients.
- *
- * The value of the contenttype id field must match what is specified in
- * plugin.xml file. Note: this value is intentially set with default
- * protected method so it will not be inlined.
- */
- public final static String ContentTypeID_SSEXML = getConstantString();
-
- /**
- * Don't allow instantiation.
- */
- private ContentTypeIdForXML() {
- super();
- }
-
- static String getConstantString() {
- return "org.eclipse.wst.xml.core.xmlsource"; //$NON-NLS-1$
- }
-
- static String getConstantString2() {
- return "org.eclipse.core.runtime.xml"; //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMAttr.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMAttr.java
deleted file mode 100644
index ee16e15de8..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMAttr.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.w3c.dom.Attr;
-
-
-/**
- * This interface provides extensions to corresponding DOM interface to enable
- * functions for source editing and incremental parsing.
- *
- * @plannedfor 1.0
- *
- */
-public interface IDOMAttr extends IDOMNode, Attr {
-
- /**
- * Get's the region in attribute representing the '=' sign. May or may not
- * have whitespace surrounding it.
- *
- * @deprecated -
- * ISSUE: need to change/remove to avoid exposing 'ITextRegion'
- * change to offset pattern, as others.
- *
- * @return ITextRegion - the region representing the equals sign, or null
- * if their is no equals sign.
- */
- ITextRegion getEqualRegion();
-
- /**
- * Gets the source location of the end of the attribute name, including
- * whitespace.
- *
- * @return int - the source location of the end of the attribute name,
- * including whitespace.
- */
- int getNameRegionEndOffset();
-
- /**
- * Gets the source location of the start of the attribute name.
- *
- * @return int - the source location of the start of the attribute name.
- */
- int getNameRegionStartOffset();
-
-
- /**
- * Gets the text associated with the attribute name.
- *
- * @return String - the text associated with the attribute name.
- */
- String getNameRegionText();
-
- /**
- * Gets the source location of the end of the attribute name, excluding
- * whitespace.
- *
- * @return int - returns the source location of the end of the attribute
- * name, excluding whitespace.
- */
- int getNameRegionTextEndOffset();
-
- /**
- * Gets the source location of the start of the attribute value.
- *
- * @return int - returns the source location of the start of the attribute
- * value.
- *
- * ISSUE: need to better spec interaction with quote marks
- */
- int getValueRegionStartOffset();
-
- /**
- * Gets the text associated with the attribute value.
- *
- * @return String - returns the text associated with the attribute value.
- */
- String getValueRegionText();
-
- /**
- * Check if Attr has a nested value (such as a JSP expression).
- *
- * @return true if contains a nested value, false otherwise.
- */
- boolean hasNestedValue();
-
- /**
- * Check if Attr has only name but not equal sign nor value.
- *
- * @return true if has only name but not equal sign nor value.
- */
- boolean hasNameOnly();
-
- /**
- * Returns true if attribute is defined globally for document. Returns
- * false if attribute is preceeded by a prefix (whether valid name space
- * or not). Returns true if its owning element is a global element.
- *
- * @return true if attribute is defined globally for document. Returns
- * false if attribute is preceeded by a prefix (whether valid name
- * space or not). Returns true if its owning element is a global
- * element.
- */
- boolean isGlobalAttr();
-
- /**
- * Returns true if is xml attr
- *
- * ISSUE: need to figure out how to specify this one in a meaningful way.
- *
- * @return boolean - returns true if is xml attr
- */
- boolean isXMLAttr();
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocument.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocument.java
deleted file mode 100644
index 4d69e58301..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocument.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.provisional.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * This interface enables creation of DOCTYPE declaration and some DOM Level 2
- * interfaces. May be referenced but not implemented by clients.
- *
- * @plannedfor 1.0
- */
-public interface IDOMDocument extends Node, Document, IDOMNode {
-
- /**
- * create comment element. tagName must be registered as comment element
- * name in plugin.xml
- *
- * @param tagName
- * the element name
- * @param isJSPTag
- * true if the element is JSP style comment (&lt;%-- ...
- * --%&gt;)
- * @return Element element instance
- * @throws DOMException
- * thrown if the element name is registered as comment element
- */
- Element createCommentElement(String tagName, boolean isJSPTag) throws DOMException;
-
- /**
- * Creates a DocumentType node
- *
- * ISSUE: I believe this 'name' is the one specific in doctype extension,
- * need to verify.
- *
- * @param name -
- * name of the doctype
- * @return DocumentType - returns a document type node.
- */
- DocumentType createDoctype(String name);
-
- /**
- * Returns the DocumentType ID. Unlike the standard DOM approach of
- * "getDocumentType().getPublicId()", this method returns the id even if
- * implicit.
- *
- * @return the DocumentType ID
- */
- String getDocumentTypeId();
-
- /**
- * NOT API ... needs to be removed/changed
- *
- * ISSUE: need to specify
- *
- * @deprecated
- *
- * @return true if is JSPDocument
- *
- */
- boolean isJSPDocument();
-
- /**
- * NOT API ... needs to be removed/changed
- *
- * ISSUE: need to specify
- *
- * @deprecated
- *
- */
- boolean isJSPType();
-
- /**
- * NOT API ... may removed/changed
- *
- * ISSUE: need to specify -- currently used to denote an HTML DOM document
- * is XHTML
- *
- * @deprecated
- *
- */
- boolean isXMLType();
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocumentType.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocumentType.java
deleted file mode 100644
index 602c65e07c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMDocumentType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-
-
-import org.w3c.dom.DocumentType;
-
-/**
- * This interface enables setting of Public and System ID for DOCTYPE
- * declaration.
- *
- * @plannedfor 1.0
- */
-public interface IDOMDocumentType extends IDOMNode, DocumentType {
-
-
- /**
- * Sets document type's public id, as source.
- *
- * @param String -
- * the publicId
- */
- void setPublicId(String publicId);
-
- /**
- * Sets docment type's system id, as source.
- *
- * @param String -
- * the systemId
- */
- void setSystemId(String systemId);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMElement.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMElement.java
deleted file mode 100644
index fcd7763397..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMElement.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-
-/**
- * This interface provides extensions to corresponding DOM interface to enable
- * functions for source editing and incremental parsing.
- *
- * @plannedfor 1.0
- *
- */
-public interface IDOMElement extends IDOMNode, Element {
-
- /**
- * Retuns the start offset of the end tag.
- *
- * ISSUE: need to sort out need for this
- *
- * @return int - the start offset of the end tag.
- */
- int getEndStartOffset();
-
- /**
- * Returns the end offset of the
- *
- * ISSUE: need to sort out need for this
- *
- * @return int - the end offset of the start tag.
- */
- int getStartEndOffset();
-
- /**
- * Returns true if has an end tag.
- *
- * In our source-oriented DOM, sometimes Elements are "ended", even
- * without an explicit end tag in the source.
- *
- * @return true if has an end tag.
- */
- boolean hasEndTag();
-
- /**
- * returns true if has a start tag.
- *
- * In our source-oriented DOM, a lone end tag will cause a node to be
- * created in the tree, unlike well-formed-only DOMs.
- *
- * @return true if has a start tag.
- */
- boolean hasStartTag();
-
- /**
- * returns true if this element is a comment element
- *
- * @return true if this element is a comment element
- */
- boolean isCommentTag();
-
- /**
- * isEmptyTag method
- *
- * @return boolean - true if is empty tag, false otherwise
- */
- boolean isEmptyTag();
-
- /**
- * Returns true if floating end tag.
- *
- * @return true if floating end tag.
- */
- boolean isEndTag();
-
- /**
- * Returns true for "global tag" (basically, without prefix)
- *
- * @return true for "global tag" (basically, without prefix)
- */
- boolean isGlobalTag();
-
- /**
- * Returns true for no start and the end tags in source.
- *
- * Provided for some very special cases when, for example, and HTML tag is
- * assumed in an HTML document that does not have a literal HTML tag.
- *
- * ISSUE: check with clients to see if still needed
- *
- * @return true or no start and the end tags in source.
- */
- boolean isImplicitTag();
-
- /**
- * isJSPTag method
- *
- * @return boolean
- *
- * ISSUE: change to isContainerLanguageTag(String type);
- */
- boolean isJSPTag();
-
- /**
- * Returns true if start tag is closed.
- *
- * @return true if start tag is closed.
- */
- boolean isStartTagClosed();
-
- /**
- * returns true if is xml tag
- *
- * ISSUE: need to spec this better.
- *
- * @return true if is xml tag
- */
- boolean isXMLTag();
-
- /**
- * NOT CLIENT API
- *
- * notifyEndTagChanged
- *
- */
- void notifyEndTagChanged();
-
- /**
- * NOT CLIENT API
- *
- * notifyStartTagChanged
- *
- */
- void notifyStartTagChanged();
-
- /**
- * NOT CLIENT API
- *
- * Signify that this tag is a comment
- *
- * For use only by parsers.
- *
- */
- void setCommentTag(boolean isCommentTag);
-
- /**
- * NOT CLIENT API
- *
- * Signify that this tag is an empty tag
- *
- * For use only by parsers
- */
- void setEmptyTag(boolean isEmptyTag);
-
- /**
- * NOT CLIENT API
- *
- * Signify that this tag is a JSP tag
- *
- * For use only by parsers
- *
- * ISSUE: I have had one non-parsing client who has had to use this ...
- * need to check
- *
- */
- void setJSPTag(boolean isJSPTag);
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttribute(String name, boolean isId);
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttributeNS(String namespaceURI, String localName, boolean isId);
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation for DOM 3.
- */
- public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException;
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMEntity.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMEntity.java
deleted file mode 100644
index 3e22ec0587..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.provisional.document;
-
-import org.w3c.dom.Entity;
-
-public interface IDOMEntity extends Entity {
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation of DOM 3.
- */
- public String getInputEncoding();
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation of DOM 3.
- */
- public String getXmlEncoding();
-
- /**
- * NOT IMPLEMENTED. Is defined here in preparation of DOM 3.
- */
- public String getXmlVersion();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMImplementation.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMImplementation.java
deleted file mode 100644
index da73e24db4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMImplementation.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.internal.provisional.document;
-
-public interface IDOMImplementation {
-
- /**
- * NOT IMPLEMENTED. This is defined here in preparation of DOM 3.
- *
- * This method returns a specialized object which implements the
- * specialized APIs of the specified feature and version, as specified in .
- * The specialized object may also be obtained by using binding-specific
- * casting methods but is not necessarily expected to, as discussed in .
- * This method also allow the implementation to provide specialized
- * objects which do not support the <code>DOMImplementation</code>
- * interface.
- *
- * @param feature
- * The name of the feature requested. Note that any plus sign
- * "+" prepended to the name of the feature will be ignored
- * since it is not significant in the context of this method.
- * @param version
- * This is the version number of the feature to test.
- * @return Returns an object which implements the specialized APIs of the
- * specified feature and version, if any, or <code>null</code>
- * if there is no object which implements interfaces associated
- * with that feature. If the <code>DOMObject</code> returned by
- * this method implements the <code>DOMImplementation</code>
- * interface, it must delegate to the primary core
- * <code>DOMImplementation</code> and not return results
- * inconsistent with the primary core
- * <code>DOMImplementation</code> such as
- * <code>hasFeature</code>, <code>getFeature</code>, etc.
- * @see DOM Level 3
- */
- public Object getFeature(String feature, String version);
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMModel.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMModel.java
deleted file mode 100644
index 3effc7ef0f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMModel.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.document.XMLModelNotifier;
-
-/**
- * Provides means to get the XMLModel form of IStrucutredModel. Not to be
- * implemented or extended by clients.
- *
- * @plannedfor 1.0
- */
-public interface IDOMModel extends IStructuredModel {
-
- /**
- * Returns the DOM Document.
- *
- * @return the DOM Document.
- */
- IDOMDocument getDocument();
-
- /**
- *
- * Returns an source generator appropriate for this model.
- *
- * @return the source generator
- */
- ISourceGenerator getGenerator();
-
- /**
- * NOT CLIENT API
- *
- * Returns an XMLModelNotifier. Clients should not use.
- *
- * ISSUE: should be "internalized".
- *
- */
- XMLModelNotifier getModelNotifier();
-
- /**
- * NOT CLIENT API
- *
- * Sets the model notifier Clients should not use.
- *
- * ISSUE: need to review with legacy clients.
- */
- void setModelNotifier(XMLModelNotifier notifier);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMNode.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMNode.java
deleted file mode 100644
index ed8875f671..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMNode.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.provisional.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.document.InvalidCharacterException;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-
-/**
- * This interface describes the extended functionality of our source-oriented
- * DOM. First, our nodes extend the w3c Node interface, IndexedRegion, and
- * INodeNotifier. Plus, has the extra methods called out here.
- *
- * ISSUE: the 'read-only' API should be broken out in their own interface
- *
- * @plannedfor 1.0
- *
- */
-public interface IDOMNode extends IndexedRegion, INodeNotifier, Node {
-
- /**
- * Gets the last structured document region of this node.
- *
- * ISSUE: need to resolve getEnd/getLast confusion.
- *
- * @return IStructuredDocumentRegion - returns the last structured
- * document region associated with
- */
- IStructuredDocumentRegion getEndStructuredDocumentRegion();
-
- /**
- * Gets the first structured document region of this node.
- *
- * ISSUE: need to resolve getFirst/getStart confusion
- *
- * @return the first structured document region of this node.
- */
- IStructuredDocumentRegion getFirstStructuredDocumentRegion();
-
- /**
- * Gets the last structured document region of this node.
- *
- * ISSUE: need to resolve getEnd/getLast confusion.
- *
- * @return IStructuredDocumentRegion - returns the last structured
- * document region associated with
- */
- IStructuredDocumentRegion getLastStructuredDocumentRegion();
-
- /**
- * Returns the model associated with this node. Returns null if not part
- * of an active model.
- *
- * @return IDOMModel - returns the IDOMModel this node is part of.
- */
- IDOMModel getModel();
-
- /**
- * Get's the region representing the name of this node
- *
- * ISSUE: only implemented/used at attribute and DTDNodes -- should move.
- *
- * @return ITextRegion - returns the ITextRegion associated with this
- * Node.
- *
- * @deprecated
- */
- ITextRegion getNameRegion();
-
- /**
- * Returns the literal source representing this node in source document.
- *
- * ISSUE: need to fix implementation to match.
- *
- * @return the literal source representing this node in source document.
- */
- String getSource();
-
- /**
- * Gets the first structured document region of this node.
- *
- * ISSUE: need to resolve getFirst/getStart confusion
- *
- * @return the first structured document region of this node.
- */
- IStructuredDocumentRegion getStartStructuredDocumentRegion();
-
- /**
- * Returns the structured document that underlies this node's model.
- *
- * Returns null if this node is not actively part of a source document. In
- * contrast, in the pure DOM world, "owning document" is not null even
- * after a node is deleted from the DOM.
- *
- * ISSUE: we need to fix our implementation to match this spec.
- *
- * @return the structured document.
- */
- IStructuredDocument getStructuredDocument();
-
- /**
- * Get's the region representing the value of this node if only one
- * ITextRegion, null otherwise.
- *
- * ISSUE: only implemented/used at attribute level, move "down".
- *
- * @return ITextRegion - returns the ITextRegion associated with this
- * Node.
- *
- * @deprecated
- */
- ITextRegion getValueRegion();
-
- /**
- * Returns a string representing the source of this node, but with
- * character enties converted (e.g. &lt; is converted to '<').
- *
- * ISSUE: need to better spec extent of this conversion, we may not know
- * all character entities.
- *
- * ISSUE: need to fix implementation to match spec.
- *
- * @return String - get's the source of this Node.
- */
- String getValueSource();
-
- /**
- * Used to know read-only state of children.
- *
- * @return boolean Whether children of the element can be appended or
- * removed.
- */
- boolean isChildEditable();
-
- /**
- * Returns true if tag is closed in source.
- *
- * In our source orient DOM we sometimes end a Node without it being
- * explicitly closed in source.
- *
- * @return boolean - true if node is closed
- */
- boolean isClosed();
-
- /**
- * Returns true if this node can contain children.
- *
- * @return boolean - true if this node can contain children.
- */
- boolean isContainer();
-
- /**
- * Used to know read-only state of data.
- *
- */
- boolean isDataEditable();
-
- /**
- * Set's readonly state of children
- *
- */
- void setChildEditable(boolean editable);
-
- /**
- * Set's readonly state of data
- *
- */
- void setDataEditable(boolean editable);
-
- /**
- * Sets readonly state of data
- *
- * faster approach to set read-only state.
- */
- void setEditable(boolean editable, boolean deep);
-
- /**
- * Sets the specified raw source to the Text node. Throws
- * InvalidCharacterException when the specified raw source includes
- * invalid characters, such as, ' <', '>' and '&'. Valid character
- * entities, such as, "&amp;lt;", are accepted.
- */
- void setSource(String source) throws InvalidCharacterException;
-
- /**
- * Sets the specified raw source to the Text or Attr node's value. When
- * the specified raw source includes invalid characters, such as, ' <',
- * '>' and '&', converts them. Valid character entities, such as,
- * "&amp;lt;", are accepted.
- */
- void setValueSource(String source);
-
-
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public short compareDocumentPosition(Node other) throws DOMException;
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String getBaseURI();
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public Object getFeature(String feature, String version);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String getTextContent() throws DOMException;
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public Object getUserData(String key);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isDefaultNamespace(String namespaceURI);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isEqualNode(Node arg);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isSameNode(Node other);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String lookupNamespaceURI(String prefix);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public String lookupPrefix(String namespaceURI);
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public void setTextContent(String textContent) throws DOMException;
-
-
- /**
- * NOT IMPLEMENTED, is defined here in preparation of DOM Level 3
- */
- public boolean isId();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMText.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMText.java
deleted file mode 100644
index 67cec3bc7d..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/IDOMText.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Text;
-
-/**
- * This interface provides extensions to corresponding DOM interface to enable
- * functions for source editing and incremental parsing.
- *
- * @plannedfor 1.0
- *
- */
-public interface IDOMText extends IDOMNode, Text {
-
- /**
- * NOT API - can be eliminated or moved to ltk level
- *
- * Appends the content of the text node
- *
- * @param text -
- * the Text to append.
- */
- void appendText(Text text);
-
- /**
- * NOT API - can be eliminated or moved to ltk level
- *
- * Returns true if is not valid.
- */
- boolean isInvalid();
-
- /**
- * Returns true if is entirely white space.
- *
- * This is intened to be better performing that all clients getting the
- * source, and checking themselves.
- *
- * ISSUE: need to clarify if implementation is pure to "white space" as
- * per DOM spec? Here is the DOM spec:
- *
- * Returns whether this text node contains <a
- * href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
- * element content whitespace</a>, often abusively called "ignorable
- * whitespace". The text node is determined to contain whitespace in
- * element content during the load of the document or if validation occurs
- * while using <code>Document.normalizeDocument()</code>.
- *
- * @see DOM Level 3
- *
- * @return true if is entirely white space.
- */
-
- public boolean isElementContentWhitespace();
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Text#getWholeText()
- */
- public String getWholeText();
-
- /**
- * NOT YET IMPLEMENTED but exists here interface in preparation for DOM3
- *
- * Replaces the text of the current node and all logically-adjacent text
- * nodes with the specified text. All logically-adjacent text nodes are
- * removed including the current node unless it was the recipient of the
- * replacement text. <br>
- * This method returns the node which received the replacement text. The
- * returned node is:
- * <ul>
- * <li><code>null</code>, when the replacement text is the empty
- * string; </li>
- * <li>the current node, except when the current node is read-only; </li>
- * <li> a new <code>Text</code> node of the same type (
- * <code>Text</code> or <code>CDATASection</code>) as the current
- * node inserted at the location of the replacement. </li>
- * </ul>
- * <br>
- * For instance, in the above example calling
- * <code>replaceWholeText</code> on the <code>Text</code> node that
- * contains "bar" with "yo" in argument results in the following: <br>
- * Where the nodes to be removed are read-only descendants of an
- * <code>EntityReference</code>, the <code>EntityReference</code>
- * must be removed instead of the read-only nodes. If any
- * <code>EntityReference</code> to be removed has descendants that are
- * not <code>EntityReference</code>, <code>Text</code>, or
- * <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
- * method must fail before performing any modification of the document,
- * raising a <code>DOMException</code> with the code
- * <code>NO_MODIFICATION_ALLOWED_ERR</code>. <br>
- * For instance, in the example below calling
- * <code>replaceWholeText</code> on the <code>Text</code> node that
- * contains "bar" fails, because the <code>EntityReference</code> node
- * "ent" contains an <code>Element</code> node which cannot be removed.
- *
- * @param content
- * The content of the replacing <code>Text</code> node.
- * @return The <code>Text</code> node created with the specified
- * content.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the
- * <code>Text</code> nodes being replaced is readonly.
- * @see DOM Level 3
- */
- public Text replaceWholeText(String content) throws DOMException;
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/ISourceGenerator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/ISourceGenerator.java
deleted file mode 100644
index 473048cd52..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/document/ISourceGenerator.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.provisional.document;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-/**
- *
- * ISourceGenerator allows DOM models to generate source appropriate for their
- * parameter, relative to the model that provides the source generator.
- *
- */
-
-public interface ISourceGenerator {
-
- /**
- * Generate attribute name.
- *
- * @param attr -
- * the Attr
- * @return String - the string generated
- */
- String generateAttrName(Attr attr);
-
- /**
- * generateAttrValue
- *
- * @param attr -
- * the Attr
- * @return String - the string generated
- */
- String generateAttrValue(Attr attr);
-
- /**
- * generateAttrValue
- *
- * @param attr -
- * the Attr
- * @param char -
- * the type of quote desired (' or ").
- * @return String - the string generated
- */
- String generateAttrValue(Attr attr, char quote);
-
- /**
- * generateAttrValue
- *
- * @param value
- * the String value
- * @param char -
- * the type of quote desired (' or ").
- * @return String - the string generated
- */
- String generateAttrValue(String value, char quote);
-
- /**
- * generateCDATASection method
- *
- * @param comment
- * CDATASection
- * @return String - the string generated
- */
- String generateCDATASection(CDATASection cdata);
-
- /**
- * generateChild method
- *
- * @return String
- * @param Node
- * @return String - the string generated
- */
- String generateChild(Node parentNode);
-
- /**
- * generateCloseTag
- *
- * @param node -
- * the Node
- * @return String - the string generated
- */
- String generateCloseTag(Node node);
-
- /**
- * generateComment method
- *
- * @param comment
- * org.w3c.dom.Comment
- * @return String - the string generated
- */
- String generateComment(Comment comment);
-
- /**
- * generateDoctype method
- *
- * @param docType
- * DocumentType
- * @return String - the string generated
- */
- String generateDoctype(DocumentType docType);
-
- /**
- * generateElement method
- *
- * @param element -
- * Element
- * @return String - the string generated
- */
- String generateElement(Element element);
-
- /**
- * generateEndTag method
- *
- * @param element -
- * Element
- * @return String - the string generated
- */
- String generateEndTag(Element element);
-
- /**
- * generateEntityRef method
- *
- * @param entityRef
- * EntityReference
- * @return String - the string generated
- */
- String generateEntityRef(EntityReference entityRef);
-
- /**
- * generatePI method
- *
- * @param pi -
- * ProcessingInstruction
- * @return String - the string generated
- */
- String generatePI(ProcessingInstruction pi);
-
- /**
- * generateSource method
- *
- * @param node -
- * the Node
- * @return String - the string generated
- */
- String generateSource(Node node);
-
- /**
- * generateStartTag method
- *
- * @param element
- * Element
- * @return String - the string generated
- */
- String generateStartTag(Element element);
-
- /**
- * Generate tag name.
- *
- * @param element -
- * element
- * @return String - the string generated
- */
- String generateTagName(Element element);
-
- /**
- * generateText method
- *
- * @param text -
- * the Text
- * @return String - the string generated
- */
- String generateText(Text text);
-
- /**
- * generate text data
- *
- * @param text -
- * the Text
- * @param data -
- * the data
- * @return String - the string generated
- */
- String generateTextData(Text text, String data);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java
deleted file mode 100644
index 7fba90580a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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
- * David Carver (STAR) - bug 296999 - Inefficient use of new String()
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-
-
-public class CommentNodeFormatter extends NodeFormatter {
- static private final String CR = "\r"; //$NON-NLS-1$
- static private final String LF = "\n"; //$NON-NLS-1$
-
- protected String adjustIndentations(String aString, String lineIndent, String singleIndent) {
- String result = NodeFormatter.EMPTY_STRING;
-
- int indexOfLineDelimiter = StringUtils.indexOfLineDelimiter(aString);
- result = aString.substring(0, indexOfLineDelimiter);
- while (indexOfLineDelimiter != -1) {
- // Before find the next LineDelimiter, we have to figure out the
- // size of the current LineDelimiter
- // so we can figure out how many bytes to skip before finding the
- // next LineDelimiter.
- // Otherwise, we may treat the LF in CRLF as the next
- // LineDelimiter.
- int lineDelimiterSize = 1;
- if (aString.length() >= indexOfLineDelimiter + 2 && aString.substring(indexOfLineDelimiter, indexOfLineDelimiter + 1).compareTo(CR) == 0 && aString.substring(indexOfLineDelimiter + 1, indexOfLineDelimiter + 2).compareTo(LF) == 0)
- lineDelimiterSize = 2;
-
- int indexOfNextLineDelimiter = StringUtils.indexOfLineDelimiter(aString, indexOfLineDelimiter + lineDelimiterSize);
- int indexOfNonblank = StringUtils.indexOfNonblank(aString, indexOfLineDelimiter);
-
- if (indexOfNonblank != -1) {
- if (indexOfNextLineDelimiter == -1) {
- // last line; copy till the end
- result += lineIndent + singleIndent + aString.substring(indexOfNonblank);
- } else if (indexOfNextLineDelimiter != -1 && indexOfNextLineDelimiter < indexOfNonblank) {
- // blank line; just add a indent
- result += lineIndent + singleIndent;
- } else {
- // copy all text between indexOfNonblank and
- // indexOfNextLineDelimiter
- result += lineIndent + singleIndent + aString.substring(indexOfNonblank, indexOfNextLineDelimiter);
- }
-
- indexOfLineDelimiter = indexOfNextLineDelimiter;
- } else {
- if (indexOfNextLineDelimiter == -1) {
- result += lineIndent;
- } else {
- // blank line; just add a indent
- result += lineIndent + singleIndent;
- }
-
- indexOfLineDelimiter = indexOfNextLineDelimiter;
- }
- }
-
- return result;
- }
-
- protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- // lineDelimiterFound means multi line comment
- String nodeValue = node.getNodeValue();
- boolean lineDelimiterFoundInComment = StringUtils.containsLineDelimiter(nodeValue);
-
- if (lineDelimiterFoundInComment) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // adjust indentations in multi line comment
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- String lineIndent = formatContraints.getCurrentIndent();
- String singleIndent = getFormatPreferences().getIndent();
- String newNodevalue = adjustIndentations(nodeValue, lineDelimiter + lineIndent, singleIndent);
- if (nodeValue.compareTo(newNodevalue) != 0)
- node.setNodeValue(newNodevalue);
- }
-
- if (!nodeHasSiblings(node) || (node.getPreviousSibling() != null && node.getPreviousSibling().getNodeType() == Node.TEXT_NODE && !StringUtils.containsLineDelimiter(node.getPreviousSibling().getNodeValue()) && node.getNextSibling() == null)) {
- // single child
- // or inline comment after text
- // do nothing
- } else
- // format indentation after node
- formatIndentationAfterNode(node, formatContraints);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/DocumentNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/DocumentNodeFormatter.java
deleted file mode 100644
index 297df28a1f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/DocumentNodeFormatter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jesper Steen Møller - xml:space='preserve' support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-
-public class DocumentNodeFormatter extends NodeFormatter {
- protected void formatChildren(IDOMNode node, IStructuredFormatContraints formatContraints) {
- String singleIndent = getFormatPreferences().getIndent();
- String lineIndent = formatContraints.getCurrentIndent();
-
- if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- // normalize node first to combine adjacent text nodes
- node.normalize();
-
- IDOMNode nextChild = (IDOMNode) node.getFirstChild();
- while (nextChild != null) {
- IDOMNode eachChildNode = nextChild;
- nextChild = (IDOMNode) eachChildNode.getNextSibling();
- IStructuredFormatter formatter = getFormatter(eachChildNode);
- IStructuredFormatContraints childFormatContraints = formatter.getFormatContraints();
- String childIndent = lineIndent + singleIndent;
- childFormatContraints.setCurrentIndent(childIndent);
- childFormatContraints.setClearAllBlankLines(formatContraints.getClearAllBlankLines());
- childFormatContraints.setInPreserveSpaceElement(formatContraints.getInPreserveSpaceElement());
-
- // format each child
- formatter.format(eachChildNode, childFormatContraints);
-
- if (nextChild != null && nextChild.getParentNode() == null)
- // nextNode is deleted during format
- nextChild = (IDOMNode) eachChildNode.getNextSibling();
- }
- }
- }
-
- protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- if (node != null)
- formatChildren(node, formatContraints);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java
deleted file mode 100644
index 6baf55b456..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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
- * Jesper Steen Møller - xml:space='preserve' support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-public class ElementNodeFormatter extends DocumentNodeFormatter {
- static private final char DOUBLE_QUOTE = '"';//$NON-NLS-1$
- static private final String DOUBLE_QUOTES = "\"\"";//$NON-NLS-1$
- static private final char EQUAL_CHAR = '='; // equal sign$NON-NLS-1$
- static private final String PRESERVE = "preserve";//$NON-NLS-1$
- static private final String PRESERVE_QUOTED = "\"preserve\"";//$NON-NLS-1$
- static private final char SINGLE_QUOTE = '\'';//$NON-NLS-1$
- static private final String XML_SPACE = "xml:space";//$NON-NLS-1$
- static private final char SPACE_CHAR = ' '; //$NON-NLS-1$
- static private final String XSL_NAMESPACE = "http://www.w3.org/1999/XSL/Transform"; //$NON-NLS-1$
- static private final String XSL_ATTRIBUTE = "attribute"; //$NON-NLS-1$
- static private final String XSL_TEXT = "text"; //$NON-NLS-1$
-
- protected void formatEndTag(IDOMNode node, IStructuredFormatContraints formatContraints) {
- if (!isEndTagMissing(node)) {
- // end tag exists
-
- IStructuredDocument structuredDocument = node.getModel().getStructuredDocument();
- String lineDelimiter = structuredDocument.getLineDelimiter();
- String nodeIndentation = getNodeIndent(node);
- IDOMNode lastChild = (IDOMNode) node.getLastChild();
- if (lastChild != null && lastChild.getNodeType() != Node.TEXT_NODE) {
- if (isEndTagMissing(lastChild)) {
- // find deepest child
- IDOMNode deepestChild = (IDOMNode) lastChild.getLastChild();
- while (deepestChild != null && deepestChild.getLastChild() != null && isEndTagMissing(deepestChild)) {
- lastChild = deepestChild;
- deepestChild = (IDOMNode) deepestChild.getLastChild();
- }
-
- if (deepestChild != null) {
- if (deepestChild.getNodeType() == Node.TEXT_NODE) {
- // Special indentation handling if lastChild's end
- // tag is missing and deepestChild is a text node.
- String nodeText = deepestChild.getNodeValue();
-
- if (!nodeText.endsWith(lineDelimiter + nodeIndentation)) {
- nodeText = StringUtils.appendIfNotEndWith(nodeText, lineDelimiter);
- nodeText = StringUtils.appendIfNotEndWith(nodeText, nodeIndentation);
- }
-
- replaceNodeValue(deepestChild, nodeText);
- }
- else
- insertAfterNode(lastChild, lineDelimiter + nodeIndentation);
- }
- }
- else
- // indent end tag
- insertAfterNode(lastChild, lineDelimiter + nodeIndentation);
- }
- else if (lastChild == null && firstStructuredDocumentRegionContainsLineDelimiters(node)) {
- // BUG174243 do not indent end tag if node has empty content
- // (otherwise new text node would be introduced)
- ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
- CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node);
- if ((elementDeclaration == null) || (elementDeclaration.getContentType() != CMElementDeclaration.EMPTY)) {
- // indent end tag
- replace(structuredDocument, node.getFirstStructuredDocumentRegion().getEndOffset(), 0, lineDelimiter + nodeIndentation);
- }
- }
-
- // format end tag name
- IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion.getRegions().size() >= 3) {
- ITextRegion endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1);
- removeRegionSpaces(node, endTagStructuredDocumentRegion, endTagNameRegion);
- }
- }
- }
-
- protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // format start tag
- IDOMNode newNode = node;
- int startTagStartOffset = node.getStartOffset();
- IDOMModel structuredModel = node.getModel();
-
- boolean currentlyInXmlSpacePreserve = formatContraints.getInPreserveSpaceElement();
- formatStartTag(node, formatContraints);
- // save new node
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset);
-
- IStructuredDocumentRegion flatNode = newNode.getFirstStructuredDocumentRegion();
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- // format children and end tag if not empty start tag
- if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- // format children
- formatChildren(newNode, formatContraints);
-
- // save new node
- newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset);
-
- // format end tag
- formatEndTag(newNode, formatContraints);
- }
- }
-
- formatContraints.setInPreserveSpaceElement(currentlyInXmlSpacePreserve);
- // only indent if not at last node
- if (newNode != null && newNode.getNextSibling() != null)
- // format indentation after node
- formatIndentationAfterNode(newNode, formatContraints);
- }
- }
-
- /**
- * This method formats the start tag name, and formats the attributes if
- * available.
- */
- protected void formatStartTag(IDOMNode node, IStructuredFormatContraints formatContraints) {
- StructuredFormatPreferencesXML preferences = (StructuredFormatPreferencesXML) getFormatPreferences();
- String singleIndent = preferences.getIndent();
- String lineIndent = formatContraints.getCurrentIndent();
- String attrIndent = lineIndent + singleIndent;
- boolean splitMultiAttrs = preferences.getSplitMultiAttrs();
- boolean alignEndBracket = preferences.isAlignEndBracket();
- boolean sawXmlSpace = false;
-
- IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
- NamedNodeMap attributes = node.getAttributes();
-
- // Note: attributes should not be null even if the node has no
- // attributes. However, attributes.getLength() will be 0. But, check
- // for null just in case.
- if (attributes != null) {
- // compute current available line width
- int currentAvailableLineWidth = 0;
- try {
- // 1 is for "<"
- int nodeNameOffset = node.getStartOffset() + 1 + node.getNodeName().length();
- int lineOffset = node.getStructuredDocument().getLineInformationOfOffset(nodeNameOffset).getOffset();
- String text = node.getStructuredDocument().get(lineOffset, nodeNameOffset - lineOffset);
- int usedWidth = getIndentationLength(text);
- currentAvailableLineWidth = preferences.getLineWidth() - usedWidth;
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
-
- StringBuffer stringBuffer = new StringBuffer();
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- int attrLength = attributes.getLength();
- int lastUndefinedRegionOffset = 0;
- boolean startTagSpansOver1Line = false;
-
- for (int i = 0; i < attrLength; i++) {
- AttrImpl attr = (AttrImpl) attributes.item(i);
- ITextRegion nameRegion = attr.getNameRegion();
- ITextRegion equalRegion = attr.getEqualRegion();
- ITextRegion valueRegion = attr.getValueRegion();
-
- // append undefined regions
- String undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, attr.getStartOffset() - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = attr.getStartOffset();
-
- // check for xml:space attribute
- if (flatNode.getText(nameRegion).compareTo(XML_SPACE) == 0) {
- if (valueRegion == null) {
- // [111674] If nothing has been written yet, treat as
- // preserve, but only as hint
- formatContraints.setInPreserveSpaceElement(true);
- // Note we don't set 'sawXmlSpace', so that default or
- // fixed DTD/XSD values may override.
- }
- else {
- ISourceGenerator generator = node.getModel().getGenerator();
- String newAttrValue = generator.generateAttrValue(attr);
-
- // There is a problem in
- // StructuredDocumentRegionUtil.getAttrValue(ITextRegion)
- // when the region is instanceof ContextRegion.
- // Workaround for now.
- if (flatNode.getText(valueRegion).length() == 1) {
- char firstChar = flatNode.getText(valueRegion).charAt(0);
- if ((firstChar == DOUBLE_QUOTE) || (firstChar == SINGLE_QUOTE))
- newAttrValue = DOUBLE_QUOTES;
- }
-
- if (newAttrValue.compareTo(PRESERVE_QUOTED) == 0)
- formatContraints.setInPreserveSpaceElement(true);
- else
- formatContraints.setInPreserveSpaceElement(false);
- sawXmlSpace = true;
- }
- }
-
- if (splitMultiAttrs && attrLength > 1) {
- stringBuffer.append(lineDelimiter + attrIndent);
- stringBuffer.append(flatNode.getText(nameRegion));
- startTagSpansOver1Line = true;
- if (valueRegion != null) {
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(equalRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(equalRegion);
-
- stringBuffer.append(EQUAL_CHAR);
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(valueRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(valueRegion);
-
- // Note: trim() should not be needed for
- // valueRegion.getText(). Just a workaround for a
- // problem found in valueRegion for now.
- stringBuffer.append(flatNode.getText(valueRegion).trim());
- }
- }
- else {
- if (valueRegion != null) {
- int textLength = 1 + flatNode.getText(nameRegion).length() + 1 + flatNode.getText(valueRegion).length();
- if (i == attrLength - 1) {
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE)
- // 3 is for " />"
- textLength += 3;
- else
- // 1 is for ">"
- textLength++;
- }
- }
-
- if (currentAvailableLineWidth >= textLength) {
- stringBuffer.append(SPACE_CHAR);
- currentAvailableLineWidth--;
- }
- else {
- stringBuffer.append(lineDelimiter + attrIndent);
- startTagSpansOver1Line = true;
- currentAvailableLineWidth = preferences.getLineWidth() - attrIndent.length();
- }
-
- stringBuffer.append(flatNode.getText(nameRegion));
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(equalRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(equalRegion);
-
- stringBuffer.append(EQUAL_CHAR);
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(valueRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(valueRegion);
-
- // Note: trim() should not be needed for
- // valueRegion.getText(). Just a workaround for a
- // problem found in valueRegion for now.
- stringBuffer.append(flatNode.getText(valueRegion).trim());
-
- currentAvailableLineWidth -= flatNode.getText(nameRegion).length();
- currentAvailableLineWidth--;
- currentAvailableLineWidth -= flatNode.getText(valueRegion).trim().length();
- }
- else {
- if (currentAvailableLineWidth >= 1 + flatNode.getText(nameRegion).length()) {
- stringBuffer.append(SPACE_CHAR);
- currentAvailableLineWidth--;
- }
- else {
- stringBuffer.append(lineDelimiter + attrIndent);
- startTagSpansOver1Line = true;
- currentAvailableLineWidth = preferences.getLineWidth() - attrIndent.length();
- }
-
- stringBuffer.append(flatNode.getText(nameRegion));
-
- currentAvailableLineWidth -= flatNode.getText(nameRegion).length();
- }
- }
- }
-
- // append undefined regions
- String undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, node.getEndOffset() - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
-
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- // 1 is for "<"
- int offset = node.getStartOffset() + 1 + node.getNodeName().length();
- // 1 is for "<"
- int length = node.getFirstStructuredDocumentRegion().getTextLength() - 1 - node.getNodeName().length();
-
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion firstRegion = regions.get(0);
- ITextRegion lastRegion = regions.get(regions.size() - 1);
-
- if (firstRegion.getType() == DOMRegionContext.XML_END_TAG_OPEN)
- // skip formatting for end tags in this format: </tagName>
- return;
- else {
- if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE || lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
- length = length - lastRegion.getLength();
-
- if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- // leave space before XML_EMPTY_TAG_CLOSE: <tagName />
- // unless already going to move end bracket
- if (!startTagSpansOver1Line || !alignEndBracket)
- stringBuffer.append(SPACE_CHAR);
- }
- }
- }
-
- if (startTagSpansOver1Line && alignEndBracket) {
- stringBuffer.append(lineDelimiter).append(lineIndent);
- }
-
- replace(structuredDocument, offset, length, stringBuffer.toString());
-
- // BUG108074 & BUG84688 - preserve whitespace in xsl:text &
- // xsl:attribute
- String nodeNamespaceURI = node.getNamespaceURI();
- if (XSL_NAMESPACE.equals(nodeNamespaceURI)) {
- String nodeName = ((Element) node).getLocalName();
- if (XSL_ATTRIBUTE.equals(nodeName) || XSL_TEXT.equals(nodeName)) {
- sawXmlSpace = true;
- formatContraints.setInPreserveSpaceElement(true);
- }
- }
-
- // If we didn't see a xml:space attribute above, we'll look for
- // one in the DTD.
- // We do not check for a conflict between a DTD's 'fixed' value
- // and the attribute value found in the instance document, we
- // leave that to the validator.
- if (!sawXmlSpace) {
- ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
- CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node);
- if (elementDeclaration != null) {
- int contentType = elementDeclaration.getContentType();
- if (preferences.isPreservePCDATAContent() && contentType == CMElementDeclaration.PCDATA) {
- formatContraints.setInPreserveSpaceElement(true);
- }
- else {
- CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes();
- // Check implied values from the DTD way.
- CMAttributeDeclaration attributeDeclaration = (CMAttributeDeclaration) cmAttributes.getNamedItem(XML_SPACE);
- if (attributeDeclaration != null) {
- // CMAttributeDeclaration found, check it out.
- String defaultValue = attributeDeclaration.getAttrType().getImpliedValue();
-
- // xml:space="preserve" means preserve space,
- // everything else means back to default.
- if (PRESERVE.compareTo(defaultValue) == 0)
- formatContraints.setInPreserveSpaceElement(true);
- else
- formatContraints.setInPreserveSpaceElement(false);
- }
- }
- }
- }
- }
- }
-
- protected String getUndefinedRegions(IDOMNode node, int startOffset, int length) {
- String result = NodeFormatter.EMPTY_STRING;
-
- IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
- ITextRegionList regions = flatNode.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- String regionType = region.getType();
- int regionStartOffset = flatNode.getStartOffset(region);
-
- if (regionType.compareTo(DOMRegionContext.UNDEFINED) == 0 && regionStartOffset >= startOffset && regionStartOffset < startOffset + length)
- result = result + flatNode.getFullText(region);
- }
-
- if (result.length() > 0)
- return SPACE_CHAR + result.trim();
- else
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java
deleted file mode 100644
index a798dbdbda..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.provisional.format;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.w3c.dom.Node;
-
-public class FormatProcessorXML extends AbstractStructuredFormatProcessor {
- protected IStructuredFormatPreferences fFormatPreferences = null;
-
- protected String getFileExtension() {
- return "xml"; //$NON-NLS-1$
- }
-
- public IStructuredFormatPreferences getFormatPreferences() {
- if (fFormatPreferences == null) {
- fFormatPreferences = new StructuredFormatPreferencesXML();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setPreservePCDATAContent(preferences.getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
-
- char indentChar = ' ';
- String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
- if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
- indentChar = '\t';
- }
- int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
-
- StringBuffer indent = new StringBuffer();
- for (int i = 0; i < indentationWidth; i++) {
- indent.append(indentChar);
- }
- fFormatPreferences.setIndent(indent.toString());
- }
- }
-
- return fFormatPreferences;
- }
-
- protected IStructuredFormatter getFormatter(Node node) {
- // 262135 - NPE during format of empty document
- if (node == null)
- return null;
-
- short nodeType = node.getNodeType();
- IStructuredFormatter formatter = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE : {
- formatter = new ElementNodeFormatter();
- break;
- }
- case Node.TEXT_NODE : {
- formatter = new TextNodeFormatter();
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- formatter = new NoMoveFormatter();
- break;
- }
- case Node.COMMENT_NODE : {
- formatter = new CommentNodeFormatter();
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- formatter = new NodeFormatter();
- break;
- }
- case Node.DOCUMENT_NODE : {
- formatter = new DocumentNodeFormatter();
- break;
- }
- case Node.ENTITY_REFERENCE_NODE : {
- formatter = new NoMoveFormatter();
- break;
- }
- default : {
- formatter = new NodeFormatter();
- }
- }
-
- // init fomatter
- formatter.setFormatPreferences(getFormatPreferences());
- formatter.setProgressMonitor(fProgressMonitor);
-
- return formatter;
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void refreshFormatPreferences() {
- fFormatPreferences = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NoMoveFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NoMoveFormatter.java
deleted file mode 100644
index 7b68ece73e..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NoMoveFormatter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-/**
- * Formats entities which really need no formatting. They are just like text
- * nodes.
- */
-class NoMoveFormatter extends NodeFormatter {
- protected void formatIndentationBeforeNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // node nothing
- }
-
- protected void formatIndentationAfterNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // still do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java
deleted file mode 100644
index f48ed184bf..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java
+++ /dev/null
@@ -1,753 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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
- * Jesper Steen Møller - xml:space='preserve' support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
-import org.eclipse.wst.sse.core.internal.format.StructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
-import org.eclipse.wst.xml.core.internal.document.CharacterDataImpl;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.core.internal.parser.regions.TagNameRegion;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Node;
-
-public class NodeFormatter implements IStructuredFormatter {
- static protected final String EMPTY_STRING = ""; //$NON-NLS-1$
- static private final char SPACE_CHAR = ' '; //$NON-NLS-1$
- static private final char TAB_CHAR = '\t'; //$NON-NLS-1$
- static private final String TAB = "\t"; //$NON-NLS-1$
- protected IStructuredFormatContraints fFormatContraints = null;
- protected IStructuredFormatPreferences fFormatPreferences = null;
- protected IProgressMonitor fProgressMonitor = null;
-
- protected boolean firstStructuredDocumentRegionContainsLineDelimiters(IDOMNode node) {
- boolean result = false;
-
- if (node != null) {
- IStructuredDocumentRegion firstStructuredDocumentRegion = node.getFirstStructuredDocumentRegion();
- if (firstStructuredDocumentRegion != null) {
- String firstStructuredDocumentRegionText = firstStructuredDocumentRegion.getText();
- result = StringUtils.containsLineDelimiter(firstStructuredDocumentRegionText);
- }
- }
-
- return result;
- }
-
- public void format(Node node) {
- IStructuredFormatContraints formatContraints = getFormatContraints();
-
- format(node, formatContraints);
- }
-
- public void format(Node node, IStructuredFormatContraints formatContraints) {
- if (formatContraints.getFormatWithSiblingIndent())
- formatContraints.setCurrentIndent(getSiblingIndent(node));
-
- if (node instanceof IDOMNode)
- formatNode((IDOMNode) node, formatContraints);
- }
-
- protected void formatIndentationAfterNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // [111674] If inside xml:space="preserve" element, we bail
- if (formatContraints.getInPreserveSpaceElement())
- return;
- if (node != null) {
- IDOMNode nextSibling = (IDOMNode) node.getNextSibling();
- IStructuredDocument doc = node.getModel().getStructuredDocument();
- String lineDelimiter = getLineDelimiter(node, doc);
-
- if (node.getParentNode() != null) {
- if (node.getParentNode().getNodeType() == Node.DOCUMENT_NODE)
- if (nextSibling != null)
- if (nextSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(nextSibling).format(nextSibling, formatContraints);
- else if (nextSibling.getNodeType() == Node.COMMENT_NODE) {
- // do nothing
- }
- else {
- String lineIndent = formatContraints.getCurrentIndent();
- insertAfterNode(node, lineDelimiter + lineIndent);
- }
- else {
- }
-
- else if (nextSibling != null)
- if (nextSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(nextSibling).format(nextSibling, formatContraints);
- else if (nextSibling.getNodeType() == Node.COMMENT_NODE) {
- // do nothing
- }
- else {
- String lineIndent = formatContraints.getCurrentIndent();
- insertAfterNode(node, lineDelimiter + lineIndent);
- }
- else {
- IDOMNode indentNode = getParentIndentNode(node);
- String lineIndent = getNodeIndent(indentNode);
- IDOMNode lastChild = getDeepestChildNode(node);
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if (lastChild != null) {
- if ((lastChild.getNodeType() == Node.TEXT_NODE) && (lastChild.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((lastChild.getNodeType() == Node.TEXT_NODE) && (lastChild.getNodeValue() != null && lastChild.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines) {
- replaceNodeValue(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- insertAfterNode(lastChild, lineIndent);
- }
- else if (lastChild.getNodeType() == Node.TEXT_NODE)
- if (lastChild.getNodeValue().length() == 0) {
- // replace
- replaceNodeValue(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- insertAfterNode(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // as long as not at the end of the document
- IStructuredDocumentRegion endRegion = node.getLastStructuredDocumentRegion();
- if (endRegion != null && endRegion.getNext() != null)
- // append indentation
- insertAfterNode(lastChild, lineDelimiter + lineIndent);
- }
- }
- }
- }
- }
- }
-
- protected void formatIndentationBeforeNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // [111674] If inside xml:space="preserve" element, we bail
- if (formatContraints.getInPreserveSpaceElement())
- return;
- if (node != null) {
- IDOMNode previousSibling = (IDOMNode) node.getPreviousSibling();
- IStructuredDocument doc = node.getModel().getStructuredDocument();
- String lineDelimiter = getLineDelimiter(node, doc);
-
- String lineIndent = formatContraints.getCurrentIndent();
-
- if (node.getParentNode() != null) {
- if (node.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
- if (previousSibling != null)
- if (previousSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(previousSibling).format(previousSibling, formatContraints);
- else {
- insertBeforeNode(node, lineDelimiter + lineIndent);
- }
- }
- else {
- if (previousSibling == null || previousSibling.getNodeType() != Node.TEXT_NODE) {
- // 261968 - formatting tag without closing bracket:
- // <t1><t1
- // 265673 - Null ptr in formatIndentationBeforeNode
- int prevEndNodeOffset = -1;
- int prevEndRegionOffset = -1;
- if (previousSibling != null) {
- prevEndNodeOffset = previousSibling.getEndOffset();
- IStructuredDocumentRegion endRegion = previousSibling.getEndStructuredDocumentRegion();
- if (endRegion != null) {
- prevEndRegionOffset = endRegion.getTextEndOffset();
- }
- }
- if ((previousSibling == null) || (prevEndNodeOffset != -1 && prevEndNodeOffset == prevEndRegionOffset)) {
- insertBeforeNode(node, lineDelimiter + lineIndent);
- }
-
- }
- else {
- if (previousSibling.getNodeValue().length() == 0) {
- // replace
- replaceNodeValue(previousSibling, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- if (!previousSibling.getNodeValue().endsWith(lineDelimiter + lineIndent)) {
- if (previousSibling.getNodeValue().endsWith(lineDelimiter)) {
- insertAfterNode(previousSibling, lineIndent);
- }
- else
- getFormatter(previousSibling).format(previousSibling, formatContraints);
- }
- }
- }
- }
- }
- }
- }
-
- private String getLineDelimiter(IDOMNode node, IStructuredDocument doc) {
- int line = doc.getLineOfOffset(node.getStartOffset());
- String lineDelimiter = doc.getLineDelimiter();
- try {
- if (line > 0) {
- lineDelimiter = doc.getLineDelimiter(line - 1);
- }
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- // BUG115716: if cannot get line delimiter from current line, just
- // use default line delimiter
- if (lineDelimiter == null)
- lineDelimiter = doc.getLineDelimiter();
- return lineDelimiter;
- }
-
- protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // format indentation after node
- formatIndentationAfterNode(node, formatContraints);
- }
- }
-
- /**
- * This method will compute the correct indentation after this node
- * depending on the indentations of its sibling nodes and parent node. Not
- * needed anymore?
- */
- protected void formatTrailingText(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // [111674] If inside xml:space="preserve" element, we bail
- if (formatContraints.getInPreserveSpaceElement())
- return;
-
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- String lineIndent = formatContraints.getCurrentIndent();
- String parentLineIndent = getNodeIndent(node.getParentNode());
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE)) {
- IDOMNode nextSibling = (IDOMNode) node.getNextSibling();
- if ((nextSibling != null) && (nextSibling.getNodeType() == Node.TEXT_NODE)) {
- String nextSiblingText = nextSibling.getNodeValue();
- if (nextSibling.getNextSibling() == null)
- if ((nextSibling.getParentNode().getNodeType() == Node.DOCUMENT_NODE) && (nextSiblingText.trim().length() == 0))
- // delete spaces at the end of the document
- replaceNodeValue(nextSibling, EMPTY_STRING);
- else
- // replace the text node with parent indentation
- replaceNodeValue(nextSibling, lineDelimiter + parentLineIndent);
- else
- // replace the text node with indentation
- replaceNodeValue(nextSibling, lineDelimiter + lineIndent);
- }
- else {
- if (nextSibling == null) {
- lineIndent = parentLineIndent;
-
- if (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)
- if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines)
- replaceNodeValue(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNode(node, lineIndent);
- else if (node.getNodeType() == Node.TEXT_NODE)
- if (node.getNodeValue().length() == 0)
- // replace
- replaceNodeValue(node, lineDelimiter + lineIndent);
- else
- // append indentation
- if (!node.getNodeValue().endsWith(lineDelimiter + lineIndent))
- if (node.getNodeValue().endsWith(lineDelimiter))
- insertAfterNode(node, lineIndent);
- else
- insertAfterNode(node, lineDelimiter + lineIndent);
- else
- replaceNodeValue(node, lineDelimiter + lineIndent);
- }
- else {
- if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines)
- replaceNodeValue(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNode(node, lineIndent);
- else if (node.getNodeType() == Node.TEXT_NODE)
- if (node.getNodeValue().length() == 0)
- // replace
- replaceNodeValue(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNode(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNode(node, lineDelimiter + lineIndent);
- }
- }
- }
- }
-
- protected IDOMNode getDeepestChildNode(IDOMNode node) {
- IDOMNode result = null;
- IDOMNode lastChild = (IDOMNode) node.getLastChild();
-
- if (lastChild == null)
- result = node;
- else {
- result = getDeepestChildNode(lastChild);
-
- if ((result.getNodeType() == Node.TEXT_NODE || result.getNodeType() == Node.COMMENT_NODE) && !isEndTagMissing(node))
- result = node;
- }
-
- return result;
- }
-
- public IStructuredFormatContraints getFormatContraints() {
- if (fFormatContraints == null) {
- fFormatContraints = new StructuredFormatContraints();
-
- fFormatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines());
- }
-
- return fFormatContraints;
- }
-
- public IStructuredFormatPreferences getFormatPreferences() {
- if (fFormatPreferences == null) {
- fFormatPreferences = new StructuredFormatPreferencesXML();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
- ((StructuredFormatPreferencesXML) fFormatPreferences).setPreservePCDATAContent(preferences.getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
-
- char indentChar = ' ';
- String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
- if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
- indentChar = '\t';
- }
- int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
-
- StringBuffer indent = new StringBuffer();
- for (int i = 0; i < indentationWidth; i++) {
- indent.append(indentChar);
- }
- fFormatPreferences.setIndent(indent.toString());
- }
- }
-
- return fFormatPreferences;
- }
-
- protected IStructuredFormatter getFormatter(IDOMNode node) {
- // 262135 - NPE during format of empty document
- if (node == null)
- return null;
-
- short nodeType = ((Node) node).getNodeType();
- IStructuredFormatter formatter = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE : {
- formatter = new ElementNodeFormatter();
- break;
- }
- case Node.TEXT_NODE : {
- formatter = new TextNodeFormatter();
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- formatter = new NoMoveFormatter();
- break;
- }
- case Node.COMMENT_NODE : {
- formatter = new CommentNodeFormatter();
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- formatter = new NodeFormatter();
- break;
- }
- case Node.DOCUMENT_NODE : {
- formatter = new DocumentNodeFormatter();
- break;
- }
- case Node.ENTITY_REFERENCE_NODE : {
- formatter = new NoMoveFormatter();
- break;
- }
- default : {
- formatter = new NodeFormatter();
- }
- }
-
- // init fomatter
- formatter.setFormatPreferences(getFormatPreferences());
- formatter.setProgressMonitor(fProgressMonitor);
-
- return formatter;
- }
-
- protected int getIndentationLength(String indent) {
- // TODO Kit : The calculation of IndentationLength is not correct
- // here.
- // nodeIndentation may contain tabs. Multiply by 4 temporarily to get
- // approx. width.
- // Need to re-work.
-
- int indentationLength = 0;
-
- for (int i = 0; i < indent.length(); i++) {
- if (indent.substring(i, i + 1).compareTo(TAB) == 0)
- indentationLength += 4;
- else
- indentationLength++;
- }
-
- return indentationLength;
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- /**
- * This method will find the indentation for this node. It will search
- * backwards starting from the beginning of the node until a character
- * other than a space or a tab is found. If this node is null or it's a
- * document node or it's a first level node (node's parent is a document
- * node) the default empty string will be returned as the indentation.
- */
- protected String getNodeIndent(Node node) {
- String result = EMPTY_STRING;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && (node.getParentNode() != null) && (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)) {
- IDOMNode siblingTextNode = (IDOMNode) node.getPreviousSibling();
- if ((siblingTextNode != null) && (siblingTextNode.getNodeType() == Node.TEXT_NODE)) {
- // find the indentation
- String siblingText = siblingTextNode.getNodeValue();
- int siblingTextLength = siblingText.length();
- if ((siblingText != null) && (siblingTextLength > 0) && ((siblingText.charAt(siblingTextLength - 1) == SPACE_CHAR) || (siblingText.charAt(siblingTextLength - 1) == TAB_CHAR))) {
- int searchIndex = siblingTextLength - 1;
- while ((searchIndex >= 0) && ((siblingText.charAt(searchIndex) == SPACE_CHAR) || (siblingText.charAt(searchIndex) == TAB_CHAR)))
- searchIndex--;
-
- if (searchIndex < siblingTextLength)
- result = siblingText.substring(searchIndex + 1, siblingTextLength);
- }
- }
- }
-
- return result;
- }
-
- protected String getNodeName(IDOMNode node) {
- return node.getNodeName();
- }
-
- protected String getNodeText(IDOMNode node) {
- String text = null;
-
- if ((node instanceof CharacterDataImpl) && !(node instanceof CommentImpl) && !(node instanceof CDATASectionImpl) && !isJSPTag(node))
- text = ((CharacterDataImpl) node).getSource();
- else
- text = node.getFirstStructuredDocumentRegion().getText();
-
- return text;
- }
-
- protected IDOMNode getParentIndentNode(IDOMNode node) {
- IDOMNode result = null;
- IDOMNode parentNode = (IDOMNode) node.getParentNode();
-
- if (parentNode.getNodeType() == Node.DOCUMENT_NODE)
- result = parentNode;
- else {
- ITextRegion region = parentNode.getLastStructuredDocumentRegion().getFirstRegion();
- if (region.getType() == DOMRegionContext.XML_END_TAG_OPEN)
- result = parentNode;
- else
- result = getParentIndentNode(parentNode);
- }
-
- return result;
- }
-
- /**
- * This method will find the indentation for a node sibling to this node.
- * It will try to find a sibling node before this node first. If there is
- * no sibling node before this node, it will try to find a sibling node
- * after this node. If still not found, we will check if this node is
- * already indented from its parent. If yes, this node's indentation will
- * be used. Otherwise, the parent node's indentation plus one indentation
- * will be used. If this node is null or it's a document node or it's a
- * first level node (node's parent is a document node) the default empty
- * string will be returned as the indentation.
- */
- protected String getSiblingIndent(Node node) {
- String result = EMPTY_STRING;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && (node.getParentNode() != null) && (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)) {
- // find the text node before the previous non-text sibling
- // if that's not found, we will try the text node before the next
- // non-text sibling
- IDOMNode sibling = (IDOMNode) node.getPreviousSibling();
- while ((sibling != null) && (sibling.getNodeType() == Node.TEXT_NODE || sibling.getNodeType() == Node.COMMENT_NODE)) {
- if (sibling.getNodeType() == Node.COMMENT_NODE && sibling.getPreviousSibling() != null && sibling.getPreviousSibling().getNodeType() == Node.TEXT_NODE && StringUtils.containsLineDelimiter(sibling.getPreviousSibling().getNodeValue()))
- break;
- sibling = (IDOMNode) sibling.getPreviousSibling();
- }
- if (sibling == null) {
- sibling = (IDOMNode) node.getNextSibling();
- while ((sibling != null) && (sibling.getNodeType() == Node.TEXT_NODE))
- sibling = (IDOMNode) sibling.getNextSibling();
- }
- String singleIndent = getFormatPreferences().getIndent();
- String parentLineIndent = getNodeIndent(node.getParentNode());
-
- if (sibling != null) {
- String siblingIndent = getNodeIndent(sibling);
- if (siblingIndent.length() > 0)
- result = siblingIndent;
- else {
- String nodeIndent = getNodeIndent(node);
- if (nodeIndent.length() > parentLineIndent.length())
- // this node is indented from its parent, its
- // indentation will be used
- result = nodeIndent;
- else
- result = parentLineIndent + singleIndent;
- }
- }
- else {
- String nodeIndent = getNodeIndent(node);
- if (nodeIndent.length() > parentLineIndent.length())
- // this node is indented from its parent, its indentation
- // will be used
- result = nodeIndent;
- else
- result = parentLineIndent + singleIndent;
- }
- }
-
- return result;
- }
-
- protected void insertAfterNode(IDOMNode node, String string) {
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- int offset = node.getEndOffset();
- int length = 0;
-
- // 261968 - formatting tag without closing bracket: <t1><t1
- if (node.getEndStructuredDocumentRegion() != null) {
- offset = node.getEndStructuredDocumentRegion().getTextEndOffset();
- length = node.getEndOffset() - offset;
- }
- replace(structuredDocument, offset, length, string);
- }
-
- protected void insertBeforeNode(IDOMNode node, String string) {
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- replace(structuredDocument, node.getStartOffset(), 0, string);
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(IStructuredFormatter.class);
- }
-
- protected boolean isEndTagMissing(IDOMNode node) {
- boolean result = false;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && !isJSPTag(node)) {
- IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getFirstStructuredDocumentRegion();
- IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion();
-
- ITextRegion startTagNameRegion = null;
- if (startTagStructuredDocumentRegion.getRegions().size() > 1)
- startTagNameRegion = startTagStructuredDocumentRegion.getRegions().get(1);
- ITextRegion endTagNameRegion = null;
- if (endTagStructuredDocumentRegion.getRegions().size() > 1)
- endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1);
-
- ITextRegionList startTagRegions = startTagStructuredDocumentRegion.getRegions();
- if (startTagNameRegion == endTagNameRegion && startTagNameRegion != null && (startTagRegions.get(0)).getType() != DOMRegionContext.XML_END_TAG_OPEN && (startTagRegions.get(startTagRegions.size() - 1).getType()) != DOMRegionContext.XML_EMPTY_TAG_CLOSE)
- // end tag missing
- result = true;
- }
-
- return result;
- }
-
- protected boolean nodeHasSiblings(IDOMNode node) {
- return (node.getPreviousSibling() != null) || (node.getNextSibling() != null);
- }
-
- /**
- * Node changed. No format should be performed automatically.
- */
- public void notifyChanged(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- protected void removeRegionSpaces(IDOMNode node, IStructuredDocumentRegion flatNode, ITextRegion region) {
- if ((region != null) && (region instanceof ContextRegion || region instanceof TagNameRegion) && (flatNode.getEndOffset(region) > flatNode.getTextEndOffset(region))) {
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- replace(structuredDocument, flatNode.getTextEndOffset(region), flatNode.getEndOffset(region) - flatNode.getTextEndOffset(region), EMPTY_STRING);
- }
- }
-
- /**
- * This method will replace the string at offset and length with a new
- * string. If the string to be replaced is the same as the new string, the
- * string will not be replaced.
- */
- protected void replace(IStructuredDocument structuredDocument, int offset, int length, String string) {
- try {
- String structuredDocumentString = structuredDocument.get(offset, length);
- if (structuredDocumentString.compareTo(string) != 0)
- structuredDocument.replaceText(structuredDocument, offset, length, string);
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- /**
- * This method will replace the node value with a new string. If the node
- * value to be replaced is the same as the new string, the node value will
- * not be replaced.
- */
- protected void replaceNodeValue(IDOMNode node, String string) {
- IDOMModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- int offset = node.getStartOffset();
- int length = node.getEndOffset() - node.getStartOffset();
-
- try {
- String structuredDocumentString = structuredDocument.get(offset, length);
- if (structuredDocumentString.compareTo(string) != 0)
- replace(structuredDocument, offset, length, string);
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- public void setFormatPreferences(IStructuredFormatPreferences formatPreferences) {
- fFormatPreferences = formatPreferences;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.format.IStructuredFormatter#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- private boolean isJSPTag(Node node) {
-
- final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
- // final String JSP_COMMENT_CLOSE = "JSP_COMMENT_CLOSE"; //$NON-NLS-1$
-
- // final String JSP_COMMENT_OPEN = "JSP_COMMENT_OPEN"; //$NON-NLS-1$
- // final String JSP_COMMENT_TEXT = "JSP_COMMENT_TEXT"; //$NON-NLS-1$
-
- final String JSP_CONTENT = "JSP_CONTENT"; //$NON-NLS-1$
- final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- final String JSP_DIRECTIVE_CLOSE = "JSP_DIRECTIVE_CLOSE"; //$NON-NLS-1$
- final String JSP_DIRECTIVE_NAME = "JSP_DIRECTIVE_NAME"; //$NON-NLS-1$
-
- final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- // final String JSP_ROOT_TAG_NAME = "JSP_ROOT_TAG_NAME"; //$NON-NLS-1$
-
- final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
-
- boolean result = false;
-
- if (node instanceof IDOMNode) {
- IStructuredDocumentRegion flatNode = ((IDOMNode) node).getFirstStructuredDocumentRegion();
- // in some cases, the nodes exists, but hasn't been associated
- // with
- // a flatnode yet (the screen updates can be initiated on a
- // different thread,
- // so the request for a flatnode can come in before the node is
- // fully formed.
- // if the flatnode is null, we'll just allow the defaults to
- // apply.
- if (flatNode != null) {
- String flatNodeType = flatNode.getType();
- // should not be null, but just to be sure
- if (flatNodeType != null) {
- if ((flatNodeType.equals(JSP_CONTENT)) || (flatNodeType.equals(JSP_EXPRESSION_OPEN)) || (flatNodeType.equals(JSP_SCRIPTLET_OPEN)) || (flatNodeType.equals(JSP_DECLARATION_OPEN)) || (flatNodeType.equals(JSP_DIRECTIVE_CLOSE)) || (flatNodeType.equals(JSP_DIRECTIVE_NAME)) || (flatNodeType.equals(JSP_DIRECTIVE_OPEN)) || (flatNodeType.equals(JSP_CLOSE))) {
- result = true;
- }
- }
- }
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java
deleted file mode 100644
index 07024eb3f5..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.provisional.format;
-
-import org.eclipse.wst.sse.core.internal.format.StructuredFormatPreferences;
-
-public class StructuredFormatPreferencesXML extends StructuredFormatPreferences {
- private boolean fSplitMultiAttrs = false;
- private boolean fPreservePCDATAContent = false;
- private boolean fAlignEndBracket = false;
-
- /**
- * True if formatter should split elements with multiple attributes onto
- * new lines.
- *
- * @return boolean
- */
- public boolean getSplitMultiAttrs() {
- return fSplitMultiAttrs;
- }
-
- /**
- * Sets whether or not formatter should split elements with multiple
- * attributes onto new lines.
- *
- * @param splitMultiAttrs
- */
- public void setSplitMultiAttrs(boolean splitMultiAttrs) {
- fSplitMultiAttrs = splitMultiAttrs;
- }
-
- /**
- * True if tags with PCDATA content should not have their whitespace
- * messed with when formatting.
- *
- * @return boolean
- */
- public boolean isPreservePCDATAContent() {
- return fPreservePCDATAContent;
- }
-
- /**
- * Sets whether or not formatter should preserve whitespace in tags with
- * PCDATA content.
- *
- * @param preservePCDATAContent
- */
- public void setPreservePCDATAContent(boolean preservePCDATAContent) {
- fPreservePCDATAContent = preservePCDATAContent;
- }
-
- /**
- * True if end brackets of start tags should be placed on a new line if
- * the start tag spans more than one line.
- *
- * @return
- */
- public boolean isAlignEndBracket() {
- return fAlignEndBracket;
- }
-
- /**
- * Sets whether or not formatter should align the end bracket of a start
- * tag on a new line if the start tag spans more than one line.
- *
- * @param alignEndBracket
- */
- public void setAlignEndBracket(boolean alignEndBracket) {
- fAlignEndBracket = alignEndBracket;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/TextNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/TextNodeFormatter.java
deleted file mode 100644
index 873ab766e4..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/TextNodeFormatter.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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
- * Jesper Steen Møller - xml:space='preserve' support
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.format;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-
-
-public class TextNodeFormatter extends NodeFormatter {
- static private final String CR = "\r"; //$NON-NLS-1$
- static private final String DELIMITERS = " \t\n\r\f"; //$NON-NLS-1$
- static private final String EMPTY_STRING = ""; //$NON-NLS-1$
- static private final String FF = "\f"; //$NON-NLS-1$
- static private final String LF = "\n"; //$NON-NLS-1$
- static private final String SPACE = " "; //$NON-NLS-1$
- static private final String TAB = "\t"; //$NON-NLS-1$
-
- private String compressSpaces(String string, IStructuredFormatContraints formatContraints) {
- /*
- * Note that the StructuredTextEditor supports mixed new line
- * characters (CR, LF, CRLF) in one file. We have to handle that when
- * we try to preserve blank lines.
- */
- String[] stringArray = null;
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if (clearAllBlankLines)
- stringArray = StringUtils.asArray(string);
- else
- stringArray = StringUtils.asArray(string, DELIMITERS, true);
-
- StringBuffer compressedString = new StringBuffer();
- if (stringArray.length > 0) {
- boolean cr = false, lf = false, cr2 = false, nonSpace = true;
-
- if (stringArray[0].compareTo(CR) == 0)
- cr = true;
- else if (stringArray[0].compareTo(LF) == 0)
- lf = true;
- else if ((stringArray[0].compareTo(SPACE) != 0) && (stringArray[0].compareTo(TAB) != 0) && (stringArray[0].compareTo(FF) != 0)) {
- compressedString.append(stringArray[0]);
- nonSpace = true;
- }
-
- for (int i = 1; i < stringArray.length; i++) {
- if (stringArray[i].compareTo(CR) == 0) {
- if (cr && lf) {
- if (nonSpace) {
- compressedString.append(CR + LF);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- cr2 = true;
- }
- else if (cr) {
- if (nonSpace) {
- compressedString.append(CR);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- cr2 = true;
- }
- else
- cr = true;
- }
- else if (stringArray[i].compareTo(LF) == 0) {
- if (cr && lf && cr2) {
- compressedString.append(stringArray[i]);
- }
- else if (lf) {
- if (nonSpace) {
- compressedString.append(LF);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- }
- else
- lf = true;
- }
- else if ((stringArray[i].compareTo(SPACE) != 0) && (stringArray[i].compareTo(TAB) != 0) && (stringArray[i].compareTo(FF) != 0)) {
- if (compressedString.length() > 0)
- compressedString.append(SPACE);
- compressedString.append(stringArray[i]);
-
- cr = false;
- lf = false;
- cr2 = false;
- nonSpace = true;
- }
- }
- }
-
- return compressedString.toString();
- }
-
- protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) {
- // [111674] If inside xml:space="preserve" element, we bail
- if (formatContraints.getInPreserveSpaceElement())
- return;
- if (node != null) {
- IStructuredDocument doc = node.getStructuredDocument();
-
- int lineWidth = getFormatPreferences().getLineWidth();
- int currentAvailableLineWidth = computeAvailableLineWidth(doc, node.getStartOffset(), lineWidth);
-
- String nodeText = getNodeText(node);
- String compressedText = compressSpaces(nodeText, formatContraints);
-
- IDOMNode parentNode = (IDOMNode) node.getParentNode();
-
- if (((enoughSpace(parentNode, currentAvailableLineWidth, compressedText)) && (noSiblingsAndNoFollowingComment(node)) && !firstStructuredDocumentRegionContainsLineDelimiters(parentNode)) || node.getStartOffset() == 0) {
- handleNoReflow(node, doc, compressedText, parentNode);
- }
- else {
- // not enough space, need to reflow text
- String nodeIndentation = formatContraints.getCurrentIndent();
- currentAvailableLineWidth = lineWidth - getIndentationLength(nodeIndentation);
- List vector = reflowText(compressedText, currentAvailableLineWidth);
- int vectorSize = vector.size();
- StringBuffer reflowedTextBuffer = new StringBuffer();
- String lineDelimiter = getLineDelimiter(doc, node.getStartOffset());
- // handle first line specially to check for allowWhitespace
- if (vectorSize > 0) {
- // determines whether or not to allow whitespace if there
- // is an entity or cdata before it
- boolean allowWhitespace = true;
- // [206072] StringIndexOutOfBoundsException
- if (nodeText.length() == 0 || !Character.isWhitespace(nodeText.charAt(0))) {
- Node previousSibling = node.getPreviousSibling();
- if (previousSibling != null && (previousSibling.getNodeType() == Node.ENTITY_REFERENCE_NODE || previousSibling.getNodeType() == Node.CDATA_SECTION_NODE))
- allowWhitespace = false;
- }
- String theString = (String) vector.get(0);
- if (allowWhitespace) {
- reflowedTextBuffer.append(lineDelimiter);
- if (theString.trim().length() > 0)
- reflowedTextBuffer.append(nodeIndentation).append(theString);
- }
- else {
- reflowedTextBuffer.append(theString);
- }
- }
- // do the rest of the lines
- for (int i = 1; i < vectorSize; i++) {
- String theString = (String) vector.get(i);
- if (theString.trim().length() > 0)
- reflowedTextBuffer.append(lineDelimiter).append(nodeIndentation).append(theString);
- else
- reflowedTextBuffer.append(lineDelimiter);
- }
- String reflowedText = reflowedTextBuffer.toString();
- if (node.getNextSibling() == null) {
- if (isEndTagMissing(parentNode)) {
- // don't add indentation to end if parent end tag is
- // missing
- }
-
- else {
- // add parent's indentation to end
- nodeIndentation = getNodeIndent(parentNode);
- if (!reflowedText.endsWith(lineDelimiter + nodeIndentation)) {
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- }
- else {
- if (!reflowedText.endsWith(lineDelimiter + nodeIndentation)) {
- // not already ended with the expected indentation
- Node nextSibling = node.getNextSibling();
- if (nextSibling.getNodeType() == Node.COMMENT_NODE) {
- // add indentation to end if
- // currentTextEndsWithLineDelimiter
- // or followed by multiLineComment
-
- int indexOfLastLineDelimiter = StringUtils.indexOfLastLineDelimiter(nodeText);
- boolean currentTextEndsWithLineDelimiter = indexOfLastLineDelimiter != -1;
- if (currentTextEndsWithLineDelimiter) {
- // no more non blank character after the last
- // line delimiter
- currentTextEndsWithLineDelimiter = StringUtils.indexOfNonblank(nodeText, indexOfLastLineDelimiter) == -1;
- }
-
- String nodeValue = nextSibling.getNodeValue();
- boolean multiLineComment = StringUtils.containsLineDelimiter(nodeValue);
-
- if (currentTextEndsWithLineDelimiter || multiLineComment) {
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- else if (nextSibling.getNodeType() == Node.ENTITY_REFERENCE_NODE || nextSibling.getNodeType() == Node.CDATA_SECTION_NODE) {
- int textLength = nodeText.length();
- if (textLength > 0 && Character.isWhitespace(nodeText.charAt(textLength - 1))) {
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- else {
- // not a comment, just add add indentation to end
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- }
-
- replaceNodeValue(node, reflowedText);
- }
- }
- }
-
- /**
- * Keeps text inline with its parent (no reflow necessary)
- *
- * @param node
- * @param doc
- * @param compressedText
- * @param parentNode
- */
- private void handleNoReflow(IDOMNode node, IStructuredDocument doc, String compressedText, IDOMNode parentNode) {
- String nodeIndentation;
- // enough space and text has no line delimiters and (node has no
- // siblings or followed by inline comment) and
- // parentFirstStructuredDocumentRegionContainsLineDelimiters
-
- if (isEndTagMissing(parentNode)) {
- parentNode = (IDOMNode) parentNode.getParentNode();
- while (isEndTagMissing(parentNode))
- parentNode = (IDOMNode) parentNode.getParentNode();
-
- // add parent's indentation to end
- nodeIndentation = getNodeIndent(parentNode);
- String lineDelimiter = getLineDelimiter(doc, node.getStartOffset());
- if (!compressedText.endsWith(lineDelimiter + nodeIndentation)) {
- compressedText = StringUtils.appendIfNotEndWith(compressedText, lineDelimiter);
- compressedText = StringUtils.appendIfNotEndWith(compressedText, nodeIndentation);
- }
- }
-
- if ((parentNode != null) && (parentNode.getNodeType() == Node.DOCUMENT_NODE) && (node.getNodeValue().length() > 0) && (node.getNodeValue().trim().length() == 0) && ((node.getPreviousSibling() == null) || (node.getNextSibling() == null)))
- // delete spaces at the beginning or end of the document
- compressedText = EMPTY_STRING;
-
- replaceNodeValue(node, compressedText);
- }
-
- private boolean noSiblingsAndNoFollowingComment(IDOMNode node) {
- IDOMNode nextSibling = (IDOMNode) node.getNextSibling();
- return !nodeHasSiblings(node) || (noLineDelimiter(node) && isComment(nextSibling) && noLineDelimiter(nextSibling));
- }
-
- private boolean isComment(IDOMNode node) {
- boolean result = false;
- if (node != null) {
- result = node.getNodeType() == Node.COMMENT_NODE;
- }
- return result;
- }
-
- private boolean noLineDelimiter(IDOMNode node) {
- boolean result = false;
- if (node != null) {
- result = !StringUtils.containsLineDelimiter(node.getNodeValue());
- }
- return result;
- }
-
- /**
- * Calculates if there is enough space on the current line for
- * compressedText (and for its parent end tag)
- *
- * @param parentNode
- * @param currentAvailableLineWidth
- * @param compressedText
- * @return
- */
- private boolean enoughSpace(IDOMNode parentNode, int currentAvailableLineWidth, String compressedText) {
- int parentEndTagLength = parentNode.getNodeName().length() + 3;
- return compressedText.length() <= (currentAvailableLineWidth - parentEndTagLength) && !StringUtils.containsLineDelimiter(compressedText);
- }
-
- protected Vector reflowText(String text, int availableWidth) {
- String[] stringArray = null;
- boolean clearAllBlankLines = getFormatPreferences().getClearAllBlankLines();
-
- if (clearAllBlankLines)
- stringArray = StringUtils.asArray(text);
- else
- stringArray = StringUtils.asArray(text, DELIMITERS, true);
-
- Vector output = new Vector();
- if ((stringArray != null) && (stringArray.length > 0)) {
- StringBuffer buffer = new StringBuffer();
- if (stringArray[0].compareTo(CR) != 0)
- buffer.append(stringArray[0]);
- int bufferLength = stringArray[0].toString().length();
- boolean cr = stringArray[0].compareTo(CR) == 0;
-
- for (int i = 1; i < stringArray.length; i++) {
- String eachString = stringArray[i];
- if ((eachString.compareTo(SPACE) != 0) && (eachString.compareTo(TAB) != 0) && (eachString.compareTo(FF) != 0)) {
- if ((bufferLength + 1 + eachString.length() > availableWidth) || (eachString.compareTo(CR) == 0) || (eachString.compareTo(LF) == 0)) {
- if ((eachString.compareTo(LF) == 0) && cr) {
- // do nothing
- }
- else {
- output.add(buffer.toString());
- buffer = new StringBuffer();
- bufferLength = 0;
- }
- cr = eachString.compareTo(CR) == 0;
- }
- else if (buffer.toString().trim().length() > 0) {
- buffer.append(SPACE);
- bufferLength++;
- }
- if ((eachString.compareTo(CR) != 0) && (eachString.compareTo(LF) != 0)) {
- buffer.append(eachString);
- bufferLength = bufferLength + eachString.length();
- }
- }
- }
- output.add(buffer.toString());
- }
- else
- output.add(text);
-
- return output;
- }
-
- private String getLineDelimiter(IStructuredDocument doc, int nodeOffset) {
- int line = doc.getLineOfOffset(nodeOffset);
- String lineDelimiter = doc.getLineDelimiter();
- try {
- if (line > 0) {
- lineDelimiter = doc.getLineDelimiter(line - 1);
- }
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- // BUG115716: if cannot get line delimiter from current line, just
- // use default line delimiter
- if (lineDelimiter == null)
- lineDelimiter = doc.getLineDelimiter();
- return lineDelimiter;
- }
-
- private int computeAvailableLineWidth(IStructuredDocument doc, int nodeOffset, int lineWidth) {
- // compute current available line width
- int currentAvailableLineWidth = 0;
- try {
- int lineOffset = doc.getLineInformationOfOffset(nodeOffset).getOffset();
- String text = doc.get(lineOffset, nodeOffset - lineOffset);
- int usedWidth = getIndentationLength(text);
- currentAvailableLineWidth = lineWidth - usedWidth;
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- return currentAvailableLineWidth;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/text/IXMLPartitions.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/text/IXMLPartitions.java
deleted file mode 100644
index 5d36751dca..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/text/IXMLPartitions.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.provisional.text;
-
-
-
-/**
- * This interface is not intended to be implemented.
- * It defines the partition types for XML.
- * Clients should reference the partition type Strings defined here directly.
- *
- * @deprecated use org.eclipse.wst.xml.core.text
- */
-public interface IXMLPartitions {
-
- String XML_DEFAULT = "org.eclipse.wst.xml.XML_DEFAULT"; //$NON-NLS-1$
- String XML_CDATA = "org.eclipse.wst.xml.XML_CDATA"; //$NON-NLS-1$
- String XML_PI = "org.eclipse.wst.xml.XML_PI"; //$NON-NLS-1$
- String XML_DECLARATION = "org.eclipse.wst.xml.XML_DECL"; //$NON-NLS-1$
- String XML_COMMENT = "org.eclipse.wst.xml.XML_COMMENT"; //$NON-NLS-1$
-
- /*
- * This value is used as a prefix to any unknown processing instructions
- * we find. The processor target name is converted to uppercase and
- * appended to the prefix to create a unique partition type.
- */
- String PROCESSING_INSTRUCTION_PREFIX = "org.eclipse.wst.xml.PROCESSING_INSTRUCTION:"; //$NON-NLS-1$
-
- /**
- * Should match
- * org.eclipse.wst.sse.core.dtd.partitioning.StructuredTextPartitionerForDTD.ST_DTD_SUBSET
- */
- String DTD_SUBSET = "org.eclipse.wst.xml.dtd.internal_subset"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/regions/DOMRegionContext.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/regions/DOMRegionContext.java
deleted file mode 100644
index 4a73d8d431..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/regions/DOMRegionContext.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.regions;
-
-public interface DOMRegionContext {
-
- public static final String BLOCK_TEXT = "BLOCK_TEXT"; //$NON-NLS-1$
-
- public static final String UNDEFINED = "UNDEFINED"; //$NON-NLS-1$
-
- public static final String WHITE_SPACE = "WHITE_SPACE"; //$NON-NLS-1$
- public static final String XML_ATTLIST_DECL_CLOSE = "XML_ATTLIST_DECL_CLOSE"; //$NON-NLS-1$
- public static final String XML_ATTLIST_DECL_CONTENT = "XML_ATTLIST_DECL_CONTENT"; //$NON-NLS-1$
- public static final String XML_ATTLIST_DECL_NAME = "XML_ATTLIST_DECL_NAME"; //$NON-NLS-1$
-
- public static final String XML_ATTLIST_DECLARATION = "XML_ATTLIST_DECLARATION"; //$NON-NLS-1$
- public static final String XML_CDATA_CLOSE = "XML_CDATA_CLOSE"; //$NON-NLS-1$
- public static final String XML_CDATA_OPEN = "XML_CDATA_OPEN"; //$NON-NLS-1$
- public static final String XML_CDATA_TEXT = "XML_CDATA_TEXT"; //$NON-NLS-1$
- public static final String XML_CHAR_REFERENCE = "XML_CHAR_REFERENCE"; //$NON-NLS-1$
- public static final String XML_COMMENT_CLOSE = "XML_COMMENT_CLOSE"; //$NON-NLS-1$
-
- public static final String XML_COMMENT_OPEN = "XML_COMMENT_OPEN"; //$NON-NLS-1$
- public static final String XML_COMMENT_TEXT = "XML_COMMENT_TEXT"; //$NON-NLS-1$
-
- public static final String XML_CONTENT = "XML_CONTENT"; //$NON-NLS-1$
- public static final String XML_DECLARATION_CLOSE = "XML_DECLARATION_CLOSE"; //$NON-NLS-1$
-
- public static final String XML_DECLARATION_OPEN = "XML_DECLARATION_OPEN"; //$NON-NLS-1$
-
- public static final String XML_DOCTYPE_DECLARATION = "XML_DOCTYPE_DECLARATION"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_DECLARATION_CLOSE = "XML_DOCTYPE_DECLARATION_CLOSE"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_EXTERNAL_ID_PUBLIC = "XML_DOCTYPE_EXTERNAL_ID_PUBLIC"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_EXTERNAL_ID_PUBREF = "XML_DOCTYPE_EXTERNAL_ID_PUBREF"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_EXTERNAL_ID_SYSREF = "XML_DOCTYPE_EXTERNAL_ID_SYSREF"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_EXTERNAL_ID_SYSTEM = "XML_DOCTYPE_EXTERNAL_ID_SYSTEM"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_INTERNAL_SUBSET = "XML_DOCTYPE_INTERNAL_SUBSET"; //$NON-NLS-1$
- public static final String XML_DOCTYPE_NAME = "XML_DOCTYPE_NAME"; //$NON-NLS-1$
- public static final String XML_ELEMENT_DECL_CLOSE = "XML_ELEMENT_DECL_CLOSE"; //$NON-NLS-1$
- public static final String XML_ELEMENT_DECL_CONTENT = "XML_ELEMENT_DECL_CONTENT"; //$NON-NLS-1$
- public static final String XML_ELEMENT_DECL_NAME = "XML_ELEMENT_DECL_NAME"; //$NON-NLS-1$
-
- public static final String XML_ELEMENT_DECLARATION = "XML_ELEMENT_DECLARATION"; //$NON-NLS-1$
- public static final String XML_EMPTY_TAG_CLOSE = "XML_EMPTY_TAG_CLOSE"; //$NON-NLS-1$
- public static final String XML_END_TAG_OPEN = "XML_END_TAG_OPEN"; //$NON-NLS-1$
- public static final String XML_ENTITY_REFERENCE = "XML_ENTITY_REFERENCE"; //$NON-NLS-1$
-
- public static final String XML_PE_REFERENCE = "XML_PE_REFERENCE"; //$NON-NLS-1$
- public static final String XML_PI_CLOSE = "XML_PI_CLOSE"; //$NON-NLS-1$
- public static final String XML_PI_CONTENT = "XML_PI_CONTENT"; //$NON-NLS-1$
- public static final String XML_PI_OPEN = "XML_PI_OPEN"; //$NON-NLS-1$
- public static final String XML_TAG_ATTRIBUTE_EQUALS = "XML_TAG_ATTRIBUTE_EQUALS"; //$NON-NLS-1$
- public static final String XML_TAG_ATTRIBUTE_NAME = "XML_TAG_ATTRIBUTE_NAME"; //$NON-NLS-1$
- public static final String XML_TAG_ATTRIBUTE_VALUE = "XML_TAG_ATTRIBUTE_VALUE"; //$NON-NLS-1$
- public static final String XML_TAG_CLOSE = "XML_TAG_CLOSE"; //$NON-NLS-1$
- public static final String XML_TAG_NAME = "XML_TAG_NAME"; //$NON-NLS-1$
-
- public static final String XML_TAG_OPEN = "XML_TAG_OPEN"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapter.java
deleted file mode 100644
index 74ad2a1a4a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.ssemodelquery;
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-
-public interface ModelQueryAdapter extends INodeAdapter {
-
- public CMDocumentCache getCMDocumentCache();
-
- public URIResolver getIdResolver();
-
- public ModelQuery getModelQuery();
-
- void release();
-
- void setIdResolver(URIResolver newIdResolver);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapterImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapterImpl.java
deleted file mode 100644
index a68e672920..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/ModelQueryAdapterImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.ssemodelquery;
-
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-
-
-public class ModelQueryAdapterImpl implements ModelQueryAdapter {
- protected CMDocumentCache cmDocumentCache;
- protected URIResolver idResolver;
-
- protected ModelQuery modelQuery;
-
- public ModelQueryAdapterImpl(CMDocumentCache cmDocumentCache, ModelQuery modelQuery, URIResolver idResolver) {
- this.cmDocumentCache = cmDocumentCache;
- this.modelQuery = modelQuery;
- this.idResolver = idResolver;
- }
-
- public CMDocumentCache getCMDocumentCache() {
- return cmDocumentCache;
- }
-
- public URIResolver getIdResolver() {
- return idResolver;
- }
-
- public ModelQuery getModelQuery() {
- return modelQuery;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(ModelQueryAdapter.class);
- }
-
- /**
- */
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- /**
- * @see ModelQueryAdapter#release()
- */
- public void release() {
- }
-
- /**
- * @see ModelQueryAdapter#setIdResolver(URIResolver)
- */
-
- public void setIdResolver(URIResolver newIdResolver) {
- idResolver = newIdResolver;
- if (modelQuery instanceof MovableModelQuery)
- ((MovableModelQuery) modelQuery).setIdResolver(newIdResolver);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/MovableModelQuery.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/MovableModelQuery.java
deleted file mode 100644
index 49d733960f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/ssemodelquery/MovableModelQuery.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.ssemodelquery;
-
-
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-
-public interface MovableModelQuery extends ModelQuery {
-
- void setIdResolver(URIResolver newURIResolver);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLFileTaskScanner.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLFileTaskScanner.java
deleted file mode 100644
index 94b81555bc..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLFileTaskScanner.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.tasks;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.tasks.StructuredFileTaskScanner;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-public class XMLFileTaskScanner extends StructuredFileTaskScanner {
- public XMLFileTaskScanner() {
- super();
- }
-
- protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) {
- return textRegion.getType().equals(DOMRegionContext.XML_COMMENT_TEXT);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/XMLStructuredDocumentRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/XMLStructuredDocumentRegion.java
deleted file mode 100644
index e26bf08551..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/XMLStructuredDocumentRegion.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 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.text;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class XMLStructuredDocumentRegion extends BasicStructuredDocumentRegion implements IStructuredDocumentRegion {
-
- public XMLStructuredDocumentRegion() {
- super();
- }
-
- public String getType() {
- String result = super.getType();
- // normally, we want the second region as the flatnode type ... since
- // the
- // first one is usually just "open tag".
- if ((result != DOMRegionContext.XML_PI_OPEN) && (getRegions().size() > 1)) {
- result = getRegions().get(1).getType();
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/rules/StructuredTextPartitionerForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/rules/StructuredTextPartitionerForXML.java
deleted file mode 100644
index 8b73869003..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/text/rules/StructuredTextPartitionerForXML.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.text.rules;
-
-import java.util.Locale;
-
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.parser.ForeignRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextPartitioner;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-public class StructuredTextPartitionerForXML extends StructuredTextPartitioner implements IStructuredTextPartitioner {
-
- private final static String[] configuredContentTypes = new String[]{IXMLPartitions.XML_DEFAULT, IXMLPartitions.XML_CDATA, IXMLPartitions.XML_PI, IXMLPartitions.XML_DECLARATION, IXMLPartitions.XML_COMMENT, IXMLPartitions.DTD_SUBSET};
-
- public StructuredTextPartitionerForXML() {
- super();
- }
-
- protected void setInternalPartition(int offset, int length, String type) {
- super.setInternalPartition(offset, length, type);
- }
-
- protected void initLegalContentTypes() {
- fSupportedTypes = configuredContentTypes;
- }
-
- public String getPartitionType(ITextRegion region, int offset) {
- String result = null;
- if (region.getType() == DOMRegionContext.XML_COMMENT_TEXT)
- result = IXMLPartitions.XML_COMMENT;
- else if (region.getType() == DOMRegionContext.XML_CDATA_TEXT)
- result = IXMLPartitions.XML_CDATA;
- else if (region.getType() == DOMRegionContext.XML_PI_CONTENT) {
- /**
- * Grammatically, it's impossible to get a PI_CONTENT region
- * without a preceding XML_TAG_NAME region. Relying on this,
- * extract the target processor name and create a partition type
- * dynamically.
- */
- IStructuredDocumentRegion docRegion = fStructuredDocument.getRegionAtCharacterOffset(offset);
- ITextRegion name = docRegion.getRegionAtCharacterOffset(docRegion.getStartOffset() + region.getStart() - 1);
- result = IXMLPartitions.PROCESSING_INSTRUCTION_PREFIX + docRegion.getText(name).toUpperCase(Locale.ENGLISH);
- }
- else if (region.getType() == DOMRegionContext.XML_PI_OPEN)
- result = IXMLPartitions.XML_PI;
- else if (region.getType() == DOMRegionContext.XML_DOCTYPE_DECLARATION)
- result = IXMLPartitions.XML_DECLARATION;
- else if (region.getType() == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)
- result = IXMLPartitions.DTD_SUBSET;
- else
- result = super.getPartitionType(region, offset);
- return result;
- }
-
- protected String getPartitionType(ForeignRegion region, int offset) {
- // temp added just to dis-ambiguate call from subclass
- return super.getPartitionType(region, offset);
- }
-
- public String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, IStructuredDocumentRegion nextNode) {
- return super.getPartitionTypeBetween(previousNode, nextNode);
- }
-
- public String getDefaultPartitionType() {
- return IXMLPartitions.XML_DEFAULT;
- }
-
- public IDocumentPartitioner newInstance() {
- StructuredTextPartitionerForXML instance = new StructuredTextPartitionerForXML();
- return instance;
- }
-
- /**
- * @return
- */
- public static String[] getConfiguredContentTypes() {
- return configuredContentTypes;
- }
-
- protected String getPartitionFromBlockedText(ITextRegion region, int offset, String result) {
- // was moved to subclass for quick transition
- String newResult = result;
- // nsd_TODO: David and I need to discuss, design, and implement this
- // for all block tags and comments
- // and make sure is part of "extensible" design of block tags
- if (region.getType() == DOMRegionContext.BLOCK_TEXT) {
- // for code safety, we'll always check instanceof, but I think
- // always true.
- if (region instanceof ForeignRegion) {
- // super is used below so won't be ambiguous
- newResult = getPartitionType((ForeignRegion) region, offset);
- }
- else if (region instanceof ForeignRegion) {
- newResult = getPartitionType((ForeignRegion) region, offset);
- }
- else {
- newResult = getUnknown();
- }
- }
- return newResult;
- }
-
- protected boolean doParserSpecificCheck(int offset, boolean partitionFound, IStructuredDocumentRegion sdRegion, IStructuredDocumentRegion previousStructuredDocumentRegion, ITextRegion next, ITextRegion previousStart) {
- // this was moved down to subclass of StructuredTextPartioner
- // for quick fix to transition problems. Heirarchy needs lots of
- // cleanup.
- if (previousStart != null && previousStart.getType() == DOMRegionContext.XML_TAG_OPEN && next.getType() == DOMRegionContext.XML_END_TAG_OPEN) {
- ITextRegion previousName = previousStructuredDocumentRegion.getRegionAtCharacterOffset(previousStructuredDocumentRegion.getEndOffset(previousStart));
- ITextRegion nextName = sdRegion.getRegionAtCharacterOffset(sdRegion.getEndOffset(next));
- if (previousName != null && nextName != null && previousName.getType() == DOMRegionContext.XML_TAG_NAME && nextName.getType() == DOMRegionContext.XML_TAG_NAME) {
- setInternalPartition(offset, 0, getPartitionTypeBetween(previousStructuredDocumentRegion, sdRegion));
- partitionFound = true;
- }
- }
- return partitionFound;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/AbstractPropagatingValidator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/AbstractPropagatingValidator.java
deleted file mode 100644
index 3fddda363a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/AbstractPropagatingValidator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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.validate;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.validate.ValidationAdapter;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractPropagatingValidator extends ValidationComponent {
-
- /**
- * Constructor for AbstractPropagatingValidator.
- */
- public AbstractPropagatingValidator() {
- super();
- }
-
- protected abstract ValidationComponent getPropagatee();
-
- protected abstract ValidationAdapter getValidator();
-
-
- public void validate(IndexedRegion node) {
- if (node == null)
- return;
- getValidator().validate(node);
-
- propagateToChildElements(getPropagatee(), (Node) node);
- }
-
- private void propagateToChildElements(ValidationComponent validator, Node parent) {
- if (parent == null)
- return;
- Class clazz = validator.getClass();
-
- Node child = parent.getFirstChild();
- while (child != null) {
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- INodeNotifier notifier = (INodeNotifier) child;
- ValidationAdapter va = (ValidationAdapter) notifier.getExistingAdapter(clazz);
- if (va == null) {
- notifier.addAdapter(validator);
- va = validator;
- }
- // bug 143213 - Can't batch validate open HTML files when
- // as-you-type validation is enabled
- va.setReporter(validator.getReporter());
- va.validate((IndexedRegion) child);
- }
- child = child.getNextSibling();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/Propagator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/Propagator.java
deleted file mode 100644
index 3ce6569ccd..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/Propagator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.validate;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.validate.ValidationAdapter;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @deprecated since 2.0 M5 - if propogateToChildElement is needed, just copy
- * method to your own class
- */
-public class Propagator {
-
- public static void propagateToChildElements(ValidationComponent validator, Node parent) {
- if (parent == null)
- return;
- Class clazz = validator.getClass();
-
- NodeList children = parent.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child == null || child.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- INodeNotifier notifier = (INodeNotifier) child;
- ValidationAdapter va = (ValidationAdapter) notifier.getExistingAdapter(clazz);
- if (va == null) {
- notifier.addAdapter(validator);
- va = validator;
- }
- va.validate((IndexedRegion) child);
- }
- }
-
- /**
- * Propagator is just a placeholder of utilities. Don't instantiate.
- */
- private Propagator() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/ValidationComponent.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/ValidationComponent.java
deleted file mode 100644
index dfd921f58c..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/validate/ValidationComponent.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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.validate;
-
-
-
-import org.eclipse.wst.sse.core.internal.validate.ValidationAdapter;
-import org.eclipse.wst.sse.core.internal.validate.ValidationReporter;
-
-public abstract class ValidationComponent implements ValidationAdapter {
-
- protected ValidationReporter reporter = null;
-
- /**
- * ValidationComponent constructor comment.
- */
- public ValidationComponent() {
- super();
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return (type == ValidationAdapter.class);
- }
-
- /**
- */
- public void notifyChanged(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // This method will be implemented in the V2.
- }
-
- /**
- */
- public void setReporter(ValidationReporter reporter) {
- this.reporter = reporter;
- }
-
- ValidationReporter getReporter() {
- return this.reporter;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/text/IXMLPartitions.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/text/IXMLPartitions.java
deleted file mode 100644
index d8da7868a3..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/text/IXMLPartitions.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- *******************************************************************************/
-package org.eclipse.wst.xml.core.text;
-
-
-
-/**
- * This interface is not intended to be implemented.
- * It defines the partition types for XML.
- * Clients should reference the partition type Strings defined here directly.
- *
- * @since 1.1
- */
-public interface IXMLPartitions {
-
- String XML_DEFAULT = "org.eclipse.wst.xml.XML_DEFAULT"; //$NON-NLS-1$
- String XML_CDATA = "org.eclipse.wst.xml.XML_CDATA"; //$NON-NLS-1$
- String XML_PI = "org.eclipse.wst.xml.XML_PI"; //$NON-NLS-1$
- String XML_DECLARATION = "org.eclipse.wst.xml.XML_DECL"; //$NON-NLS-1$
- String XML_COMMENT = "org.eclipse.wst.xml.XML_COMMENT"; //$NON-NLS-1$
-
- /*
- * This value is used as a prefix to any unknown processing instructions
- * we find. The processor target name is converted to uppercase and
- * appended to the prefix to create a unique partition type.
- */
- String PROCESSING_INSTRUCTION_PREFIX = "org.eclipse.wst.xml.PROCESSING_INSTRUCTION:"; //$NON-NLS-1$
-
- /**
- * Should match
- * org.eclipse.wst.sse.core.dtd.partitioning.StructuredTextPartitionerForDTD.ST_DTD_SUBSET
- */
- String DTD_SUBSET = "org.eclipse.wst.xml.dtd.internal_subset"; //$NON-NLS-1$
-}

Back to the top