2 * Copyright (c) 2002-2004 Widespace, OU and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Igor Malinin - initial contribution
11 * $Id: DTDTextTools.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
14 package net.sourceforge.phpeclipse.xml.ui.text;
18 import net.sourceforge.phpeclipse.ui.text.AbstractTextTools;
19 import net.sourceforge.phpeclipse.xml.ui.internal.text.DeclScanner;
20 import net.sourceforge.phpeclipse.xml.ui.internal.text.SingleTokenScanner;
21 import net.sourceforge.phpeclipse.xml.ui.internal.text.TextScanner;
22 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
24 import org.eclipse.jface.preference.IPreferenceStore;
25 import org.eclipse.jface.text.IDocumentPartitioner;
26 //import org.eclipse.jface.text.rules.DefaultPartitioner;
27 import org.eclipse.jface.text.rules.FastPartitioner;
28 import org.eclipse.jface.text.rules.IPartitionTokenScanner;
29 import org.eclipse.jface.text.rules.RuleBasedScanner;
34 * @author Igor Malinin
36 public class DTDTextTools extends AbstractTextTools {
37 private static final String[] TOKENS = { IXMLSyntaxConstants.XML_DEFAULT,
38 IXMLSyntaxConstants.XML_ATT_NAME,
39 IXMLSyntaxConstants.XML_ATT_VALUE, IXMLSyntaxConstants.XML_ENTITY,
40 IXMLSyntaxConstants.XML_PI, IXMLSyntaxConstants.XML_COMMENT,
41 IXMLSyntaxConstants.XML_DECL, IXMLSyntaxConstants.DTD_CONDITIONAL, };
43 private static final String[] TYPES = { XMLPartitionScanner.XML_PI,
44 XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL,
45 XMLPartitionScanner.DTD_CONDITIONAL, };
47 /** The DTD partitions scanner */
48 private XMLPartitionScanner dtdPartitionScanner;
50 /** The DTD text scanner */
51 private TextScanner dtdTextScanner;
53 /** The DTD conditional sections scanner */
54 private SingleTokenScanner dtdConditionalScanner;
56 /** The XML processing instructions scanner */
57 private SingleTokenScanner xmlPIScanner;
59 /** The XML comments scanner */
60 private SingleTokenScanner xmlCommentScanner;
62 /** The XML declarations scanner */
63 private DeclScanner xmlDeclScanner;
66 * Creates a new DTD text tools collection.
68 public DTDTextTools(IPreferenceStore store) {
71 dtdPartitionScanner = new XMLPartitionScanner(true);
73 Map tokens = getTokens();
75 dtdTextScanner = new TextScanner(tokens, '%',
76 IXMLSyntaxConstants.XML_DEFAULT);
78 dtdConditionalScanner = new SingleTokenScanner(tokens,
79 IXMLSyntaxConstants.DTD_CONDITIONAL); // cond
81 xmlPIScanner = new SingleTokenScanner(tokens,
82 IXMLSyntaxConstants.XML_PI);
84 xmlCommentScanner = new SingleTokenScanner(tokens,
85 IXMLSyntaxConstants.XML_COMMENT);
87 xmlDeclScanner = new DeclScanner(tokens);
93 public IDocumentPartitioner createDTDPartitioner() {
94 return new /*DefaultPartitioner*/FastPartitioner(dtdPartitionScanner, TYPES);
100 public IPartitionTokenScanner getDTDPartitionScanner() {
101 return dtdPartitionScanner;
105 * Returns a scanner which is configured to scan DTD text.
107 * @return an DTD text scanner
109 public RuleBasedScanner getDTDTextScanner() {
110 return dtdTextScanner;
114 * Returns a scanner which is configured to scan DTD conditional sections.
116 * @return an DTD conditional section scanner
118 public RuleBasedScanner getDTDConditionalScanner() {
119 return dtdConditionalScanner;
123 * Returns a scanner which is configured to scan XML processing
126 * @return an XML processing instruction scanner
128 public RuleBasedScanner getXMLPIScanner() {
133 * Returns a scanner which is configured to scan XML comments.
135 * @return an XML comment scanner
137 public RuleBasedScanner getXMLCommentScanner() {
138 return xmlCommentScanner;
142 * Returns a scanner which is configured to scan XML declarations.
144 * @return an XML declaration scanner
146 public RuleBasedScanner getXMLDeclScanner() {
147 return xmlDeclScanner;