2002/css-validator/org/w3c/css/util Warnings.java,1.4,1.5 ApplContext.java,1.8,1.9

Update of /sources/public/2002/css-validator/org/w3c/css/util
In directory hutz:/tmp/cvs-serv2279/org/w3c/css/util

Modified Files:
	Warnings.java ApplContext.java 
Log Message:
Improved warning count

Index: ApplContext.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/util/ApplContext.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ApplContext.java	14 Sep 2005 15:15:32 -0000	1.8
+++ ApplContext.java	16 Dec 2006 20:22:26 -0000	1.9
@@ -45,6 +45,8 @@
 
     String medium;
 
+    int warningLevel = 0;
+    
     static {
 	try {
 	    Class c = Class.forName("java.nio.charset.Charset");
@@ -65,7 +67,15 @@
         msgs = new Messages(lang);
     }
 
-    // as ugly as everything else
+    public int getWarningLevel() {
+		return warningLevel;
+	}
+
+	public void setWarningLevel(int warningLevel) {
+		this.warningLevel = warningLevel;
+	}
+
+	// as ugly as everything else
     public String getCredential() {
 	return credential;
     }

Index: Warnings.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/util/Warnings.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Warnings.java	14 Sep 2005 15:15:32 -0000	1.4
+++ Warnings.java	16 Dec 2006 20:22:26 -0000	1.5
@@ -16,18 +16,41 @@
 
   private Warning[] warningData = new Warning[20];
 
-  private int       warningCount;
+  private int       warningCount = 0;
 
-  private final int capacityIncrement = 10;
+  private int ignoredWarningCount = 0;
 
-  /**
+  private int warningLevel = 0;
+  
+  public Warnings() {
+	  
+  }
+  
+  public Warnings(int level) {
+	  this.warningLevel = level;
+  }
+  
+  	public int getWarningLevel() {
+  		return warningLevel;
+  	}
+
+  	public void setWarningLevel(int warningLevel) {
+  		this.warningLevel = warningLevel;
+  	}
+
+/**
    * Add a warning.
    *
    * @param warm the warning
    */
   public final void addWarning(Warning warm) {
-    resize(1);
-    warningData[warningCount++] = warm;
+	  if(warm.getLevel() > warningLevel) {
+		  ignoredWarningCount++;
+	  }
+	  else {
+		  resize(1);
+		  warningData[warningCount++] = warm;
+	  }
   }
 
   /**
@@ -36,10 +59,10 @@
    * @param warnings All warnings
    */
   public final void addWarnings(Warnings warnings) {
-    resize(warnings.warningCount);
-    System.arraycopy(warnings.warningData, 0, warningData, warningCount,
-		     warnings.warningCount);
-    warningCount += warnings.warningCount;
+    //resize(warnings.warningCount);
+    for(int i=0; i < warnings.warningCount; i++) {
+    	addWarning(warnings.warningData[i]);
+    }
   }
 
   /**
@@ -50,6 +73,13 @@
   }
 
   /**
+   * Get the number of ignored warnings (not corresponding to the warning level)
+   */
+  public final int getIgnoredWarningCount() {
+    return ignoredWarningCount;
+  }
+  
+  /**
    * Get an array with all warnings.
    */
   public final Warning[] getWarnings() {

Received on Saturday, 16 December 2006 20:22:39 UTC