summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2003-09-02 16:01:58 +0000
committermichelou <michelou@epfl.ch>2003-09-02 16:01:58 +0000
commit3cb7eb8fcdbf3cd5d24859fe6cb42be49e71ed54 (patch)
treea0bc665b6aeb552abb909ab59e774b670fc1d22e /sources
parenta290cbe0a1b53147fa78881839c494085365d35a (diff)
downloadscala-3cb7eb8fcdbf3cd5d24859fe6cb42be49e71ed54.tar.gz
scala-3cb7eb8fcdbf3cd5d24859fe6cb42be49e71ed54.tar.bz2
scala-3cb7eb8fcdbf3cd5d24859fe6cb42be49e71ed54.zip
- added DEFAULT_* constants
Diffstat (limited to 'sources')
-rw-r--r--sources/ch/epfl/lamp/util/HTMLRepresentation.java64
1 files changed, 46 insertions, 18 deletions
diff --git a/sources/ch/epfl/lamp/util/HTMLRepresentation.java b/sources/ch/epfl/lamp/util/HTMLRepresentation.java
index 5894c9df07..debe5288bd 100644
--- a/sources/ch/epfl/lamp/util/HTMLRepresentation.java
+++ b/sources/ch/epfl/lamp/util/HTMLRepresentation.java
@@ -8,19 +8,24 @@
package ch.epfl.lamp.util;
-/** This class contains properties of HTML document representation
- * (see http://www.w3.org/TR/REC-html40/charset.html).
+/**
+ * This class contains properties of HTML document representation
+ * (see http://www.w3.org/TR/REC-html40/charset.html).
*/
public class HTMLRepresentation {
+ public static final String DEFAULT_DOCTYPE = "HTML 4.01 Transitional";
+ public static final String DEFAULT_DOCENCODING = "iso-8859-1";
+ public static final String DEFAULT_DOCLANGUAGE = "EN";
+
//########################################################################
// Private Fields
/** The document type */
- private final String type;
+ private final String doctype;
/** The document character encoding */
- private final String encoding;
+ private final String docencoding;
/** The document language */
private final String language;
@@ -29,43 +34,66 @@ public class HTMLRepresentation {
// Public Constructors
/** Creates a new instance */
- public HTMLRepresentation(String type, String encoding, String language) {
- this.type = type;
- this.encoding = encoding;
+ public HTMLRepresentation(String doctype, String docencoding, String language) {
+ this.doctype = doctype;
+ this.docencoding = docencoding;
this.language = language;
}
/** Creates a new instance */
- public HTMLRepresentation(String type, String encoding) {
- this(type, encoding, "EN");
+ public HTMLRepresentation(String doctype, String docencoding) {
+ this(doctype, docencoding, DEFAULT_DOCLANGUAGE);
}
/** Creates a new instance */
- public HTMLRepresentation(String type) {
- this(type, "iso-8859-1", "EN");
+ public HTMLRepresentation(String doctype) {
+ this(doctype, DEFAULT_DOCENCODING, DEFAULT_DOCLANGUAGE);
}
/** Creates a new instance */
public HTMLRepresentation() {
- this("HTML 4.01 Transitional", "iso-8859-1", "EN");
+ this(DEFAULT_DOCTYPE, DEFAULT_DOCENCODING, DEFAULT_DOCLANGUAGE);
}
//########################################################################
// Public Methods - Getting & Setting
- /** Returns the underlying document type. */
+ /**
+ * Returns the underlying document type.
+ */
public String getType() {
- return type;
+ return doctype;
}
- /** Returns the underlying character encoding. */
+ /**
+ * Returns the underlying character encoding.
+ */
public String getEncoding() {
- return encoding;
+ return docencoding;
}
- /** Returns the underlying character encoding. */
+ /**
+ * Returns the underlying document language.
+ *
+ * @ return the language name of the underlying document
+ */
public String getLanguage() {
return language;
}
-} \ No newline at end of file
+ /**
+ * Returns <code>true</code> if the document type is HTML.
+ */
+ public boolean isHTMLType() {
+ return doctype.toLowerCase().matches("^html\\p{Space}\\d\\.\\d.*");
+ }
+
+ /**
+ * Returns <code>true</code> if the document type is XHTML.
+ */
+ public boolean isXHTMLType() {
+ return doctype.toLowerCase().matches("^xhtml\\p{Space}\\d\\.\\d.*");
+ }
+
+ //########################################################################
+}