001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027package org.opends.server.tools.makeldif;
028
029
030
031/**
032 * This class defines a data structure that provides information about the
033 * result of tag processing.
034 */
035public class TagResult
036{
037  /**
038   * A tag result in which all components have a value of <CODE>true</CODE>.
039   */
040  public static final TagResult SUCCESS_RESULT =
041       new TagResult(true, true, true, true);
042
043
044
045  /**
046   * A tag result that indicates the value should not be included in the entry,
047   * but all other processing should continue.
048   */
049  public static final TagResult OMIT_FROM_ENTRY =
050       new TagResult(false, true, true, true);
051
052
053
054  /**
055   * A tag result in whihc all components have a value of <CODE>false</CODE>.
056   */
057  public static final TagResult STOP_PROCESSING =
058       new TagResult(false, false, false, false);
059
060
061
062  /** Indicates whether to keep processing the associated line. */
063  private boolean keepProcessingLine;
064
065  /** Indicates whether to keep processing the associated entry. */
066  private boolean keepProcessingEntry;
067
068  /** Indicates whether to keep processing entries below the associated parent. */
069  private boolean keepProcessingParent;
070
071  /** Indicates whether to keep processing entries for the template file. */
072  private boolean keepProcessingTemplateFile;
073
074
075
076  /**
077   * Creates a new tag result object with the provided information.
078   *
079   * @param  keepProcessingLine          Indicates whether to continue
080   *                                     processing for the current line.  If
081   *                                     not, then the line will not be included
082   *                                     in the entry.
083   * @param  keepProcessingEntry         Indicates whether to continue
084   *                                     processing for the current entry.  If
085   *                                     not, then the entry will not be
086   *                                     included in the data.
087   * @param  keepProcessingParent        Indicates whether to continue
088   *                                     processing entries below the current
089   *                                     parent in the template file.
090   * @param  keepProcessingTemplateFile  Indicates whether to continue
091   *                                     processing entries for the template
092   *                                     file.
093   */
094  public TagResult(boolean keepProcessingLine, boolean keepProcessingEntry,
095                   boolean keepProcessingParent,
096                   boolean keepProcessingTemplateFile)
097  {
098    this.keepProcessingLine         = keepProcessingLine;
099    this.keepProcessingEntry        = keepProcessingEntry;
100    this.keepProcessingParent       = keepProcessingParent;
101    this.keepProcessingTemplateFile = keepProcessingTemplateFile;
102  }
103
104
105
106  /**
107   * Indicates whether to continue processing for the current line.  If this is
108   * <CODE>false</CODE>, then the current line will not be included in the
109   * entry.  It will have no impact on whehter the entry itself is included in
110   * the generated LDIF.
111   *
112   * @return  <CODE>true</CODE> if the line should be included in the entry, or
113   *          <CODE>false</CODE> if not.
114   */
115  public boolean keepProcessingLine()
116  {
117    return keepProcessingLine;
118  }
119
120
121
122  /**
123   * Indicates whether to continue processing for the current entry.  If this is
124   * <CODE>false</CODE>, then the current entry will not be included in the
125   * generated LDIF, and processing will resume with the next entry below the
126   * current parent.
127   *
128   * @return  <CODE>true</CODE> if the entry should be included in the
129   *          generated LDIF, or <CODE>false</CODE> if not.
130   */
131  public boolean keepProcessingEntry()
132  {
133    return keepProcessingEntry;
134  }
135
136
137
138  /**
139   * Indicates whether to continue processing entries below the current parent.
140   * If this is <CODE>false</CODE>, then the current entry will not be included,
141   * and processing will resume below the next parent in the template file.
142   *
143   * @return  <CODE>true</CODE> if processing for the current parent should
144   *          continue, or <CODE>false</CODE> if not.
145   */
146  public boolean keepProcessingParent()
147  {
148    return keepProcessingParent;
149  }
150
151
152
153  /**
154   * Indicates whether to keep processing entries for the template file.  If
155   * this is <CODE>false</CODE>, then LDIF processing will end immediately (and
156   * the current entry will not be included).
157   *
158   * @return  <CODE>true</CODE> if processing for the template file should
159   *          continue, or <CODE>false</CODE> if not.
160   */
161  public boolean keepProcessingTemplateFile()
162  {
163    return keepProcessingTemplateFile;
164  }
165}
166