<commit_before>/*
 * JBoss, Home of Professional Open Source
 * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
 * contributors by the @authors tag. See the copyright.txt in the 
 * distribution for a full listing of individual contributors.
 *
 * 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.jboss.wise.gui.treeElement;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLEncoder;

import org.jboss.wise.core.exception.WiseRuntimeException;
import org.jboss.wise.core.utils.JavaUtils;

import sun.misc.BASE64Encoder;

/**
 * A WiseTreeElement for simple types, like primitives and their corresponding
 * classes. This is to be used for types having a simple value.
 * 
 * @author <NAME>, <EMAIL>
 * 
 */
public class SimpleWiseTreeElement extends WiseTreeElement {

    private static final long serialVersionUID = 1L;

    protected String value;

    public SimpleWiseTreeElement() {
	super(true);
	this.kind = SIMPLE;
	this.id = IDGenerator.nextVal();
    }

    public SimpleWiseTreeElement(Class<?> classType, String name, String value) {
	super(true);
	this.kind = SIMPLE;
	this.id = IDGenerator.nextVal();
	this.classType = classType;
	this.name = name;
	init(classType, value);
    }

    /**
     * Returns the String value of the instance corresponding to this element.
     * 
     * @return The value
     */
    public String getValue() {
	return value;
    }

    /**
     * This is the same as getValue except only the first 40 characters are
     * considered. This is needed to preview invocation results.
     * 
     * @return The substring(0,40) of the value
     */
    public String getShortValue() {
	if (getValue() == null) {
	    return null;
	}
	if (getValue().length() <= 40) {
	    return getValue();
	}
	return getValue().substring(0, 40) + "...";
    }

    /**
     * This is the same as getValue except it double encode (BASE64 + URL) the
     * value.
     * 
     * @return The encoded value
     */
    public String getLongValue() {<commit_msg>Raise preview to 60 chars<commit_after>/*
 * JBoss, Home of Professional Open Source
 * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
 * contributors by the @authors tag. See the copyright.txt in the 
 * distribution for a full listing of individual contributors.
 *
 * 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.jboss.wise.gui.treeElement;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLEncoder;

import org.jboss.wise.core.exception.WiseRuntimeException;
import org.jboss.wise.core.utils.JavaUtils;

import sun.misc.BASE64Encoder;

/**
 * A WiseTreeElement for simple types, like primitives and their corresponding
 * classes. This is to be used for types having a simple value.
 * 
 * @author <NAME>, a<EMAIL>
 * 
 */
public class SimpleWiseTreeElement extends WiseTreeElement {

    private static final long serialVersionUID = 1L;

    protected String value;

    public SimpleWiseTreeElement() {
	super(true);
	this.kind = SIMPLE;
	this.id = IDGenerator.nextVal();
    }

    public SimpleWiseTreeElement(Class<?> classType, String name, String value) {
	super(true);
	this.kind = SIMPLE;
	this.id = IDGenerator.nextVal();
	this.classType = classType;
	this.name = name;
	init(classType, value);
    }

    /**
     * Returns the String value of the instance corresponding to this element.
     * 
     * @return The value
     */
    public String getValue() {
	return value;
    }

    /**
     * This is the same as getValue except only the first 60 characters are
     * considered. This is needed to preview invocation results.
     * 
     * @return The substring(0,60) of the value
     */
    public String getShortValue() {
	if (getValue() == null) {
	    return null;
	}
	if (getValue().length() <= 60) {
	    return getValue();
	}
	return getValue().substring(0, 60) + "...";
    }

    /**
     * This is the same as getValue except it double encode (BASE64 + URL) the
     * value.
     * 
     * @return The encoded value
     */
    public String getLongValue() {
{'fraction_non_alphanumeric': 0.09408135723925197, 'fraction_numerical': 0.009253903990746095, 'mean_word_length': 3.2982601491300745, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '1374700', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1446, 'n_words': 556}