All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.jsieve.Arguments Maven / Gradle / Ivy

Go to download

Apache jSieve is a server side mail filtering system implementing RFC3028. Apache jSieve is developed by the JAMES project.

There is a newer version: 0.8
Show newest version
/****************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one   *
 * or more contributor license agreements.  See the NOTICE file *
 * distributed with this work for additional information        *
 * regarding copyright ownership.  The ASF licenses this file   *
 * to you under the Apache License, Version 2.0 (the            *
 * "License"); you may not use this file except in compliance   *
 * with the License.  You may obtain a copy of the License at   *
 *                                                              *
 *   http://www.apache.org/licenses/LICENSE-2.0                 *
 *                                                              *
 * Unless required by applicable law or agreed to in writing,   *
 * software distributed under the License is distributed on an  *
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
 * KIND, either express or implied.  See the License for the    *
 * specific language governing permissions and limitations      *
 * under the License.                                           *
 ****************************************************************/

package org.apache.jsieve;

import java.util.ArrayList;
import java.util.List;

/**
 * 

* A parsed representation of the RFC3028 BNF... *

* * arguments = *argument [test / test-list] * *

* Note that a test is represented as a test-list with a single element. *

* */ public class Arguments { /** * A List of the parsed Arguments */ private List fieldArgumentList; /** * The parsed tests */ private TestList fieldTestList; /** * Constructor for Arguments. */ private Arguments() { super(); } /** * Constructor for Arguments. * * @param arguments * @param testList */ public Arguments(List arguments, TestList testList) { this(); setArgumentList(arguments); setTestList(testList); } /** * Returns the arguments. * * @return List */ public List getArgumentList() { return fieldArgumentList; } /** * Returns the testList, lazily initialised if required. * * @return TestList */ public TestList getTestList() { TestList testList = null; if (null == (testList = getTestListBasic())) { updateTestList(); return getTestList(); } return testList; } /** * Returns true if there is a TestList and it has Tests. Saves triggering * lazy initialisation. * * @return boolean */ public boolean hasTests() { TestList testList = getTestListBasic(); return null != testList && testList.getTests().size() == 0; } /** * Returns the testList. * * @return TestList */ private TestList getTestListBasic() { return fieldTestList; } /** * Computes the testList. * * @return TestList */ protected TestList computeTestList() { return new TestList(new ArrayList()); } /** * Sets the arguments. * * @param arguments * The arguments to set */ protected void setArgumentList(List arguments) { fieldArgumentList = arguments; } /** * Sets the testList. * * @param testList * The testList to set */ protected void setTestList(TestList testList) { fieldTestList = testList; } /** * Updates the TestList */ protected void updateTestList() { setTestList(computeTestList()); } /** * @see java.lang.Object#toString() */ public String toString() { return "Arguments: " + getArgumentList().toString() + " Tests: " + (hasTests() ? getTestList().toString() : "null"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy