001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.node.policy;
020
021import org.jppf.utils.PropertiesCollection;
022
023/**
024 * An execution policy rule that accepts everything.
025 * @author Laurent Cohen
026 */
027public class AcceptAll extends ExecutionPolicy {
028  /**
029   * Explicit serialVersionUID.
030   */
031  private static final long serialVersionUID = 1L;
032  /**
033   * Name of the corresponding XML element.
034   */
035  public static final String XML_TAG = AcceptAll.class.getSimpleName();
036
037  /**
038   * Create an accept all policy not wrapping another policy.
039   */
040  public AcceptAll() {
041    super();
042  }
043
044  /**
045   * Create an "accept all" policy wrapping another policy.
046   * @param wrappedPolicy the policy to wrap.
047   */
048  public AcceptAll(final ExecutionPolicy wrappedPolicy) {
049    super();
050  }
051
052  @Override
053  public boolean accepts(final PropertiesCollection<String> info) {
054    return true;
055  }
056
057  @Override
058  public String toString(final int i) {
059    if (children.length == 0) return indent(i) + "<" + XML_TAG + "/>\n";
060    return new StringBuilder(indent(i)).append(tagStart(XML_TAG)).append('\n').append(children[0].toString(i + 1)).append(tagEnd(XML_TAG)).append('\n').toString();
061  }
062}