001/* 002 * Copyright 2012-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2012-2018 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldif; 022 023 024 025import com.unboundid.util.StaticUtils; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This enum defines a set of possible behaviors that may be exhibited by the 033 * LDIF reader when encountering trailing spaces in attribute values that are 034 * not base64-encoded. 035 */ 036@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 037public enum TrailingSpaceBehavior 038{ 039 /** 040 * Indicates that illegal trailing spaces should be silently stripped from 041 * attribute values. 042 */ 043 STRIP, 044 045 046 047 /** 048 * Indicates that illegal trailing spaces should be retained (as if the value 049 * had been base64-encoded). 050 */ 051 RETAIN, 052 053 054 055 /** 056 * Indicates that illegal trailing spaces should cause the associated entry to 057 * be rejected. 058 */ 059 REJECT; 060 061 062 063 /** 064 * Retrieves the trailing space behavior with the specified name. 065 * 066 * @param name The name of the trailing space behavior to retrieve. It must 067 * not be {@code null}. 068 * 069 * @return The requested trailing space behavior, or {@code null} if no such 070 * behavior is defined. 071 */ 072 public static TrailingSpaceBehavior forName(final String name) 073 { 074 switch (StaticUtils.toLowerCase(name)) 075 { 076 case "strip": 077 return STRIP; 078 case "retain": 079 return RETAIN; 080 case "reject": 081 return REJECT; 082 default: 083 return null; 084 } 085 } 086}