james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r801717 - in /james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf: core/ impl/ policies/ policies/local/
Date Thu, 06 Aug 2009 16:55:18 GMT
Author: norman
Date: Thu Aug  6 16:55:18 2009
New Revision: 801717

URL: http://svn.apache.org/viewvc?rev=801717&view=rev
Log:
Start to generify (JSPF-78)

Modified:
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSResponse.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSService.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/SPFSession.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceAsynchSimulator.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/SPFRetriever.java
    james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSResponse.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSResponse.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSResponse.java (original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSResponse.java Thu
Aug  6 16:55:18 2009
@@ -30,7 +30,7 @@
  */
 public class DNSResponse {
     
-    private List response;
+    private List<String> response;
     
     private TimeoutException exception;
     
@@ -39,7 +39,7 @@
         this.response = null;
     }
     
-    public DNSResponse(List response) {
+    public DNSResponse(List<String> response) {
         this.exception = null;
         this.response = response;
     }
@@ -51,7 +51,7 @@
      * @throws TimeoutException get thrown if an timeout was returned while tried to 
      *         process a dns request
      */
-    public List getResponse() throws TimeoutException {
+    public List<String> getResponse() throws TimeoutException {
         if (exception != null) {
             throw exception;
         } else {

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSService.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSService.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSService.java (original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/DNSService.java Thu
Aug  6 16:55:18 2009
@@ -43,7 +43,7 @@
      * 
      * @return names A List contains all domain names which could resolved
      */
-    public List getLocalDomainNames();
+    public List<String> getLocalDomainNames();
 
     /**
      * Set the timeout for DNS-Requests

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java (original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java Thu
Aug  6 16:55:18 2009
@@ -98,11 +98,11 @@
             // later
             session.setClientDomain("unknown");
             try {
-                List records = response.getResponse();
+                List<String> records = response.getResponse();
                 if (records != null && records.size() > 0) {
-                    Iterator i = records.iterator();
+                    Iterator<String> i = records.iterator();
                     while (i.hasNext()) {
-                        String next = (String) i.next();
+                        String next = i.next();
                         if (IPAddr.getAddress(session.getIpAddress())
                                 .toString().equals(
                                         IPAddr.getAddress(next).toString())) {
@@ -134,10 +134,10 @@
 
             try {
                 boolean ip6 = IPAddr.isIPV6(session.getIpAddress());
-                List records = response.getResponse();
+                List<String> records = response.getResponse();
 
                 if (records != null && records.size() > 0) {
-                    String record = (String) records.get(0);
+                    String record = records.get(0);
                     session.setAttribute(ATTRIBUTE_MACRO_EXPAND_CHECKED_RECORD,
                             record);
 
@@ -376,7 +376,7 @@
         }
 
         // Reverse domains as necessary
-        ArrayList data = split(variable, delimeters);
+        ArrayList<String> data = split(variable, delimeters);
         if (isReversed) {
             data = reverse(data);
         }
@@ -436,7 +436,7 @@
             rValue = macroData.getReceivingDomain();
             if (rValue == null) {
                 rValue = "unknown";
-                List dNames = dnsProbe.getLocalDomainNames();
+                List<String> dNames = dnsProbe.getLocalDomainNames();
 
                 for (int i = 0; i < dNames.size(); i++) {
                     // check if the domainname is a FQDN
@@ -472,11 +472,11 @@
      *            The delimeter we want to use to split the String
      * @return ArrayList which contains the String parts
      */
-    private ArrayList split(String data, String delimeters) {
+    private ArrayList<String> split(String data, String delimeters) {
 
         String currentChar;
         StringBuffer element = new StringBuffer();
-        ArrayList splitParts = new ArrayList();
+        ArrayList<String> splitParts = new ArrayList<String>();
 
         for (int i = 0; i < data.length(); i++) {
             currentChar = data.substring(i, i + 1);
@@ -498,9 +498,9 @@
      *            The ArrayList we want to get reversed
      * @return reversed The reversed given ArrayList
      */
-    private ArrayList reverse(ArrayList data) {
+    private ArrayList<String> reverse(ArrayList<String> data) {
 
-        ArrayList reversed = new ArrayList();
+        ArrayList<String> reversed = new ArrayList<String>();
         for (int i = 0; i < data.size(); i++) {
             reversed.add(0, data.get(i));
         }
@@ -510,7 +510,7 @@
     /**
      * @see #subset(ArrayList, int)
      */
-    private String subset(ArrayList data) {
+    private String subset(ArrayList<String> data) {
         return subset(data, data.size());
     }
 
@@ -521,7 +521,7 @@
      * @param length The ArrayLength
      * @return A String which holds all entries seperated by dots
      */
-    private String subset(ArrayList data, int length) {
+    private String subset(ArrayList<String> data, int length) {
 
         StringBuffer buildString = new StringBuffer();
         if (data.size() < length) {

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/SPFSession.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/SPFSession.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/SPFSession.java (original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/core/SPFSession.java Thu
Aug  6 16:55:18 2009
@@ -68,9 +68,9 @@
 
     private boolean ignoreExplanation = false;
     
-    private Map attributes = new HashMap();
+    private Map<String,Object> attributes = new HashMap<String,Object>();
     
-    private Stack checkers = new Stack();
+    private Stack<SPFChecker> checkers = new Stack<SPFChecker>();
     
     private String currentResultExpanded;
     
@@ -364,7 +364,7 @@
         if (checkers.isEmpty()) {
             return null;
         } else {
-            SPFChecker checker = (SPFChecker) checkers.pop();
+            SPFChecker checker = checkers.pop();
             return checker;
         }
     }

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceAsynchSimulator.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceAsynchSimulator.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceAsynchSimulator.java
(original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceAsynchSimulator.java
Thu Aug  6 16:55:18 2009
@@ -35,7 +35,7 @@
 
     private DNSService dnsService;
     private Thread worker;
-    private LinkedList queue;
+    private LinkedList<Request> queue;
     private int waitingThreads = 0;
     private boolean multiThread;
     
@@ -64,7 +64,7 @@
         this.dnsService = service;
         this.multiThread = multiThread;
 
-        this.queue = new LinkedList();
+        this.queue = new LinkedList<Request>();
         this.worker = new Thread(this);
         this.worker.setDaemon(true);
         this.worker.setName("DNSServiceAsynchSimulator");

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
(original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
Thu Aug  6 16:55:18 2009
@@ -91,8 +91,8 @@
     /**
      * @see org.apache.james.jspf.core.DNSService#getLocalDomainNames()
      */
-    public List getLocalDomainNames() {
-        List names = new ArrayList();
+    public List<String> getLocalDomainNames() {
+        List<String> names = new ArrayList<String>();
 
         log.debug("Start Local ipaddress lookup");
         try {

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/SPFRetriever.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/SPFRetriever.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/SPFRetriever.java
(original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/SPFRetriever.java
Thu Aug  6 16:55:18 2009
@@ -53,7 +53,7 @@
                 NoneException, TempErrorException,
                 NeutralException {
             
-            List spfR;
+            List<String> spfR;
             try {
                 spfR = response.getResponse();
                 String record = extractSPFRecord(spfR);
@@ -79,7 +79,7 @@
                 throws PermErrorException, NoneException,
                 TempErrorException, NeutralException {
             try {
-                List spfR = response.getResponse();
+                List<String> spfR = response.getResponse();
                 
                 if (spfR == null || spfR.isEmpty()) {
                     
@@ -118,15 +118,15 @@
      * @throws PermErrorException if more then one SPF - Record was found in the 
      *                            given List.
      */
-    protected static String extractSPFRecord(List spfR) throws PermErrorException {
+    protected static String extractSPFRecord(List<String> spfR) throws PermErrorException
{
         if (spfR == null || spfR.isEmpty()) return null;
         
         String returnValue = null;
-        Iterator all = spfR.iterator();
+        Iterator<String> all = spfR.iterator();
            
         while (all.hasNext()) {
             // DO NOT trim the result!
-            String compare = all.next().toString();
+            String compare = all.next();
 
             // We trim the compare value only for the comparison
             if (compare.toLowerCase().trim().startsWith(SPF1Constants.SPF_VERSION1 + " ")
|| compare.trim().equalsIgnoreCase(SPF1Constants.SPF_VERSION1)) {

Modified: james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java?rev=801717&r1=801716&r2=801717&view=diff
==============================================================================
--- james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
(original)
+++ james/jspf/trunk/resolver/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
Thu Aug  6 16:55:18 2009
@@ -39,7 +39,7 @@
  */
 public class FallbackPolicy implements PolicyPostFilter {
 
-    private Map entryMap;
+    private Map<String,SPF1Record> entryMap;
 
     private SPFRecordParser parser;
 
@@ -47,7 +47,7 @@
 
     public FallbackPolicy(Logger log, SPFRecordParser parser) {
         this.log = log;
-        entryMap = Collections.synchronizedMap(new HashMap());
+        entryMap = Collections.synchronizedMap(new HashMap<String,SPF1Record>());
         this.parser = parser;
     }
 
@@ -132,14 +132,14 @@
      *         the given host
      */
     protected SPF1Record getMySPFRecord(String host) {
-        Object entry = null;
+        SPF1Record entry = null;
 
         synchronized (entryMap) {
             entry = getRawEntry(host);
         }
 
         if (entry != null) {
-            return (SPF1Record) entry;
+            return entry;
         } else {
             return null;
         }
@@ -154,11 +154,11 @@
      *            the host
      * @return the stored object for the given host or null
      */
-    private Object getRawEntry(String host) {
-        Iterator fallBackIt = entryMap.keySet().iterator();
+    private SPF1Record getRawEntry(String host) {
+        Iterator<String> fallBackIt = entryMap.keySet().iterator();
 
         while (fallBackIt.hasNext()) {
-            String rawHost = fallBackIt.next().toString();
+            String rawHost = fallBackIt.next();
 
             if ((rawHost.startsWith(".") && host.startsWith(rawHost))
                     || rawHost.endsWith(".") && host.endsWith(rawHost)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message