<commit_before>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.model.plugin;

import org.eclipse.birt.report.model.api.metadata.IChoice;
import org.eclipse.birt.report.model.api.metadata.IChoiceSet;
import org.eclipse.birt.report.model.api.metadata.IElementDefn;
import org.eclipse.birt.report.model.api.metadata.IStructureDefn;
import org.eclipse.birt.report.model.metadata.ChoiceSet;
import org.eclipse.birt.report.model.metadata.MetaDataDictionary;
import org.eclipse.birt.report.model.metadata.PropertyType;
import org.eclipse.birt.report.model.metadata.SystemPropertyDefn;
import org.eclipse.datatools.connectivity.oda.util.manifest.Property;
import org.eclipse.datatools.connectivity.oda.util.manifest.PropertyChoice;

/**
 */

public class ODAPropertyDefn extends SystemPropertyDefn
{

	private Property property = null;

	ODAPropertyDefn( Property property )
	{
		assert property != null;

		this.property = property;

		name = property.getName( );
		type = MetaDataDictionary.getInstance( ).getPropertyType(
				property.getType( ) );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#isList()
	 */

	public boolean isList( )
	{
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getName()
	 */
	public String getName( )
	{
		return property.getName( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getTypeCode()
	 */
	public int getTypeCode( )
	{
		PropertyType type = MetaDataDictionary.getInstance( ).getPropertyType(
				property.getType( ) );
		return type == null ? -1 : type.getTypeCode( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getDisplayName()
	 */

	public String getDisplayName( )
	{
		return property.getDisplayName( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getDisplayNameID()
	 */

	public String getDisplayNameID( )
	{
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getChoices()
	 */

	public IChoiceSet getChoices( )
	{
		PropertyChoice[] propertyChoices = property.getChoices( );

		ChoiceSet choiceSet = new ChoiceSet( );
		if ( propertyChoices != null && propertyChoices.length > 0 )
		{
			IChoice[] choices = new ODAChoice[propertyChoices.length];
			for ( int i = 0; i < propertyChoices.length; i++ )
			{
				choices[i] = new ODAChoice( propertyChoices[i] );

			}
			choiceSet.setChoices( choices );
		}

		return choiceSet;<commit_msg>Do not create empty choice set if there are no choices.<commit_after>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.model.plugin;

import org.eclipse.birt.report.model.api.metadata.IChoice;
import org.eclipse.birt.report.model.api.metadata.IChoiceSet;
import org.eclipse.birt.report.model.api.metadata.IElementDefn;
import org.eclipse.birt.report.model.api.metadata.IStructureDefn;
import org.eclipse.birt.report.model.metadata.ChoiceSet;
import org.eclipse.birt.report.model.metadata.MetaDataDictionary;
import org.eclipse.birt.report.model.metadata.PropertyType;
import org.eclipse.birt.report.model.metadata.SystemPropertyDefn;
import org.eclipse.datatools.connectivity.oda.util.manifest.Property;
import org.eclipse.datatools.connectivity.oda.util.manifest.PropertyChoice;

/**
 */

public class ODAPropertyDefn extends SystemPropertyDefn
{

	private Property property = null;

	ODAPropertyDefn( Property property )
	{
		assert property != null;

		this.property = property;

		name = property.getName( );
		type = MetaDataDictionary.getInstance( ).getPropertyType(
				property.getType( ) );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#isList()
	 */

	public boolean isList( )
	{
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getName()
	 */
	public String getName( )
	{
		return property.getName( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getTypeCode()
	 */
	public int getTypeCode( )
	{
		PropertyType type = MetaDataDictionary.getInstance( ).getPropertyType(
				property.getType( ) );
		return type == null ? -1 : type.getTypeCode( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getDisplayName()
	 */

	public String getDisplayName( )
	{
		return property.getDisplayName( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getDisplayNameID()
	 */

	public String getDisplayNameID( )
	{
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.api.metadata.IPropertyDefn#getChoices()
	 */

	public IChoiceSet getChoices( )
	{
		PropertyChoice[] propertyChoices = property.getChoices( );

		ChoiceSet choiceSet = null;
		if ( propertyChoices != null && propertyChoices.length > 0 )
		{
			choiceSet = new ChoiceSet( );
			IChoice[] choices = new ODAChoice[propertyChoices.length];
			for ( int i = 0; i < propertyChoices.length; i++ )
			{
				choices[i] = new ODAChoice( propertyChoices[i] );

			}
			choiceSet.setChoices( choices );
		}

		return choiceSet;
{'fraction_non_alphanumeric': 0.16985911033718537, 'fraction_numerical': 0.003482665822384043, 'mean_word_length': 4.103392568659127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5633633', 'n_tokens_mistral': 2184, 'n_tokens_neox': 1972, 'n_words': 357}