<commit_before>/*
 * Copyright 2003 - 2015 The eFaps Team
 *
 * Licensed 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.efaps.esjp.admin.common.systemconfiguration;

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

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.efaps.admin.common.SystemConfiguration;
import org.efaps.admin.event.Parameter;
import org.efaps.admin.program.esjp.EFapsApplication;
import org.efaps.admin.program.esjp.EFapsUUID;
import org.efaps.util.EFapsException;

/**
 * The Class PropertiesSysConfAttribute_Base.
 *
 * @author The eFaps Team
 */
@EFapsUUID("ad2c0d04-d055-402a-891a-6bff9b5848dd")
@EFapsApplication("eFaps-Kernel")
public abstract class ListSysConfAttribute_Base
    extends AbstractSysConfAttribute<ListSysConfAttribute, List<String>>
{

    @Override
    protected ListSysConfAttribute getThis()
    {
        return (ListSysConfAttribute) this;
    }

    @Override
    public List<String> get()
        throws EFapsException
    {
        final List<String> ret = new ArrayList<>();
        final String str = SystemConfiguration.get(getSysConfUUID()).getAttributeValue(getKey());
        if (str != null && !str.isEmpty()) {
            ret.addAll(Arrays.asList(StringUtils.split(str, "\n")));
        }
        return ret;
    }

    @Override
    public CharSequence getHtml(final Parameter _parameter,
                                final Object _value)
    {
        final StringBuilder ret = new StringBuilder()
                        .append("<textarea rows=\"5\" cols=\"80\" name=\"value\">");
        if (_value != null ) {
            ret.append(StringEscapeUtils.escapeHtml4((String) _value));
        } else if (getDefaultValue() != null && !getDefaultValue().isEmpty()) {
            for (final String val : getDefaultValue()) {
                ret.append(StringEscapeUtils.escapeHtml4(val + "\n"));
            }
        }
        ret.append("</textarea>");
        return ret;
    }

}
<commit_msg>- Issue #80: Splitting for StringList must be done with Regex <commit_after>/*
 * Copyright 2003 - 2015 The eFaps Team
 *
 * Licensed 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.efaps.esjp.admin.common.systemconfiguration;

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

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.efaps.admin.common.SystemConfiguration;
import org.efaps.admin.event.Parameter;
import org.efaps.admin.program.esjp.EFapsApplication;
import org.efaps.admin.program.esjp.EFapsUUID;
import org.efaps.util.EFapsException;

/**
 * The Class PropertiesSysConfAttribute_Base.
 *
 * @author The eFaps Team
 */
@EFapsUUID("ad2c0d04-d055-402a-891a-6bff9b5848dd")
@EFapsApplication("eFaps-Kernel")
public abstract class ListSysConfAttribute_Base
    extends AbstractSysConfAttribute<ListSysConfAttribute, List<String>>
{

    @Override
    protected ListSysConfAttribute getThis()
    {
        return (ListSysConfAttribute) this;
    }

    @Override
    public List<String> get()
        throws EFapsException
    {
        final List<String> ret = new ArrayList<>();
        final String str = SystemConfiguration.get(getSysConfUUID()).getAttributeValue(getKey());
        if (StringUtils.isNotEmpty(str)) {
            ret.addAll(Arrays.asList(str.split("\\r?\\n")));
        }
        return ret;
    }

    @Override
    public CharSequence getHtml(final Parameter _parameter,
                                final Object _value)
    {
        final StringBuilder ret = new StringBuilder()
                        .append("<textarea rows=\"5\" cols=\"80\" name=\"value\">");
        if (_value != null) {
            ret.append(StringEscapeUtils.escapeHtml4((String) _value));
        } else if (getDefaultValue() != null && !getDefaultValue().isEmpty()) {
            for (final String val : getDefaultValue()) {
                ret.append(StringEscapeUtils.escapeHtml4(val + "\n"));
            }
        }
        ret.append("</textarea>");
        return ret;
    }
}

{'fraction_non_alphanumeric': 0.10968743933216851, 'fraction_numerical': 0.015142690739662202, 'mean_word_length': 3.0598896769109536, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1379117', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1441, 'n_words': 390}