001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.xsl;
030:
031: import com.caucho.xpath.pattern.AbstractPattern;
032: import com.caucho.xpath.pattern.FromAny;
033:
034: public class Template {
035: AbstractPattern pattern;
036: String mode;
037: int minImportance;
038: int maxImportance;
039: double priority;
040: int count;
041: String function;
042: public int funId;
043:
044: public Template(AbstractPattern pattern, String mode,
045: int minImportance, int maxImportance, double priority,
046: int count, String function, int funId) {
047: if (mode == null)
048: mode = "";
049: this .mode = mode;
050: if (pattern == null)
051: pattern = new FromAny();
052: this .pattern = pattern;
053: this .function = function;
054: this .funId = funId;
055: this .minImportance = minImportance;
056: this .maxImportance = maxImportance;
057: this .priority = priority;
058: this .count = count;
059: }
060:
061: public AbstractPattern getPattern() {
062: return pattern;
063: }
064:
065: public int getId() {
066: return funId;
067: }
068:
069: public String getMode() {
070: return mode;
071: }
072:
073: public int getMin() {
074: return minImportance;
075: }
076:
077: public int getMax() {
078: return maxImportance;
079: }
080:
081: public double getPriority() {
082: return priority;
083: }
084:
085: public int getCount() {
086: return count;
087: }
088:
089: public String getFunction() {
090: return function;
091: }
092:
093: int compareTo(Template right) {
094: if (this .maxImportance < right.maxImportance)
095: return -1;
096: if (this .maxImportance > right.maxImportance)
097: return 1;
098: if (this .priority < right.priority)
099: return -1;
100: if (this .priority > right.priority)
101: return 1;
102:
103: return this .count - right.count;
104: }
105:
106: public String toString() {
107: return "[Template " + pattern
108: + (mode != null ? (" mode:" + mode) : "") + "]";
109: }
110: }
|