Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package com.sporniket.libre.javabeans.generator.core;
  
Base class for processing the type attribute of a property.

© Copyright 2012-2013 David Sporn


This file is part of The Sporniket Javabeans Library – core.

The Sporniket Javabeans Library – core is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Sporniket Javabeans Library – core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with The Sporniket Javabeans Library – core. If not, see http://www.gnu.org/licenses/. 2


Author(s):
David SPORN
Version:
13.01.01
Since:
13.01.01
 
 public class PropertyType
 {

© Copyright 2012-2013 David Sporn


This file is part of The Sporniket Javabeans Library – core.

The Sporniket Javabeans Library – core is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Sporniket Javabeans Library – core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with The Sporniket Javabeans Library – core. If not, see http://www.gnu.org/licenses/. 2


Author(s):
David SPORN
Version:
13.01.01
Since:
13.01.01
 
 	public static enum Prefix
 	{
 		COLL("coll"),
 		ENUM("enum"),
 		JAVA("java"),
 		MAP("map");
 		public static Prefix parseString(String value)
 		{
 			return Prefix.valueOf(value.toUpperCase());
 		}
 
 		private String myName;

Parameters:
name
 
 		private Prefix(String name)
 		{
 			 = name;
 		}

Returns:
the name
 
 		public String getName()
 		{
 			return ;
		}
	}

© Copyright 2012-2013 David Sporn


This file is part of The Sporniket Javabeans Library – core.

The Sporniket Javabeans Library – core is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Sporniket Javabeans Library – core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with The Sporniket Javabeans Library – core. If not, see http://www.gnu.org/licenses/. 2


Author(s):
David SPORN
Version:
13.01.01
Since:
13.01.01
	public static class Utils
	{

Parameters:
type value from the xml model.
target type to define from type.
		private static void doExtractBasicInfo(String typePropertyType target)
		{
			int _markerPos = type.indexOf();
			if (-1 == _markerPos)
			{
				throw new IllegalArgumentException("type is surely incorrect, should be '(java|enum|coll):...', got : '" + type
"'.");
			}
			String _prefix = type.substring(0, _markerPos);
			String _description = type.substring(_markerPos + 1);
			target.setPrefix(Prefix.parseString(_prefix));
			target.setDescription(_description);
		}

Find the prefix and the description from the type.

Parameters:
type type value from the xml model.
target property definition to fill.
		public static void extractBasicInfo(String typePropertyType target)
		{
			// sanity check
			if (null == target)
			{
				throw new IllegalArgumentException("target must be not null");
			}
			if (StringTools.isEmptyString(type))
			{
				String message = (null == type) ? "type must be not null" : "type must be not empty";
				throw new IllegalArgumentException(message);
			}
			// ok
			doExtractBasicInfo(typetarget);
		}

Build a specific PropertyType from the value of the type attribute.

Parameters:
type the value of the type attribute
Returns:
a property definition.
See also:
com.sporniket.studio.schema.model.set.javabean.Property.getType()
		public static PropertyType instanciate(String type)
		{
			PropertyType _result = null;
			PropertyType _temp = new PropertyType();
			extractBasicInfo(type_temp);
			switch (_temp.getPrefix())
			{
				case :
					_result = _temp;
					break;
				case :
				{
					_result = _enum;
				}
					break;
				case :
				{
					_result = _coll;
				}
					break;
				case :
				{
					_result = _coll;
				}
					break;
				// case COLL:
				// break;
				default:
					throw new IllegalStateException("Unsupported prefix:" + _temp.getPrefix());
			}
			return _result;
		}
	}
	public static final String MARKER__SEPARATOR = ":";

Part "after" the prefix.
	private Prefix myPrefix;

Returns:
the description
	{
	}

Returns:
the prefix
	public Prefix getPrefix()
	{
		return ;
	}

Parameters:
description the description to set
	public void setDescription(String description)
	{
		 = description;
	}

Parameters:
prefix the prefix to set
	public void setPrefix(Prefix prefix)
	{
		 = prefix;
	}
New to GrepCode? Check out our FAQ X