001/*
002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.platform.htmlsanitizer;
020
021import java.util.ArrayList;
022import java.util.List;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XNodeList;
026import org.nuxeo.common.xmap.annotation.XObject;
027
028@XObject("sanitizer")
029public class HtmlSanitizerDescriptor {
030
031    @XNode("@name")
032    public String name = "";
033
034    @XNode("@enabled")
035    public boolean enabled = true;
036
037    // unused
038    @XNode("@override")
039    public boolean override = false;
040
041    @XNodeList(value = "type", type = ArrayList.class, componentType = String.class)
042    public final List<String> types = new ArrayList<String>();
043
044    @XNodeList(value = "field", type = ArrayList.class, componentType = FieldDescriptor.class)
045    public final List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
046
047    @Override
048    public String toString() {
049        StringBuilder buf = new StringBuilder();
050        buf.append(getClass().getSimpleName());
051        buf.append('(');
052        buf.append(name);
053        if (!types.isEmpty()) {
054            buf.append(",types=");
055            buf.append(types);
056        }
057        if (!fields.isEmpty()) {
058            buf.append(",fields=");
059            buf.append(fields);
060        }
061        buf.append(')');
062        return buf.toString();
063    }
064
065}