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.1 2004-09-02 18:28:03 jsurfer Exp $
14 package net.sourceforge.phpeclipse.xml.ui.text;
18 import org.eclipse.jface.preference.IPreferenceStore;
19 import org.eclipse.jface.text.IDocumentPartitioner;
20 import org.eclipse.jface.text.rules.DefaultPartitioner;
21 import org.eclipse.jface.text.rules.IPartitionTokenScanner;
22 import org.eclipse.jface.text.rules.RuleBasedScanner;
24 import net.sourceforge.phpeclipse.ui.text.AbstractTextTools;
25 import net.sourceforge.phpeclipse.xml.ui.internal.text.DeclScanner;
26 import net.sourceforge.phpeclipse.xml.ui.internal.text.SingleTokenScanner;
27 import net.sourceforge.phpeclipse.xml.ui.internal.text.TextScanner;
28 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
34 * @author Igor Malinin
36 public class DTDTextTools extends AbstractTextTools {
37 private static final String[] TOKENS = {
38 IXMLSyntaxConstants.XML_DEFAULT,
39 IXMLSyntaxConstants.XML_ATT_NAME,
40 IXMLSyntaxConstants.XML_ATT_VALUE,
41 IXMLSyntaxConstants.XML_ENTITY,
42 IXMLSyntaxConstants.XML_PI,
43 IXMLSyntaxConstants.XML_COMMENT,
44 IXMLSyntaxConstants.XML_DECL,
45 IXMLSyntaxConstants.DTD_CONDITIONAL,
48 private static final String[] TYPES = {
49 XMLPartitionScanner.XML_PI,
50 XMLPartitionScanner.XML_COMMENT,
51 XMLPartitionScanner.XML_DECL,
52 XMLPartitionScanner.DTD_CONDITIONAL,
55 /** The DTD partitions scanner */
56 private XMLPartitionScanner dtdPartitionScanner;
58 /** The DTD text scanner */
59 private TextScanner dtdTextScanner;
61 /** The DTD conditional sections scanner */
62 private SingleTokenScanner dtdConditionalScanner;
64 /** The XML processing instructions scanner */
65 private SingleTokenScanner xmlPIScanner;
67 /** The XML comments scanner */
68 private SingleTokenScanner xmlCommentScanner;
70 /** The XML declarations scanner */
71 private DeclScanner xmlDeclScanner;
74 * Creates a new DTD text tools collection.
76 public DTDTextTools( IPreferenceStore store ) {
77 super( store, TOKENS );
79 dtdPartitionScanner = new XMLPartitionScanner( true );
81 Map tokens = getTokens();
83 dtdTextScanner = new TextScanner(
84 tokens, '%', IXMLSyntaxConstants.XML_DEFAULT );
86 dtdConditionalScanner = new SingleTokenScanner(
87 tokens, IXMLSyntaxConstants.DTD_CONDITIONAL ); //cond
89 xmlPIScanner = new SingleTokenScanner(
90 tokens, IXMLSyntaxConstants.XML_PI );
92 xmlCommentScanner = new SingleTokenScanner(
93 tokens, IXMLSyntaxConstants.XML_COMMENT );
95 xmlDeclScanner = new DeclScanner( tokens );
101 public IDocumentPartitioner createDTDPartitioner() {
102 return new DefaultPartitioner( dtdPartitionScanner, TYPES );
108 public IPartitionTokenScanner getDTDPartitionScanner() {
109 return dtdPartitionScanner;
113 * Returns a scanner which is configured to scan DTD text.
115 * @return an DTD text scanner
117 public RuleBasedScanner getDTDTextScanner() {
118 return dtdTextScanner;
122 * Returns a scanner which is configured to scan DTD
123 * conditional sections.
125 * @return an DTD conditional section scanner
127 public RuleBasedScanner getDTDConditionalScanner() {
128 return dtdConditionalScanner;
132 * Returns a scanner which is configured to scan XML
133 * processing instructions.
135 * @return an XML processing instruction scanner
137 public RuleBasedScanner getXMLPIScanner() {
142 * Returns a scanner which is configured to scan XML comments.
144 * @return an XML comment scanner
146 public RuleBasedScanner getXMLCommentScanner() {
147 return xmlCommentScanner;
151 * Returns a scanner which is configured to scan XML declarations.
153 * @return an XML declaration scanner
155 public RuleBasedScanner getXMLDeclScanner() {
156 return xmlDeclScanner;